# Delivery log

- Section: Webhook management (TTF API reference)
- Source: https://ttf.bot/developers/docs/#api-deliveries
- The whole reference as one text: https://ttf.bot/developers/docs/llms-full.txt

`GET /v1/webhooks/endpoints/{endpoint_id}/deliveries`

- Base URL: `https://api.ttf.bot`
- Cost: Free
- Plan: Free
- API key: required. Send `Authorization: Bearer YOUR_KEY` (or `X-API-Key: YOUR_KEY`).
- A refused or failed call costs nothing.
- Key needs: webhooks: read

Debug a receiver: what was sent, how many tries it took and what your server answered.

- The one-click page key has no webhook access: paste a key made with **Webhook access** ([how](https://ttf.bot/developers/docs/md/webhook-api.md)).

## Exact rules

What was sent to the endpoint, newest first, with your receiver's answer. Pages: data.next_cursor -> ?cursor=. Needs an API key with `webhooks: read` (write includes read). Costs 0 credits; counted in your account's webhook read limit.

## Parameters

### Path parameters

- `endpoint_id` (string, path, required): Endpoint id (data.endpoint.id).
  - At most 64 characters.
  - Example: `whe_8b1f0c2d9a7e4f3b5c6d1e2a`

### Query parameters

- `cursor` (string, query, optional): data.next_cursor of the previous page. Omit for the newest page.
  - At most 64 characters.
  - Example: `01JDR4Q7Z2N8M5K3X9V6B4C2HA`
- `limit` (integer, query, optional): Rows per page, 1-100. Default 25.
  - Default: `25`.
  - Range: 1 to 100.
  - Example: `25`
- `event_id` (string, query, optional): Only the rows of this event (the event_id of a test).
  - At most 64 characters.
  - Example: `01JDZ8Q7X3M4N5P6Q7R8S9T0PE`

## Example request

```bash
curl -sS 'https://api.ttf.bot/v1/webhooks/endpoints/whe_8b1f0c2d9a7e4f3b5c6d1e2a/deliveries' \
  -H 'Authorization: Bearer YOUR_KEY'
```

Put your key in place of `YOUR_KEY`.

## Example answer

`200` (`default`): Delivery log of an endpoint

```json
{
  "data": {
    "deliveries": [
      {
        "attempts": 1,
        "event_id": "01JDZ8Q7X3M4N5P6Q7R8S9T0PE",
        "id": "01JDR4Q7Z2N8M5K3X9V6B4C2HA",
        "kind": "price_cross",
        "latency_ms": 84,
        "response_snippet": "ok",
        "response_status": 200,
        "rule_id": "whr_6f1c0a9e2b7d4c3a1e0f9b8d",
        "snippet_truncated": false,
        "status": "delivered",
        "ts": 1795000000
      }
    ],
    "next_cursor": "01JDR4Q7Z2N8M5K3X9V6B4C2HA"
  },
  "meta": {
    "cost": 0,
    "request_id": "3f2a9c0e5b7d4e18a6c1f0b2d9e8a7c6"
  }
}
```

## Response fields

`always` = in every answer; `always*` = in every answer that does not narrow it with `fields`; any other field is left out when there is no value (never `null`). Objects are open: ignore keys you do not know.

A `200` answer is `{"data", "meta"}` (`HookDeliveryListAnswer`).

### `data`

- `deliveries` (array of objects, always): The rows.
  - `attempts` (integer, always): Attempts made.
  - `event_id` (string, always): The event it delivered.
  - `id` (string, always): Delivery id (= the X-TTF-Delivery header).
  - `kind` (string, always): The rule type, or ping. Known values: `price_cross`, `pct_move`, `trending_enter`, `wallet_activity`, `signal`, `ping` (more may come: handle unknown ones).
  - `response_snippet` (string, always): The first 1 KB of your receiver's answer (empty text when none).
  - `rule_id` (string, always): The rule that fired (empty text for a test ping).
  - `snippet_truncated` (boolean, always): true = the answer was longer.
  - `status` (string, always): pending = being sent; delivered = a 2xx answer; retrying = it will be tried again; dead = every try failed; delayed_expired = it waited too long to be sent; lost = its data was lost on our side. Known values: `pending`, `delivered`, `retrying`, `dead`, `delayed_expired`, `lost` (more may come: handle unknown ones).
  - `ts` (integer, always): When the rule fired. Unix time in SECONDS.
  - `error` (string): A short reason code of the last failure.
  - `latency_ms` (integer): How long your receiver took, in milliseconds.
  - `next_attempt` (integer): When the next attempt is due, while one is. Unix time in SECONDS.
  - `response_status` (integer): The HTTP status your receiver answered, when it answered.
- `next_cursor` (string): Pass as ?cursor= for the older page. Absent on the last page.

### `meta`

- `cost` (integer, always): Credits this call finally spent (= the X-Credits-Cost header). 0 for free routes and refused calls.
- `request_id` (string, always): Id of this request (= the X-Request-Id header). Quote it to support.
- `cached` (array of strings): The groups answered from the shared answer cache (charged at their cached weight). Absent when none.
- `partial` (array of strings): Something is missing. A bare group name ("holders"): that group failed, its entry in data is {"error": {...}} and only the attempt fee can apply. A dotted "\<group>.\<part>" ("security.holders"): a part of a group that DID answer is missing (see its complete / missing); that group is still billed. Absent when nothing is missing.

## Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `bad_request` | Bad request: an unknown field or a bad value. Nothing changed. Codes: bad_request. |
| 401 | `unauthorized` | The API key is missing or not valid. Codes: unauthorized. |
| 402 | `payment_required` | The subscription of this API key has ended. Codes: payment_required. |
| 403 | `forbidden` | The key lacks the webhook permission (or its plan, IP or account refuses the call), or a plan limit is reached. Codes: forbidden. |
| 404 | `not_found` | No such endpoint or rule in your account, or the webhook API is switched off. Codes: not_found. |
| 405 | `method_not_allowed` | Wrong HTTP method for this route. Codes: method_not_allowed. |
| 429 | `rate_limited` | Too many requests, or too many webhook reads or changes of your account. See Retry-After. Codes: rate_limited. |
| 500 | `internal` | Unexpected error. Codes: internal. |
| 503 | `unavailable` | The service cannot answer right now. See Retry-After. Codes: unavailable. |
| other | `error` | Any other refusal of the HTTP layer (rare): the status says which. Codes: error. |

Every error is `{"error": {"code", "message", "doc_url", "request_id"}}`. What each code means and how to fix it: [Errors](https://ttf.bot/developers/docs/md/errors.md).
