# Customers (subusers) and GB

> Create, list, edit and delete customers, get credentials, add and remove GB and track each customer's usage.
> Page: https://rh7proxys.com/en/docs/revenda-clientes · Index: https://rh7proxys.com/llms.txt

Each customer (subuser) has their own proxy, with a username and password. You create the customer, move GB from your balance and hand them the credentials.

In the routes below, `{id}` is the customer id (a UUID).

## Create a customer

```bash
curl -X POST https://api.rh7proxys.com/subusers \
  -H "x-api-key: rh7_your_key" \
  -H "Content-Type: application/json" \
  -d '{"name": "Cliente Loja 1", "email": "cliente@exemplo.com", "note": "Plano 10 GB"}'
```

| Field | Required | What it is |
|---|---|---|
| `name` | Yes | Customer name (up to 120 characters) |
| `email` | No | Customer email |
| `note` | No | Your own note (up to 500 characters) |

Response (201):

```json
{
  "subuser": { "id": "uuid", "name": "Cliente Loja 1", "proxy_username": "cliente_ab12", "gb_allocated": 0, "gb_used": 0, "status": "active" },
  "credentials": { "host": "auto-rh7proxys.com", "port": 823, "username": "cliente_ab12", "password": "password", "formatted": "auto-rh7proxys.com:823:cliente_ab12:password" },
  "client_api_key": "rh7c_...",
  "notice": "Salve a senha e a client_api_key agora..."
}
```

The password and the `client_api_key` show up only in this response. The customer key lets them use the [end customer API](https://rh7proxys.com/en/docs/revenda-cliente-final). The proxy starts with its exit in Brazil, on HTTP and SOCKS5, and with no GB: move GB to it so it works.

Errors: `invalid_name`, `invalid_email`, `rate_limited` (429), `too_many_empty_subusers` (409, when there are too many customers with no GB).

## Move GB to the customer

```bash
curl -X POST https://api.rh7proxys.com/subusers/CLIENT_ID/allocate-gb \
  -H "x-api-key: rh7_your_key" \
  -H "Idempotency-Key: order-7781-gb" \
  -H "Content-Type: application/json" \
  -d '{"gb": 10}'
```

- `gb` is a whole number greater than zero.
- The GB leaves your balance and goes into the customer's proxy right away.
- Use the `Idempotency-Key` header with a code of your own (for example, the order number in your store). Repeating with the same code does not move GB twice.
- GB moved to a customer does not come back to your balance. Move it a little at a time if you are not sure.

Errors:

| Code | Meaning |
|---|---|
| `insufficient_pool` (402) | Your balance does not cover it. `required_gb` says how much is missing. Buy more in [Balance and buying GB](https://rh7proxys.com/en/docs/revenda-saldo). |
| `commercial_gb_must_be_integer` | Send a whole number of GB. |
| `subuser_not_provisioned` (409) | The customer's proxy is not ready yet. Try again in a few seconds. |
| `upstream_delivery_failed_refunded` (502) | Delivery failed and the GB went back to your balance. You can try again. |

## List customers

`GET /subusers` returns all active customers:

```json
{ "subusers": [{ "id": "uuid", "name": "Cliente Loja 1", "email": null, "proxy_username": "cliente_ab12", "gb_allocated": 10, "gb_used": 2.31, "status": "active", "created_at": "2026-11-20T12:00:00Z" }] }
```

## Customer details

`GET /subusers/{id}` also returns the settings: `threads`, `country`, `state`, `city`, `blocklist_hosts` and `allowed_self_fields`.

## Change the customer

`PATCH /subusers/{id}` changes only what you send:

| Field | What it does |
|---|---|
| `name` / `note` | Name and note |
| `country` | Country with 2 letters, or `null` for any country |
| `state` / `city` | State and city |
| `threads` | Maximum concurrent connections (0 to 2000) |
| `blocklist_hosts` | Up to 100 blocked websites. Accepts `*.dominio.com`. |
| `status` | `active` or `suspended` (suspended stops connecting) |
| `allowed_self_fields` | What the customer can change on their own: `{"threads": true, "geo": true, "blocklist": false}` |

```bash
curl -X PATCH https://api.rh7proxys.com/subusers/CLIENT_ID \
  -H "x-api-key: rh7_your_key" \
  -H "Content-Type: application/json" \
  -d '{"country": "BR", "state": "sao paulo", "threads": 50}'
```

The response includes the customer and the `applied` list with what changed.

## Credentials

`GET /subusers/{id}/credentials` returns `host`, `port`, `username`, `password` and `formatted`. Use it to show the proxy in your customer's area.

## Delete a customer

`DELETE /subusers/{id}` deletes the proxy and archives the customer. Any GB left on it is lost. It responds with `{"ok": true, "id": "..."}`.

## Usage for a customer

Look it up by the proxy username:

```bash
curl https://api.rh7proxys.com/usage/user/cliente_ab12 \
  -H "x-api-key: rh7_your_key"
```

```json
{
  "subuser": { "id": "uuid", "name": "Cliente Loja 1", "username": "cliente_ab12", "status": "active", "gb_allocated": 10, "gb_used": 2.31, "gb_remaining": 7.69 },
  "upstream": { "traffic_limit_gb": 10, "traffic_used_gb": 2.31, "traffic_remaining_gb": 7.69 }
}
```

It also works as `GET /usage/user/query?username=cliente_ab12`.

To know right away when a customer is running low on GB, use the `client.gb.low` and `client.gb.exhausted` [webhooks](https://rh7proxys.com/en/docs/revenda-webhooks).
