# First message in 5 minutes

https://docs.sendsms.to/en/guides/quickstart/

From the key to the delivery status: five steps after which your system sends SMS through api.sendsms.to.

## 1. Prepare the cabinet

Sign in to the cabinet at [app.sendsms.to](https://app.sendsms.to/). Sending opens when the cabinet shows that the account is ready to send. Until the account is admitted you can send one trial SMS to your own confirmed number, from the platform sender.

## 2. Issue an API key

1. In the cabinet open “API and integrations” and create a key for your integration.
2. Tick the permissions: `messages.send` to send and `messages.read` for statuses; `balance.read` if you need the balance.
3. Enter the external IP address of the server that will call the API: a key without addresses does not work (see [IP address allowlist](https://docs.sendsms.to/en/guides/ip-allowlist/)).
4. Keep the key in your server secrets: it is shown once.

```bash
export SENDSMS_API_KEY='your-key'
```

## 3. Check access

Ask for the balance: 200 means the key, its permissions and the address are fine. 401 — wrong key; 403 `ip_not_allowed` — the server address is not on the key’s list (the answer carries `clientIp`, the address we see).

```bash
curl --max-time 30 --request GET \
  --url 'https://api.sendsms.to/v1/balance' \
  --header "X-API-Key: $SENDSMS_API_KEY"
```

Response 200:

```json
{
  "money": {
    "balance": "125.12345",
    "currency": "USD"
  },
  "smsCredits": {
    "total": "1500.00"
  }
}
```

## 4. Send an SMS

Put an approved sender name of your account in `from` (the list: [GET /v1/senders](https://docs.sendsms.to/en/api/list-senders/)). Pass an `Idempotency-Key`: a repeat with the same key does not create a second message. First send a **trial request** with the `X-Dry-Run: true` header — it passes every check but sends nothing ([Trial requests](https://docs.sendsms.to/en/guides/dry-run/)); then the same request without the header.

**202** means “accepted for processing”, not “delivered”. Keep the `messageId`.

```bash
curl --max-time 30 --request POST \
  --url 'https://api.sendsms.to/v1/messages' \
  --header "X-API-Key: $SENDSMS_API_KEY" \
  --header "Idempotency-Key: $(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)" \
  --header 'X-Dry-Run: true' \
  --header 'Content-Type: application/json' \
  --data '{
  "channel": "sms",
  "to": "994XXXXXXXXX",
  "from": "APPROVED_SENDER",
  "text": "Your order is ready",
  "trafficClass": "transactional"
}'
```

Response 202:

```json
{
  "messageId": "00000000-0000-0000-0000-000000000000",
  "status": "queued",
  "dryRun": true
}
```

```bash
curl --max-time 30 --request POST \
  --url 'https://api.sendsms.to/v1/messages' \
  --header "X-API-Key: $SENDSMS_API_KEY" \
  --header "Idempotency-Key: $(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)" \
  --header 'Content-Type: application/json' \
  --data '{
  "channel": "sms",
  "to": "994XXXXXXXXX",
  "from": "APPROVED_SENDER",
  "text": "Your order is ready",
  "trafficClass": "transactional"
}'
```

Response 202:

```json
{
  "messageId": "00000000-0000-4000-8000-000000000001",
  "status": "queued"
}
```

## 5. Get the status

Ask no more often than `poll_after_seconds` in the answer suggests. Details: [Delivery reports](https://docs.sendsms.to/en/guides/delivery-reports/).

> Done. Next: [templates with variables](https://docs.sendsms.to/en/api/create-template/), [batch sending](https://docs.sendsms.to/en/api/batch-send/), [event scenarios](https://docs.sendsms.to/en/guides/scenario-events/), [error codes](https://docs.sendsms.to/en/guides/errors/).

```bash
curl --max-time 30 --request GET \
  --url 'https://api.sendsms.to/v1/messages/MESSAGE_ID' \
  --header "X-API-Key: $SENDSMS_API_KEY"
```

Response 200:

```json
{
  "id": "00000000-0000-0000-0000-000000000002",
  "status": "sent",
  "status_info": {
    "outcome": "pending",
    "poll_after_seconds": 5
  }
}
```

Response 200:

```json
{
  "id": "00000000-0000-0000-0000-000000000002",
  "status": "delivered",
  "status_info": {
    "outcome": "delivered",
    "poll_after_seconds": null
  }
}
```
