# Buy proxies with the API

Check country stock and pricing, quote a datacenter or ISP package, place the order safely, wait for provisioning and buy rotating plans from the catalog — over REST or MCP.

- Canonical: https://fineproxy.org/developers/docs/guides/buy-proxies/

This guide walks you through a complete purchase: you pick countries, get a price, order the package, wait until the IPs are ready and fetch them. Datacenter and ISP proxies are sold as a **composite** package — a mix of `{country, count}` segments. Rotating plans are fixed catalog products and use a separate, shorter flow.

You need an API key with `catalog:read` to browse and quote, plus `services:write` and `wallet:spend` to buy. Purchases are paid from your wallet balance, so check it first with `GET /api/v1/customer/wallet/balance` (see [Wallet and payments](/developers/docs/guides/wallet/)).

All examples read the key from `FINEPROXY_API_KEY`:

```bash
export FINEPROXY_API_KEY="fb_your_api_key"
```

## 1. List countries and live stock

`GET /api/v1/billing/countries` returns the countries you can order, sorted by available IPs, most stock first. Use the ISO 3166-1 alpha-2 `code` as `country` in quotes and orders.

```bash
curl "https://fineproxy.org/account_new/api/v1/billing/countries?product_kind=proxy_datacenter&geo_source=maxmind" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

```javascript
const url = new URL('https://fineproxy.org/account_new/api/v1/billing/countries');
url.searchParams.set('product_kind', 'proxy_datacenter');
const response = await fetch(url, {
  headers: { Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}` },
});
const { countries } = await response.json();
console.log(countries.filter((c) => c.available > 0).map((c) => `${c.code}: ${c.available}`));
```

```python
import os
import requests

response = requests.get(
    "https://fineproxy.org/account_new/api/v1/billing/countries",
    params={"product_kind": "proxy_datacenter"},
    headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
    timeout=60,
)
response.raise_for_status()
for country in response.json()["countries"]:
    if country["available"] > 0:
        print(country["code"], country["available"])
```

The response (shortened):

```json
{
  "geo_source": "maxmind",
  "product_kind": "proxy_datacenter",
  "countries": [
    { "code": "US", "name": "United States", "tag_id": 197148, "available": 32452 },
    { "code": "GB", "name": "United Kingdom", "tag_id": 197147, "available": 1952 },
    { "code": "DE", "name": "Germany", "tag_id": 197153, "available": 1464 },
    { "code": "JP", "name": "Japan", "tag_id": 1452361, "available": 0 }
  ]
}
```

| Query parameter | Values | Default |
| --- | --- | --- |
| `product_kind` | `proxy_datacenter`, `proxy_isp` | `proxy_datacenter` |
| `geo_source` | `maxmind` (geolocation) or `ripe` (registry allocation) | `maxmind` |

- `available` is live stock. Countries with `0` are listed but cannot be ordered right now.
- Pass the same `product_kind` and `geo_source` to the quote and the order.
- This call can take around 10 seconds. Cache the result for a few minutes instead of calling it before every quote.

Reference: [Get countries](/developers/docs/api/catalog/#get-get-countries).

## 2. Read the pricing terms

`GET /api/v1/billing/composite/pricing-info` returns the volume ladder, period discounts and minimums. It is advisory — the quote is the source of truth for the actual price.

```bash
curl https://fineproxy.org/account_new/api/v1/billing/composite/pricing-info \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

Key fields from a real response:

```json
{
  "volume_tiers": [
    { "min_ips": 0, "price_millicents_per_ip": 12000, "label": null },
    { "min_ips": 1000, "price_millicents_per_ip": 11100, "label": null }
  ],
  "period_discounts": { "1": 0, "3": 10, "6": 15, "12": 20 },
  "min_ips_per_segment": 1,
  "min_ips_per_order": 100,
  "whitelist_free_quota": 5,
  "extra_whitelist_ip_price_cents": 100,
  "free_refresh_days": 8
}
```

| Field | Meaning |
| --- | --- |
| `min_ips_per_order` | Minimum total IPs per order, summed across all segments: **100**. |
| `volume_tiers[].price_millicents_per_ip` | Monthly price per IP in **millicents** (`12000` = 12 cents). Every other price in the API is in cents. |
| `period_discounts` | Discount in whole percent per period length in months. You can order 1, 3, 6 or 12 months. |
| `whitelist_free_quota` | IP allowlist entries included per service. See [IP allowlist](/developers/docs/guides/ip-allowlist/). |
| `free_refresh_days` | Free IP refresh window. See [Manage services](/developers/docs/guides/manage-services/#refresh-replace-ips). |

> **Note:** A single segment may be as small as 1 IP, but the order as a whole must reach 100 IPs. A smaller total is rejected with `422` and a plain `detail` string, for example `"Total order IP count (10) is below the tenant minimum of 100 IPs per order"`.

Reference: [Composite pricing info](/developers/docs/api/catalog/#get-composite-pricing-info).

## 3. Optional: let the API split the IPs for you

If you need "100 IPs, any mix", `POST /api/v1/billing/composite/auto-plan` distributes `total_ip` across countries in proportion to stock. No money is involved. Use `excluded_countries` (ISO codes) to skip countries.

```bash
curl -X POST https://fineproxy.org/account_new/api/v1/billing/composite/auto-plan \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"total_ip": 100, "excluded_countries": ["RU"]}'
```

The response contains `segments` (each with `country_code` and `count`) that add up to `total_ip`, plus `countries_used`. Feed the segments, as `{"country": "<country_code>", "count": <count>}`, straight into the quote. `total_ip` below 100 returns `422`.

Reference: [Composite auto plan](/developers/docs/api/orders/#post-composite-auto-plan).

## 4. Get a quote

`POST /api/v1/billing/composite/quote` prices a mix. It is free and non-binding (`binding: false`).

```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}'
```

```javascript
const response = await fetch('https://fineproxy.org/account_new/api/v1/billing/composite/quote', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ segments: [{ country: 'DE', count: 100 }], period_months: 1 }),
});
if (!response.ok) throw new Error(`Quote failed ${response.status}: ${await response.text()}`);
const quote = await response.json();
console.log(quote.total_price_cents, quote.errors);
```

```python
import os
import requests

response = requests.post(
    "https://fineproxy.org/account_new/api/v1/billing/composite/quote",
    headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
    json={"segments": [{"country": "DE", "count": 100}], "period_months": 1},
    timeout=30,
)
response.raise_for_status()
quote = response.json()
print(quote["total_price_cents"], quote["errors"])
```

Response for 100 German IPs for one month:

```json
{
  "snapshot_version": "00000000-0000-0000-0000-000000000000",
  "built_at": "2026-11-19T15:32:06.105136Z",
  "binding": false,
  "segments": [
    {
      "provider": 2,
      "country": 197153,
      "country_code": "DE",
      "count": 100,
      "unit_base_cents": 12,
      "type_multiplier": 1.0,
      "geo_multiplier": 1.0,
      "segment_price_cents": 1200,
      "available": true
    }
  ],
  "errors": [],
  "total_ip": 100,
  "total_price_cents": 1200,
  "unit_base_cents": 12,
  "period_months": 1,
  "discount_pct": 0,
  "volume_discount_pct": 0,
  "monthly_price_cents": 1200,
  "promo_discount_cents": 0,
  "trial": false,
  "addon_monthly_cents": 0,
  "extra_whitelist_count": 0,
  "extra_connections_count": 0,
  "udp_unlock": false
}
```

| Field | Meaning |
| --- | --- |
| `total_price_cents` | What the order will charge for the whole period: `1200` = $12.00. Equals `monthly_price_cents` × `period_months` minus the period discount. |
| `monthly_price_cents` | Undiscounted monthly total (sum of `segment_price_cents`). |
| `discount_pct` | Period discount applied (0, 10, 15 or 20). |
| `segments[].available` | `false` means that segment cannot be fulfilled right now. |
| `errors` | Unavailable or invalid segments. The quote still succeeds; check that this array is empty before ordering. |

A mix works the same way: 25 × US + 75 × GB also quoted `1200` cents for one month.

Optional body fields: `product_kind` (`proxy_datacenter`, `proxy_isp`), `geo_source`, `promo_code`, and pre-purchase add-ons `extra_whitelist_count`, `extra_connections_count`, `udp_unlock` — their price is included in `monthly_price_cents`. Unknown fields are rejected with `422 {"detail":"Validation error"}`.

Reference: [Composite quote](/developers/docs/api/orders/#post-composite-quote).

## 5. Place the order

`POST /api/v1/billing/composite/order` charges the wallet and creates one service holding all segments. Send the same segments, period, `product_kind` and `geo_source` that you quoted.

```bash
curl -X POST https://fineproxy.org/account_new/api/v1/billing/composite/order \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "segments": [{"country": "DE", "count": 100}],
    "period_months": 1,
    "whitelist_ips": ["203.0.113.10"],
    "use_balance": true,
    "auto_renew": false,
    "idempotency_key": "order-de100-2026-11-27-001"
  }'
```

```javascript
import { randomUUID } from 'node:crypto';

const idempotencyKey = randomUUID(); // store it with your order before sending
const response = await fetch('https://fineproxy.org/account_new/api/v1/billing/composite/order', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    segments: [{ country: 'DE', count: 100 }],
    period_months: 1,
    whitelist_ips: ['203.0.113.10'],
    use_balance: true,
    auto_renew: false,
    idempotency_key: idempotencyKey,
  }),
});
if (!response.ok) throw new Error(`Order failed ${response.status}: ${await response.text()}`);
const order = await response.json();
console.log(order.service_id, order.status, order.balance_applied_cents);
```

```python
import os
import uuid
import requests

idempotency_key = str(uuid.uuid4())  # store it with your order before sending
response = requests.post(
    "https://fineproxy.org/account_new/api/v1/billing/composite/order",
    headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
    json={
        "segments": [{"country": "DE", "count": 100}],
        "period_months": 1,
        "whitelist_ips": ["203.0.113.10"],
        "use_balance": True,
        "auto_renew": False,
        "idempotency_key": idempotency_key,
    },
    timeout=90,
)
response.raise_for_status()
order = response.json()
print(order["service_id"], order["status"], order["balance_applied_cents"])
```

A successful order returns `201`:

```json
{
  "service_id": "00000000-0000-0000-0000-000000000000",
  "status": "active",
  "segments": [
    { "country": 197153, "country_code": "DE", "count": 100, "segment_price_cents": 1200, "available": true }
  ],
  "total_ip": 100,
  "total_price_cents": 1200,
  "period_months": 1,
  "discount_pct": 0,
  "monthly_price_cents": 1200,
  "balance_applied_cents": 1200,
  "amount_due_cents": 0,
  "invoice_url": null,
  "payment_required": false,
  "intent_id": null,
  "promo_discount_cents": 0,
  "trial": false,
  "addon_monthly_cents": 0
}
```

| Request field | Required | Notes |
| --- | --- | --- |
| `segments` | Yes | `[{"country": "DE", "count": 100}]`. `country` is an ISO code (a `tag_id` also works). |
| `whitelist_ips` | Yes | At least one IPv4 address allowed to use the proxies without a password. An order without it is rejected with `422` before any charge. Use the public IP of the machine that will connect. |
| `use_balance` | — | Set `true` to pay from the wallet. The default is `false`, which leaves the amount to be paid through a payment gateway (`amount_due_cents`, `invoice_url`, `payment_required` in the response). |
| `auto_renew` | — | Defaults to **`true`**: the service renews from the wallet every period. Send `false` if you don't want that. |
| `idempotency_key` | Recommended | Up to 128 characters. The same key replays the original order without a second charge; the same key with a different body returns `409 IDEMPOTENCY_KEY_REUSED`. |
| `period_months` | — | 1, 3, 6 or 12. Default 1. |

In the response, `balance_applied_cents` is what was taken from the wallet. When you replay an order with the same `idempotency_key`, you get the same `service_id` and `balance_applied_cents: 0` — nothing was charged twice.

> **Important:** This REST endpoint has no price-guard field: the server re-prices the order at the moment you send it, and adding a field such as `expected_total_cents` is rejected with `422 {"detail":"Validation error"}`. Quote immediately before you order and compare `total_price_cents` with what you expect. If you need the server to refuse an order whose price changed, use the MCP tool `order_composite` with `expected_total_cents` — see [Buy through MCP](#buy-through-mcp) and [Idempotency](/developers/docs/idempotency/).

Reference: [Composite order](/developers/docs/api/orders/#post-composite-order).

## 6. Wait for provisioning and fetch the proxies

A 100-IP datacenter order had all IPs active about 2 seconds after the order returned. Poll the service until `status` is `active` and the IP list has the size you ordered, pausing at least one second between calls (see [Rate limits](/developers/docs/rate-limits/)).

```bash
SERVICE_ID="00000000-0000-0000-0000-000000000000"

curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"

curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/ips" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

```javascript
const BASE = 'https://fineproxy.org/account_new/api/v1/customer/services';
const headers = { Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}` };
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function waitForProxies(serviceId, expectedCount, timeoutMs = 120_000) {
  const deadline = Date.now() + timeoutMs;
  while (Date.now() < deadline) {
    const service = await (await fetch(`${BASE}/${serviceId}`, { headers })).json();
    if (service.status === 'active') {
      const { ips } = await (await fetch(`${BASE}/${serviceId}/proxy/ips`, { headers })).json();
      if (ips.length >= expectedCount) return ips;
    }
    await sleep(2000);
  }
  throw new Error(`Service ${serviceId} is not ready yet`);
}

console.log(await waitForProxies(order.service_id, 100));
```

```python
import os
import time
import requests

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


def wait_for_proxies(service_id, expected_count, timeout=120):
    deadline = time.time() + timeout
    while time.time() < deadline:
        service = requests.get(f"{BASE}/{service_id}", headers=HEADERS, timeout=30).json()
        if service["status"] == "active":
            ips = requests.get(f"{BASE}/{service_id}/proxy/ips", headers=HEADERS, timeout=30).json()["ips"]
            if len(ips) >= expected_count:
                return ips
        time.sleep(2)
    raise TimeoutError(f"Service {service_id} is not ready yet")
```

Each entry of `ips` has `ip`, `country`, `type` and `site`:

```json
{
  "service_id": "00000000-0000-0000-0000-000000000000",
  "ips": [
    { "ip": "203.0.113.10", "country": "DE", "type": "socks5", "site": "nyc-1" },
    { "ip": "203.0.113.11", "country": "DE", "type": "socks5", "site": "nyc-1" }
  ]
}
```

Then read the login, password and ports with `GET .../proxy/auth?reveal=true` and connect — see [Connect to datacenter proxies](/developers/docs/proxies/datacenter/).

References: [Get service](/developers/docs/api/services/#get-get-service), [Get proxy IPs](/developers/docs/api/proxy-access/#get-get-proxy-ips), [Get proxy auth](/developers/docs/api/proxy-access/#get-get-proxy-auth).

## Buy a rotating plan

Rotating proxies are fixed products priced per package of requests. List them with `GET /api/v1/customer/catalog` and filter by `kind`.

```bash
curl "https://fineproxy.org/account_new/api/v1/customer/catalog?limit=100" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

One product from the response:

```json
{
  "products": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "kind": "proxy_rotating",
      "billing_model": "metered_requests",
      "name": "Rotating Proxies 2.5M Credits",
      "params": {
        "sticky": true,
        "pool_class": "datacenter",
        "period_days": 30,
        "request_package_size": 2500000
      },
      "price_cents": 3500,
      "price_unit": "period",
      "is_active": true,
      "features": ["2.5 million requests", "IPv4 HTTP, HTTPS, SOCKS4/5"]
    }
  ],
  "total": 1,
  "offset": 0,
  "limit": 100
}
```

`price_cents` is the price per period (`3500` = $35.00 for 30 days); `request_package_size` is the number of requests included. The list is paginated with `offset` and `limit` (1–100).

Buy it with `POST /api/v1/customer/services`, passing the catalog price as `expected_price_cents`:

```bash
curl -X POST https://fineproxy.org/account_new/api/v1/customer/services \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "00000000-0000-0000-0000-000000000000",
    "expected_price_cents": 3500,
    "auto_renew": false,
    "params": {"client_idempotency_key": "rotating-2026-11-27-001"}
  }'
```

```javascript
const response = await fetch('https://fineproxy.org/account_new/api/v1/customer/services', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    product_id: product.id,
    expected_price_cents: product.price_cents,
    auto_renew: false,
    params: { client_idempotency_key: 'rotating-2026-11-27-001' },
  }),
});
if (!response.ok) throw new Error(`Purchase failed ${response.status}: ${await response.text()}`);
const { service } = await response.json();
console.log(service.id, service.status, service.expires_at);
```

```python
response = requests.post(
    "https://fineproxy.org/account_new/api/v1/customer/services",
    headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
    json={
        "product_id": product["id"],
        "expected_price_cents": product["price_cents"],
        "auto_renew": False,
        "params": {"client_idempotency_key": "rotating-2026-11-27-001"},
    },
    timeout=60,
)
response.raise_for_status()
service = response.json()["service"]
print(service["id"], service["status"], service["expires_at"])
```

The `201` response wraps the new service: `{"service": {...}, "invoice_url": null}`. The service has `product_kind: "proxy_rotating"`, `status: "active"`, `price_cents: 3500`, `expires_at` 30 days ahead and `params.requests_quota` / `params.requests_remaining` for the request quota.

- `params` accepts only `whitelist_ips`, `billing_period_months` (1/3/6/12/24/36) and `client_idempotency_key`; any other key is rejected with `422` before the wallet is touched.
- Repeating the call with the same product and `params` returns the existing service without charging again.
- Where price confirmation applies, a missing or wrong `expected_price_cents` is rejected with `409` before any debit.
- `auto_renew` defaults to `true` here too.

To connect, read the gateway hosts and ports from `GET .../proxy/config` — see [Connect to rotating proxies](/developers/docs/proxies/rotating/) and [Sticky sessions](/developers/docs/guides/sticky-sessions/).

Reference: [List products](/developers/docs/api/catalog/#get-list-products), [Create service](/developers/docs/api/orders/#post-create-service).

## Buy through MCP

An AI agent connected to the [MCP server](/developers/docs/mcp/) follows the same flow with tools. The server's built-in instructions tell agents to use exactly this order.

| Step | MCP tool | REST equivalent |
| --- | --- | --- |
| Countries and stock | [`list_countries`](/developers/docs/mcp/tools/#list_countries) | `GET /api/v1/billing/countries` |
| Pricing terms | [`get_pricing_info`](/developers/docs/mcp/tools/#get_pricing_info) | `GET /api/v1/billing/composite/pricing-info` |
| Auto-split | [`plan_composite`](/developers/docs/mcp/tools/#plan_composite) | `POST /api/v1/billing/composite/auto-plan` |
| Quote | [`quote_composite`](/developers/docs/mcp/tools/#quote_composite) | `POST /api/v1/billing/composite/quote` |
| Your egress IP for `whitelist_ips` | [`get_my_ip`](/developers/docs/mcp/tools/#get_my_ip) | — |
| Order | [`order_composite`](/developers/docs/mcp/tools/#order_composite) | `POST /api/v1/billing/composite/order` |
| Rotating plans | [`list_catalog`](/developers/docs/mcp/tools/#list_catalog) → [`buy_service`](/developers/docs/mcp/tools/#buy_service) | `GET /customer/catalog` → `POST /customer/services` |

`order_composite` requires `segments`, `whitelist_ips` and `idempotency_key`, and accepts `expected_total_cents` — pass the quote's `total_price_cents` there. Over raw JSON-RPC the call looks like this:

```bash
curl -X POST https://fineproxy.org/account_new/api/v1/mcp \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "order_composite",
      "arguments": {
        "segments": [{"country": "DE", "count": 100}],
        "period_months": 1,
        "whitelist_ips": ["203.0.113.10"],
        "idempotency_key": "order-de100-2026-11-27-001",
        "expected_total_cents": 1200,
        "auto_renew": false
      }
    }
  }'
```

If the total does not match the current price, the tool refuses and charges nothing. The JSON-RPC call still returns HTTP 200; the failure is in `result.isError`:

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Invalid arguments: Price mismatch: expected_total_cents=1199, actual quote is 1200 cents. Nothing was charged."
      }
    ],
    "isError": true
  }
}
```

Replaying `order_composite` with the same `idempotency_key` returns the same `service_id` without a second charge.

> **Warning:** Over MCP, `get_my_ip` returns the IP of the machine running the agent, which is not necessarily the machine that will use the proxies. Confirm the address before putting it into `whitelist_ips`.

## Common pitfalls

- **Below the minimum.** Orders, quotes and add-IP top-ups under 100 IPs in total return `422`.
- **Forgetting `use_balance: true`** on the REST composite order. Without it the response asks for a gateway payment (`payment_required`, `amount_due_cents`) instead of charging the wallet.
- **Unwanted renewals.** `auto_renew` defaults to `true` on both order endpoints. Turn it off later with the MCP tool `set_auto_renew` — see [Manage services](/developers/docs/guides/manage-services/#auto-renew).
- **Reusing an idempotency key** for a different order returns `409 IDEMPOTENCY_KEY_REUSED`. Generate a new key per purchase intent and reuse it only for retries of the same request.
- **Bursting.** More than about 2 requests per second gets `429`. Poll provisioning every 1–2 seconds, not in a tight loop.

## Next steps

- [Manage services](/developers/docs/guides/manage-services/) — renew, add IPs, refresh IPs, add-ons and cancellation.
- [IP allowlist](/developers/docs/guides/ip-allowlist/) — change the IPs allowed to connect without a password.
- [Connect to datacenter proxies](/developers/docs/proxies/datacenter/) — ports, protocols and authentication.
