Skip to content
Hayonix

API reference · Serverless

Partial output streamed by the handler, in order (long-poll with `wait`)

GET/v1/serverless/jobs/{job_id}/stream
API keyserverless_job:readProject
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

Headers
HeaderRequiredDescription
AuthorizationyesBearer and your API key. The key implies its project.
X-Project-Idsession onlyThe project to act in, for console sessions. Requests with an API key leave it out.

Path parameters

  • job_idstringrequired

    ID of the job

    ID with prefix sjb_

Query parameters

  • afterinteger | null

    Return chunks with a sequence number above this (`next_after` of the previous page)

    at least 0

  • waitinteger | null

    Long-poll up to this many seconds for new chunks

    0–30

Response

200 ServerlessJobStream — Chunks after `after`

  • objectstringrequired

    Always `serverless_job_stream`: the type of this object

    One ofserverless_job_stream

  • job_idstringrequired

    ID of the job

  • attemptintegerrequired

    Chunks belong to this attempt; after a retry the stream starts over

  • statestringrequired

    The job's state (see `ServerlessJob.state`)

  • chunksarray of objectrequired

    Up to 200 chunks, in order

    Show 3 fields of chunks
    • seqintegerrequired

      Position of the chunk in the attempt, increasing

    • dataany JSON

      Details; their shape depends on the kind of entry

    • created_atstring (date-time)required

      When it was created (ISO 8601, UTC)

  • next_afterintegerrequired

    Pass as `after` to read the following chunks (unchanged when none arrived)

  • donebooleanrequired

    True when the job has finished and every chunk has been returned

Example response
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:

Errors
StatusTypeWhen
400invalid_request_errorA parameter or body field is missing or not allowed; param names it.
401authentication_errorThe key or session is missing, revoked or expired.
403permission_errorThe credential lacks the permission this needs, or the organization is suspended.
404not_found_errorNo such resource in this project (an ID from another project is answered the same way).
429rate_limit_error rate_limitedToo many requests; retry after retry-after seconds.