Перейти к основному содержанию
POST
/
v1
/
purchases
/
{purchase_id}
/
request-code
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.purchases.requestVerificationCode(12345);

console.log(response.code_request);
{
  "purchase": {
    "id": 12345,
    "country_code": "US",
    "display_name": {
      "ru": "США",
      "en": "United States"
    },
    "phone_number": "+12025550123",
    "price": {
      "amount": "1.50",
      "currency_code": "USD"
    },
    "status": "SUCCESS",
    "purchase_type": "SINGLE",
    "verification": {
      "code": "12345",
      "password": "secret123",
      "received_at": "2024-11-19T07:52:00.000Z"
    },
    "created_at": "2024-11-19T07:50:00.000Z"
  },
  "code_request": {
    "status": "pending",
    "attempt": 1,
    "max_attempts": 18,
    "next_attempt_at": "2024-01-15T10:30:00.000Z",
    "retry_after": 10
  }
}

Авторизации

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

API-key that you received from Telegram Bot.

Параметры пути

purchase_id
integer
обязательно

Unique purchase identifier.

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

12345

Тело

callback_url
string<uri>

URL to receive webhook notification when code is received. POST request will be sent with either WebhookSuccessPayload or WebhookFailedPayload.

Retry policy. If your endpoint does not return HTTP 200, webhook will be retried up to 3 times with delays: immediately, after 10 seconds, after 30 seconds. Any non-200 response triggers retry.

Пример:

"https://example.com/webhooks/code-received"

Ответ

200 - application/json

Response for status 200

purchase
object
обязательно
code_request
object
обязательно