# Endpoints

### Get Account Info

Returns your email and current balance.

```
GET /account?api_key={api_key}
```

**Response:**

```json
{
  "status": true,
  "data": {
    "email": "user@example.com",
    "balance": 50000
  }
}
```

***

### Get Operators

Returns available mobile operators for Indonesia.

```
GET /operators?api_key={api_key}
```

**Response:**

```json
{
  "status": true,
  "data": {
    "country": 6,
    "operators": ["AXIS", "TSEL", "ISAT", "XL", "TRI"]
  }
}
```

***

### Create Order

Creates a new OTP activation order. Deducts balance immediately.

```
POST /order/create?api_key={api_key}
Content-Type: application/json
```

**Body:**

| Field      | Type   | Required | Description                      |
| ---------- | ------ | -------- | -------------------------------- |
| `service`  | string | Yes      | Service slug (e.g. `wa`, `tg`)   |
| `operator` | string | No       | Operator name. Default: `Random` |

**Example:**

```json
{ "service": "wa", "operator": "TSEL" }
```

**Response:**

```json
{
  "status": true,
  "data": {
    "orderId": "uuid",
    "phoneNumber": "628123456789",
    "operator": "TSEL",
    "service": "wa",
    "price": 3000,
    "expiresAt": "2025-01-01T12:20:00.000Z"
  }
}
```

**Errors:**

| Error                           | Cause                              |
| ------------------------------- | ---------------------------------- |
| `Service not found or inactive` | Invalid service slug               |
| `Insufficient balance`          | Not enough balance                 |
| `Failed to get number`          | No numbers available from provider |

***

### Check Order Status

Returns the current status and OTP code (if received) for an order.

```
GET /order/status?api_key={api_key}&order_id={order_id}
```

**Response:**

```json
{
  "status": true,
  "data": {
    "orderId": "uuid",
    "phoneNumber": "628123456789",
    "otpCode": "123456",
    "status": "received",
    "operator": "TSEL",
    "service": "wa",
    "serviceName": "WhatsApp",
    "price": 3000,
    "expiresAt": "2025-01-01T12:20:00.000Z",
    "createdAt": "2025-01-01T12:00:00.000Z"
  }
}
```

**Order statuses:**

| Status      | Description                  |
| ----------- | ---------------------------- |
| `pending`   | Waiting for SMS              |
| `received`  | OTP code received            |
| `completed` | Order finished by user       |
| `expired`   | Timed out (auto-refunded)    |
| `cancelled` | Cancelled by user (refunded) |

***

### Set Order Status

Cancel a pending order (refunds balance) or finish a received order.

```
POST /order/status?api_key={api_key}
Content-Type: application/json
```

**Body:**

| Field      | Type   | Required | Description          |
| ---------- | ------ | -------- | -------------------- |
| `order_id` | string | Yes      | The order UUID       |
| `action`   | string | Yes      | `cancel` or `finish` |

**Cancel example:**

```json
{ "order_id": "uuid", "action": "cancel" }
```

```json
{
  "status": true,
  "data": {
    "orderId": "uuid",
    "action": "cancel",
    "message": "Order cancelled and balance refunded"
  }
}
```

**Finish example:**

```json
{ "order_id": "uuid", "action": "finish" }
```

```json
{
  "status": true,
  "data": {
    "orderId": "uuid",
    "action": "finish",
    "message": "Order completed"
  }
}
```

**Errors:**

| Error                                           | Cause                             |
| ----------------------------------------------- | --------------------------------- |
| `Only pending orders can be cancelled`          | Order is not in `pending` status  |
| `Only orders with received OTP can be finished` | Order is not in `received` status |

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://otpgan.gitbook.io/overview/endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
