# Test ping `ping`

- Section: Webhooks (TTF API reference)
- Source: https://ttf.bot/developers/docs/#webhook-ping
- The whole reference as one text: https://ttf.bot/developers/docs/llms-full.txt

`POST` to your endpoint, with the header `X-TTF-Event: ping`.

Rule types: `ping`

Sent when the dashboard's Test button.

## Delivery rules

TTF sends an HTTPS POST with a JSON body to your endpoint when a rule fires (and when you press Test in the dashboard). Answer any 2xx within 10 seconds (queue the work on your side); anything else, a timeout or a redirect is retried after 1 min, 5 min, 30 min, 2 h and 12 h. Delivery is AT LEAST ONCE: dedupe on X-TTF-Delivery (= body.id). Deliveries are not ordered: order by created_ms / event.ts. Verify X-TTF-Signature over the RAW body before you trust it. Deliveries come from changing proxy addresses: never allowlist IPs, verify the signature.

## Headers

| Header | Type | Meaning | Example |
| --- | --- | --- | --- |
| `X-TTF-Event` | string | The event type of the body's `event`: price, trending, wallet, signal or ping. | `ping` |
| `X-TTF-Event-Id` | string | The event id (a ULID). One event can fire several of your rules: each is its own delivery. | `01JDZ8Q7X3M4N5P6Q7R8S9T0PE` |
| `X-TTF-Delivery` | string | The delivery id (a ULID) = body.id, THE SAME on every retry and re-send: drop duplicates on it. | `01JDR4Q7Z2N8M5K3X9V6B4C2HA` |
| `X-TTF-Attempt` | integer | 1 for the first try, then 2, 3, ... (at most 6 attempts over about 15 hours). | `1` |
| `X-TTF-Timestamp` | integer | Unix SECONDS when this attempt was signed (every retry is signed afresh). Refuse it when more than 300 s away from your clock (replay window). | `1795000000` |
| `X-TTF-Signature` | string | v1=\<hex>: HMAC-SHA256(key = your endpoint secret "whsec_...", message = X-TTF-Timestamp + "." + the raw body bytes), lower-case hex. During the 24 h after a secret rotation: "v1=\<new>,v1=\<old>". Compare in constant time; accept if any value matches. | `v1=0000000000000000000000000000000000000000000000000000000000000000` |
| `User-Agent` | string | Always TTF-Webhooks/1.0. | `TTF-Webhooks/1.0` |

## Signature

| Field | Value |
| --- | --- |
| algorithm | HMAC-SHA256 |
| format | v1=\<64 lower-case hex>[,v1=\<hex>] |
| header | X-TTF-Signature |
| rotation | for 24 h after a secret rotation the header carries two values (new secret first): accept if any matches |
| secret | the endpoint secret, the whole whsec_... string as UTF-8 |
| signed payload | \<X-TTF-Timestamp>.\<raw request body bytes> |
| timestamp header | X-TTF-Timestamp |
| tolerance s | 300 |

Copy-paste verification code in Python and Node.js: [Verify the signature](https://ttf.bot/developers/docs/md/webhook-signatures.md).

## Body

One body per fired rule. `always` = in every body; other fields are left out when unknown. Text inside events comes from third parties: escape it before you show it.

### `WebhookPing`

The dashboard's test button.

- `created_ms` (integer, always): When the test was queued. Unix time in milliseconds.
- `event` (object, always): The dashboard's test delivery (webhooks only, never on the bus).
  - `data` (object, always): The test delivery's data.
    - `text` (string, always): A fixed text ("Test delivery from TTF").
  - `id` (string, always): Event id: a ULID (26 characters, sorts by time). One event can fire several rules.
  - `ts` (integer, always): When the event happened. Unix time in milliseconds.
  - `type` (string, always): The event type.
  - `v` (integer, always): Envelope version (1).
- `id` (string, always): Delivery id (a ULID) = the X-TTF-Delivery header.
- `reason` (string, always): Always test.
- `type` (string, always): ping

## Examples

`ping`: ping delivery

```json
{
  "created_ms": 1795000000000,
  "event": {
    "data": {
      "text": "Test delivery from TTF"
    },
    "id": "01JDZ8Q7X3M4N5P6Q7R8S9T0PE",
    "ts": 1795000000000,
    "type": "ping",
    "v": 1
  },
  "id": "01JDR4Q7Z2N8M5K3X9V6B4C2HA",
  "reason": "test",
  "type": "ping"
}
```

## Your answer

- `2XX`: Delivered: any 2xx. The first 1 KB of your answer shows in the delivery log.
- `default`: Any other answer (or a timeout, a TLS / connection failure, a redirect) is a failed attempt and is retried.

## JSON Schema

Validate bodies in your own code with the published schemas (draft 2020-12):

- [events/ping.json](https://ttf.bot/developers/docs/schemas/events/ping.json)
- [webhook.json](https://ttf.bot/developers/docs/schemas/webhook.json)
