# Airtime API

Use the Airtime API to send prepaid airtime from your own app or service. A successful placement queues the recharge and returns a request ID. Keep that ID so your app can check the original order before reporting delivery or trying again.

[Web guide](https://simcloud.co.za/docs/guide/airtime-api/)

POST /api/airtime.php · GET /api/airtime.php

[API reference](https://simcloud.co.za/api/airtime.html)

## Place an airtime order

Send msisdn, network, amount in rand from R2 to R999, and your reference. Network aliases include vodacom or p-vodacom, mtn or p-mtn, cellc and telkom. HTTP 201 means the recharge was queued. Save request_id and your reference.

1. HTTP 400 can mean invalid input or insufficient funds. Check required_balance and available_balance when present.
2. A repeat for the same recipient and amount within five minutes can return 409. Check the original outcome before attempting another purchase.

### POST /api/airtime.php

```bash
curl -4 -sS -i -X POST "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/api/airtime.php" \
  -H "Authorization: Bearer $SIMCLOUD_API_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{
  "msisdn": "YOUR_LOCAL_CELL",
  "network": "vodacom",
  "amount": 10,
  "reference": "DOCS-AIRTIME-01"
}'
```

HTTP 201 response excerpt

```json
{
  "status": "success",
  "service": "airtime",
  "queue_status": "queued"
}
```

## Query an airtime order

Set SIMCLOUD_AIRTIME_ID to the original request_id. You can alternatively query the original allocated orderno. A queued order awaits placement. Pending means the result is still outstanding. Delivered and failed are final.

### GET /api/airtime.php

```bash
curl -4 -sS -i "${SIMCLOUD_API_BASE:-https://simcloud.co.za}/api/airtime.php" \
  -H "Authorization: Bearer $SIMCLOUD_API_TOKEN" \
  --get \
  --data-urlencode "request_id=$SIMCLOUD_AIRTIME_ID"
```

HTTP 200 response excerpt

```json
{
  "status": "queued"
}
```
