diff --git a/api/openapi.json b/api/openapi.json index 3056bd32..2fd6fe66 100644 --- a/api/openapi.json +++ b/api/openapi.json @@ -358,6 +358,14 @@ "type": "integer" } }, + "tokenQuery": { + "in": "query", + "name": "token", + "schema": { + "example": "NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODQ3...", + "type": "string" + } + }, "traceIDParameter": { "description": "trace ID or transaction hash in hex (without 0x) or base64url format", "in": "path", @@ -378,6 +386,15 @@ "type": "string" } }, + "webhookId": { + "in": "path", + "name": "webhook_id", + "required": true, + "schema": { + "format": "int64", + "type": "integer" + } + }, "workchainQuery": { "description": "workchain", "in": "query", @@ -680,6 +697,74 @@ }, "description": "Data that is expected", "required": true + }, + "WebhookAccountTxSubscribeRequest": { + "content": { + "application/json": { + "schema": { + "properties": { + "accounts": { + "items": { + "properties": { + "account_id": { + "type": "string" + } + }, + "required": [ + "account_id" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "accounts" + ], + "type": "object" + } + } + }, + "required": true + }, + "WebhookAccountTxUnsubscribeRequest": { + "content": { + "application/json": { + "schema": { + "properties": { + "accounts": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "accounts" + ], + "type": "object" + } + } + }, + "required": true + }, + "WebhookConfiguration": { + "content": { + "application/json": { + "schema": { + "properties": { + "endpoint": { + "type": "string" + } + }, + "required": [ + "endpoint" + ], + "type": "object" + } + } + }, + "required": true } }, "responses": { @@ -5828,6 +5913,37 @@ ], "type": "object" }, + "UsageStats": { + "properties": { + "account_subscriptions": { + "format": "int64", + "type": "integer" + }, + "period_ended_at": { + "format": "date-time", + "type": "string" + }, + "period_started_at": { + "format": "date-time", + "type": "string" + }, + "webhooks_delivered": { + "format": "int64", + "type": "integer" + }, + "webhooks_failed": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "period_started_at", + "account_subscriptions", + "webhooks_delivered", + "webhooks_failed" + ], + "type": "object" + }, "Validator": { "properties": { "address": { @@ -6042,6 +6158,186 @@ ], "type": "object" }, + "WebhookAccountTxSubscriptions": { + "properties": { + "account_tx_subscriptions": { + "items": { + "properties": { + "account_id": { + "type": "string" + }, + "failed_at": { + "format": "date-time", + "type": "string" + }, + "failed_attempts": { + "format": "int64", + "type": "integer" + }, + "failed_lt": { + "format": "int64", + "type": "integer" + }, + "last_delivered_lt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "account_id", + "last_delivered_lt" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "account_tx_subscriptions" + ], + "type": "object" + }, + "WebhookList": { + "properties": { + "webhooks": { + "items": { + "properties": { + "endpoint": { + "type": "string" + }, + "id": { + "format": "int64", + "type": "integer" + }, + "last_online_at": { + "format": "date-time", + "type": "string" + }, + "status": { + "enum": [ + "online", + "offline" + ], + "type": "string" + }, + "status_failed_attempts": { + "type": "integer" + }, + "status_updated_at": { + "format": "date-time", + "type": "string" + }, + "subscribed_accounts": { + "type": "integer" + }, + "subscribed_msg_opcodes": { + "type": "integer" + }, + "subscribed_to_mempool": { + "type": "boolean" + }, + "subscribed_to_new_contracts": { + "type": "boolean" + }, + "token": { + "type": "string" + } + }, + "required": [ + "id", + "endpoint", + "token", + "status", + "status_updated_at", + "last_online_at", + "status_failed_attempts", + "subscribed_accounts", + "subscribed_to_mempool", + "subscribed_to_new_contracts", + "subscribed_msg_opcodes" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "webhooks" + ], + "type": "object" + }, + "WebhookLogs": { + "properties": { + "logs": { + "items": { + "properties": { + "event_type": { + "type": "string" + }, + "message": { + "type": "string" + }, + "timestamp": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "timestamp", + "message", + "event_type" + ], + "type": "object" + }, + "type": "array" + }, + "next_offset": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "logs" + ], + "type": "object" + }, + "WebhookMsgOpcodeSubscriptions": { + "properties": { + "subscriptions": { + "items": { + "properties": { + "disabled_at": { + "format": "date-time", + "type": "string" + }, + "disabled_reason": { + "type": "string" + }, + "opcode": { + "type": "string" + }, + "status": { + "enum": [ + "active", + "disabled" + ], + "type": "string" + } + }, + "required": [ + "opcode", + "status" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "subscriptions" + ], + "type": "object" + }, "WithdrawStakeAction": { "description": "validator's participation in elections", "properties": { @@ -6182,6 +6478,42 @@ }, "openapi": "3.1.0", "paths": { + "/usage-stats": { + "get": { + "operationId": "getUsageStats", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsageStats" + } + } + }, + "description": "usage stats" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, "/v2/accounts/_bulk": { "post": { "description": "Get human-friendly information about several accounts without low-level details.", @@ -10520,28 +10852,738 @@ "Wallet" ] } - } - }, - "servers": [ - { - "url": "https://tonapi.io" }, - { - "url": "https://testnet.tonapi.io" - }, - { - "url": "http://localhost:8081" - } - ], - "tags": [ - { - "externalDocs": { - "description": "Additional documentation", - "url": "https://docs.tonconsole.com/tonapi/rest-api/accounts" - }, - "name": "Accounts" - }, - { + "/webhooks": { + "get": { + "description": "Get list of webhooks", + "operationId": "getWebhooks", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebhookList" + } + } + }, + "description": "list of webhooks" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + }, + "post": { + "operationId": "createWebhook", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/WebhookConfiguration" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "token": { + "description": "secret token which will be used by TONAPI to authenticate itself when sending notifications to the webhook endpoint", + "type": "string" + }, + "webhook_id": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "webhook_id", + "token" + ], + "type": "object" + } + } + }, + "description": "information about created webhook" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}": { + "delete": { + "description": "remove webhook and its subscriptions", + "operationId": "deleteWebhook", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/account-tx/subscribe": { + "post": { + "description": "subscribe to notifications for a particular set of accounts", + "operationId": "webhookAccountTxSubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/WebhookAccountTxSubscribeRequest" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/account-tx/subscriptions": { + "get": { + "operationId": "webhookAccountTxSubscriptions", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + }, + { + "$ref": "#/components/parameters/offsetQuery" + }, + { + "$ref": "#/components/parameters/limitQuery" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebhookAccountTxSubscriptions" + } + } + }, + "description": "subscriptions" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/account-tx/unsubscribe": { + "post": { + "operationId": "webhookAccountTxUnsubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/WebhookAccountTxUnsubscribeRequest" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/back-online": { + "post": { + "description": "Let TONAPI know that webhook is ready to receive notifications after it has been unavailable", + "operationId": "webhookBackOnline", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/generate-new-token": { + "post": { + "description": "generate a new secret token which will be used by TONAPI to authenticate itself when sending notifications to the webhook endpoint. The old token will be invalidated.", + "operationId": "webhookGenerateNewToken", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "token": { + "type": "string" + } + }, + "required": [ + "token" + ], + "type": "object" + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/logs": { + "get": { + "description": "Get logs of failed attempts to deliver notifications to the webhook", + "operationId": "getFailureLogs", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + }, + { + "in": "query", + "name": "offset", + "required": false, + "schema": { + "default": 0, + "minimum": 0, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebhookLogs" + } + } + }, + "description": "list of webhooks" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/mempool/subscribe": { + "post": { + "description": "subscribe to notifications for mempool messages", + "operationId": "webhookMempoolSubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/mempool/unsubscribe": { + "post": { + "operationId": "webhookMempoolUnsubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/msg-opcode/subscriptions": { + "get": { + "operationId": "webhookNewContractsSubscriptions", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + }, + { + "$ref": "#/components/parameters/offsetQuery" + }, + { + "$ref": "#/components/parameters/limitQuery" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebhookMsgOpcodeSubscriptions" + } + } + }, + "description": "subscriptions" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/subscribe-msg-opcode/{opcode}": { + "post": { + "description": "receive a notification when there is a new message with a given opcode", + "operationId": "webhookMsgOpcodeSubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + }, + { + "in": "path", + "name": "opcode", + "required": true, + "schema": { + "description": "hex string starting with 0x", + "example": 1193046, + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/subscribe-new-contracts": { + "post": { + "description": "receive a notification when a new contract is deployed to the blockchain", + "operationId": "webhookNewContractSubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/unsubscribe-msg-opcode/{opcode}": { + "post": { + "description": "stop receiving a notification about a new message with a given opcode", + "operationId": "webhookMsgOpcodeUnsubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + }, + { + "in": "path", + "name": "opcode", + "required": true, + "schema": { + "description": "hex string starting with 0x", + "example": 1193046, + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + }, + "/webhooks/{webhook_id}/unsubscribe-new-contracts": { + "post": { + "description": "receive a notification when a new contract is deployed to the blockchain", + "operationId": "webhookNewContractUnsubscribe", + "parameters": [ + { + "$ref": "#/components/parameters/tokenQuery" + }, + { + "$ref": "#/components/parameters/webhookId" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "example": {} + } + } + }, + "description": "" + }, + "default": { + "$ref": "#/components/responses/Error" + } + }, + "servers": [ + { + "url": "https://rt.tonapi.io" + }, + { + "url": "https://rt-testnet.tonapi.io" + } + ], + "tags": [ + "Webhooks" + ] + } + } + }, + "servers": [ + { + "url": "https://tonapi.io" + }, + { + "url": "https://testnet.tonapi.io" + }, + { + "url": "http://localhost:8081" + } + ], + "tags": [ + { + "externalDocs": { + "description": "Additional documentation", + "url": "https://docs.tonconsole.com/tonapi/rest-api/accounts" + }, + "name": "Accounts" + }, + { "externalDocs": { "description": "Additional documentation", "url": "https://docs.tonconsole.com/tonapi/rest-api/nft" @@ -10659,6 +11701,9 @@ "url": "https://docs.tonconsole.com/tonapi/rest-api/utilities" }, "name": "Utilities" + }, + { + "name": "Webhooks" } ] } diff --git a/api/openapi.yml b/api/openapi.yml index f7f1be40..9bd6ec4b 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -84,6 +84,7 @@ tags: externalDocs: description: Additional documentation url: https://docs.tonconsole.com/tonapi/rest-api/utilities + - name: Webhooks paths: /v2/status: @@ -2811,8 +2812,426 @@ paths: $ref: '#/components/schemas/AccountEvent' 'default': $ref: '#/components/responses/Error' + /webhooks: + get: + description: "Get list of webhooks" + operationId: getWebhooks + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + responses: + '200': + description: "list of webhooks" + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookList' + 'default': + $ref: '#/components/responses/Error' + post: + operationId: createWebhook + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + requestBody: + $ref: "#/components/requestBodies/WebhookConfiguration" + responses: + '200': + description: "information about created webhook" + content: + application/json: + schema: + type: object + required: + - webhook_id + - token + properties: + webhook_id: + type: integer + format: int64 + token: + description: "secret token which will be used by TONAPI to authenticate itself when sending notifications to the webhook endpoint" + type: string + + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}: + delete: + description: "remove webhook and its subscriptions" + operationId: deleteWebhook + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/generate-new-token: + post: + description: "generate a new secret token which will be used by TONAPI to authenticate itself when sending notifications to the webhook endpoint. The old token will be invalidated." + operationId: webhookGenerateNewToken + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + type: object + required: + - token + properties: + token: + type: string + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/back-online: + post: + description: "Let TONAPI know that webhook is ready to receive notifications after it has been unavailable" + operationId: webhookBackOnline + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/logs: + get: + description: "Get logs of failed attempts to deliver notifications to the webhook" + operationId: getFailureLogs + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + - in: query + name: offset + required: false + schema: + type: integer + default: 0 + minimum: 0 + responses: + '200': + description: "list of webhooks" + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookLogs' + 'default': + $ref: '#/components/responses/Error' + /usage-stats: + get: + operationId: getUsageStats + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + responses: + '200': + description: "usage stats" + content: + application/json: + schema: + $ref: '#/components/schemas/UsageStats' + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/account-tx/subscribe: + post: + description: "subscribe to notifications for a particular set of accounts" + operationId: webhookAccountTxSubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + requestBody: + $ref: "#/components/requestBodies/WebhookAccountTxSubscribeRequest" + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + + /webhooks/{webhook_id}/account-tx/unsubscribe: + post: + operationId: webhookAccountTxUnsubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + requestBody: + $ref: "#/components/requestBodies/WebhookAccountTxUnsubscribeRequest" + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/account-tx/subscriptions: + get: + operationId: webhookAccountTxSubscriptions + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + - $ref: '#/components/parameters/offsetQuery' + - $ref: '#/components/parameters/limitQuery' + responses: + '200': + description: "subscriptions" + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookAccountTxSubscriptions' + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/msg-opcode/subscriptions: + get: + operationId: webhookNewContractsSubscriptions + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + - $ref: '#/components/parameters/offsetQuery' + - $ref: '#/components/parameters/limitQuery' + responses: + '200': + description: "subscriptions" + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookMsgOpcodeSubscriptions' + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/subscribe-new-contracts: + post: + description: "receive a notification when a new contract is deployed to the blockchain" + operationId: webhookNewContractSubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/unsubscribe-new-contracts: + post: + description: "receive a notification when a new contract is deployed to the blockchain" + operationId: webhookNewContractUnsubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/subscribe-msg-opcode/{opcode}: + post: + description: "receive a notification when there is a new message with a given opcode" + operationId: webhookMsgOpcodeSubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + - name: opcode + in: path + required: true + schema: + type: string + description: "hex string starting with 0x" + example: 0x123456 + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/unsubscribe-msg-opcode/{opcode}: + post: + description: "stop receiving a notification about a new message with a given opcode" + operationId: webhookMsgOpcodeUnsubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + - name: opcode + in: path + required: true + schema: + type: string + description: "hex string starting with 0x" + example: 0x123456 + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/mempool/subscribe: + post: + description: "subscribe to notifications for mempool messages" + operationId: webhookMempoolSubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/mempool/unsubscribe: + post: + operationId: webhookMempoolUnsubscribe + tags: + - Webhooks + servers: + - url: https://rt.tonapi.io + - url: https://rt-testnet.tonapi.io + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + responses: + '200': + description: "" + content: + application/json: + schema: + additionalProperties: true + example: { } + 'default': + $ref: '#/components/responses/Error' components: parameters: + tokenQuery: + in: query + name: token + schema: + type: string + example: NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODQ3... + webhookId: + in: path + name: webhook_id + required: true + schema: + type: integer + format: int64 masterchainSeqno: in: path name: masterchain_seqno @@ -3318,6 +3737,48 @@ components: body: type: string format: cell-base64 + WebhookConfiguration: + required: true + content: + application/json: + schema: + type: object + required: + - endpoint + properties: + endpoint: + type: string + WebhookAccountTxSubscribeRequest: + required: true + content: + application/json: + schema: + type: object + required: + - accounts + properties: + accounts: + type: array + items: + type: object + required: + - account_id + properties: + account_id: + type: string + WebhookAccountTxUnsubscribeRequest: + required: true + content: + application/json: + schema: + type: object + required: + - accounts + properties: + accounts: + type: array + items: + type: string schemas: Error: @@ -7378,7 +7839,155 @@ components: type: integer format: int64 example: 1668436763 - + UsageStats: + type: object + required: + - period_started_at + - account_subscriptions + - webhooks_delivered + - webhooks_failed + properties: + period_started_at: + type: string + format: date-time + period_ended_at: + type: string + format: date-time + account_subscriptions: + type: integer + format: int64 + webhooks_delivered: + type: integer + format: int64 + webhooks_failed: + type: integer + format: int64 + WebhookLogs: + type: object + required: + - logs + properties: + next_offset: + type: integer + format: int64 + logs: + type: array + items: + type: object + required: + - timestamp + - message + - event_type + properties: + message: + type: string + event_type: + type: string + timestamp: + type: string + format: date-time + WebhookList: + type: object + required: + - webhooks + properties: + webhooks: + type: array + items: + type: object + required: + - id + - endpoint + - token + - status + - status_updated_at + - last_online_at + - status_failed_attempts + - subscribed_accounts + - subscribed_to_mempool + - subscribed_to_new_contracts + - subscribed_msg_opcodes + properties: + id: + type: integer + format: int64 + endpoint: + type: string + token: + type: string + subscribed_accounts: + type: integer + subscribed_msg_opcodes: + type: integer + subscribed_to_mempool: + type: boolean + subscribed_to_new_contracts: + type: boolean + status: + type: string + enum: + - online + - offline + status_updated_at: + type: string + format: date-time + last_online_at: + type: string + format: date-time + status_failed_attempts: + type: integer + WebhookAccountTxSubscriptions: + type: object + required: + - account_tx_subscriptions + properties: + account_tx_subscriptions: + type: array + items: + type: object + required: + - account_id + - last_delivered_lt + properties: + account_id: + type: string + last_delivered_lt: + type: integer + format: int64 + failed_at: + type: string + format: date-time + failed_lt: + type: integer + format: int64 + failed_attempts: + type: integer + format: int64 + WebhookMsgOpcodeSubscriptions: + type: object + required: + - subscriptions + properties: + subscriptions: + type: array + items: + type: object + required: + - opcode + - status + properties: + opcode: + type: string + status: + type: string + enum: + - active + - disabled + disabled_at: + type: string + format: date-time + disabled_reason: + type: string responses: Error: description: Some error during request processing diff --git a/api/rt.yml b/api/rt.yml deleted file mode 100644 index 6d0d9357..00000000 --- a/api/rt.yml +++ /dev/null @@ -1,588 +0,0 @@ -openapi: 3.0.2 -info: - title: Realtime API. - version: 0.0.1 - contact: - name: Support - email: support@tonkeeper.com -servers: - - url: "https://rt.tonapi.io" -paths: - /webhooks: - get: - description: "Get list of webhooks" - operationId: getWebhooks - parameters: - - $ref: '#/components/parameters/tokenQuery' - responses: - '200': - description: "list of webhooks" - content: - application/json: - schema: - $ref: '#/components/schemas/WebhookList' - 'default': - $ref: '#/components/responses/Error' - post: - operationId: createWebhook - parameters: - - $ref: '#/components/parameters/tokenQuery' - requestBody: - $ref: "#/components/requestBodies/WebhookConfiguration" - responses: - '200': - description: "information about created webhook" - content: - application/json: - schema: - type: object - required: - - webhook_id - - token - properties: - webhook_id: - type: integer - format: int64 - token: - description: "secret token which will be used by TONAPI to authenticate itself when sending notifications to the webhook endpoint" - type: string - - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}: - delete: - description: "remove webhook and its subscriptions" - operationId: deleteWebhook - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/generate-new-token: - post: - description: "generate a new secret token which will be used by TONAPI to authenticate itself when sending notifications to the webhook endpoint. The old token will be invalidated." - operationId: webhookGenerateNewToken - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - type: object - required: - - token - properties: - token: - type: string - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/back-online: - post: - description: "Let TONAPI know that webhook is ready to receive notifications after it has been unavailable" - operationId: webhookBackOnline - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/logs: - get: - description: "Get logs of failed attempts to deliver notifications to the webhook" - operationId: getFailureLogs - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - - in: query - name: offset - required: false - schema: - type: integer - default: 0 - minimum: 0 - responses: - '200': - description: "list of webhooks" - content: - application/json: - schema: - $ref: '#/components/schemas/WebhookLogs' - 'default': - $ref: '#/components/responses/Error' - /usage-stats: - get: - operationId: getUsageStats - parameters: - - $ref: '#/components/parameters/tokenQuery' - responses: - '200': - description: "usage stats" - content: - application/json: - schema: - $ref: '#/components/schemas/UsageStats' - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/account-tx/subscribe: - post: - description: "subscribe to notifications for a particular set of accounts" - operationId: webhookAccountTxSubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - requestBody: - $ref: "#/components/requestBodies/WebhookAccountTxSubscribeRequest" - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - - /webhooks/{webhook_id}/account-tx/unsubscribe: - post: - operationId: webhookAccountTxUnsubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - requestBody: - $ref: "#/components/requestBodies/WebhookAccountTxUnsubscribeRequest" - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/account-tx/subscriptions: - get: - operationId: webhookAccountTxSubscriptions - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - - $ref: '#/components/parameters/offsetQuery' - - $ref: '#/components/parameters/limitQuery' - responses: - '200': - description: "subscriptions" - content: - application/json: - schema: - $ref: '#/components/schemas/WebhookAccountTxSubscriptions' - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/msg-opcode/subscriptions: - get: - operationId: webhookNewContractsSubscriptions - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - - $ref: '#/components/parameters/offsetQuery' - - $ref: '#/components/parameters/limitQuery' - responses: - '200': - description: "subscriptions" - content: - application/json: - schema: - $ref: '#/components/schemas/WebhookMsgOpcodeSubscriptions' - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/subscribe-new-contracts: - post: - description: "receive a notification when a new contract is deployed to the blockchain" - operationId: webhookNewContractSubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/unsubscribe-new-contracts: - post: - description: "receive a notification when a new contract is deployed to the blockchain" - operationId: webhookNewContractUnsubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/subscribe-msg-opcode/{opcode}: - post: - description: "receive a notification when there is a new message with a given opcode" - operationId: webhookMsgOpcodeSubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - - name: opcode - in: path - required: true - schema: - type: string - description: "hex string starting with 0x" - example: 0x123456 - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/unsubscribe-msg-opcode/{opcode}: - post: - description: "stop receiving a notification about a new message with a given opcode" - operationId: webhookMsgOpcodeUnsubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - - name: opcode - in: path - required: true - schema: - type: string - description: "hex string starting with 0x" - example: 0x123456 - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/mempool/subscribe: - post: - description: "subscribe to notifications for mempool messages" - operationId: webhookMempoolSubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - /webhooks/{webhook_id}/mempool/unsubscribe: - post: - operationId: webhookMempoolUnsubscribe - parameters: - - $ref: '#/components/parameters/tokenQuery' - - $ref: '#/components/parameters/webhookId' - responses: - '200': - description: "" - content: - application/json: - schema: - additionalProperties: true - example: { } - 'default': - $ref: '#/components/responses/Error' - -components: - parameters: - token: - in: header - name: X-TonConnect-Auth - schema: - type: string - example: NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODQ3... - tokenQuery: - in: query - name: token - schema: - type: string - example: NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODQ3... - webhookId: - in: path - name: webhook_id - required: true - schema: - type: integer - format: int64 - limitQuery: - in: query - name: limit - required: false - schema: - type: integer - default: 1000 - maximum: 1000 - offsetQuery: - in: query - name: offset - required: false - schema: - type: integer - default: 0 - i18n: - in: header - name: Accept-Language - required: false - schema: - type: string - example: "ru-RU,ru;q=0.5" - default: "en" - requestBodies: - WebhookConfiguration: - required: true - content: - application/json: - schema: - type: object - required: - - endpoint - properties: - endpoint: - type: string - WebhookAccountTxSubscribeRequest: - required: true - content: - application/json: - schema: - type: object - required: - - accounts - properties: - accounts: - type: array - items: - type: object - required: - - account_id - properties: - account_id: - type: string - WebhookAccountTxUnsubscribeRequest: - required: true - content: - application/json: - schema: - type: object - required: - - accounts - properties: - accounts: - type: array - items: - type: string - schemas: - Error: - type: object - required: - - error - properties: - error: - type: string - example: error description - UsageStats: - type: object - required: - - period_started_at - - account_subscriptions - - webhooks_delivered - - webhooks_failed - properties: - period_started_at: - type: string - format: date-time - period_ended_at: - type: string - format: date-time - account_subscriptions: - type: integer - format: int64 - webhooks_delivered: - type: integer - format: int64 - webhooks_failed: - type: integer - format: int64 - WebhookLogs: - type: object - required: - - logs - properties: - next_offset: - type: integer - format: int64 - logs: - type: array - items: - type: object - required: - - timestamp - - message - - event_type - properties: - message: - type: string - event_type: - type: string - timestamp: - type: string - format: date-time - WebhookList: - type: object - required: - - webhooks - properties: - webhooks: - type: array - items: - type: object - required: - - id - - endpoint - - token - - status - - status_updated_at - - last_online_at - - status_failed_attempts - - subscribed_accounts - - subscribed_to_mempool - - subscribed_to_new_contracts - - subscribed_msg_opcodes - properties: - id: - type: integer - format: int64 - endpoint: - type: string - token: - type: string - subscribed_accounts: - type: integer - subscribed_msg_opcodes: - type: integer - subscribed_to_mempool: - type: boolean - subscribed_to_new_contracts: - type: boolean - status: - type: string - enum: - - online - - offline - status_updated_at: - type: string - format: date-time - last_online_at: - type: string - format: date-time - status_failed_attempts: - type: integer - WebhookAccountTxSubscriptions: - type: object - required: - - account_tx_subscriptions - properties: - account_tx_subscriptions: - type: array - items: - type: object - required: - - account_id - - last_delivered_lt - properties: - account_id: - type: string - last_delivered_lt: - type: integer - format: int64 - failed_at: - type: string - format: date-time - failed_lt: - type: integer - format: int64 - failed_attempts: - type: integer - format: int64 - WebhookMsgOpcodeSubscriptions: - type: object - required: - - subscriptions - properties: - subscriptions: - type: array - items: - type: object - required: - - opcode - - status - properties: - opcode: - type: string - status: - type: string - enum: - - active - - disabled - disabled_at: - type: string - format: date-time - disabled_reason: - type: string - responses: - Error: - description: Some error during request processing - content: - application/json: - schema: - type: object - required: - - error - properties: - error: - type: string diff --git a/ogen.yaml b/ogen.yaml index 155c2c1d..2b017ceb 100644 --- a/ogen.yaml +++ b/ogen.yaml @@ -9,4 +9,6 @@ generator: - client/request/validation - paths/client - webhooks/client - - webhooks/server \ No newline at end of file + - webhooks/server + filters: + path_regex: "^/v2/.*" \ No newline at end of file