# Add prepaid services to your app

Sell South African airtime, data, vouchers and electricity or send SMS with the SIMcloud API. Use this reference to choose a service, make your first request and see how to read the response.

[API quickstart](#quickstart) [Connect an AI agent](https://simcloud.co.za/api/ai.html#oauth-scope)

## Check your wallet balance

REST `GET /api/balance.php`

```bash
curl -4 -sSi https://simcloud.co.za/api/balance.php \
  -H "Authorization: Bearer $SIMCLOUD_API_TOKEN"
```

Reporting MCP `reports:read`

> Use SIMcloud Reporting to check my wallet balance in rand.

[Set up Reporting](https://simcloud.co.za/mcp-reporting.php) · [Search docs from an agent](https://simcloud.co.za/docs/agent-search/)

[Browse services](#available-services) [Conventions](#conventions) [OpenAPI and MCP](#machine-readable-spec)

## Available Services

### [User Registration API](https://simcloud.co.za/api/register.md)

Create a normal SIMcloud child account from your app and receive its API token.

### [SMS API](https://simcloud.co.za/api/sms.md)

Send SMS messages and query SMS delivery status.

### [Airtime API](https://simcloud.co.za/api/airtime.md)

Queue prepaid airtime purchases and poll the order status.

### [Data API](https://simcloud.co.za/api/data.md)

List available data bundle products, queue prepaid data purchases, and poll the order status.

### [VAS API](https://simcloud.co.za/api/vas.md)

List available voucher products, queue VAS purchases, and poll voucher results.

### [Electricity API](https://simcloud.co.za/api/electricity.md)

Check supported prepaid meters, submit electricity requests, and poll the order until the municipality returns the final result.

### [Transaction History API](https://simcloud.co.za/api/transactions.md)

Retrieve account transaction history across airtime, data, SMS, VAS, and electricity.

### [Balance API](https://simcloud.co.za/api/balance.md)

Fetch the authenticated account's last known SIMcloud wallet balance.

### [Network Lookup API](https://simcloud.co.za/api/network.md)

Look up the mobile network for a South African cell number using token-based authentication.

## Quickstart

1.  Sign in and choose **API \> Get Token** to [view or generate an API token](https://simcloud.co.za/api_token.php). Set `SIMCLOUD_API_TOKEN` in your shell.

2.  Check the wallet balance in rand with a read-only request.

    ``` bash
    curl -4 -sSi https://simcloud.co.za/api/balance.php \
      -H "Authorization: Bearer $SIMCLOUD_API_TOKEN"
    ```

3.  To test order placement, replace the example number, network, amount and reference with your own values. Select the network and recipient carefully. This POST queues a real airtime purchase when you use a funded account.

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

4.  HTTP `201` means SIMcloud accepted the request into the queue. Replace `1527245` with the `request_id` from your response. Poll that request until it reports `delivered` or `failed`.

    ``` bash
    curl -4 -sS -i 'https://simcloud.co.za/api/airtime.php?request_id=1527245' \
      -H "Authorization: Bearer $SIMCLOUD_API_TOKEN"
    ```

## Conventions

- **Authentication.** Send `Authorization: Bearer YOUR_API_TOKEN` on every REST request. Send JSON with `Content-Type: application/json` on POST requests. A `401` means the token is missing or invalid.
- **Transport.** Use HTTPS over IPv4. The cURL examples use `-4` to select IPv4.
- **Mobile numbers.** Use South African numbers as strings, such as `+27821234567`. For registration, use a 10-digit local number starting with `0`. In a query string, encode the leading `+` as `%2B`.
- **Money.** Send amounts in rand (ZAR). Airtime accepts R2–R999. Use a current catalogue amount for data or VAS and whole rand from R11–R1,000 for electricity.
- **Rate limits and timeouts.** SIMcloud publishes no fixed REST request quota or API-wide response-time guarantee. As a client starting point, allow 10 seconds to connect and 60 seconds for the complete request. On `429` or `503`, honour `Retry-After` when present and apply the retry rules below.
- **Polling.** Save the ID or reference returned by POST. Wait at least 15 seconds before the first GET status check, then poll every 15–30 seconds and back off if the order stays pending. These are suggested client intervals. SMS status reads in the first 15 seconds always report `queued`.
- **Retries.** Retry temporary GET failures with backoff. Fix a validation or authentication error before retrying. If an order or SMS POST times out or returns an uncertain result, check the existing order or account history before any resubmission. For electricity, query the original `client_reference`. The service pages describe the identifier and final states for each endpoint.
- **Errors.** Read the HTTP status and the JSON `status` and `message` fields. Use a machine-readable `code` where the endpoint documents one.

## Machine-Readable Spec

Use the OpenAPI contract in [YAML](https://simcloud.co.za/api/openapi.yaml) or [JSON](https://simcloud.co.za/api/openapi.json). The [API documentation index](https://simcloud.co.za/api/llms.txt) links to the Markdown reference pages.

### [OpenAPI Spec](https://simcloud.co.za/api/openapi.md)

Machine-readable API contract for LLMs, tooling, and generated clients.

### [AI & Codex Integration](https://simcloud.co.za/api/ai.md)

Connect an MCP-compatible client to Reporting with `reports:read` or Transactions with `api`.
