# Webhook usage and limits

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

`GET /v1/webhooks/usage`

- 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

How much room is left: endpoints, rules, watched wallets and deliveries of this month against what your plan allows.

- 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

Endpoints, rules, watched wallets and this month's deliveries against your plan. Needs an API key with `webhooks: read` (write includes read). Costs 0 credits; counted in your account's webhook read limit.

## Parameters

No parameters: just send it.

## Example request

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

Put your key in place of `YOUR_KEY`.

## Example answer

`200` (`default`): Webhook usage and limits

```json
{
  "data": {
    "deliveries": {
      "limit": 250000,
      "over_quota": false,
      "resets": 1796000000,
      "used": 1840
    },
    "endpoints": {
      "limit": 10,
      "over_limit": 0,
      "used": 2
    },
    "partial": [],
    "plan": {
      "groups": [
        "core",
        "security",
        "signals",
        "wallet"
      ],
      "plan_id": "pro",
      "plan_name": "Pro",
      "state": "ok"
    },
    "rules": {
      "active": 6,
      "limit": 100,
      "over_limit": 0,
      "used": 7
    },
    "watch": {
      "limit": 2500,
      "used": 12
    }
  },
  "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"}` (`HookUsageAnswer`).

### `data`

- `deliveries` (object, always): Deliveries of the running subscription month.
  - `limit` (integer, always): Allowed.
  - `over_quota` (boolean, always): true = used up: rules do not fire until the reset or an upgrade.
  - `resets` (integer, always): When the count starts again. Unix time in SECONDS.
  - `used` (integer, always): Sent.
- `endpoints` (object, always): Endpoints.
  - `limit` (integer, always): Allowed.
  - `over_limit` (integer, always): Above the plan (paused).
  - `used` (integer, always): In use.
- `partial` (array of strings, always): Parts that could not be read just now (empty when everything was).
- `plan` (object, always): Your plan.
  - `groups` (array of strings, always): Data groups of the plan.
  - `plan_id` (string, always): Plan id.
  - `plan_name` (string, always): Plan name.
  - `state` (string, always): ok, or why paid terms do not apply (expired = the Free terms).
- `rules` (object, always): Rules.
  - `active` (integer, always): Switched on and inside the plan.
  - `limit` (integer, always): Allowed.
  - `over_limit` (integer, always): Above the plan (paused).
  - `used` (integer, always): In use.
- `watch` (object, always): Watched wallet addresses.
  - `limit` (integer, always): Allowed.
  - `used` (integer, always): In use.

### `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 |
| --- | --- | --- |
| 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` `account_suspended` | The key lacks the webhook permission (or its plan, IP or account refuses the call), or a plan limit is reached. Codes: forbidden, account_suspended. |
| 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).
