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

# Ingest trace events

> Ingest a batch of trace/span events. The request body is newline-delimited JSON (`application/x-ndjson`): one JSON event object per line. A maximum of 100 events per request and a 1 MB body size limit apply. Events are validated and queued asynchronously; invalid lines are skipped rather than failing the whole batch.

Authenticated with `x-api-key`. Rate limited to 300 requests/minute per API key.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/ingest
openapi: 3.1.0
info:
  title: Zespan Public API
  version: 1.0.0
  description: >
    The Zespan Public API covers the endpoints that customers call directly or
    through the Zespan SDKs: trace ingestion (native and OpenTelemetry), prompt
    management, datasets and dataset runs, and the runtime guardrails check.

    All endpoints authenticate with a project API key sent in the `x-api-key`
    header. Create and manage API keys from the project settings in the Zespan
    dashboard.
servers:
  - url: https://api.zespan.com
    description: Zespan production API
security:
  - ApiKeyAuth: []
tags:
  - name: Ingestion
    description: Send traces and events to Zespan.
  - name: OpenTelemetry
    description: OTLP-compatible ingestion endpoints.
  - name: Prompts
    description: Manage versioned prompts and their labels, tags, and folders.
  - name: Datasets
    description: Read datasets and manage dataset runs used for experiments and scoring.
  - name: Guardrails
    description: Runtime guardrail evaluation.
paths:
  /v1/ingest:
    post:
      tags:
        - Ingestion
      summary: Ingest trace events
      description: >
        Ingest a batch of trace/span events. The request body is
        newline-delimited JSON (`application/x-ndjson`): one JSON event object
        per line. A maximum of 100 events per request and a 1 MB body size limit
        apply. Events are validated and queued asynchronously; invalid lines are
        skipped rather than failing the whole batch.


        Authenticated with `x-api-key`. Rate limited to 300 requests/minute per
        API key.
      operationId: ingestEvents
      requestBody:
        required: true
        content:
          application/x-ndjson:
            schema:
              type: string
              description: |
                Newline-delimited JSON. Each line is a single event object.
              example: >
                {"trace_id":"3b1c...","span_id":"a91f...","name":"chat.completions","provider":"openai","model":"gpt-4o","operation":"chat.completions","input_tokens":812,"output_tokens":146,"latency_ms":1240,"status":"success","timestamp":"2026-07-05T12:00:00.000Z"}

                {"trace_id":"3b1c...","span_id":"c72d...","parent_span_id":"a91f...","name":"vector.search","operation":"retrieval.query","latency_ms":54,"status":"success","timestamp":"2026-07-05T12:00:00.050Z"}
      responses:
        '202':
          description: Batch accepted for asynchronous processing.
          content:
            application/json:
              schema:
                type: object
                properties:
                  accepted:
                    type: integer
                    description: Number of events accepted from the batch.
                    example: 2
                  cv:
                    type: integer
                    description: >-
                      Current project config version (used by SDKs for config
                      propagation).
                    example: 7
                required:
                  - accepted
                  - cv
        '400':
          description: No valid events found, or more than 100 events in the batch.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Rate limit or trace quota exceeded. Includes a `Retry-After` header
            for rate limiting.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            Service temporarily unavailable (ingest hot path dependency down).
            Retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
          example: Unauthorized
        code:
          type: string
          description: Machine-readable error code, when present.
          example: rate_limit_exceeded
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Project API key. Manage keys in the Zespan dashboard under project
        settings.

````