> ## Documentation Index
> Fetch the complete documentation index at: https://dev.writer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List log records

> Read LLM-call and agent-run records for the organization. Use `order=tail` to read an incremental stream that you resume with the `x-next-cursor` header, or `order=browse` to read a date window. The response is OTLP JSON by default; set `format=native` for Writer-native JSON.

> [!NOTE]
>
> Each API key can export logs only for its own organization. See [Export logs](https://dev.writer.com/home/logs-export.md) for start points, cursor handling, delivery guarantees, and polling examples.


## OpenAPI

````yaml get /api/observability/v1/organization/{organizationId}/logs/export
openapi: 3.0.3
info:
  title: Logs Export API
  version: '1.0'
  description: >-
    Poll captured LLM-call, agent-run, and agent-feedback records for an
    organization, and resume the feed from a cursor.
servers:
  - url: https://api.writer.com
security:
  - bearerAuth: []
tags:
  - name: Logs Export API
paths:
  /api/observability/v1/organization/{organizationId}/logs/export:
    get:
      tags:
        - Logs Export API
      summary: List log records
      description: >-
        Read LLM-call and agent-run records for the organization. Use
        `order=tail` to read an incremental stream that you resume with the
        `x-next-cursor` header, or `order=browse` to read a date window. The
        response is OTLP JSON by default; set `format=native` for Writer-native
        JSON.
      operationId: exportLogs
      parameters:
        - $ref: '#/components/parameters/organization_id'
        - $ref: '#/components/parameters/order'
        - name: cursor
          in: query
          required: false
          description: >-
            Opaque resume token from a prior `x-next-cursor` header. Tail only.
            Can't be combined with `start_date`.
          schema:
            type: string
        - name: start_date
          in: query
          required: false
          description: >-
            ISO 8601 timestamp, epoch seconds, or epoch milliseconds. In tail
            mode, the backfill start; defaults to now. In browse mode, the
            window start; send it with `end_date`, or omit both to read the last
            90 days. A date older than the retention window (90 days by default)
            returns `400`.
          schema:
            type: string
          example: '2026-07-01T00:00:00Z'
        - name: end_date
          in: query
          required: false
          description: >-
            ISO 8601 timestamp, epoch seconds, or epoch milliseconds. Browse
            window end; send it with `start_date`. Rejected when `order=tail`.
          schema:
            type: string
        - name: cursor_started_at_ms
          in: query
          required: false
          description: >-
            Browse-only continuation timestamp. Send together with
            `cursor_log_id`.
          schema:
            type: integer
            format: int64
            minimum: 0
        - name: cursor_log_id
          in: query
          required: false
          description: >-
            Browse-only continuation ID. Send together with
            `cursor_started_at_ms`.
          schema:
            type: string
        - name: limit
          in: query
          required: false
          description: >-
            Page size. Values above 1000 are reduced to 1000. With
            `include_bodies=true`, set `limit` to 50 or less; the default of 100
            returns `400`.
          schema:
            type: integer
            minimum: 1
            default: 100
        - name: format
          in: query
          required: false
          description: Response body shape.
          schema:
            type: string
            enum:
              - otlp
              - native
            default: otlp
        - name: signal
          in: query
          required: false
          description: >-
            OTLP only. `traces` returns `resourceSpans`; `logs` returns
            `resourceLogs`.
          schema:
            type: string
            enum:
              - traces
              - logs
            default: traces
        - name: include_bodies
          in: query
          required: false
          description: >-
            Request available prompt and response bodies for LLM calls. API-key
            callers receive unmasked bodies even when content masking is enabled
            in Control Center.
          schema:
            type: boolean
            default: false
        - name: model
          in: query
          required: false
          description: Filter by model. Repeat the parameter to pass more than one value.
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string
        - name: created_by
          in: query
          required: false
          description: Filter by user ID. Repeat the parameter to pass more than one value.
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string
        - name: source
          in: query
          required: false
          description: >-
            Filter by source. `writer_agent` is WRITER Agent. Repeat the
            parameter to pass more than one value.
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string
              enum:
                - llm_gateway
                - writer_agent
                - other
        - name: provider
          in: query
          required: false
          description: Filter by provider.
          schema:
            type: string
        - name: status
          in: query
          required: false
          description: Filter by status.
          schema:
            type: string
        - name: finish_reason
          in: query
          required: false
          description: Filter by finish reason.
          schema:
            type: string
        - name: guardrail_outcome
          in: query
          required: false
          description: Filter by guardrail outcome.
          schema:
            type: string
        - name: search
          in: query
          required: false
          description: >-
            Search metadata such as request, session, run, root-run, and user
            IDs, and model. Doesn't search prompt or response text.
          schema:
            type: string
      responses:
        '200':
          description: >-
            One page of log records. With `format=native`, the body is a
            `result` array and `pagination` object. With `format=otlp`, the body
            is an OTLP/JSON payload with `resourceSpans` or `resourceLogs`.
          headers:
            x-next-cursor:
              $ref: '#/components/headers/x_next_cursor'
            x-has-more:
              $ref: '#/components/headers/x_has_more'
            x-tail-watermark:
              $ref: '#/components/headers/x_tail_watermark'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/native_logs_page'
              example:
                result:
                  - record_type: llm_call
                    log_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    inserted_at_ms: 1734600000000
                    model: palmyra-x5
                    duration_ms: 1200
                  - record_type: agent_run
                    log_id: agent-run:run-123
                    inserted_at_ms: 1734600001000
                    agent_run_id: run-123
                    root_agent_run_id: run-123
                    run_status: completed
                    duration_ms: null
                    model: ''
                    prompt_tokens: null
                    completion_tokens: null
                    total_tokens: null
                pagination:
                  limit: 1000
                  has_more: true
                  next_cursor: null
        '400':
          $ref: '#/components/responses/validation_error'
        '401':
          $ref: '#/components/responses/unauthorized'
        '403':
          $ref: '#/components/responses/forbidden'
        '429':
          $ref: '#/components/responses/rate_limited'
components:
  parameters:
    organization_id:
      name: organizationId
      in: path
      required: true
      description: ID of the organization the API key belongs to.
      schema:
        type: integer
        format: int64
    order:
      name: order
      in: query
      required: false
      description: >-
        `tail` reads the incremental stream in `(inserted_at, id)` order.
        `browse` reads a date window.
      schema:
        type: string
        enum:
          - browse
          - tail
        default: browse
  headers:
    x_next_cursor:
      description: >-
        Opaque resume token. Present on every tail response. Store it unchanged
        and send it as `cursor` on the next request.
      schema:
        type: string
    x_has_more:
      description: >-
        `true` when another page is available. `false` when the stream is caught
        up to the settled boundary.
      schema:
        type: string
        enum:
          - 'true'
          - 'false'
    x_tail_watermark:
      description: >-
        Tail only. Settled boundary in epoch milliseconds: now minus a 5-minute
        settle lag. Rows inserted after this time are withheld from the page.
      schema:
        type: integer
        format: int64
  schemas:
    native_logs_page:
      type: object
      properties:
        result:
          type: array
          items:
            $ref: '#/components/schemas/native_log_record'
        pagination:
          $ref: '#/components/schemas/pagination'
    native_log_record:
      type: object
      description: >-
        An LLM call or an agent run. Upsert by `log_id`, keeping the revision
        with the newest `inserted_at_ms`.
      properties:
        record_type:
          type: string
          enum:
            - llm_call
            - agent_run
          description: Kind of record.
        log_id:
          type: string
          description: Record identity. Agent runs use `agent-run:<agent_run_id>`.
        inserted_at_ms:
          type: integer
          format: int64
          description: Ingestion time in epoch milliseconds. Tail ordering axis.
        started_at_ms:
          type: integer
          format: int64
          description: Call start time, or the terminal event time for an agent run.
        duration_ms:
          type: integer
          nullable: true
          description: Call duration, or the run's lifecycle duration. `null` when unknown.
        model:
          type: string
          description: Inference model. Empty string for agent runs.
        agent_run_id:
          type: string
          nullable: true
          description: Agent run ID, where present.
        root_agent_run_id:
          type: string
          nullable: true
          description: Root agent run ID, where present.
        run_status:
          type: string
          description: Agent runs only. Terminal status of the run.
        prompt_tokens:
          type: integer
          nullable: true
          description: Input tokens. `null` for agent runs.
        completion_tokens:
          type: integer
          nullable: true
          description: Output tokens. `null` for agent runs.
        total_tokens:
          type: integer
          nullable: true
          description: Total tokens. `null` for agent runs.
        has_body:
          type: boolean
          description: Whether the call has a body. Always `false` for agent runs.
        body_unavailable_reason:
          type: string
          description: With `include_bodies=true`, why a call body is `null`.
          enum:
            - not_captured
            - pending
            - missing
            - failed
            - ekm_denied
            - unauthorized
            - expired
            - deleted
            - unavailable
    pagination:
      type: object
      properties:
        limit:
          type: integer
          description: Page size used for this response.
        has_more:
          type: boolean
          description: Matches the `x-has-more` header.
        next_cursor:
          type: string
          nullable: true
          description: '`null` in tail mode; read the resume token from `x-next-cursor`.'
    problem:
      type: object
      description: Problem+JSON error body.
      properties:
        code:
          type: string
          enum:
            - VALIDATION_ERROR
            - UNAUTHORIZED
            - FORBIDDEN
            - RATE_LIMITED
          description: Error code.
        detail:
          type: string
          description: Readable description of the error.
  responses:
    validation_error:
      description: >-
        The request parameters are invalid. For example, the cursor was tampered
        with, `start_date` is older than the retention window, `start_date` was
        sent with `cursor`, or `include_bodies=true` was sent with `limit` above
        50.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/problem'
    unauthorized:
      description: >-
        The API key is missing, malformed, or rejected. Gateway errors can use a
        different body than the service error shape.
    forbidden:
      description: The API key belongs to a different organization, or access is denied.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/problem'
    rate_limited:
      description: >-
        The organization exceeded 120 requests in 60 seconds. Wait for
        `retry-after` seconds, then retry.
      headers:
        retry-after:
          description: >-
            Whole seconds until the rate-limit window resets, with a minimum of
            one.
          schema:
            type: integer
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/problem'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your [Writer API
        key](https://dev.writer.com/api-reference/api-keys). Each key can export
        logs only for its own organization.

````