Ingest traces (OTLP)
https://api.respan.ai/api/v2/tracesAccepts OTLP/HTTP JSON or protobuf. The span fields accepted by POST /api/request-logs/ are not valid here. The Sample two-span trace example creates a workflow root span and one chat child span. Before rerunning it, replace traceId and spanId with new 32-hex and 16-hex IDs to create a separate trace.
For SDK setup, see the Tracing quickstart or the OpenTelemetry integration, which configures the exporter automatically.
Servers
https://api.respan.ai — Respan API Server
Authentication
RespanApiKey
Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.
HTTP scheme: bearer; format: Respan API key.
Authorization: Bearer $RESPAN_API_KEYRequest body
A request body is required.
application/json
$ object Required body
resourceSpans array<object> Required in parent
resourceSpans[] object Array item
resourceSpans[].resource object Optional
service.name attribute to identify your application.resourceSpans[].resource.attributes array<object> Optional
resourceSpans[].resource.attributes[] object Array item
resourceSpans[].resource.attributes[].key string Optional"service.name"resourceSpans[].resource.attributes[].value object OptionalstringValue, intValue, doubleValue, boolValue, arrayValue, or kvlistValue.Example:
{"stringValue":"my-service"}resourceSpans[].scopeSpans array<object> Optional
resourceSpans[].scopeSpans[] object Array item
resourceSpans[].scopeSpans[].scope object Optional
resourceSpans[].scopeSpans[].scope.name string Optional"manual"resourceSpans[].scopeSpans[].scope.version string Optional"1.0.0"resourceSpans[].scopeSpans[].spans array<object> Optional
resourceSpans[].scopeSpans[].spans[] object Array item
resourceSpans[].scopeSpans[].spans[].traceId string Required in parentExample:
"0af7651916cd43dd8448eb211c80319c"resourceSpans[].scopeSpans[].spans[].spanId string Required in parentExample:
"b7ad6b7169203332"resourceSpans[].scopeSpans[].spans[].parentSpanId string OptionalExample:
""resourceSpans[].scopeSpans[].spans[].name string Required in parentExample:
"my-operation"resourceSpans[].scopeSpans[].spans[].startTimeUnixNano string Required in parentExample:
"1700000000000000000"resourceSpans[].scopeSpans[].spans[].endTimeUnixNano string Required in parentExample:
"1700000001000000000"resourceSpans[].scopeSpans[].spans[].status object Optional
resourceSpans[].scopeSpans[].spans[].status.code integer Optional1 = OK, 2 = ERROR.Allowed:
1, 2Example:
1resourceSpans[].scopeSpans[].spans[].status.message string OptionalExample:
""resourceSpans[].scopeSpans[].spans[].attributes array<object> Optional
stringValue, intValue, doubleValue, boolValue, arrayValue, or kvlistValue.Trace shape: use
traceloop.span.kind (workflow, task, tool, chat, etc.) to classify spans, and traceloop.workflow.name to make the workflow name searchable. For chat/completion child spans, include llm.request.type (chat or completion) so model, messages, and token fields are promoted.LLM fields:
gen_ai.request.model, gen_ai.response.model, gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens, gen_ai.usage.total_tokens, gen_ai.prompt.{N}.role, gen_ai.prompt.{N}.content, gen_ai.completion.{N}.role, gen_ai.completion.{N}.content.Respan fields:
respan.customer_params.customer_identifier, respan.customer_params.email, respan.customer_params.name, respan.threads.thread_identifier, respan.trace.trace_group_identifier, and respan.metadata.<key> for custom metadata.All other attributes are stored in metadata and queryable via metadata filters.
resourceSpans[].scopeSpans[].spans[].attributes[] object Array item
resourceSpans[].scopeSpans[].spans[].attributes[].key string Optional"gen_ai.request.model"resourceSpans[].scopeSpans[].spans[].attributes[].value object Optional{"stringValue":"gpt-4"}resourceSpans[].scopeSpans[].spans[].events array<object> Optional
name, timeUnixNano, and attributes.resourceSpans[].scopeSpans[].spans[].events[] object Array itemOpenAPI request schema
{
"type": "object",
"required": [
"resourceSpans"
],
"properties": {
"resourceSpans": {
"type": "array",
"description": "Array of resource spans. Each element represents spans from a single resource (service).",
"items": {
"type": "object",
"properties": {
"resource": {
"type": "object",
"description": "Resource metadata. Set `service.name` attribute to identify your application.",
"properties": {
"attributes": {
"type": "array",
"description": "Key-value attributes identifying the resource.",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"example": "service.name"
},
"value": {
"type": "object",
"description": "OTLP typed value. Use `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`.",
"example": {
"stringValue": "my-service"
}
}
}
}
}
}
},
"scopeSpans": {
"type": "array",
"description": "Array of instrumentation scope spans.",
"items": {
"type": "object",
"properties": {
"scope": {
"type": "object",
"description": "Instrumentation scope (library name and version).",
"properties": {
"name": {
"type": "string",
"example": "manual"
},
"version": {
"type": "string",
"example": "1.0.0"
}
}
},
"spans": {
"type": "array",
"description": "Array of span objects.",
"items": {
"type": "object",
"required": [
"traceId",
"spanId",
"name",
"startTimeUnixNano",
"endTimeUnixNano"
],
"properties": {
"traceId": {
"type": "string",
"description": "Hex-encoded trace ID (32 hex chars).",
"example": "0af7651916cd43dd8448eb211c80319c"
},
"spanId": {
"type": "string",
"description": "Hex-encoded span ID (16 hex chars).",
"example": "b7ad6b7169203332"
},
"parentSpanId": {
"type": "string",
"description": "Parent span ID. Empty for root spans.",
"example": ""
},
"name": {
"type": "string",
"description": "Span operation name.",
"example": "my-operation"
},
"startTimeUnixNano": {
"type": "string",
"description": "Start time as nanoseconds since Unix epoch.",
"example": "1700000000000000000"
},
"endTimeUnixNano": {
"type": "string",
"description": "End time as nanoseconds since Unix epoch.",
"example": "1700000001000000000"
},
"status": {
"type": "object",
"description": "Span status.",
"properties": {
"code": {
"type": "integer",
"description": "`1` = OK, `2` = ERROR.",
"enum": [
1,
2
],
"example": 1
},
"message": {
"type": "string",
"description": "Error description (when code=2).",
"example": ""
}
}
},
"attributes": {
"type": "array",
"description": "Span attributes as OTLP key-value pairs. Values use OTLP typed wrappers: `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`.\n\n**Trace shape:** use `traceloop.span.kind` (`workflow`, `task`, `tool`, `chat`, etc.) to classify spans, and `traceloop.workflow.name` to make the workflow name searchable. For chat/completion child spans, include `llm.request.type` (`chat` or `completion`) so model, messages, and token fields are promoted.\n\n**LLM fields:** `gen_ai.request.model`, `gen_ai.response.model`, `gen_ai.usage.prompt_tokens`, `gen_ai.usage.completion_tokens`, `gen_ai.usage.total_tokens`, `gen_ai.prompt.{N}.role`, `gen_ai.prompt.{N}.content`, `gen_ai.completion.{N}.role`, `gen_ai.completion.{N}.content`.\n\n**Respan fields:** `respan.customer_params.customer_identifier`, `respan.customer_params.email`, `respan.customer_params.name`, `respan.threads.thread_identifier`, `respan.trace.trace_group_identifier`, and `respan.metadata.<key>` for custom metadata.\n\nAll other attributes are stored in metadata and queryable via metadata filters.",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"example": "gen_ai.request.model"
},
"value": {
"type": "object",
"example": {
"stringValue": "gpt-4"
}
}
}
}
},
"events": {
"type": "array",
"description": "Span events (e.g. exceptions). Each has `name`, `timeUnixNano`, and `attributes`.",
"items": {
"type": "object"
}
}
}
}
}
}
}
}
}
}
}
}
}Sample two-span trace
Creates a visible sample trace: a workflow root span plus a chat child span. Replace traceId/spanId values before rerunning to avoid appending to the same trace.
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "respan-docs-api-reference"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "manual-api-reference",
"version": "1.0.0"
},
"spans": [
{
"traceId": "11111111111111111111111111111111",
"spanId": "2222222222222222",
"name": "sample_trace",
"startTimeUnixNano": "1780000000000000000",
"endTimeUnixNano": "1780000001000000000",
"attributes": [
{
"key": "traceloop.span.kind",
"value": {
"stringValue": "workflow"
}
},
{
"key": "traceloop.workflow.name",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.trace.trace_group_identifier",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.customer_params.customer_identifier",
"value": {
"stringValue": "docs-sample-user"
}
},
{
"key": "respan.metadata.source",
"value": {
"stringValue": "api-reference-create-trace"
}
}
],
"status": {
"code": 1
}
},
{
"traceId": "11111111111111111111111111111111",
"spanId": "3333333333333333",
"parentSpanId": "2222222222222222",
"name": "sample_llm_call",
"startTimeUnixNano": "1780000000100000000",
"endTimeUnixNano": "1780000000900000000",
"attributes": [
{
"key": "traceloop.span.kind",
"value": {
"stringValue": "chat"
}
},
{
"key": "llm.request.type",
"value": {
"stringValue": "chat"
}
},
{
"key": "traceloop.workflow.name",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.trace.trace_group_identifier",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.customer_params.customer_identifier",
"value": {
"stringValue": "docs-sample-user"
}
},
{
"key": "gen_ai.system",
"value": {
"stringValue": "openai"
}
},
{
"key": "gen_ai.request.model",
"value": {
"stringValue": "gpt-4o-mini"
}
},
{
"key": "gen_ai.response.model",
"value": {
"stringValue": "gpt-4o-mini"
}
},
{
"key": "gen_ai.prompt.0.role",
"value": {
"stringValue": "user"
}
},
{
"key": "gen_ai.prompt.0.content",
"value": {
"stringValue": "Hello from the Create a trace API reference."
}
},
{
"key": "gen_ai.completion.0.role",
"value": {
"stringValue": "assistant"
}
},
{
"key": "gen_ai.completion.0.content",
"value": {
"stringValue": "Hello! This is a sample trace."
}
},
{
"key": "gen_ai.usage.prompt_tokens",
"value": {
"intValue": "9"
}
},
{
"key": "gen_ai.usage.completion_tokens",
"value": {
"intValue": "8"
}
},
{
"key": "gen_ai.usage.total_tokens",
"value": {
"intValue": "17"
}
}
],
"status": {
"code": 1
}
}
]
}
]
}
]
}Responses
200
Spans accepted.
application/json
$ object Body
partialSuccess object Optional
partialSuccess.rejectedSpans integer OptionalExample:
0partialSuccess.errorMessage string OptionalExample:
""OpenAPI response schema
{
"type": "object",
"properties": {
"partialSuccess": {
"type": "object",
"properties": {
"rejectedSpans": {
"type": "integer",
"description": "Number of spans that failed to ingest.",
"example": 0
},
"errorMessage": {
"type": "string",
"description": "Error description (empty on success).",
"example": ""
}
}
}
}
}Example
{
"partialSuccess": {
"rejectedSpans": 0,
"errorMessage": ""
}
}400
The payload isn’t valid OTLP JSON.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Invalid JSON in OTLP trace payload: Expecting value: line 1 column 20 (char 19)"
}403
The API key is missing, invalid or expired.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}OpenAPI source
The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.
OpenAPI operation
{
"summary": "Ingest traces (OTLP)",
"operationId": "createTrace",
"tags": [
"Traces"
],
"description": "Accepts [OTLP/HTTP](https://opentelemetry.io/docs/specs/otlp/) JSON or protobuf. The span fields accepted by `POST /api/request-logs/` are not valid here. The `Sample two-span trace` example creates a workflow root span and one chat child span. Before rerunning it, replace `traceId` and `spanId` with new 32-hex and 16-hex IDs to create a separate trace.\n\nFor SDK setup, see the [Tracing quickstart](/docs/documentation/features/tracing/quickstart) or the [OpenTelemetry integration](/docs/integrations/opentelemetry), which configures the exporter automatically.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"resourceSpans"
],
"properties": {
"resourceSpans": {
"type": "array",
"description": "Array of resource spans. Each element represents spans from a single resource (service).",
"items": {
"type": "object",
"properties": {
"resource": {
"type": "object",
"description": "Resource metadata. Set `service.name` attribute to identify your application.",
"properties": {
"attributes": {
"type": "array",
"description": "Key-value attributes identifying the resource.",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"example": "service.name"
},
"value": {
"type": "object",
"description": "OTLP typed value. Use `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`.",
"example": {
"stringValue": "my-service"
}
}
}
}
}
}
},
"scopeSpans": {
"type": "array",
"description": "Array of instrumentation scope spans.",
"items": {
"type": "object",
"properties": {
"scope": {
"type": "object",
"description": "Instrumentation scope (library name and version).",
"properties": {
"name": {
"type": "string",
"example": "manual"
},
"version": {
"type": "string",
"example": "1.0.0"
}
}
},
"spans": {
"type": "array",
"description": "Array of span objects.",
"items": {
"type": "object",
"required": [
"traceId",
"spanId",
"name",
"startTimeUnixNano",
"endTimeUnixNano"
],
"properties": {
"traceId": {
"type": "string",
"description": "Hex-encoded trace ID (32 hex chars).",
"example": "0af7651916cd43dd8448eb211c80319c"
},
"spanId": {
"type": "string",
"description": "Hex-encoded span ID (16 hex chars).",
"example": "b7ad6b7169203332"
},
"parentSpanId": {
"type": "string",
"description": "Parent span ID. Empty for root spans.",
"example": ""
},
"name": {
"type": "string",
"description": "Span operation name.",
"example": "my-operation"
},
"startTimeUnixNano": {
"type": "string",
"description": "Start time as nanoseconds since Unix epoch.",
"example": "1700000000000000000"
},
"endTimeUnixNano": {
"type": "string",
"description": "End time as nanoseconds since Unix epoch.",
"example": "1700000001000000000"
},
"status": {
"type": "object",
"description": "Span status.",
"properties": {
"code": {
"type": "integer",
"description": "`1` = OK, `2` = ERROR.",
"enum": [
1,
2
],
"example": 1
},
"message": {
"type": "string",
"description": "Error description (when code=2).",
"example": ""
}
}
},
"attributes": {
"type": "array",
"description": "Span attributes as OTLP key-value pairs. Values use OTLP typed wrappers: `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`.\n\n**Trace shape:** use `traceloop.span.kind` (`workflow`, `task`, `tool`, `chat`, etc.) to classify spans, and `traceloop.workflow.name` to make the workflow name searchable. For chat/completion child spans, include `llm.request.type` (`chat` or `completion`) so model, messages, and token fields are promoted.\n\n**LLM fields:** `gen_ai.request.model`, `gen_ai.response.model`, `gen_ai.usage.prompt_tokens`, `gen_ai.usage.completion_tokens`, `gen_ai.usage.total_tokens`, `gen_ai.prompt.{N}.role`, `gen_ai.prompt.{N}.content`, `gen_ai.completion.{N}.role`, `gen_ai.completion.{N}.content`.\n\n**Respan fields:** `respan.customer_params.customer_identifier`, `respan.customer_params.email`, `respan.customer_params.name`, `respan.threads.thread_identifier`, `respan.trace.trace_group_identifier`, and `respan.metadata.<key>` for custom metadata.\n\nAll other attributes are stored in metadata and queryable via metadata filters.",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"example": "gen_ai.request.model"
},
"value": {
"type": "object",
"example": {
"stringValue": "gpt-4"
}
}
}
}
},
"events": {
"type": "array",
"description": "Span events (e.g. exceptions). Each has `name`, `timeUnixNano`, and `attributes`.",
"items": {
"type": "object"
}
}
}
}
}
}
}
}
}
}
}
}
},
"examples": {
"sampleTwoSpanTrace": {
"summary": "Sample two-span trace",
"description": "Creates a visible sample trace: a workflow root span plus a chat child span. Replace traceId/spanId values before rerunning to avoid appending to the same trace.",
"value": {
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "respan-docs-api-reference"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "manual-api-reference",
"version": "1.0.0"
},
"spans": [
{
"traceId": "11111111111111111111111111111111",
"spanId": "2222222222222222",
"name": "sample_trace",
"startTimeUnixNano": "1780000000000000000",
"endTimeUnixNano": "1780000001000000000",
"attributes": [
{
"key": "traceloop.span.kind",
"value": {
"stringValue": "workflow"
}
},
{
"key": "traceloop.workflow.name",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.trace.trace_group_identifier",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.customer_params.customer_identifier",
"value": {
"stringValue": "docs-sample-user"
}
},
{
"key": "respan.metadata.source",
"value": {
"stringValue": "api-reference-create-trace"
}
}
],
"status": {
"code": 1
}
},
{
"traceId": "11111111111111111111111111111111",
"spanId": "3333333333333333",
"parentSpanId": "2222222222222222",
"name": "sample_llm_call",
"startTimeUnixNano": "1780000000100000000",
"endTimeUnixNano": "1780000000900000000",
"attributes": [
{
"key": "traceloop.span.kind",
"value": {
"stringValue": "chat"
}
},
{
"key": "llm.request.type",
"value": {
"stringValue": "chat"
}
},
{
"key": "traceloop.workflow.name",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.trace.trace_group_identifier",
"value": {
"stringValue": "api-reference-sample-trace"
}
},
{
"key": "respan.customer_params.customer_identifier",
"value": {
"stringValue": "docs-sample-user"
}
},
{
"key": "gen_ai.system",
"value": {
"stringValue": "openai"
}
},
{
"key": "gen_ai.request.model",
"value": {
"stringValue": "gpt-4o-mini"
}
},
{
"key": "gen_ai.response.model",
"value": {
"stringValue": "gpt-4o-mini"
}
},
{
"key": "gen_ai.prompt.0.role",
"value": {
"stringValue": "user"
}
},
{
"key": "gen_ai.prompt.0.content",
"value": {
"stringValue": "Hello from the Create a trace API reference."
}
},
{
"key": "gen_ai.completion.0.role",
"value": {
"stringValue": "assistant"
}
},
{
"key": "gen_ai.completion.0.content",
"value": {
"stringValue": "Hello! This is a sample trace."
}
},
{
"key": "gen_ai.usage.prompt_tokens",
"value": {
"intValue": "9"
}
},
{
"key": "gen_ai.usage.completion_tokens",
"value": {
"intValue": "8"
}
},
{
"key": "gen_ai.usage.total_tokens",
"value": {
"intValue": "17"
}
}
],
"status": {
"code": 1
}
}
]
}
]
}
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "Spans accepted.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"partialSuccess": {
"type": "object",
"properties": {
"rejectedSpans": {
"type": "integer",
"description": "Number of spans that failed to ingest.",
"example": 0
},
"errorMessage": {
"type": "string",
"description": "Error description (empty on success).",
"example": ""
}
}
}
}
},
"example": {
"partialSuccess": {
"rejectedSpans": 0,
"errorMessage": ""
}
}
}
}
},
"400": {
"description": "The payload isn't valid OTLP JSON.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Invalid JSON in OTLP trace payload: Expecting value: line 1 column 20 (char 19)"
}
}
}
},
"403": {
"$ref": "#/components/responses/InvalidApiKey"
}
},
"security": [
{
"RespanApiKey": []
}
]
}OpenAPI path metadata
{}Referenced OpenAPI components
{
"responses": {
"InvalidApiKey": {
"description": "The API key is missing, invalid or expired.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
}
}
}
},
"securitySchemes": {
"RespanApiKey": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "Respan API key",
"description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
"x-fern-bearer": {
"name": "respanApiKey",
"env": "RESPAN_API_KEY"
}
}
}
}