Send a code
Generates a one-time code and sends it by SMS. A new code replaces any pending code for the same number. With a test key the code is returned in the response and nothing is sent.
Generates a one-time code and sends it by SMS. A new code replaces any pending code for the same number. With a test key the code is returned in the response and nothing is sent.
bearerAuthorizationBearer <JWT>Your secret API key: sk_live_… for live traffic or sk_test_… for testing.
application/json- body
to*stringRecipient phone number. Ghana numbers can be local (0241234567) or international (+233241234567).
length <= 32from*stringAn approved sender ID on your account, 3 to 11 letters or digits.
^[A-Za-z0-9]{3,11}$length?numberNumber of digits in the code, 4 to 8. Defaults to 6.
4 <= value <= 8expiresInMinutes?numberMinutes until the code expires, 1 to 30. Defaults to 5.
1 <= value <= 30message?stringCustom message text. Must contain {{code}}; {{minutes}} is replaced with the expiry time.
\{\{code\}\}length <= 500reference?stringYour own reference, returned in responses and webhooks. Up to 100 characters.
length <= 100The code was sent.
application/jsoncurl -X POST 'https://api.appstractone.com/v1/otp/send' \
-H 'Content-Type: application/json' \
-d '{
"to": "+233241234567",
"from": "MYSHOP"
}'{
"id": "otp_01M6MJSBXRZS9JGB57380Y48E5",
"to": "+233241234567",
"status": "pending",
"expiresAt": "2026-11-05T00:52:20.504Z",
"messageId": "msg_01M6MJSBXYJ0RDQ393W5N1HGE0",
"cost": {
"amount": "0.04",
"currency": "GHS"
},
"test": true,
"code": "102028"
}