Skip to content
Codelia SMSDocs
Guides: Quickstart

Quickstart

Send your first message in five steps. Each step shows curl and a TypeScript fetch call; choose a tab once and every example on the page follows. To call the API through a typed client instead, see the TypeScript SDK.

1. Create an API key

  1. Sign in to the portal and open API keys.
  2. Choose Create API key, give it a name, and keep Send only selected. It can send messages and campaigns, check their status, and change or cancel campaigns.
  3. Copy the key. The portal shows it only once.

Keep the key in an environment variable. The examples read it from there:

export CODELIA_API_KEY="your API key"

2. Check the key

curl "https://api.sms.codelia.studio/v1/api-key" \
  -H "Authorization: Bearer $CODELIA_API_KEY"

The answer names the organization the key belongs to, with its account ID. Save that too:

export CODELIA_ACCOUNT_ID="your account ID"

3. Price the message

Pricing a message never sends it and never charges. Put your own mobile number in to, with its country code.

curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages/quote" \
  -H "Authorization: Bearer $CODELIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": [
    "+442079460123"
  ],
  "from": "InfoSMS",
  "body": "Your order 1042 is ready to collect."
}'

totalMicros is the estimated cost in millionths of your organization's currency: 32000 is 0.032. from is the sender name. InfoSMS is a shared one every organization can use. Leave from out to send as your default sender name.

4. Send it

curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages" \
  -H "Authorization: Bearer $CODELIA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-ready" \
  -d '{
  "to": [
    "+442079460123"
  ],
  "from": "InfoSMS",
  "body": "Your order 1042 is ready to collect."
}'

The Idempotency-Key header makes a retry safe. If the request times out, send it again with the same key and body. Once the first request has finished, you get its answer back and the message isn't sent twice; a 409 with idempotency_conflict means it hasn't finished, so wait and retry with the same key. Use a value from your own system, like the order the message is about. Retrying safely has the details.

The answer lists one message per number in to. Save the id:

export MESSAGE_ID="the id from the answer"

5. Check its status

curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages/$MESSAGE_ID" \
  -H "Authorization: Bearer $CODELIA_API_KEY"

status starts as sending. It becomes delivered once the phone confirms the message arrived, or undelivered, failed or rejected if it didn't, with errorCode saying why.

outcome gives the same answer in plain words: pending, sent, delivered, not_delivered, not_sent or opted_out. It's what the portal shows, and you can filter your message list by it with ?outcome=.

Next, read Authentication to choose what each key can do, and Retrying safely before you send from production.