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

# Replay

> Accepts a batch of rrweb events for a single session window. Batches are idempotent per `(sessionId, sequence)` — the same batch submitted twice is stored once. When `flush` is `final`, the server dispatches the session for processing immediately; otherwise the session is left in a `receiving` state until a scheduled finalizer picks it up.



## OpenAPI

````yaml POST /api/sdk/replay
openapi: 3.1.0
info:
  title: Lucent API
  description: >-
    HTTP APIs for Lucent. The Data API reads Lucent data and updates issue
    status. The Ingest API receives rrweb batches from the @lucenthq/sdk browser
    package and custom integrations built on top of the same contract.
  license:
    name: MIT
  version: 0.1.0
servers:
  - url: https://app.lucenthq.com
    description: Production app
security: []
paths:
  /api/sdk/replay:
    servers:
      - url: https://batch-jobs-lucent.onrender.com
        description: Production ingest
    post:
      summary: Submit a replay batch
      description: >-
        Accepts a batch of rrweb events for a single session window. Batches are
        idempotent per `(sessionId, sequence)` — the same batch submitted twice
        is stored once. When `flush` is `final`, the server dispatches the
        session for processing immediately; otherwise the session is left in a
        `receiving` state until a scheduled finalizer picks it up.
      operationId: sdkReplay
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplayBatch'
      responses:
        '200':
          description: Batch accepted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                properties:
                  ok:
                    type: boolean
                    const: true
        '400':
          description: Invalid replay batch.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                    example: Invalid replay batch
                  details:
                    type: array
                    description: Zod validation issues.
                    items:
                      type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: Storage upload or server error.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
      security:
        - lucentApiKey: []
components:
  schemas:
    ReplayBatch:
      type: object
      required:
        - session
        - user
        - page
        - replay
      properties:
        session:
          type: object
          required:
            - id
            - windowId
            - startedAt
            - lastActivityAt
            - url
          properties:
            id:
              type: string
              minLength: 1
              description: >-
                Stable session ID generated by the SDK. Shared across batches
                belonging to the same session.
            windowId:
              type: string
              minLength: 1
              description: >-
                Per-tab window ID. Distinguishes concurrent tabs within a
                session.
            startedAt:
              type: number
              description: Epoch milliseconds when the session started.
            lastActivityAt:
              type: number
              description: >-
                Epoch milliseconds of the most recent event in the session so
                far.
            url:
              type: string
              description: URL the session started on.
        user:
          type: object
          required:
            - anonymousId
          properties:
            id:
              type: string
              nullable: true
              description: Your internal user ID if `identify` has been called.
            anonymousId:
              type: string
              minLength: 1
              description: Anonymous ID generated by the SDK and persisted in localStorage.
            properties:
              type: object
              additionalProperties: true
              nullable: true
              description: >-
                Arbitrary user properties. `email` and `name` are surfaced in
                the dashboard when present.
        page:
          type: object
          required:
            - url
          properties:
            url:
              type: string
            referrer:
              type: string
              nullable: true
            viewport:
              type: object
              nullable: true
              required:
                - width
                - height
              properties:
                width:
                  type: number
                height:
                  type: number
        replay:
          type: object
          required:
            - events
            - sequence
          properties:
            events:
              type: array
              minItems: 1
              items:
                $ref: '#/components/schemas/RrwebEvent'
              description: rrweb events in chronological order.
            sequence:
              type: integer
              minimum: 0
              description: >-
                Monotonically increasing batch sequence number within a session.
                Used as an idempotency key together with `session.id`.
        metadata:
          type: object
          nullable: true
          properties:
            userAgent:
              type: string
              nullable: true
            language:
              type: string
              nullable: true
        flush:
          type: string
          enum:
            - normal
            - final
          default: normal
          description: >-
            `final` tells the server this is the last batch for the session —
            typically sent from a `beforeunload` handler. `final` batches
            trigger immediate session processing.
    RrwebEvent:
      type: object
      description: A single rrweb event. Opaque to Lucent — stored and replayed as-is.
      required:
        - timestamp
        - type
        - data
      properties:
        timestamp:
          type: number
          description: Epoch milliseconds when the event was captured.
        type:
          type: integer
          description: rrweb event type discriminator.
        data:
          description: rrweb event payload. Shape depends on `type`.
  responses:
    Unauthorized:
      description: Missing, invalid, or revoked API key.
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
                enum:
                  - Missing API key
                  - Invalid or revoked API key
    RateLimited:
      description: Rate limit exceeded (100 requests per minute per API key).
      headers:
        Retry-After:
          description: Seconds until the rate limit resets.
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
                const: Rate limit exceeded
  securitySchemes:
    lucentApiKey:
      type: apiKey
      in: header
      name: X-Lucent-Api-Key
      description: >-
        Public key prefixed with `luc_pk_`. Safe to expose in client-side code.
        For `navigator.sendBeacon` callers that cannot set headers, the key may
        also be passed as the `api_key` query parameter.

````