> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# POST /v1/trace-sinks

```text
POST https://weights.fyi/run/v1/trace-sinks
Authorization: Bearer <token>                    scope: manage
Content-Type: application/json

{"name": "<name>", "kind": "otlp_http" | "mlflow" | "webhook", "url": "https://...",
 ["headers": {"<Name>": "<value>"}], ["include_outputs": true | false]}
```

**Available since:** 2026-10-08, when the service went live on weights.fyi/run. a sample of logged inputs and outputs for a destination with `include_outputs`.

**Answer time:** synchronous: the destination is checked, its address resolved, and the destination stored before the answer comes. Nothing is sent to it by this call; use [POST /v1/trace-sinks/{sink_id}/test](/run/docs/reference/trace-sinks-test.md) to send a test span.

Adds a destination outside this service where every span of your account is delivered as it ends: jobs, calls to the model, moves, charges and credit, in your own tools. `otlp_http`, the default, is OpenTelemetry over HTTP in JSON for any collector; `mlflow` sends the same to an MLflow tracking server's trace intake; `webhook` posts signed JSON lines to a receiver you write. Delivery runs on the Tracing and tracking option, switched on your panel only (Tracing and tracking is free today: its fee per job is $0.00.); while it is off a destination is kept but paused (`enabled: false`), and spans that end then are not sent later. A destination never gets spans that ended before it was added; use [GET /v1/traces](/run/docs/reference/traces.md) for those.

Nothing is lost while your end is down. Spans go in order, at most 512 a request, each answered within 10 s; a `2xx` marks them delivered, anything else is retried from 1 s, doubling to 64 s or as your `Retry-After` asks. A lost answer can mean a second delivery, so key spans on their span id. Test a new destination with [POST /v1/trace-sinks/{sink_id}/test](/run/docs/reference/trace-sinks-test.md).

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | `Bearer` and a token with `manage`. |
| `Content-Type` | header | yes | `application/json`, at most 65,536 bytes. |
| `name` | body | yes | Your name for it, not empty. An account has at most 6 destinations, paused ones included. |
| `kind` | body | no | `otlp_http` (default), `mlflow` or `webhook`. |
| `url` | body | yes | `https`, a host that resolves only to public addresses (no loopback, private, link-local, multicast or reserved), checked now and at every delivery; redirects never followed; no user name or password (use `headers`). For `otlp_http` and `mlflow`, the base address without a query: `/v1/traces` is added, and a URL already ending in it is refused. A webhook URL is used as given. |
| `headers` | body | no | Names and values sent with every delivery, values never shown back. Not allowed: `Host`, `Content-Length`, `Content-Type`, `Content-Encoding`, `Transfer-Encoding`, `Connection`, `X-Weights-Signature`, `X-Weights-Timestamp`, or one name twice in any case. `mlflow` needs `x-mlflow-experiment-id`. |
| `include_outputs` | body | no | `true` sends each page's result with the calls' spans (`weights.output.<seq>.label` and so on; `outputs` for a webhook); default `false`, content-free. also a bounded sample of logged content on the `job` span (`logged_content`, `content_cursor`), never again once expired or deleted. |


## Return value

**201 Created** with the destination.

| Field | Meaning |
|---|---|
| `id` | The destination's number, the `sink_id` the other calls take. |
| `account_id` | Your account's number. |
| `name` | The name you gave, with leading and trailing spaces removed. |
| `kind` | `otlp_http`, `mlflow` or `webhook`. |
| `url` | The address as you gave it; the OpenTelemetry kinds deliver to it with `/v1/traces` added. |
| `header_names` | The names of the headers you set, sorted; never their values. |
| `include_outputs` | Whether each page's result is sent. |
| `enabled` | `true` when the destination receives spans; `false` while your Tracing and tracking option is off. |
| `created_at` | When it was added. Only spans that end after this moment are sent to it. |
| `delivered` | How many spans it has received, `0` in this answer. |
| `backlog` | How many spans wait for it, `0` in this answer. |
| `backlog_oldest_at`, `next_try_at` | When the oldest waiting span was queued, and when it will next be tried; `null` while nothing waits. |
| `last_ok_at`, `last_error`, `last_error_at` | The last delivery that succeeded, and the last error with its time; `null` until there is one. |
| `signing_secret` | For a `webhook` only: the secret its deliveries are signed with, `fabwh_` followed by 64 hexadecimal characters. It is shown in this answer and never again, so keep it now. |

A webhook delivery is a `POST` of `application/x-ndjson`, one span a line with sorted keys: `type` (`span`), `resource`, and the span as [the job log](/run/docs/reference/jobs-logs.md) shows it, plus `outputs` when included.

## Errors

| Status | Code | When it happens | What to do |
|---|---|---|---|
| `400` | `invalid_json`, `invalid_body` | The body is not a JSON object. | Send the object above. |
| `400` | `invalid_headers` | `headers` is not an object of strings; `expected` shows the shape. | Send `{"Name": "value"}`. |
| `400` | `invalid_header`, `reserved_header` | A header name is not a valid name, a value holds a line break, a name appears twice, or the name is one the service sets. | Fix or leave out that header. |
| `400` | `invalid_name`, `invalid_kind` | The name is empty, or the kind is not one of the three. | Give a name; use `otlp_http`, `mlflow` or `webhook`. |
| `400` | `invalid_url`, `url_credentials`, `url_is_traces_endpoint` | The URL is not an http(s) address, has a fragment, has a query (for the OpenTelemetry kinds), carries a user name or password, or already ends in `/v1/traces`. | Give the base `https` address; put credentials in `headers`. |
| `400` | `https_required` | The URL is not `https`. | Use `https`. |
| `400` | `unresolvable_host`, `address_not_public` | The host does not resolve, or one of its addresses is not public. | Use a public host. |
| `400` | `mlflow_experiment_header_missing` | An `mlflow` destination without the `x-mlflow-experiment-id` header. | Add the header with your experiment's id. |
| `400` | `invalid_preferences` | The workspace is confidential: it keeps governed tracing, so no destination can be added, whatever the body holds. The `message` says so. | Nothing to fix in the request. Read traces with [GET /v1/traces](/run/docs/reference/traces.md), or turn confidential mode off first with [POST /v1/workspaces](/run/docs/reference/workspaces-post.md). |
| `400` | `too_many_sinks` | The account already has 6 destinations. | Remove one with [DELETE /v1/trace-sinks/{sink_id}](/run/docs/reference/trace-sinks-delete.md). |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | No token, or one that does not work (any more). | Use a valid token. |
| `403` | `scope_required`, `account_suspended` | The token lacks `manage`, or the account is suspended. | Use a token with `manage`. |
| `413` | `body_too_large` | The body is larger than `limit_bytes`. | Send fewer or shorter headers. |

## Examples

A webhook; the signing secret is in the answer, once:

```sh
curl -s https://weights.fyi/run/v1/trace-sinks \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "my receiver", "kind": "webhook", "url": "https://hooks.example.org/weights"}'
```

```json
{
  "id": 2,
  "account_id": 1,
  "name": "my receiver",
  "kind": "webhook",
  "url": "https://hooks.example.org/weights",
  "header_names": [],
  "include_outputs": false,
  "enabled": false,
  "created_at": "2026-10-09T09:13:02.540Z",
  "delivered": 0,
  "backlog": 0,
  "backlog_oldest_at": null,
  "next_try_at": null,
  "last_ok_at": null,
  "last_error": null,
  "last_error_at": null,
  "signing_secret": "fabwh_59bdfdff0cf290c56dc43a24107a50c8484636d95603088ca0edb08b2e8fde59"
}
```

## Patterns

### Checking a webhook's signature

`X-Weights-Timestamp` is the signing time in Unix seconds; `X-Weights-Signature` is `sha256=` and the HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the secret. Compute it from the raw body, compare in constant time, refuse timestamps too far from your clock, and answer `2xx` once stored:

```python
import hashlib, hmac

def genuine(secret: str, timestamp: str, body: bytes, signature: str) -> bool:
    expected = hmac.new(secret.encode(), timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest("sha256=" + expected, signature)
```

## History

- 2026-10-08: live: three kinds, public `https` only, secret headers, ordered delivery that never drops a span.
- 2026-10-08: delivery runs on the Tracing and tracking option, off by default; existing destinations were paused when it arrived.
- 2026-10-09: destinations receive exactly the fields of [GET /v1/traces](/run/docs/reference/traces.md) and the job log; before, the charge event carried two internal pricing fields.
- 2026-10-10 implementation review: logged content on the `job` span.
- 2026-11-16: the confidential-workspace refusal documented.

## See also

[GET /v1/trace-sinks](/run/docs/reference/trace-sinks-list.md), [DELETE /v1/trace-sinks/{sink_id}](/run/docs/reference/trace-sinks-delete.md), [Tracing and exports](/run/docs/tracing.md).
