Skip to main content
This guide covers two approaches to tracing with the REST API: basic tracing using the POST /runs and PATCH /runs endpoints, and batch ingestion using POST /runs/multipart for higher throughput. For a full list of endpoints and request/response schemas, refer to the API reference.
We strongly recommend using the Python or TypeScript SDK to send traces to LangSmith instead of the REST API directly. The SDKs include batching and background sending optimizations that prevent tracing from affecting your application’s performance.If you cannot use an SDK, note that sending traces synchronously may impact application performance.
We recommend using UUID v7 for run IDs. UUIDv7 embeds a timestamp, which preserves correct time-ordering of runs in a trace. Use uuid7() from the LangSmith SDK to generate them, or see Specify a custom run ID for more details.

Basic tracing

The simplest way to log runs is via the POST /runs and PATCH /runs endpoints. This approach requires minimal information to establish the trace hierarchy.
When using the LangSmith REST API, provide your API key in the request headers as "x-api-key".If your API key is linked to multiple workspaces, specify the workspace in the header with "x-tenant-id".In this approach, you do not need to set the dotted_order or trace_id fields—the system generates them automatically. Though simpler, it is slower and subject to lower rate limits than batch ingestion.
The following example traces a chat completion with a parent chain run and a child LLM run. Set parent_run_id on a child run to attach it to its parent:
For more information, refer to Run (span) data format.

Batch ingestion

For faster ingestion and higher rate limits, use the POST /runs/multipart endpoint. This requires the requests-toolbelt and uuid-utils packages. Unlike basic tracing, this endpoint requires you to compute and set dotted_order and trace_id yourself. dotted_order encodes each run’s timestamp and UUID with parent and child entries joined by dots (e.g., 20240101T000000Z<parent-uuid>.20240101T000001Z<child-uuid>), telling LangSmith how runs relate and in what order they occurred. trace_id is the UUID of the root run. The following example creates a parent run and a child run, sends them in a single batch request, then patches both with their outputs: