# Signal rules `signal`

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

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

Rule types: `signal`

Sent when a `signal` rule fired on a `signal` event.

## 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. | `signal` |
| `X-TTF-Event-Id` | string | The event id (a ULID). One event can fire several of your rules: each is its own delivery. | `01JDZ8Q7X3M4N5P6Q7R8S9T0SD` |
| `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.

### `WebhookSignal`

A `signal` rule fired.

- `created_ms` (integer, always): When the rule fired. Unix time in milliseconds.
- `detail` (object, always): Why a signal rule fired.
  - `kind` (string, always): The signal kind your rule asked for. One of: `breakout`, `trending`, `call`.
- `event` (object, always): A TTF signal: an ATH breakout or a call milestone.
  - `data` (object, always): A TTF signal: an ATH breakout or a call milestone. The event data (the keys of this type; unknown = absent).
    - `kind` (string, always): breakout = a new all-time high was broken, call = a call reached a milestone, trending = a trending signal. One of: `breakout`, `trending`, `call`.
    - `buys_24h` (integer): Buys in the last 24 hours.
    - `called_at_ms` (integer): When the call was made. Unix time in milliseconds.
    - `dex` (string): The exchange of the main pool (third-party text: escape it).
    - `entry_mc_usd` (string): call: the market cap when the call was made, US dollars. Decimal string (never a float, no exponent).
    - `grade` (string): The signal grade: strong (daily ATH) or early (hourly ATH). One of: `strong`, `early`.
    - `liquidity_usd` (string): Liquidity of its main pool, US dollars. Decimal string (never a float, no exponent).
    - `market_cap_usd` (string): Market cap now, US dollars. Decimal string (never a float, no exponent).
    - `multiple` (number): breakout: market cap / the all-time high it broke; call: the milestone reached since the call (2 = 2x).
    - `name` (string): Token name (third-party text: escape it).
    - `pair_created_ms` (integer): When its main pool was created (the token age).
    - `plan_text` (string): The plan line of the call ("if it holds 24h -> enter, sell 50% at 2x ...").
    - `prev_ath_mc_usd` (string): breakout: the all-time high it broke, as a market cap in US dollars. Decimal string (never a float, no exponent).
    - `prev_ath_ms` (integer): breakout: when that all-time high was set.
    - `price_change_24h_pct` (number): Price change of the last 24 hours, percent (negative = down).
    - `price_usd` (string): Price of one token now, US dollars. Decimal string (never a float, no exponent).
    - `ref` (string): An id of the signal.
    - `score` (number): Strength of the signal (higher = stronger), when given.
    - `sells_24h` (integer): Sells in the last 24 hours.
    - `symbol` (string): Ticker (third-party text: escape it).
    - `text` (string): The signal in words (third-party text: escape it).
    - `tier` (string): Which all-time high: daily (the daily ATH) or 1h (the hourly ATH). One of: `daily`, `1h`.
    - `volume_24h_usd` (string): Trading volume of the last 24 hours, US dollars. Decimal string (never a float, no exponent).
  - `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).
  - `chain` (string): Chain id. Absent for a signal about no chain.
  - `token` (string): Token address (one canonical form per chain: EVM lower-case 0x + 40 hex). Absent for a signal about no token.
- `id` (string, always): Delivery id (a ULID) = the X-TTF-Delivery header.
- `reason` (string, always): Why it fired. One of: `signal`.
- `rule` (object, always): The rule that fired.
  - `id` (string, always): Rule id (whr_ + 24 hex).
  - `kind` (string, always): The rule type.
- `type` (string, always): rule.fired

## Examples

`signal`: signal delivery

```json
{
  "created_ms": 1795000000000,
  "detail": {
    "kind": "breakout"
  },
  "event": {
    "chain": "eth",
    "data": {
      "buys_24h": 4210,
      "called_at_ms": 1794996400000,
      "dex": "uniswap",
      "grade": "strong",
      "kind": "breakout",
      "liquidity_usd": "1240000",
      "market_cap_usd": "19614400",
      "multiple": 1.04,
      "name": "Orbit Cat",
      "pair_created_ms": 1794222400000,
      "plan_text": "if it holds 24h -> enter, sell 50% at 2x, sell 50% every 3x after",
      "prev_ath_mc_usd": "18860000",
      "prev_ath_ms": 1794827200000,
      "price_change_24h_pct": 31.4,
      "price_usd": "0.0196144",
      "sells_24h": 2960,
      "symbol": "ORBIT",
      "tier": "daily",
      "volume_24h_usd": "3870000"
    },
    "id": "01JDZ8Q7X3M4N5P6Q7R8S9T0SD",
    "token": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
    "ts": 1795000000000,
    "type": "signal",
    "v": 1
  },
  "id": "01JDR4Q7Z2N8M5K3X9V6B4C2HA",
  "reason": "signal",
  "rule": {
    "id": "whr_6f1c0a9e2b7d4c3a1e0f9b8d",
    "kind": "signal"
  },
  "type": "rule.fired"
}
```

## 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/signal.json](https://ttf.bot/developers/docs/schemas/events/signal.json)
- [webhook.json](https://ttf.bot/developers/docs/schemas/webhook.json)
