Request verification code
Changed onRequests verification code and password from provider. Updates purchase status to SUCCESS.
Idempotent Operation. Safe to retry on network errors - will not generate duplicate codes.
Behavior.
- First call: Fetches code from provider, updates status to SUCCESS
- Subsequent calls: Returns conflict error (use GET /purchases/:id to retrieve existing code)
Provider timeout. Code retrieval may take 5-30 seconds depending on provider availability.
Webhook notification. Optionally provide callback_url to receive a POST webhook when code is retrieved. See Webhooks section for payload structure and Models section for WebhookSuccessPayload / WebhookFailedPayload schemas.
Request
- Base URLhttps://api.getmytg.com
- URLhttps://api.getmytg.com/v1/purchases/{purchase_id}/request-code
- Auth
- API key in header x-api-key
- or HTTP bearer
Path parameters
Unique purchase identifier.
Request body
Example request
{
"callback_url": "https://example.com/webhooks/code-received"
}Response
Response for status 200
Example response
{
"purchase": {
"id": 12345,
"country_code": "US",
"emoji": "🇺🇸",
"display_name": {
"ru": "США",
"en": "United States"
},
"phone_number": "+12025550123",
"price": {
"amount": "1.50",
"currency_code": "USD"
},
"status": "SUCCESS",
"purchase_type": "SINGLE",
"purchase_source": "BOT",
"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
}
}Changes
- breaking
the response property
//became nullable for the status - warning
added the new
EXPIREDenum value to the/response property for the response status - info
added the non-success response with the status
- info
added the non-success response with the status
- info
added the non-success response with the status
- info
added the non-success response with the status
- info
added the non-success response with the status
- info
added the non-success response with the status
- info
added the required property
/to the response with the status - info
added the required property
/to the response with the status
- breaking