OTP

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.

POST
/v1/otp/send

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.

Authorization

bearer
headerAuthorizationBearer <JWT>

Your secret API key: sk_live_… for live traffic or sk_test_… for testing.

Request Body

application/json
  1. body
to*string

Recipient phone number. Ghana numbers can be local (0241234567) or international (+233241234567).

Lengthlength <= 32
from*string

An approved sender ID on your account, 3 to 11 letters or digits.

Match^[A-Za-z0-9]{3,11}$
length?number

Number of digits in the code, 4 to 8. Defaults to 6.

Range4 <= value <= 8
expiresInMinutes?number

Minutes until the code expires, 1 to 30. Defaults to 5.

Range1 <= value <= 30
message?string

Custom message text. Must contain {{code}}; {{minutes}} is replaced with the expiry time.

Match\{\{code\}\}
Lengthlength <= 500
reference?string

Your own reference, returned in responses and webhooks. Up to 100 characters.

Lengthlength <= 100

Response Body

The code was sent.

application/json
Example Request
curl -X POST 'https://api.appstractone.com/v1/otp/send' \
  -H 'Content-Type: application/json' \
  -d '{
  "to": "+233241234567",
  "from": "MYSHOP"
}'
Example Response
{
  "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"
}