> ## Documentation Index
> Fetch the complete documentation index at: https://runpod-b18f5ded-lg-apiv2-new.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Stream serverless worker logs

> Streams a serverless worker's logs as Server-Sent Events. The `source`
query parameter selects which log source to include.

The SSE `data` payload shape is:
`{ "source": "container", "line": "...", "ts": "..." }`.
Log-event `id` values are the event `ts` timestamp so browser/EventSource
reconnects can resume with `Last-Event-ID`.




## OpenAPI

````yaml get /v2/serverless/{id}/workers/{workerId}/logs
openapi: 3.1.0
info:
  title: Runpod REST API
  version: 2.0.0
  description: Runpod public REST API — v2
servers:
  - url: https://api.runpod.io
    description: Runpod API v2 production server
security:
  - bearerAuth: []
tags:
  - name: Pods
    description: GPU and CPU pod lifecycle, configuration, actions, and log streaming.
  - name: Serverless
    description: >-
      Serverless endpoint lifecycle, worker visibility, releases, and worker log
      streaming.
  - name: Templates
    description: Reusable pod and endpoint configuration templates.
  - name: Network Volumes
    description: Persistent network storage volumes for workloads.
  - name: Registries
    description: Container registry credentials used to pull private images.
  - name: Catalog
    description: Available GPU, CPU, and data center catalog metadata.
  - name: Billing
    description: Billing history and usage cost records across resource types.
paths:
  /v2/serverless/{id}/workers/{workerId}/logs:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Serverless endpoint identifier
        example: ep_abc123
      - name: workerId
        in: path
        required: true
        schema:
          type: string
        description: Worker identifier (from GET /v2/serverless/{id}/workers)
        example: worker_abc
    get:
      tags:
        - Serverless
      summary: Stream serverless worker logs
      description: >
        Streams a serverless worker's logs as Server-Sent Events. The `source`

        query parameter selects which log source to include.


        The SSE `data` payload shape is:

        `{ "source": "container", "line": "...", "ts": "..." }`.

        Log-event `id` values are the event `ts` timestamp so
        browser/EventSource

        reconnects can resume with `Last-Event-ID`.
      operationId: getWorkerLogs
      parameters:
        - $ref: '#/components/parameters/LogSourceParam'
        - $ref: '#/components/parameters/LogTail'
        - $ref: '#/components/parameters/LogSince'
        - $ref: '#/components/parameters/LogLastEventID'
      responses:
        '200':
          description: Worker log event stream
          headers:
            Cache-Control:
              schema:
                type: string
              description: Always `no-cache` for SSE responses.
            Connection:
              schema:
                type: string
              description: Always `keep-alive` to hold the SSE stream open.
            X-Accel-Buffering:
              schema:
                type: string
              description: Always `no` to disable proxy buffering of the SSE stream.
          content:
            text/event-stream:
              schema:
                type: string
                description: >-
                  Server-Sent Events stream. Each event includes an `id:` line
                  and a JSON `data:` payload with `source`, `line`, and `ts`
                  fields.
              examples:
                logLine:
                  summary: Successful response
                  value: >
                    id: 2026-06-01T12:05:04Z/000000000042

                    data:
                    {"ts":"2026-06-01T12:05:04Z","source":"container","line":"Worker
                    ready."}
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '429':
          $ref: '#/components/responses/TooManyRequestsError'
        default:
          description: Error
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    LogSourceParam:
      name: source
      in: query
      required: false
      description: Log source to stream. Omit to include both container and system logs.
      schema:
        $ref: '#/components/schemas/LogSource'
    LogTail:
      name: tail
      in: query
      required: false
      description: |
        Number of historical lines to backfill before streaming. Defaults to
        100 when omitted; set `0` to stream live with no backfill. Maximum 5000.
        Ignored when `since` or `Last-Event-ID` is provided — the resume cursor
        drives the backfill instead.
      schema:
        type: integer
        minimum: 0
        maximum: 5000
        default: 100
    LogSince:
      name: since
      in: query
      required: false
      description: |
        RFC3339 timestamp to resume from. Ignored when `Last-Event-ID` is
        provided. When set, the stream resumes from this point and `tail` is
        ignored.
      schema:
        type: string
        format: date-time
    LogLastEventID:
      name: Last-Event-ID
      in: header
      required: false
      description: |
        SSE reconnect cursor — a timestamp emitted by this endpoint. Takes
        precedence over `since` and `tail`: when present, the stream resumes
        from this point. Sent automatically by EventSource on reconnect.
      schema:
        type: string
        format: date-time
  responses:
    UnauthorizedError:
      description: >-
        Authentication failed because the bearer token is missing, malformed,
        expired, or invalid.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingBearerToken:
              summary: Missing bearer token
              value:
                title: Unauthorized
                status: 401
                detail: missing bearer token
    ForbiddenError:
      description: >-
        The bearer token is valid, but it does not grant access to the requested
        resource or action.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            insufficientAccess:
              summary: Insufficient access
              value:
                title: Forbidden
                status: 403
                detail: access denied
    NotFoundError:
      description: The requested resource was not found or is not accessible to the caller.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            notFound:
              summary: Resource not found
              value:
                title: Not Found
                status: 404
                detail: resource not found
    TooManyRequestsError:
      description: >
        The caller exceeded its per-user rate limit. The response identifies the
        window that was exceeded and how long to wait. The `RateLimit` and
        `RateLimit-Policy` headers (per the IETF ratelimit-headers draft) also
        accompany successful responses, so clients can track quota before a 429.
      headers:
        Retry-After:
          description: Seconds to wait before retrying, per the exceeded window.
          schema:
            type: integer
          example: 12
        RateLimit:
          description: >
            Live per-window state as a structured-field list — one member per
            window (`minute`, `hour`, `day`) with remaining count `r` and
            seconds-until-reset `t`.
          schema:
            type: string
          example: '"minute";r=0;t=12, "hour";r=2800;t=1812, "day";r=49500;t=45012'
        RateLimit-Policy:
          description: >
            Static quota policy as a structured-field list — one member per
            window with quota `q` and window length `w` (seconds).
          schema:
            type: string
          example: '"minute";q=60;w=60, "hour";q=3000;w=3600, "day";q=50000;w=86400'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              summary: Rate limit exceeded
              value:
                title: Too Many Requests
                status: 429
                detail: rate limit exceeded for the minute window
  schemas:
    ErrorResponse:
      type: object
      required:
        - title
        - status
        - detail
      properties:
        title:
          type: string
          description: Short human-readable summary
          examples:
            - Not Found
        status:
          type: integer
          description: HTTP status code
          examples:
            - 404
        detail:
          type: string
          description: Human-readable explanation
          examples:
            - pod not found
        errors:
          type: array
          description: Individual request-validation failures.
          items:
            type: string
          examples:
            - - '$: additional properties ''bogus'' not allowed'
    LogSource:
      type: string
      description: |
        Log source to include in a log stream.
        - `container` — container stdout/stderr log stream
        - `system`    — host lifecycle/userlogs stream
      x-enum-varnames:
        - LogSourceContainer
        - LogSourceSystem
      enum:
        - container
        - system
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Runpod API Key
      description: >
        Runpod API key authentication. Generate an API key in the Runpod console
        and send it in the `Authorization` header as `Bearer <api_key>`. Keys
        are scoped to the permissions granted when created; requests may return
        `403` when a valid key lacks access to the requested resource or action.

````