PATCH /api/traces/{traceId}/metadata
Update metadata on a trace after it has been created. Under the hood, this injects a synthetic span through the standard ingestion pipeline — traces remain immutable per the OpenTelemetry spec, and “updating” a trace means adding a span that carries the new attributes. This is useful for attaching labels, user identity, or custom metadata from backend processes that resolve after trace ingestion.
Authentication
Pass your LangWatch API key in theX-Auth-Token header.
Path Parameters
Request Body
Metadata Fields
Reserved Fields
Custom Fields
Any key not in the reserved list is stored asmetadata.{key} in trace attributes. Custom fields support strings, numbers, booleans, string arrays, and JSON objects.
Merge Semantics
- Attribute accumulation: the synthetic span’s resource attributes are processed through the standard attribute accumulation pipeline — new keys are added, existing keys are updated by the last-write-wins rule
- Labels: the labels array is set as-is on the span resource. If a later span also carries labels, last write wins
- Custom fields: stored as
langwatch.metadata.*resource attributes on the synthetic span
Size Limits
Permissions
Requirestraces:update permission on the project.
Response
Error Responses
Example
Custom metadata keys share the same namespace as metadata set via the SDK during trace ingestion. If both the SDK and this API set the same key, the last write wins.