# User Registration API Documentation

## Base URL

```text
https://simcloud.co.za/api/register.php
```

## What This API Does

Use this endpoint when your application signs people up for their own normal SIMcloud account. Authenticate with your parent account API token. SIMcloud creates a separate account for the new user, links it to your account as a child, and returns that child's API token.

The child account has its own wallet, orders, transaction history, portal login and API access. The parent link is only for downline visibility; it does not share funds or allow a child token to access the parent account.

## Authentication

Send the parent account token in the Authorization header:

```http
Authorization: Bearer YOUR_PARENT_API_TOKEN
```

See the [API conventions](https://simcloud.co.za/api/index.md#conventions) for IPv4, request timeouts, and retries.

The response includes the new child account API token. Store it securely in your application and use it as that user's Bearer token for subsequent SIMcloud API calls. Do not expose either parent or child tokens in browser code.

## Endpoints

### Register a User

Send a JSON `POST` request. The fields `first_name`, `last_name`, `cell`, `email` and `password` are required. The cell number must be a 10-digit South African mobile number beginning with `0`.

#### Example Request

```bash
curl -4 -sS -i -X POST 'https://simcloud.co.za/api/register.php' \
  -H "Authorization: Bearer $SIMCLOUD_PARENT_API_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{
  "first_name": "Jane",
  "last_name": "Doe",
  "cell": "0821234567",
  "email": "jane@example.com",
  "password": "user-chosen-password"
}'
```

`id_number` is optional, but must be a valid South African ID number if supplied. The optional business fields are `business_name`, `business_reg`, `vatno` and `address`.

#### Success Response

A newly created account returns HTTP `201`:

```json
{
  "status": "success",
  "message": "SIMcloud account registered successfully",
  "user_id": 2719,
  "username": "1234567",
  "api_token": "NEW_CHILD_API_TOKEN",
  "existing": false
}
```

If your application retries after an interrupted response using the same parent token and cell number, SIMcloud returns HTTP `200` with that parent-owned child account and `existing: true`. A cell number already registered outside your downline returns HTTP `409`.

## Using The Returned Token

Store `api_token` against the user in your app. Use it—not the parent token—when calling balance, airtime, data, SMS, VAS, electricity, transaction-history, or network-lookup endpoints for that person.

## Error Responses

| HTTP Status | Description |
|----|----|
| 400 | Invalid JSON or missing/invalid registration fields. |
| 401 | Missing or invalid parent API token. |
| 403 | The registration is blocked. Contact SIMcloud support. |
| 409 | The cell number already belongs to an account outside your downline. |
| 405 | Method not allowed. |
| 422 | The upstream registration service rejected the account details. |
| 500 | Registration could not be confirmed locally. Contact support if the response says it succeeded upstream. |
| 502 | Upstream registration request failed. |
| 503 | Registration service is temporarily unavailable. |
