---
title: "Ingest Traces (OTLP)"
method: POST
path: "/v1/traces"
tags: ["otlp"]
---

# Ingest Traces (OTLP)

`POST /v1/traces`

## Query parameters

- `close_after` boolean

## Headers

- `Content-Type` 'application/x-protobuf' | 'application/json', required
- `Content-Encoding` 'gzip'

## Request body

- OtlpExportTraceServiceRequest — An OTLP ExportTraceServiceRequest in JSON encoding. See the [OTLP specification](https://opentelemetry.io/docs/specs/otlp/#otlphttp-request) for the full schema.
  - `resourceSpans` object[] — An array of ResourceSpans. Each element describes spans from a single instrumented resource.
    - `resource` object — The resource that produced the spans.
      - `attributes` OtlpKeyValue[] — Resource attributes as key-value pairs.
        - `key` string, required
        - `value` object, required — The attribute value. Exactly one of the value fields must be set.
          - `stringValue` string
          - `intValue` string
          - `doubleValue` number
          - `boolValue` boolean
          - `arrayValue` object
            - `values` object[]
              - …
    - `scopeSpans` object[] — An array of ScopeSpans, grouping spans by instrumentation scope.
      - `scope` object — The instrumentation scope that produced the spans.
        - `name` string
        - `version` string
      - `spans` OtlpSpan[] — Array of Span objects.
        - `traceId` string, required — Hex-encoded trace ID (32 hex characters / 16 bytes).
        - `spanId` string, required — Hex-encoded span ID (16 hex characters / 8 bytes).
        - `parentSpanId` string — Hex-encoded parent span ID. Empty or omitted for root spans.
        - `name` string, required — The name of the span.
        - `kind` 0 | 1 | 2 | 3 | 4 | 5 — Span kind: 0=UNSPECIFIED, 1=INTERNAL, 2=SERVER, 3=CLIENT, 4=PRODUCER, 5=CONSUMER.
        - `startTimeUnixNano` string, required — Start time in nanoseconds since Unix epoch, encoded as a string.
        - `endTimeUnixNano` string — End time in nanoseconds since Unix epoch, encoded as a string.
        - `attributes` OtlpKeyValue[] — Span attributes as key-value pairs. GenAI semantic convention attributes (e.g. `gen_ai.request.model`, `gen_ai.usage.input_tokens`) are automatically extracted.
          - `key` string, required
          - `value` object, required — The attribute value. Exactly one of the value fields must be set.
            - `stringValue` string
            - `intValue` string
            - `doubleValue` number
            - `boolValue` boolean
            - `arrayValue` object
              - …
        - `status` object — Span status.
          - `code` 0 | 1 | 2 — Status code: 0=UNSET, 1=OK, 2=ERROR.
          - `message` string — Status message (typically set for ERROR status).
        - `events` object[] — Span events (e.g. exceptions).
          - `timeUnixNano` string
          - `name` string
          - `attributes` OtlpKeyValue[]
            - `key` string, required
            - `value` object, required — The attribute value. Exactly one of the value fields must be set.
              - …
        - `links` object[] — Links to other spans.
          - `traceId` string
          - `spanId` string
          - `attributes` OtlpKeyValue[]
            - `key` string, required
            - `value` object, required — The attribute value. Exactly one of the value fields must be set.
              - …

## Response `200`

Successful Response. When using protobuf, the response is a binary `ExportTraceServiceResponse`. When using JSON, the response is a JSON object.

- OtlpExportTraceServiceResponse — Response to an OTLP trace export request.
  - `partialSuccess` object, nullable — Present only when some spans were rejected. Null when all spans were accepted.
    - `rejectedSpans` integer — The number of spans that were rejected.
    - `errorMessage` string — A human-readable error message describing why spans were rejected.

## Other responses

- `401` — Unauthorized - missing or invalid API key.
- `409` — One or more traces in the request are already closed.
- `415` — Unsupported Content-Type
- `422` — Validation error - request parameters or body are invalid.
- `500` — Internal server error during ingestion

---

[API](https://skmtc.dev/promptlayer/apis/promptlayer-api.md) · [All operations](https://skmtc.dev/promptlayer/apis/promptlayer-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/promptlayer/promptlayer-api/revisions/a23093a0a506/schema)
