API key is required for all webhook operations. Get one at tonconsole.com.
Architecture
| Component | Description |
|---|---|
TonapiWebhookClient | HTTP client for webhook CRUD — create, list, delete, subscribe/unsubscribe. |
TonapiWebhook | Bound webhook object — manages subscriptions without explicit ID. |
TonapiWebhookDispatcher | Decorator-based event dispatcher — register handlers, auto-setup, process incoming events. |
Event Types
| Type | Enum | Decorator | Description |
|---|---|---|---|
| Account TX | ACCOUNT_TX | @dispatcher.account_tx() | Account transactions. |
| Mempool MSG | MEMPOOL_MSG | @dispatcher.mempool_msg() | Pending mempool messages. |
| Opcode MSG | OPCODE_MSG | @dispatcher.opcode_msg() | Messages filtered by opcode. |
| New Contracts | NEW_CONTRACTS | @dispatcher.new_contracts() | New contract deployments. |
Endpoints
| Network | URL |
|---|---|
| Mainnet | https://rt.tonapi.io |
| Testnet | https://rt-testnet.tonapi.io |
Quick Example
FastAPI integration with automatic webhook setup and event dispatch:Each webhook has a unique secret token. TON API sends it as
Authorization: Bearer {token} with every event delivery — use it to verify that incoming requests are genuine. The dispatcher verifies it automatically in process().Event Models
All models are PydanticBaseModel subclasses.
AccountTxEvent
AccountTxEvent
| Field | Type | Description |
|---|---|---|
event_type | Literal["account_tx"] | Always "account_tx". |
account_id | str | Account address. |
lt | int | Logical time. |
tx_hash | str | Transaction hash. |
MempoolMsgEvent
MempoolMsgEvent
| Field | Type | Description |
|---|---|---|
event_type | Literal["mempool_msg"] | Always "mempool_msg". |
boc | str | Base64-encoded BOC. |
OpcodeMsgEvent
OpcodeMsgEvent
| Field | Type | Description |
|---|---|---|
event_type | Literal["opcode_msg"] | Always "opcode_msg". |
account_id | str | Account address. |
lt | int | Logical time. |
tx_hash | str | Transaction hash. |
NewContractsEvent
NewContractsEvent
| Field | Type | Description |
|---|---|---|
event_type | Literal["new_contracts"] | Always "new_contracts". |
account_id | str | Account address. |
lt | int | Logical time. |
tx_hash | str | Transaction hash. |
All webhook events are finalized — there is no pending/confirmed distinction unlike streaming mempool events.