> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refuseless.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Top-ups API

> POST /v1/top-ups — add credits with crypto from code. Get an address and an exact amount, send it, and poll until it is credited.

# Crypto top-ups

Add credits to your account with crypto, without opening the console. You
create a top-up for an amount in US dollars. The response gives you an address
and the exact amount of coin to send. Once the network confirms the transfer,
the credits are added to the account that owns the API key.

```
GET  https://api.refuseless.com/v1/top-ups/methods
POST https://api.refuseless.com/v1/top-ups
GET  https://api.refuseless.com/v1/top-ups/{id}
Authorization: Bearer abl_...
```

The flow:

1. `GET /v1/top-ups/methods` lists the coins and networks you can pay with right now, and the minimum for each.
2. `POST /v1/top-ups` with `amount` and `method` returns `address`, `pay_amount` and `expires_at`.
3. Send exactly `pay_amount` of that coin, on that network, to `address`, before `expires_at`.
4. Poll `GET /v1/top-ups/{id}` until `status` is `paid`. A `paid` top-up has been credited: [`GET /v1/credits`](https://docs.refuseless.com/api/credits) already includes it.

> [!WARNING]
>
> Send only the coin and network of the method you chose. Coins sent on another
> network, or another token sent to the same address, are not detected
> automatically and may be lost. If you need a memo (`memo` is not `null`),
> include it, or the payment cannot be matched.

## List methods

```bash theme={null}
curl https://api.refuseless.com/v1/top-ups/methods \
  -H "Authorization: Bearer $REFUSELESS_API_KEY"
```

```json theme={null}
{
  "object": "list",
  "data": [
    { "object": "top_up_method", "id": "usdt-tron", "currency": "USDT", "network": "Tron", "min_amount": 5, "max_amount": 10000 },
    { "object": "top_up_method", "id": "usdc-base", "currency": "USDC", "network": "Base", "min_amount": 5, "max_amount": 10000 },
    { "object": "top_up_method", "id": "btc", "currency": "BTC", "network": "Bitcoin", "min_amount": 5, "max_amount": 10000 },
    { "object": "top_up_method", "id": "xmr", "currency": "XMR", "network": "Monero", "min_amount": 5, "max_amount": 10000 }
  ]
}
```

| Field | Type | Notes |
| - | - | - |
| `id` | string | What you pass as `method` |
| `currency` | string | The coin you send |
| `network` | string | The chain you send it on |
| `min_amount` | number | Smallest top-up in USD for this method. Never below 5 |
| `max_amount` | number | Largest top-up in USD |

Method ids are stable, but which ones are listed can change. Possible ids:
`usdt-tron`, `usdt-ethereum`, `usdt-bsc`, `usdt-polygon`, `usdt-solana`,
`usdc-ethereum`, `usdc-base`, `usdc-polygon`, `usdc-solana`, `usdc-bsc`, `btc`,
`eth`, `xmr`, `ltc`, `sol`, `trx`. Read the list before creating a top-up
rather than hard-coding one.

## Create a top-up

```bash theme={null}
curl https://api.refuseless.com/v1/top-ups \
  -H "Authorization: Bearer $REFUSELESS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7d0c3b1e-5f2a-4a8e-9b61-2f0e0a1c9d44" \
  -d '{"amount": 50, "method": "usdt-tron"}'
```

| Parameter | Type | Required | Notes |
| - | - | - | - |
| `amount` | number | yes | US dollars to add, 5 to 10000, at most 2 decimals. At least the method's `min_amount` |
| `method` | string | yes | A method `id` from `GET /v1/top-ups/methods` |

Send an optional `Idempotency-Key` header (up to 200 characters) to retry
safely. A retry with the same key returns the same top-up and the same address
instead of opening a new one. Reusing the key with a different `amount` or
`method` returns `409 idempotency_conflict`.

The response is `201` with a [top-up object](#the-top-up-object), or `200` for a
retry with an `Idempotency-Key` that was already used.

```json theme={null}
{
  "object": "top_up",
  "id": "tu_k3j9x0q2m8v1c7d5f4h6a2s9w0e3r8t1",
  "status": "pending",
  "amount": 50,
  "bonus": 0,
  "method": "usdt-tron",
  "currency": "USDT",
  "network": "Tron",
  "address": "TQ5m1Lw3zJ7h8c9eS2fN4kR6pV1xB3yD7a",
  "memo": null,
  "pay_amount": "50.12",
  "paid_amount": null,
  "remaining_amount": null,
  "created_at": 1795783200,
  "expires_at": 1795786800,
  "paid_at": null
}
```

## Check a top-up

```bash theme={null}
curl https://api.refuseless.com/v1/top-ups/tu_k3j9x0q2m8v1c7d5f4h6a2s9w0e3r8t1 \
  -H "Authorization: Bearer $REFUSELESS_API_KEY"
```

Returns the [top-up object](#the-top-up-object) with its current `status`. A
top-up can be read with any key of the account that created it. Polling every
10 to 30 seconds is plenty: the state is refreshed from the payment network at
most every 10 seconds.

## The top-up object

| Field | Type | Notes |
| - | - | - |
| `object` | string | Always `top_up` |
| `id` | string | `tu_` followed by 32 characters |
| `status` | string | See [Statuses](#statuses) |
| `amount` | number | US dollars credited when paid |
| `bonus` | number | Bonus credits added with this top-up, in US dollars. `0` until paid, and when none applies |
| `method` | string | The method id |
| `currency` | string | The coin to send |
| `network` | string | The chain to send it on |
| `address` | string | Where to send it |
| `memo` | string \| null | Memo or destination tag to include with the transfer, when the coin needs one |
| `pay_amount` | string | Amount of `currency` to send. A string, so no decimals are lost. Rounded up to what wallets accept: 2 decimals for USDT and USDC, at most 6 for other coins |
| `paid_amount` | string \| null | Coin received so far, once the network has seen any |
| `remaining_amount` | string \| null | Coin still owed when less than `pay_amount` arrived |
| `created_at` | integer | Unix time in seconds |
| `expires_at` | integer \| null | Unix time in seconds. Send before then. Usually one hour after creation; some coins allow longer |
| `paid_at` | integer \| null | Unix time in seconds when the credits were added |

### Statuses

| Status | Meaning |
| - | - |
| `pending` | Waiting for the transfer. If `remaining_amount` is set, part has arrived and you can send the rest before `expires_at` |
| `confirming` | The transfer was seen and is waiting for network confirmations. Credits follow automatically |
| `paid` | Credited. Final |
| `underpaid` | Less than `pay_amount` arrived and the payment closed. Nothing is credited automatically: [contact support](https://refuseless.com/console/support) with the top-up `id` |
| `expired` | Nothing arrived before `expires_at`. Final. Create a new top-up; do not reuse the address |
| `failed` | The payment failed or was cancelled. Final |
| `refunded` | The payment was returned to the sender. Final |

Exchanges often take a withdrawal fee from the amount you send. Make sure
`pay_amount` is what arrives, after fees, or the top-up can end `underpaid`.

## Notes

* Credits go to the account that owns the key. A workspace member's key tops up the workspace owner's account.
* First-deposit and deposit bonuses apply to API top-ups as they do in the console. `bonus` shows what was added.
* An account can have up to 20 unpaid top-ups opened in the last 24 hours.
* Plans and card payments are not available through this API. Use the [console](https://refuseless.com/console/billing) for those.

## Errors

| Status | Code | Meaning |
| - | - | - |
| 400 | `bad_request` | Body is not JSON, or `Idempotency-Key` is longer than 200 characters |
| 400 | `invalid_amount` | `amount` is missing, outside 5 to 10000, or has more than 2 decimals |
| 400 | `amount_below_minimum` | `amount` is below this method's `min_amount` |
| 400 | `invalid_method` | `method` is not a method listed right now |
| 401 | `missing_api_key` / `invalid_key_format` / `invalid_key` / `key_revoked` / `key_expired` | The key does not authenticate. See [Authentication](https://docs.refuseless.com/authentication.md) |
| 403 | `email_unverified` / `account_deleted` / `member_inactive` / `account_suspended` | The key is valid but its account cannot top up |
| 404 | `top_up_not_found` | No top-up with this id on this account |
| 409 | `idempotency_conflict` | The `Idempotency-Key` was already used with another `amount` or `method` |
| 429 | `too_many_open_top_ups` | 20 unpaid top-ups were opened in the last 24 hours |
| 429 | `rate_limit_exceeded` | More than 60 top-up requests per minute for this key. Separate from your inference rate limit |
| 502 | `payment_gateway_error` | The payment provider refused to open this payment. Try another method, or retry |
| 503 | `crypto_unavailable` / `gateway_down` | Crypto payments or billing are unreachable. Retry with backoff; with the same `Idempotency-Key` it is safe |

Errors use the [standard error shape](https://docs.refuseless.com/guides/errors.md).

## Example: top up and wait

```python theme={null}
import os, time, uuid, requests

API = "https://api.refuseless.com/v1"
H = {"Authorization": f"Bearer {os.environ['REFUSELESS_API_KEY']}"}

methods = requests.get(f"{API}/top-ups/methods", headers=H).json()["data"]
method = next(m for m in methods if m["id"] == "usdt-tron")

top_up = requests.post(
    f"{API}/top-ups",
    headers={**H, "Idempotency-Key": str(uuid.uuid4())},
    json={"amount": 50, "method": method["id"]},
).json()
print(f"Send {top_up['pay_amount']} {top_up['currency']} on {top_up['network']} to {top_up['address']}")

while top_up["status"] in ("pending", "confirming"):
    time.sleep(15)
    top_up = requests.get(f"{API}/top-ups/{top_up['id']}", headers=H).json()

print(top_up["status"])  # paid, expired, underpaid, ...
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.