# Trending rules `trending`

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

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

Rule types: `trending_enter`

Sent when a `trending_enter` rule fired on a `trending` 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. | `trending` |
| `X-TTF-Event-Id` | string | The event id (a ULID). One event can fire several of your rules: each is its own delivery. | `01JDZ8Q7X3M4N5P6Q7R8S9T0TB` |
| `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.

### `WebhookTrendingEnter`

A `trending_enter` rule fired.

- `created_ms` (integer, always): When the rule fired. Unix time in milliseconds.
- `detail` (object, always): Why a trending_enter rule fired.
  - `first_seen_ms` (integer, always): When the token entered the board. Unix time in milliseconds.
  - `min_scans` (integer, always): Your minimum (on the token's chain, when that chain has its own).
  - `scans` (integer, always): Scans of the token on the board.
  - `filters` (array of strings): The filters of your rule that applied on this chain and passed (besides min_scans). Absent for a rule without filters.
  - `not_applied` (array of strings): Filters of your rule that did not apply on this chain because TTF never has their value there (e.g. a tax filter on Solana). Absent when every filter applied.
  - `unknown` (array of strings): With unknown: mark, the values a filter needed that are unknown (event data keys, e.g. holders). Absent when every value was known.
- `event` (object, always): A token on TTF's trending board (the most scanned tokens).
  - `chain` (string, always): Chain id. Absent for a signal about no chain.
  - `data` (object, always): A token on TTF's trending board (the most scanned tokens). The event data (the keys of this type; unknown = absent).
    - `rank` (integer, always): Position on the board (1 = most scanned).
    - `scans` (integer, always): TTF scans of the token in the board window.
    - `buy_tax_pct` (number): Buy tax measured by that simulation, percent.
    - `buys_1h` (integer): Buys in the last hour.
    - `first_seen_ms` (integer): When the token entered the board. Absent when its entry was not observed (after a gap). Unix time in milliseconds.
    - `freeze_disabled` (boolean): Solana: true = the freeze authority is off.
    - `has_telegram` (boolean): true = a Telegram group is listed for the token.
    - `has_website` (boolean): true = a website is listed for the token.
    - `has_x` (boolean): true = an X account is listed for the token.
    - `holders` (integer): Number of holders the TTF scan read.
    - `honeypot` (boolean): The TTF scan's buy / sell simulation: true = selling failed or was blocked. Absent when no simulation ran (never false for a check that failed). EVM chains only.
    - `interval_min` (integer): The board window, in minutes.
    - `launchpad` (boolean): Solana: true = the token comes from a launchpad; false = no launchpad detected by TTF (a graduated Moonshot token, a LaunchLab token without its suffix or a pump.fun mint whose read failed can still be false).
    - `liquidity_usd` (string): Liquidity of its most liquid pool, US dollars. Decimal string (never a float, no exponent).
    - `locked_pct` (number): Share of the liquidity that is locked or burned, percent.
    - `market_cap_usd` (string): Market cap (or the fully diluted value when no market cap is known), US dollars. Decimal string (never a float, no exponent).
    - `mint_disabled` (boolean): Solana: true = the mint authority is off.
    - `name` (string): Token name (third-party text: escape it).
    - `pair` (string): The main pair (pool).
    - `pair_created_ms` (integer): When its pool was created (the token age).
    - `pair_with` (string): What the pool pairs it with: native (the chain coin), stable (a stablecoin) or other. One of: `native`, `stable`, `other`.
    - `price_change_1h_pct` (number): Price change of the last hour, percent (negative = down).
    - `renounced` (boolean): true = the contract owner is renounced (EVM chains).
    - `sell_tax_pct` (number): Sell tax measured by that simulation, percent.
    - `symbol` (string): Ticker (third-party text: escape it).
    - `top10_pct` (number): Share of the supply the 10 largest holders hold, percent.
    - `verified_source` (boolean): true = the contract source code is verified.
    - `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.
  - `token` (string, always): Token address (one canonical form per chain: EVM lower-case 0x + 40 hex). Absent for a signal about no token.
  - `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): Why it fired. One of: `entered`.
- `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

`trending_enter`: trending_enter delivery

```json
{
  "created_ms": 1795000000000,
  "detail": {
    "filters": [
      "min_liquidity_usd",
      "exclude_honeypot"
    ],
    "first_seen_ms": 1794999880000,
    "min_scans": 25,
    "scans": 41
  },
  "event": {
    "chain": "eth",
    "data": {
      "buy_tax_pct": 0.0,
      "buys_1h": 412,
      "first_seen_ms": 1794999880000,
      "has_telegram": true,
      "has_website": true,
      "has_x": true,
      "holders": 400000,
      "honeypot": false,
      "interval_min": 5,
      "liquidity_usd": "38200000",
      "locked_pct": 100.0,
      "market_cap_usd": "3870000000",
      "name": "Pepe",
      "pair": "0xa43fe16908251ee70ef74718545e4fe6c5ccec9f",
      "pair_created_ms": 1681900000000,
      "pair_with": "native",
      "price_change_1h_pct": 1.8,
      "rank": 3,
      "renounced": true,
      "scans": 41,
      "sell_tax_pct": 0.0,
      "symbol": "PEPE",
      "top10_pct": 41.2,
      "verified_source": true,
      "volume_24h_usd": "51200000"
    },
    "id": "01JDZ8Q7X3M4N5P6Q7R8S9T0TB",
    "token": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
    "ts": 1795000000000,
    "type": "trending",
    "v": 1
  },
  "id": "01JDR4Q7Z2N8M5K3X9V6B4C2HA",
  "reason": "entered",
  "rule": {
    "id": "whr_6f1c0a9e2b7d4c3a1e0f9b8d",
    "kind": "trending_enter"
  },
  "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/trending.json](https://ttf.bot/developers/docs/schemas/events/trending.json)
- [webhook.json](https://ttf.bot/developers/docs/schemas/webhook.json)
