Fluiddocs
Reference

API

Call Fluid from your own code with a key. What a key may do, each route of Fluid compute with its request and its answer, and every refusal.

Warnings and limits

  • This is the API the fluid command and the MCP server call. A key reaches what they reach, within its scopes, and nothing more.
  • A key is shown once, when it is made. Fluid keeps its hash only. Never paste a key into a chat or a command line.
  • The routes under /api/compute exist only where Fluid compute is switched on. Elsewhere they answer 404 not_found, as any path Fluid does not have. Fluid compute is by invitation: without one the answer is 403 not_invited.
  • A job starts only from an uploaded bundle of your project's files, which the fluid command builds. Fluid takes no git repository and no container image as a job's source.
  • No answer names a supplier, a machine type, a market, a zone or a move. See What no answer says.
  • Requests, bodies and uploads have limits, and a key can have limits of its own. See Limits and A key's limits.
  • A webhook is sent at least once, and may be sent twice. Dedupe by the event's id, and check the signature before you trust a delivery. See Webhooks.

This page is for code that calls Fluid with a key: a script, a service, a CI job. It covers the key and the routes of Fluid compute. The fluid command and the MCP server call the same API and are the easier way in: see the CLI reference and the MCP tools.

The key

A key is ptl_ followed by 43 URL-safe characters: letters, digits, - and _. Send it in one Authorization header, to the gateway at https://api.fluid.sh:

Authorization: Bearer ptl_...
  • The gateway's host is the only one that takes a key. The console's host, fluid.sh, takes none: a request there that carries an Authorization header is refused (400 two_credentials).
  • Send the header once, in exactly this form. Anything else is 401 signin. So is a key that is unknown, revoked or past its end, and a key whose maker has left the workspace or whose account is not active. The answer is the same for all of them.
  • Make a key in the console, under Settings, Agents. Where the console has a Developers page, keys are made there, with their limits. Anyone in the workspace but a Viewer makes one.
  • The key's value is shown once. Fluid keeps its SHA-256 hash, and no later answer holds the value.
  • A key lasts 1, 7 or 30 days. On the Developers page, an Administrator or an Owner can make one that lasts until it is revoked.
  • Revoking a key is complete at once: its next request is 401 signin. Anyone revokes their own key, and an Administrator or an Owner any key of the workspace.
  • Keys are made, changed and revoked in the console, by a person. No route does it for a key.

On a machine with no browser, such as a CI runner, the fluid command takes a key from a file: fluid login --token-file PATH.

What a key did

Where the console has a Developers page, its Activity tab lists the requests a key made, reads and refusals included: when, which key, the method, the route as a template such as /api/jobs/{id}/stop, the status, the refusal's code, the job, and how long it took. The job is the one the request started, or the one it named when Fluid found it. An id sent for a job that is not there is not kept. Fluid keeps no address, no body and no query of a request there. A request is kept 30 days, and the latest 100,000 of a workspace at most. An Administrator or an Owner sees every key's requests. Anyone else sees those of the keys they made. A request shows a few seconds after it is answered.

The tab also sums the last 24 hours of those requests: how many came, how many were refused, the median time one took and how many started a job. It draws a bar for each hour and names the refusals met most.

The list is a record of use, not an audit. Every 2 seconds each of Fluid's servers records at most 20 requests of one key and 50 of one workspace. A burst past that is answered as always, and what is over is not listed.

The workspace

A key belongs to the workspace it was made in, and every request it makes is that workspace's. The X-Portal-Workspace header, which the console sends to choose a workspace, is not read for a key. To work in another workspace, make a key there.

Scopes and roles

A key has one or more of three scopes. No key has admin.

ScopeWhat it lets a key do
readread jobs, the balance and the usage
jobsstart and stop jobs, and everything read does
connectionsadd, change and remove connections, secrets and machines, and everything read does

A key acts within the current role of the person who made it:

Role of the personScopes their keys use
Viewerread. A Viewer makes no key, so this is a key made before the person became a Viewer
Memberread, jobs
Administrator, Ownerread, jobs, connections

When the person's role changes, their keys change with it on the next request: a scope the role no longer allows is dropped. A request for a route the key's scopes do not cover is 403 scope. What each role may do is on Sign in.

Two kinds of key end with the role instead. They are revoked when the role changes, and the person is told by mail:

  • A key that lasts until it is revoked, when the person who made it is no longer an Administrator or an Owner.
  • Where the console has a Developers page, a key with a scope the new role does not hold.

A key's limits

Where the console has a Developers page, a key can have three limits. Each is optional. A person sets and changes them on that page. The person who made a key can lower its limits, and set one where it had none. Raising a limit or removing one takes an Administrator or an Owner.

LimitWhat it countsAt the limit
The most one job may costeach job the key starts on your own clouds: the job's budget is this amount at mostthe job is held to it as to any budget: see Spend caps and budgets
The spend limit for the monththe calendar month, in UTC. Three sums together: what the key's own-cloud jobs have cost by Fluid's estimate, what those still running hold, and what its Fluid compute jobs were charged, less refundsthe key starts nothing new: 402 key_spend_limit
The GPUs it may hold at oncethe GPUs of the key's Fluid compute jobs, each from its admission to its enda job that would pass it is refused: 409 key_gpu_limit

A limit only narrows what the workspace allows. The workspace's own balance and caps are checked first, and the key's limits after them. A limit binds from the moment it is set.

The spend limit on your own clouds

A job on your own cloud spends there, and Fluid learns what it cost reading by reading. So the month's limit is kept by each job's budget:

  • A job the key starts gets a budget no larger than what the month has left. A job that names no budget gets all of it. A job that asks for more is refused with 400, and the sentence says how much is left.
  • The job's budget policy is on, and the key cannot switch it off. At its budget the job is suspended with its state saved, as under any budget.
  • A job that has not ended holds its whole budget of the month, whatever it has cost so far. So a job with no budget of its own holds everything that is left, and the key starts nothing else until it ends. Give each job a budget_usd to run several at once.
  • A job counts in the month it was started in, all of it, however long it runs. A job started on the last day of a month goes on in the next one under the budget its own month gave it. It takes nothing from the new month, and its budget cannot be raised past what its own month has left.
  • Two requests of one key that start a job or set a budget at the same moment take turns, so both are never given the same remainder. One that waits too long is answered 429 key_busy with Retry-After. Send it again.
  • A key with a monthly limit changes, moves and resumes only the jobs it started: 403 key_job for any other. It reads, stops and suspends any job its scopes cover.
  • A job the key started before it had the limit keeps the budget it was started with, or none.

When the month has nothing left, an upload, a launch and a resume of a job with nothing left to spend are refused: 402 key_spend_limit. A quote is still answered. The answer says the limit, what the key has used, what its running jobs hold and when the month ends:

{
  "error": "This key's $500.00 limit for this month is taken: $112.37 used, and $387.63 held by the budgets of its jobs still running. It starts nothing new until one ends. Give its jobs smaller budgets to run more at once, or have the key's limit raised on the Developers page.",
  "code": "key_spend_limit",
  "retryable": false,
  "limit_usd": "500.00",
  "used_usd": "112.37",
  "held_usd": "387.63",
  "resets_at": 1796083200.0
}

If Fluid cannot read what the key has used, the request is refused as not checked: 503 key_limit_unread, with Retry-After. That is the upload, the launch and its quote, a change of a job, a move and a resume, on your own clouds. A compute route never answers it.

The spend limit on Fluid compute

Fluid compute charges by the minute, so the limit is asked at the admission and then each minute:

  • A new job is refused: 402 key_spend_limit. The answer holds the sentence and the code alone.
  • A job that is running when the month is used up is suspended and kept at no charge. It goes on when the limit is raised, a job of the key's on your own cloud ends and frees its budget, or the next month begins. A job whose program cannot be paused is stopped instead.
  • A refund gives the key's month back, as it gives the workspace's spend back.

The limit on GPUs

Under the limit on GPUs, the jobs admitted first run. If the limit is lowered below what the key's jobs hold, the later ones are suspended until an earlier one ends. One whose program cannot be paused is stopped instead.

A key reads its own limits with GET /api/me.

Routes

Every path is on the gateway's host. Where the console has a Developers page, its API tab shows these calls in curl, Python and JavaScript, ready to copy, and can try a read for you with your own sign-in.

RouteScopeWhat it does
GET /api/meany keywho the key is, its workspace and its limits
GET /api/compute/pricingnone: no key is neededthe rate card
POST /api/compute/admissionjobswhether a job would be admitted, before anything is uploaded
POST /api/uploadsjobsa link to upload the bundle to
POST /api/jobsjobsstarts a job
GET /api/compute/jobsreadthe workspace's Fluid compute jobs
GET /api/compute/jobs/{id}readone job
POST /api/compute/jobs/{id}/stopjobsstops a job
GET /api/compute/balancereadthe workspace's balance
GET /api/compute/usagereadthe workspace's usage, a line a job
  • A body is a JSON object, sent with Content-Type: application/json. A GET takes no body.
  • An answer is a JSON object.
  • Money is a string of dollars, such as "182.40", never a number. It is to the cent, except a rate and the charges of the usage, which keep every digit they have. One member is older than the rule: budget_usd in GET /api/me is a number.
  • A time is in seconds since the start of 1970, in UTC.
  • The rates and amounts in the examples below are made up. The rates in force are the ones the rate card answers.

Every compute route but the rate card and the stop asks whether the person who made the key is invited to Fluid compute.

Who is calling

GET /api/me, with any key. The answer, less what a key has no use for:

{
  "principal": {
    "kind": "token",
    "id": "agt_5c1e9a0b7d3f2e48",
    "name": "nightly training",
    "scopes": ["jobs", "read"],
    "expires_at": null,
    "budget_usd": 25.0,
    "limits": {"month_usd": "500.00", "gpus": 4}
  },
  "workspace": {
    "id": "ws_8a41f0c2d97b3e65",
    "name": "Research",
    "kind": "team",
    "state": "active",
    "role": "member"
  }
}
MemberWhat it says
principal.scopesthe key's scopes within its maker's current role
principal.expires_atwhen the key ends, or null for a key that lasts until it is revoked
principal.budget_usdthe most one job may cost, a number, or null for none
principal.limitsthere where the console has a Developers page: month_usd, the spend limit for the month as a string of dollars, and gpus, the GPUs the key may hold at once. Each is null for none
workspace.rolethe role of the person who made the key

The answer also holds controller, which describes the gateway that answered, and billing, the workspace's plan, while plans are on.

The rate card

GET /api/compute/pricing. It is public: send no key.

curl https://api.fluid.sh/api/compute/pricing
{
  "version": 7,
  "chips": [
    {
      "chip": "A100",
      "sizes": [
        {"vram_gb": 40, "usd_per_hour": "1.50", "available": true, "gpus": [1, 4]},
        {"vram_gb": 80, "usd_per_hour": "2.10", "available": true, "gpus": [1]}
      ]
    },
    {
      "chip": "H100",
      "sizes": [
        {"vram_gb": 80, "usd_per_hour": "3.955", "available": false, "gpus": []}
      ]
    }
  ]
}
MemberWhat it says
versionthe rate card's version. A job keeps the rate of the version it was admitted under
chipthe chip's name, as a job's spec names it
vram_gbone memory size the chip is sold in, in GB
usd_per_hourthe rate of one GPU for an hour of computing. A job of several GPUs pays it once for each. A rate may have more than two decimals
availablewhether a job of one GPU can be had now
gpusthe counts of GPUs on one machine the size can be had with now, smallest first. Empty where none can

While no rates are published the answer is 503 unavailable. fluid rates prints the same card: see fluid rates.

Ask before the upload

POST /api/compute/admission, with the jobs scope. The body is the spec the submission will send, without its upload:

{
  "spec": {
    "entry": "train.py",
    "project": "training",
    "chip": "A100",
    "vram": 80
  }
}

The answer is the chip, the size and the rate the job would be admitted under:

{
  "chip": "A100",
  "vram_gb": 80,
  "usd_per_hour": "2.10",
  "rate_card_version": 7,
  "gpus": 1
}
  • A refusal is the one the submission would answer. Nothing was uploaded for it.
  • The answer is no promise. Nothing is held and no job is made. The submission is checked in full, and may still be refused.
  • usd_per_hour is the job's whole rate: the chip's rate, once for each of its gpus.

Upload the bundle

POST /api/uploads, with the jobs scope. The body is the bundle's size in bytes and its SHA-256 in hex:

{
  "bytes": 48211934,
  "sha256": "b5790eaab58e675da4a3732b7a53afea7b61c87bc3810b06772c64fae9f986ec"
}

The answer is a link to put the bundle to, and the id the submission names:

{
  "upload_id": "up-3f9c2a7d41b06e58",
  "put": "https://store.example.com/uploads/up-3f9c2a7d41b06e58/workspace.tar.zst?signature=...",
  "expires_s": 3600,
  "expires_at": 1795618931.0
}

Then send the bundle with a PUT to the put link:

  • The body is the bundle's bytes, with a Content-Length of exactly the bytes announced. The link is signed for that length, and any other is refused.
  • The fluid command sends Content-Type: application/zstd.
  • Send no Authorization header. The link is the credential, and the bytes go to the store, not through Fluid.
  • The link works for an hour (expires_s).

The bundle is a tar archive of the project's files, compressed with zstd, of 600 MB at most. The fluid command builds it: it leaves out files over 100 MB and refuses a project over 500 MB.

An upload no job takes counts against the workspace, which may hold 2 GB and 64 of them. One nothing was put to stops counting when its link expires, and one that holds files a day after it was made. At the limit the next upload is refused with 429. So ask before the upload.

This route serves the jobs on your own clouds too. Its refusals hold error, and not always a code.

Start a job

POST /api/jobs, with the jobs scope, as JSON. A job whose spec names a chip is a Fluid compute job. The body is the spec and the upload:

{
  "spec": {
    "entry": "train.py",
    "args": ["--epochs", "3"],
    "project": "training",
    "env_spec": {"python": "3.12", "requirements": ["torch==2.5.1"], "source": "requirements.txt"},
    "chip": "A100",
    "vram": 80,
    "gpus": 1
  },
  "upload_id": "up-3f9c2a7d41b06e58"
}
Member of the specRequiredWhat it is
chipyesa chip's name from the rate card, such as A100
vramnothe chip's memory in whole GB. Without it the job takes the cheapest size the chip comes in
gpusnohow many GPUs of the chip the job has, all on one machine: a whole number from 1. Without it, 1
entryyesthe script's path inside the bundle
projectyesthe project's name, 1 to 100 characters
argsnothe script's arguments, a list of strings
namenoa name for the job. Without it, the script's file name
envnoenvironment variables for the script, names to strings
secretsnonames of stored secrets, each given to the script as an environment variable
env_specnothe project's environment as the fluid command read it: its Python version and its requirements

Fluid places a compute job, so its spec may not say:

MemberRefused with
on, requirements, gpu_fallback400 placement_is_portals: they choose a machine
plan_only400 invalid_request: a compute job has no quote. Its rates are on the rate card
budget_usd400 invalid_request: a compute job has no budget. It is paid from the workspace's balance
policy, policy_apart400 invalid_request: a compute job has no policy
ranks other than 1, requirements.nodes other than 1400 several_ranks: a compute job is one process on one machine. It can have several GPUs there: ask with gpus. This is asked before the members above

A spec with a chip sent as a multipart form, or without its upload_id, is 400 invalid_request. Where Fluid compute is off, a spec with a chip is 400 unknown_field.

The answer is 201, at once. There is no quote:

{
  "job_id": "job-1125-141502-3fa9",
  "chip": "A100",
  "vram_gb": 80,
  "usd_per_hour": "2.10",
  "rate_card_version": 7,
  "gpus": 1
}

The job keeps its chip, its size, its count of GPUs and its rate for life. usd_per_hour is the job's whole rate: the chip's, once for each of its gpus.

Fluid checks a submission in this order. The first check that fails is the answer:

  1. The person who made the key is invited to Fluid compute (not_invited).
  2. The job is one process on one machine (several_ranks), and its spec says nothing a compute job does not take.
  3. The chip is on the rate card, in the size asked for (unknown_chip, unknown_size).
  4. The chip and size can be had now, with the count of GPUs asked for (chip_unavailable).
  5. The workspace may run it: its spend cap, the GPUs it may hold at once and its balance, in that order (spend_cap, gpu_cap, balance). Then the key's own limits (key_spend_limit, key_gpu_limit).

The fluid command does all of it in one line. It asks for admission, builds the bundle, uploads it and submits the job:

fluid run SCRIPT --chip CHIP --project NAME

--vram GB names the size and --gpus N the count. See fluid run.

List the jobs

GET /api/compute/jobs, with the read scope. The answer is the workspace's Fluid compute jobs, newest first, each as one job reads:

{
  "jobs": [
    {
      "id": "job-1125-141502-3fa9",
      "project": "training",
      "status": "running",
      "chip": "A100",
      "vram_gb": 80,
      "region": "US East",
      "started_at": 1795616110.0,
      "ended_at": null,
      "computed_s": 5400,
      "cost_usd": "3.15",
      "waiting": null,
      "cannot_pause": null,
      "stopped_because": null,
      "gpus": 1,
      "failed_because": null
    }
  ]
}

Read a job

GET /api/compute/jobs/{id}, with the read scope. The answer is the job, as one entry of the list above.

MemberWhat it says
idthe job's id
projectthe job's project
statusone of the statuses below
chip, vram_gb, gpusthe chip, its memory in GB and the count of GPUs. The job keeps them for life
regionwhere the job runs, as a neutral name such as US East. Null until the job has landed somewhere
started_atwhen the job first started. Null until then
ended_atwhen the job ended. Null until then
computed_sthe seconds the program computed. Booting, waiting and a suspension are not counted
cost_usdwhat that has cost at the job's rate, in whole minutes. The last minute is rounded up once the job has ended
waitingone sentence while the job waits, and null at every other time
cannot_pausea few sentences while the job runs and Fluid cannot pause its program, and null at every other time. They say which of the program's values are in the way, by name and type, and that the job would be stopped, not suspended, if the workspace ran out of credit or reached a cap
stopped_becauseone sentence at the end of a job Fluid stopped because the workspace or the key could not run it and its program could not be paused. Null for every other job
failed_becauseone sentence at the end of a job Fluid could not start: none of its program ran and nothing was billed. Null for every other job, a program that failed by itself among them

The statuses:

StatusWhat it means
startingthe program is not computing yet: the job is queued, its machine is booting, or it is being continued
runningthe program computes. A move is not a status: a job that is being moved reads running
suspendedthe program is not computing: it is saved, or being saved, to go on later
stoppingsaid in the answer to a stop, for a job that has not ended yet
finishedthe program ended with exit code 0
stoppedthe job was stopped. Where Fluid stopped it because the workspace or the key could not run it, stopped_because says so
failedthe program ended with another exit code, or the job could not be run. Where Fluid could not start it, failed_because says so

A job that reads starting or suspended with waiting null is booting or being carried, and needs nothing. Otherwise waiting says why it waits and what ends the wait:

waiting opens withWhy the job waitsWhat ends the wait
Waiting for a machine.no machine with the chip is freeFluid keeps trying
Waiting for credit.the workspace has no credit leftthe workspace has credit again
Waiting on the spend cap.the workspace has reached its spend capthe cap is raised
Waiting for a free slot.the workspace, or the key that started the job, holds as many GPUs at once as it mayan earlier job ends
Waiting on the key's spend limit.the key that started the job has reached its limit for the monththe limit is raised, or the next month begins
Waiting on the workspace.the workspace may not run the job, for a reason with no sentence of its ownit may again

A job that waits for credit, a cap or a limit is kept at no charge. The sentences are for a person to read. A program checks whether waiting is null.

Stop a job

POST /api/compute/jobs/{id}/stop, with the jobs scope. It needs no body. The answer is the job: stopping until it has ended, and a job that had already ended as it is.

A stop is never refused for money. It asks nothing of the balance, a cap, a key's limit or an invitation, and it works in a frozen workspace. The only compute refusal it answers is 404 no_such_job.

The balance

GET /api/compute/balance, with the read scope.

curl -H "Authorization: Bearer $API_KEY" https://api.fluid.sh/api/compute/balance

Here the key is in the environment variable API_KEY.

{
  "balance_usd": "182.40",
  "held_usd": "5.00",
  "spend_cap_usd": null,
  "gpu_cap": 8
}
MemberWhat it says
balance_usdthe workspace's credits and top-ups, less the usage it is charged
held_usdits open holds: the minimum of the chip of each job that has not ended. A new job must fit in the balance less the holds
spend_cap_usdthe workspace's spend cap, or null when none is set
gpu_capthe GPUs the workspace's jobs may hold at once, or null when none is set

fluid balance prints the balance and the usage: see fluid balance.

The usage

GET /api/compute/usage, with the read scope. The answer is one line a job, oldest first, and the total. A refund is not a line of it.

{
  "lines": [
    {
      "job_id": "job-1125-141502-3fa9",
      "chip": "A100",
      "vram_gb": 80,
      "computed_s": 5400,
      "usd_per_hour": "2.10",
      "rate_card_version": 7,
      "cost_usd": "3.15"
    },
    {
      "job_id": "job-1125-160233-b71c",
      "chip": "T4",
      "vram_gb": 16,
      "computed_s": 177,
      "usd_per_hour": "0.53",
      "rate_card_version": 7,
      "cost_usd": "0.0265"
    }
  ],
  "total_usd": "3.1765"
}
  • cost_usd and total_usd here are the exact charges, not rounded to the cent. A charge has two decimals, and up to six where it has a part of a cent: three minutes on a T4 are "0.0265".
  • The lines add up to total_usd exactly. Add them as decimals, not as floating-point numbers.
  • A job's cost_usd on its own answer is to the cent. For a job that has ended it is the job's line here, rounded. The balance is to the cent too.

Webhooks

A webhook is a POST Fluid sends to a server of yours when something happens to a job. Where the console has a Developers page, an Administrator or an Owner sets them up on its Webhooks tab: the address, and the kinds of event it takes. A workspace has 5 endpoints at most. No route with a key makes or changes one.

The events

typeWhen
job.starteda job's program began to run, for the first time
job.suspendeda job was suspended: its state is saved and it holds no machine
job.resumeda suspended job's program runs again
job.finisheda job's program ended with exit code 0
job.faileda job ended in failure: its program exited with another code, or the job could not be run
job.stoppeda job was stopped: by a person, a key, a budget or a limit

A move between machines is no event: the job is running before it and after it. An endpoint is sent the events that happen after it was made, of the kinds it takes, for every job of the workspace: on Fluid compute and on your own clouds.

An end is not always a job's last event. A job on your own clouds that failed can be resumed, and so can one that found no machine, which is told as job.failed with the status no_capacity. A job that is resumed tells job.resumed, or job.started where its program starts from the beginning, and later its end. The events are what happened, in order.

webhook.test is the event the console's "Send a test event" sends, to one endpoint, whatever kinds it takes.

The body

The body is JSON with five members:

{
  "id": "evt_6f1c2a9d4b7e4c0f8a3d5e21",
  "type": "job.finished",
  "created": 1795623370.412,
  "workspace": "ws_8a41f0c2d97b3e65",
  "data": {
    "job": {
      "id": "job-1125-141502-3fa9",
      "project": "training",
      "status": "finished",
      "chip": "A100",
      "vram_gb": 80,
      "region": "US East",
      "started_at": 1795616110.0,
      "ended_at": 1795623370.0,
      "computed_s": 7200,
      "cost_usd": "4.20",
      "waiting": null,
      "cannot_pause": null,
      "stopped_because": null,
      "gpus": 1,
      "failed_because": null
    }
  }
}
MemberWhat it says
idthe event's id. It is the same at every try of the event, and the same for every endpoint the event goes to
typethe kind of event
createdwhen it happened, in seconds since 1970
workspacethe workspace's id
datawhat the event is about. For a job, data.job is the job
  • A job on Fluid compute is the job as Read a job answers it, member for member. So no delivery names a supplier, a machine type, a market, a zone or a move.
  • A job on your own clouds is the job as the job list answers it (GET /api/jobs, with the read scope), member for member. That is its id, name, project and status; the program it runs, as entry and args; its times; where it runs; what it has cost, what it saved and its budget; its progress and its last_event; and, for a job a failure left suspended, why and what was lost.
  • args is in the body. The arguments a job was started with are sent as they were given. Pass a secret to a job through your cloud's own secret store, not as an argument.
  • Money is a string of dollars, in every body, for a job of either kind: "4.20", never 4.2. It has two decimals at least and six at most. This holds for every member whose name says money (cost_usd, saved_usd, budget_usd, a rate such as price_per_hour), at any depth. The job list sends an own-cloud job's amounts as numbers. A webhook's body does not: it follows the rule of every answer made since, the same as The balance.
  • data.job.status is the status the event tells. job.started and job.resumed say running, job.suspended says suspended, job.finished says finished, job.stopped says stopped, and job.failed says failed, or no_capacity for a job on your own clouds that found no machine. The rest of the job is read when Fluid makes the event, moments after the change. Where the job had already moved on by then, ended_at, stopped_because and failed_because are null in an event that is not its end.
  • data of a webhook.test event is {"endpoint": "whk_...", "message": "..."}.
  • A later release may add members to the body and kinds of event. Ignore what you do not know.

The signature

Every delivery carries three headers:

HeaderWhat it holds
webhook-idthe event's id, the body's id
webhook-timestampwhen this try was sent, in whole seconds since 1970
webhook-signaturev1, and a base64 signature

The signature is HMAC-SHA256 over the id, a dot, the timestamp, a dot and the body exactly as it was sent. The key is your endpoint's signing secret: whsec_ followed by the base64 of the key's bytes. This is the Standard Webhooks scheme, so its libraries verify a delivery as it is.

Check three things before you trust a delivery: the signature, on the raw bytes of the body and not on a parsed copy; the timestamp, within 5 minutes of your clock; and the id, which you have not taken before.

In Python, with the standard library:

import base64, hashlib, hmac, time

def verified(secret: str, headers: dict, body: bytes) -> bool:
    """Whether Fluid sent this body. `headers` has its names in lowercase."""
    event_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    if abs(time.time() - int(timestamp)) > 300:
        return False
    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{event_id}.{timestamp}.".encode() + body
    expected = "v1," + base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    return any(hmac.compare_digest(expected, one) for one in headers["webhook-signature"].split())

In Node:

import { createHmac, timingSafeEqual } from "node:crypto";

// Whether Fluid sent this body. `body` is the raw request body, a Buffer.
export function verified(secret, headers, body) {
  const id = headers["webhook-id"], timestamp = headers["webhook-timestamp"];
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const key = Buffer.from(secret.slice("whsec_".length), "base64");
  const signed = Buffer.concat([Buffer.from(`${id}.${timestamp}.`), body]);
  const expected = Buffer.from("v1," + createHmac("sha256", key).update(signed).digest("base64"));
  return headers["webhook-signature"].split(" ").some((one) => {
    const given = Buffer.from(one);
    return given.length === expected.length && timingSafeEqual(given, expected);
  });
}
  • The request's User-Agent names the sender and ends in -Webhooks/1. It proves nothing: trust the signature, not the name.
  • The secret is shown once, when the endpoint is made. Fluid keeps it sealed and never shows it again.
  • An Administrator or an Owner can make a new secret. The one before it stops signing at once, and every later try, of an earlier event too, is signed with the new one.

Deliveries and retries

  • Answer any 2xx within 10 seconds to take a delivery. Fluid reads the status and never the answer's body. Do the work after you answer.
  • Any other answer, a redirect, a timeout, a failed connection or an answer that is not HTTP is a try that was not taken. Fluid tries again after a minute, then after twice as long each time, up to an hour between tries, for 24 hours from when the event was made. Then the delivery is dropped.
  • A delivery is sent at least once. You can get the same event twice, with the same id: take it once.
  • One job's events reach an endpoint in the order they happened. job.started never arrives after that job's job.finished: the later event is held until the earlier one is taken or dropped. Events of different jobs can arrive in any order. Order those by created.
  • An endpoint is sent one delivery at a time, and a workspace's endpoints share a few sends at once. An endpoint that answers fast gets its next delivery sooner than one that answers slowly.
  • While an endpoint takes nothing, Fluid makes one try in a while for all of its deliveries, not one for each. An endpoint that takes nothing for 24 hours is paused, and the Webhooks tab says so. Events that happen while it is paused are not sent to it later. Resume it there once it works.
  • A try that Fluid itself could not make is not held against your endpoint. It counts toward no pause and no drop, and is made again within a minute. An endpoint is paused only for 24 hours in which it was really tried.
  • A test event is sent at once, to an endpoint that is waiting after a failed try too. It does not end that wait for the endpoint's other deliveries.
  • The Webhooks tab lists each endpoint's recent deliveries for 7 days: the event, the tries, the status your server answered, how long the try took in steps of a tenth of a second, and when the next try is.
  • The Webhooks tab also shows what a delivery was sent: the body, byte for byte, and the names of its headers with the event's id. Fluid keeps an event's body for about a day (26 hours), so an older delivery is listed without it. The tab never shows a signature: check yours against the body with your own secret.
  • From a delivery in the Webhooks tab you can send it again once it has ended, delivered or dropped, while Fluid still keeps the event's body (26 hours from the event). It is the same event: the same id and the same body, with a new timestamp and signature. If your server already took that id, it skips it, as it should. A delivery sent again goes at once and is outside its job's order: it can arrive after later events of the same job.
  • Fluid's team can pause a workspace's webhooks, for an endpoint that harms others. The Webhooks tab then says so on every endpoint, one added afterwards too, and only Fluid's team resumes them.

The address

Fluid's servers make the request, so the address is held to what the public internet can reach:

  • https only, to a host name: not an IP address, and with no user name or password in it.
  • Port 443, or one from 1024 up.
  • The name must resolve to public addresses only. One that resolves to a private, loopback or link-local address is refused, at every send. Fluid connects to the address it checked.
  • Not a name of Fluid's own: clusy.io, fluid.sh and every name under them are refused.
  • No redirect is followed.
  • A try that could not reach a public address says one thing, whichever way it failed: that the endpoint could not be reached at a public address. Fluid does not say whether the name was not found or what it resolved to.

An address can hold a credential, such as a token in its path or its query. So Fluid shows an endpoint's address whole only to the workspace's Administrators and Owners, and writes it to no log and no audit entry. Your server should still trust the signature, not the address.

Refusals

A refusal is a status of 400 or more and a JSON object with a sentence for a person and a code for a program:

{
  "error": "The workspace's balance does not cover the minimum of $5.00 for A100.",
  "code": "balance",
  "needed_usd": "5.00"
}

Act on the code and the status, and show the sentence. Some refusals add members: balance adds needed_usd, the minimum the balance must cover, and the gateway's key_spend_limit adds the key's figures.

The codes of the compute routes. The list is closed:

CodeStatusWhat it means
not_invited403the person who made the key is not invited to Fluid compute
invalid_request400a member is missing or wrong. The sentence names it
several_ranks400the spec asks for several processes or machines. A compute job is one process on one machine
unknown_chip400the chip is not on the rate card
unknown_size400the chip is not sold in that memory size. The sentence lists the sizes it is sold in
chip_unavailable409the chip and size are on the rate card and cannot be had now, or not with that count of GPUs
balance402the workspace's balance does not cover the chip's minimum
spend_cap402the workspace's spend cap is reached
gpu_cap409with this job the workspace would hold more GPUs than it may at once
key_spend_limit402the key has reached its spend limit for the calendar month
key_gpu_limit409with this job the key would hold more GPUs than it may at once
no_such_job404no compute job of this workspace has that id
placement_is_portals400the spec chooses or reveals a machine. Fluid places a compute job
unavailable503a fault of Fluid's. Send the request again. A stop is never refused for one

The gateway's own:

CodeStatusWhat it means
signin401no key, a header in another form, or a key that does not work any more
invalid_body400a body on a GET, or a body that is no JSON object
scope403the key's scopes do not cover the route
not_found404no such path or method. A compute route answers it where Fluid compute is off
too_large413the body is over the route's limit
rate_limited429too many of the workspace's requests are in flight. The answer carries Retry-After
key_spend_limit402on your own clouds: the key's month has nothing left. The answer adds the key's figures
key_job403a key with a monthly limit asked to change, move or resume a job it did not start
key_busy429another request of the key's is starting a job or setting a budget. The answer carries Retry-After
key_limit_unread503what the key has used could not be read, so the request was not checked against its limit. The answer carries Retry-After
payment_method_required402on the admission, the upload and the start: the workspace was asked to link a payment method before its first job, and has none yet. The rule asks before any job, on your own clouds or on Fluid compute. An Owner links a bank account or a card on the console's Billing page, which charges nothing. Sending the request again does not help until then. Reading and stopping still work
payment_method_unchecked503on the same three: Fluid could not read whether the workspace has a payment method, so it started nothing. Nothing is wrong with the request. Send it again in a moment. The answer carries Retry-After
workspace_frozen409on the admission, the upload and the start: the workspace has no active Owner, so nothing new starts. Reading and stopping still work
platform_frozen409on the same three: Fluid's operator has paused new work everywhere. Reading and stopping still work
timeout504a read of a compute route took too long. Send it again
controller_timeout504the upload route did not answer in time. Send it again

Limits

  • Requests in flight. A workspace has at most 128 requests in flight at one time. One more is 429 rate_limited with Retry-After: 1. Every key and every person of the workspace share them.
  • No limit per key. There is no separate rate limit for one key.
  • A body. At most 1 MiB, then 413 too_large.
  • A read. A GET of a compute route is given 35 seconds, then 504 timeout.
  • The bundle. An archive of 600 MB at most. An upload link works for an hour. A workspace holds at most 2 GB and 64 uploads no job has taken.
  • Webhooks. 5 endpoints a workspace. A delivery is given 10 seconds, and is tried for 24 hours. A recent delivery is listed for 7 days.
  • Request activity. A request made with a key is kept 30 days, and the latest 100,000 of a workspace at most. Every 2 seconds a server records at most 20 requests of one key and 50 of one workspace.
  • Jobs at once. A workspace runs at most 100 jobs at once, on Fluid compute and on its own clouds together. At that count an upload is refused with 429, and a submission that arrives then with 503 unavailable, whose sentence names the count.

Every limit, with its value and where it is set, is on Limits.

What no answer says

Fluid places a compute job, and where it runs is Fluid's to choose and to change.

  • No answer of a compute route names a supplier, a machine type, a market, a zone or a move. A sentence that would is replaced before it is sent.
  • A region is a neutral name: US, US East, US Central, US West, Canada, Mexico, South America, Europe, Middle East, Africa or Asia Pacific. When a job lands in another region its region changes, and nothing else does.
  • The rate is the job's own: the chip's published rate, once for each of its GPUs, as the job was admitted. It does not change with where the job runs.

On this page