Spans

Create spans in bulk

Changed on

Accepts up to 500 spans per request. Each item in logs uses the fields in Create a span. Rows are processed independently. A 201 Created response means at least one row was accepted, so check error_count and errors for partial failures. success_count counts rows that passed synchronous validation and were accepted for ingestion.

Rate limit: 30 requests per minute per organization for API-key calls, shared across the organization's keys. For JWT calls, the limit is per user. Metadata keys beginning with _ are reserved for platform use and omitted from span and trace read responses.

post/api/request-logs/bulk/

Request

  • Base URL
    https://api.respan.ai
  • URL
    https://api.respan.ai/api/request-logs/bulk/
  • Auth
    • HTTP bearer
    • or HTTP bearer

Request body

Example request

{
  "logs": [
    {
      "model": "gpt-4o-mini",
      "prompt_messages": [
        {
          "role": "user",
          "content": "Hello"
        }
      ],
      "completion_message": {
        "role": "assistant",
        "content": "Hi there!"
      },
      "prompt_tokens": 50,
      "completion_tokens": 100,
      "usage": {
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0
      },
      "temperature": 0.7,
      "top_p": 1,
      "max_tokens": 1024,
      "generation_time": 1.23,
      "ttft": 0.35,
      "customer_params": {
        "customer_identifier": "user_123",
        "email": "alice@example.com",
        "name": "Alice"
      },
      "metadata": {
        "env": "production",
        "feature": "chat"
      },
      "environment": "prod",
      "status_code": 200,
      "tools": [
        {
          "type": "function",
          "function": {
            "name": "lookup_order",
            "description": "Lookup an order by ID"
          }
        }
      ],
      "tool_calls": [
        {
          "id": "call_abc123",
          "type": "function",
          "function": {
            "name": "lookup_order",
            "arguments": "{\"order_id\":\"ord_123\"}"
          }
        }
      ],
      "timestamp": "2025-03-15T10:30:00Z",
      "trace_unique_id": "trace_abc123",
      "span_name": "classify_intent",
      "span_parent_id": "span_parent_001",
      "span_workflow_name": "customer_support_flow",
      "custom_identifier": "order_456",
      "thread_identifier": "thread_abc",
      "group_identifier": "batch_789",
      "latency": 1.23,
      "time_to_first_token": 0.35,
      "log_type": "chat",
      "messages": [
        {
          "role": "user",
          "content": "Hello"
        }
      ],
      "cost": 0.0025,
      "tokens_per_second": 45.2,
      "properties": {
        "cache_hit": false,
        "score": 0.98
      },
      "variables": {
        "customer_name": "Alice"
      },
      "customer_identifier": "user_123",
      "status": "success",
      "prompt_id": "prompt_abc123",
      "prompt_name": "customer_support",
      "start_time": "2025-03-15T10:29:59Z",
      "prompt_unit_price": 2.5,
      "completion_unit_price": 10,
      "positive_feedback": true
    }
  ]
}

Response

At least one row was accepted. This status is also used for partial success; inspect the response counts and indexed errors.

success_countinteger required

Number of items successfully processed.

error_countinteger required

Number of items that failed.

Example response

{
  "success_count": 1,
  "error_count": 0,
  "errors": []
}

Changes

    • breaking

      added the new required request property //

    • breaking

      request body became required

    • breaking

      the request property's minItems was increased to 1

    • info

      api operation id spans_bulkCreateSpans removed and replaced with bulkCreateSpans

    • info

      the endpoint scheme security DashboardJwt was added to the API

    • info

      api tag Spans added

    • info

      api tag spans removed

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added subschema #2 to the response body anyOf list for the response status

    • info

      removed subschema #2 from the response body oneOf list for the response status

    • breaking

      the response's body type changed from no type to object for status

    • info

      removed the non-success response with the status

    • info

      added the required property to the response with the status