For AI agents: this page is also available as Markdown at https://docs.refabric.com/task-apis/headers.md, and the index of every page is https://docs.refabric.com/llms.txt.

Task APIs

Headers

The request headers that change how a task call is handled, and the headers every answer carries.

These are request options, not task inputs. A task's input is the JSON body, checked against its schema; a header changes how the call is handled — whether it is safe to retry, how long to wait, when to give up. The two stay separate: a header is sent with the HTTP request, a task input is a field of the body.

Idempotency-Key

Makes a retried submit safe: the same key with the same body answers the first job again instead of starting a second one.

HeaderIdempotency-Key
Defaultnone — every submit starts a new job
Formatan opaque string; use a UUID v4
Where it appliesPOST /v1/tasks/{name} only; other operations ignore it
import uuid
key = str(uuid.uuid4())  # once per operation, kept with it
s.post(f"{API}/tasks/image.generate", json=body, headers={"Idempotency-Key": key})

The same key with a different body answers 409 idempotency_key_reused; nothing runs.

Idempotency →

Prefer: wait

Holds the submit's answer until the job ends, up to N seconds.

HeaderPrefer: wait=N
Defaultabsent: the submit answers 202 at once
Unitseconds, a whole number
Max60; a larger N is cut to it
Where it appliesPOST /v1/tasks/{name}
Prefer: wait=30

A job that ends within N seconds answers 200 with its result; otherwise you get the usual 202 and the job keeps running. A malformed Prefer is treated as no wait. Set your HTTP client's timeout longer than N.

Synchronous →

X-Refabric-Start-Timeout

Despite the name, this limits time-to-start, not the run: a job that has not started within this many seconds of the submit ends without running.

HeaderX-Refabric-Start-Timeout
Defaultabsent: the job waits in the queue as long as it takes
Unitseconds; decimals allowed
Min0.1
Max86400
Valuesa value outside the range, or not a number, answers 422 invalid_request naming the header
Where it appliesPOST /v1/tasks/{name}
X-Refabric-Start-Timeout: 30

A job that misses its start deadline fails with start_timeout, releases its credit hold, and the answer about it carries X-Refabric-Start-Timeout-Type: user.

Start deadline →

Refabric-Version

Pins the dated contract version you wrote against.

HeaderRefabric-Version
Defaultabsent: the current version
Formata date, YYYY-MM-DD
Valuesthe published versions; any other value answers 400 invalid_request
Where it appliesevery operation; every answer echoes the version it followed
Refabric-Version: <a published version date>

Versioning →

X-Request-ID

Your own id for a request, logged next to ours.

HeaderX-Request-ID
Defaultabsent
Formata short id of letters, digits and . _ : -; the exact rule is in Conventions
Where it appliesevery operation
X-Request-ID: order-4711-render

Every answer carries OUR id in X-Request-ID (req_…) — quote it to support. Yours comes back as X-Client-Request-ID. An id that does not fit the format is dropped, never refused.

Support →

webhook_url

A query parameter, not a header: the address we POST the job's terminal event to.

Parameter?webhook_url=https://…
Defaultabsent: no per-job callback
Formatan https:// URL that resolves to a public address
Where it appliesPOST /v1/tasks/{name}
curl -s -X POST "https://api.refabric.com/v1/tasks/image.generate?webhook_url=https://example.com/hooks/refabric" \
  -H "Authorization: Key $REFABRIC_API_KEY" -H "Content-Type: application/json" -d @body.json

A webhook_url we will not deliver to is refused at submit, before anything is held. It receives the terminal events only; registered endpoints can receive more.

Webhooks →

Response headers

HeaderOnMeaning
X-Request-IDevery answerour id for the request (req_…)
X-Client-Request-IDanswers to a request that sent a valid X-Request-IDyour id, echoed
Refabric-Versionevery answerthe contract version the answer follows
X-Refabric-Creditsa submit of a task that costs creditsthe credits held for the job
X-Refabric-Credit-Typethe same answersthe credit type of that hold
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Resetanswers to a request made with a keythe state of the key's rate window (Limits)
Retry-After429seconds until you may call again
X-Refabric-Error-Typeevery error answerthe error's type, the same as error.type
X-Refabric-Start-Timeout-Typean answer about a job that missed its start deadlineuser: the deadline was yours