API reference · Serverless
Partial output streamed by the handler, in order (long-poll with `wait`)
/v1/serverless/jobs/{job_id}/stream- TypeScript
client.serverless.streamJob()- Python
client.serverless.stream_job()- CLI
hayonix serverless run
Returns the chunks of the current attempt after after, up to 200 at a time; call again with next_after until done is true. If the job is retried, the stream starts over with the new attempt (watch attempt).
Project API key (Authorization: Bearer sk_…), or a console session. Requires the serverless_job:read permission (a key's scope, or a role that includes it).
Examples
The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.
curl -sS "$API_BASE_URL/serverless/jobs/sjb_01jc5zq4m8k3v6x9t2w7r0b1e4/stream" \
-H "Authorization: Bearer $API_KEY"Request
| Header | Required | Description |
|---|---|---|
Authorization | yes | Bearer and your API key. The key implies its project. |
X-Project-Id | session only | The project to act in, for console sessions. Requests with an API key leave it out. |
Path parameters
job_idstringrequiredID of the job
ID with prefix sjb_
Query parameters
afterinteger | nullReturn chunks with a sequence number above this (`next_after` of the previous page)
at least 0
waitinteger | nullLong-poll up to this many seconds for new chunks
0–30
Response
200 ServerlessJobStream — Chunks after `after`
objectstringrequiredAlways `serverless_job_stream`: the type of this object
One of
serverless_job_streamjob_idstringrequiredID of the job
attemptintegerrequiredChunks belong to this attempt; after a retry the stream starts over
statestringrequiredThe job's state (see `ServerlessJob.state`)
chunksarray of objectrequiredUp to 200 chunks, in order
ShowHide 3 fields of
chunksseqintegerrequiredPosition of the chunk in the attempt, increasing
dataany JSONDetails; their shape depends on the kind of entry
created_atstring (date-time)requiredWhen it was created (ISO 8601, UTC)
next_afterintegerrequiredPass as `after` to read the following chunks (unchanged when none arrived)
donebooleanrequiredTrue when the job has finished and every chunk has been returned
Example response
{
"object": "serverless_job_stream",
"job_id": "string",
"attempt": 1,
"state": "string",
"chunks": [
{
"seq": 1,
"data": {},
"created_at": "2026-01-01T00:00:00.000Z"
}
],
"next_after": 1,
"done": true
}Errors
Errors use the standard envelope. What this operation can answer:
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | A parameter or body field is missing or not allowed; param names it. |
401 | authentication_error | The key or session is missing, revoked or expired. |
403 | permission_error | The credential lacks the permission this needs, or the organization is suspended. |
404 | not_found_error | No such resource in this project (an ID from another project is answered the same way). |
429 | rate_limit_error rate_limited | Too many requests; retry after retry-after seconds. |