# API conventions

Base URL, versioning, JSON format, identifiers, money in integer cents, timestamps, country codes, pagination, CORS and request IDs in the FineProxy REST API.

- Canonical: https://fineproxy.org/developers/docs/conventions/

These rules apply to every endpoint of the FineProxy REST API. Read this page once and you will know how to build URLs, read amounts and dates, and page through lists.

## Base URL and versioning

| Item | Value |
| --- | --- |
| Base URL | `https://fineproxy.org/account_new` |
| Version prefix | `/api/v1/` — every path starts with it |
| MCP endpoint | `https://fineproxy.org/account_new/api/v1/mcp` |
| OpenAPI specification | [`/developers/openapi.json`](/developers/openapi.json) |

A full URL is the base URL plus the path from the [API reference](/developers/docs/api/services/):

```text
https://fineproxy.org/account_new/api/v1/customer/wallet/balance
```

The version is part of the path. Build URLs from a single base constant so that you only change one place if a new version appears.

All traffic is HTTPS. Requests are authenticated with a bearer API key — see [Authentication](/developers/docs/authentication/). A few read-only billing endpoints that describe public offers — `GET /api/v1/billing/countries`, `GET /api/v1/billing/catalog/facets`, `GET /api/v1/billing/composite/pricing-info` and `POST /api/v1/billing/composite/auto-plan` — also answer without a key; sending one does no harm.

## Request and response format

- Request and response bodies are JSON (`Content-Type: application/json`). Send `Content-Type: application/json` with every request that has a body.
- Field names are `snake_case`.
- Many request schemas are strict: an unknown field is rejected with `422` before anything else happens. Send only the fields documented in the API reference.
- Fields without a value are usually returned as `null`. Treat both `null` and a missing optional field as "not set".

```bash
curl -X POST https://fineproxy.org/account_new/api/v1/billing/composite/quote \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"segments":[{"country":"DE","count":100}],"period_months":1}'
```

## Identifiers

Services, products, tickets, webhook endpoints, ledger entries and other objects are identified by UUIDs:

```text
00000000-0000-0000-0000-000000000000
```

Store IDs as strings. A path parameter that is not a valid UUID returns `422` with `{"detail": "Validation error"}`; a well-formed UUID that is not found in your account returns `404`.

## Money

All amounts are **integer cents** in the account currency. Field names end in `_cents`:

| Field | Value | Meaning |
| --- | --- | --- |
| `balance_cents` | `2800` | $28.00 |
| `total_price_cents` | `1200` | $12.00 — 100 datacenter IPs for 1 month |
| `unit_base_cents` | `12` | $0.12 per IP |
| `amount_cents` (ledger) | `-1200` | A debit of $12.00; refunds and top-ups are positive |

The currency is returned next to the balance (`"currency": "USD"`). Never use floating-point numbers for money: keep cents as integers and format them only for display.

```javascript
const formatUsd = (cents) => `$${(cents / 100).toFixed(2)}`;
formatUsd(1200); // "$12.00"
```

> **Note:** `GET /api/v1/billing/composite/pricing-info` is the one exception: its volume tiers use `price_millicents_per_ip` (thousandths of a cent). `12000` millicents = 12 cents per IP.

## Timestamps

Timestamps are ISO 8601 strings in UTC, with a `Z` suffix and optional fractional seconds:

```json
{
  "created_at": "2026-11-27T10:04:24.239082Z",
  "expires_at": "2026-12-27T10:04:24.403579Z"
}
```

Send timestamps in the same format. For example, `GET .../usage` takes a window as `start` and `end` query parameters:

```bash
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/usage?start=2026-11-01T00:00:00Z&end=2026-11-27T23:59:59Z" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

## Country codes

Countries use ISO 3166-1 alpha-2 codes in upper case: `DE`, `US`, `GB`, `CN`. Request fields such as `segments[].country` take the code; responses return it as `country` or `country_code`. Use `GET /api/v1/billing/countries` to get the countries that are currently available.

## Pagination

List endpoints use **offset pagination**. Pass `offset` (how many items to skip, default `0`) and `limit` (page size). The response contains the items plus `total`, `offset` and `limit`:

```json
{
  "entries": [],
  "total": 9,
  "offset": 5,
  "limit": 5
}
```

| Endpoint | Items field | `limit` default / max |
| --- | --- | --- |
| `GET /api/v1/customer/services` | `services` | 50 / 100 |
| `GET /api/v1/customer/catalog` | `products` | 50 / 100 |
| `GET /api/v1/customer/wallet/ledger` | `entries` | 50 / 200 |
| `GET /api/v1/customer/me/whmcs-invoices` | `items` | 50 / 200 |
| `GET /api/v1/customer/tickets` | `tickets` | 50 |

Request the next page with `offset = offset + limit` until `offset >= total`:

```javascript
const BASE = 'https://fineproxy.org/account_new/api/v1';
const headers = { Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}` };

const entries = [];
for (let offset = 0; ; offset += 200) {
  const res = await fetch(`${BASE}/customer/wallet/ledger?limit=200&offset=${offset}`, { headers });
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
  const page = await res.json();
  entries.push(...page.entries);
  if (offset + page.limit >= page.total) break;
}
console.log(`${entries.length} ledger entries`);
```

```python
import os
import requests

BASE = "https://fineproxy.org/account_new/api/v1"
headers = {"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"}

entries, offset = [], 0
while True:
    page = requests.get(
        f"{BASE}/customer/wallet/ledger",
        params={"limit": 200, "offset": offset},
        headers=headers,
        timeout=30,
    )
    page.raise_for_status()
    data = page.json()
    entries.extend(data["entries"])
    offset += data["limit"]
    if offset >= data["total"]:
        break
print(f"{len(entries)} ledger entries")
```

Webhook deliveries are the exception: `GET /api/v1/customer/webhooks/{endpoint_id}/deliveries` takes only `limit` (default and maximum `50`) and returns a plain array. There is no cursor pagination in the API.

## CORS and browser use

The API is meant to be called from servers, scripts and agents — not from web pages. CORS preflight responses allow only the FineProxy dashboard origin (`https://fineproxy.org`), so browser requests from your own site are blocked.

Keep API keys on the server side. If your web app needs FineProxy data, call the API from your backend and expose only what the user needs.

## Request IDs

Every response carries an `x-request-id` header with a unique hexadecimal ID:

```text
x-request-id: 0123456789abcdef0123456789abcdef
```

Log it together with the status code for every failed request. When you contact support about a specific call, include the request ID — it identifies the request without sharing your API key.

Responses also carry `x-ratelimit-*` headers; see [Rate limits](/developers/docs/rate-limits/).

## Next steps

- [Errors](/developers/docs/errors/) — error bodies and status codes.
- [Rate limits](/developers/docs/rate-limits/) — headers and backoff.
- [Idempotency & price guards](/developers/docs/idempotency/) — retry purchases safely.
