Перейти к основному содержанию
POST
/
v1
/
webhooks
/
test
JavaScript
import Gmt from 'gmt-typescript-sdk';

const client = new Gmt({
  apiKey: process.env['GMT_API_KEY'], // This is the default and can be omitted
});

const response = await client.webhooks.test({
  type: 'success',
  url: 'https://example.com/webhooks/handler',
});

console.log(response.success);
{
  "success": true,
  "http_code": 200,
  "response_time_ms": 150,
  "response_body": "OK",
  "error": "<string>"
}

Авторизации

x-api-key
string
header
обязательно

API-key that you received from Telegram Bot.

Тело

url
string<uri>
обязательно

Webhook endpoint URL. Must be a valid URL.

Пример:

"https://example.com/webhooks/handler"

type
enum<string>
по умолчанию:success
обязательно

Webhook payload type to send: success or failed.

Доступные опции:
success,
failed
Пример:

"success"

Ответ

200 - application/json

Result of webhook test request.

Result of webhook test request.

success
boolean
обязательно

Whether the webhook was delivered successfully (HTTP 200).

Пример:

true

http_code
integer

HTTP status code returned by your endpoint.

Требуемый диапазон: -9007199254740991 <= x <= 9007199254740991
Пример:

200

response_time_ms
integer

Response time in milliseconds.

Требуемый диапазон: -9007199254740991 <= x <= 9007199254740991
Пример:

150

response_body
string

Response body from your endpoint (truncated to 1000 characters).

Пример:

"OK"

error
string

Error message if delivery failed.