NEW! |One API call, clean data back. No scrapers needed.Get 10,000 Free Tokens →

Idempotency & price guards

Retry purchases without double charges and make sure you never pay more than you agreed to, using idempotency keys, expected-price fields and the quote-then-order pattern.

Requests that spend money must be safe to retry and must never charge more than you expect. FineProxy gives you two tools for that: idempotency keys, which make a retry return the original result instead of buying again, and price guards, which reject a purchase when the actual price differs from the price you confirmed.

Why you need both

  • Networks fail. A request can time out after the server has already charged the wallet. Without an idempotency key, a retry would buy a second service.
  • Prices move. Quotes are non-binding ("binding": false): stock, volume tiers and discounts can change between the quote and the order. A price guard makes the order fail instead of charging a different amount.

When a guard rejects a request, nothing is charged.

Money operations at a glance

OperationIdempotencyPrice guard
MCP order_composite, order_dedicatedidempotency_key (required)expected_total_cents
MCP add_ipsidempotency_key (required)expected_charge_cents
MCP refresh_ipsidempotency_key (required)expected_amount_cents (0 = expected free)
MCP purchase_addonidempotency_key (required)expected_price_cents (required)
REST POST /api/v1/customer/services (catalog products such as rotating plans)params.client_idempotency_keyexpected_price_cents
REST POST /api/v1/billing/composite/orderidempotency_keyNone — see below
REST POST /api/v1/billing/services/{service_id}/add-ipsidempotency_key (required)expected_charge_cents
REST POST /api/v1/billing/services/{service_id}/addonsidempotency_key (required)expected_price_cents
REST POST /api/v1/customer/services/{service_id}/proxy/refreshidempotency_key (required)— (preview the price with POST .../proxy/refresh/quote)
REST POST /api/v1/customer/services/{service_id}/renewidempotency_key in the body or the Idempotency-Key header—
REST POST /api/v1/customer/wallet/deposit/init, MCP init_depositidempotency_key— (a deposit only creates a checkout link)

All guard values are integer cents. Exact parameters are in the API reference and the MCP tools reference.

Quote, then order

Every safe purchase follows the same three steps:

  1. Quote. Ask for the price of exactly what you want to buy.
  2. Confirm. Compare the quoted total with your budget (or show it to a human) and check the wallet balance.
  3. Order with the same parameters, a fresh idempotency key and the quoted total as the price guard.

For a composite datacenter order through MCP, the quote is quote_composite:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "quote_composite",
    "arguments": { "segments": [{ "country": "DE", "count": 100 }], "period_months": 1 }
  }
}

The result contains the price in cents — 100 IPs × 1 month = 1200 cents ($12.00):

{
  "binding": false,
  "segments": [{ "country_code": "DE", "count": 100, "unit_base_cents": 12, "segment_price_cents": 1200, "available": true }],
  "errors": [],
  "total_ip": 100,
  "total_price_cents": 1200,
  "monthly_price_cents": 1200,
  "period_months": 1
}

Then order with the same segments and pass total_price_cents as expected_total_cents:

{
  "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-7f3c2a9e-5b1d-4c8e-9a0f-2d6b8e4c1a37",
      "expected_total_cents": 1200,
      "auto_renew": false
    }
  }
}

whitelist_ips must contain at least one IPv4 address: the machine that will connect to the proxies. See the buy proxies guide for the full flow.

MCP price guards

order_composite and order_dedicated compare expected_total_cents with a fresh server-side quote before charging:

  • Match — the order is placed and the wallet is debited by exactly that amount.
  • Mismatch — the tool returns isError: true and nothing is charged:
Invalid arguments: Price mismatch: expected_total_cents=1199, actual quote is 1200 cents. Nothing was charged.

On a mismatch, quote again, confirm the new price and order with the new value. expected_total_cents is optional in the tool schema, but always send it — it is what protects you from a price change between quote and order.

The other money tools work the same way: add_ips checks expected_charge_cents, refresh_ips checks expected_amount_cents and purchase_addon checks expected_price_cents.

MCP idempotency keys

Every MCP money tool requires an idempotency_key that identifies one purchase intent:

  • Same key again — returns the original result without a second charge. For order_composite, a replay returns the same service_id with "balance_applied_cents": 0, and the wallet balance does not change.
  • New key — a new purchase, even if the parameters are identical to an earlier one.

So: one key per thing you want to buy, reused for every retry of that purchase.

REST rotating plans and catalog products

POST /api/v1/customer/services buys a fixed catalog product, such as a rotating proxy plan. Pass the product price from the catalog as expected_price_cents:

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-0001" }
  }'
  • For billing-only products, expected_price_cents is required: a mismatch or a missing value returns 409 before any wallet debit.
  • params accepts only whitelist_ips, billing_period_months and client_idempotency_key; any other key returns 422 before any debit.
  • Repeating the call with the same product and params returns the existing service without charging again.

A successful purchase returns 201 Created with the new service.

REST composite orders

POST /api/v1/billing/composite/order (datacenter and ISP mixes) has no price-guard field. The request schema is strict, so adding expected_total_cents does not protect you — it is rejected with 422 {"detail": "Validation error"} and nothing is charged.

The endpoint does support idempotency_key:

  • A new key buys a new service, even if an identical one exists.
  • The same key replays the service it created, without a second charge.
  • The same key with a different order returns 409 IDEMPOTENCY_KEY_REUSED.
  • Without a key, an identical live order (same owner and segments) returns the existing service instead of charging again.

To stay safe with REST composite orders:

  1. Call POST /api/v1/billing/composite/quote immediately before ordering, with exactly the same segments, period_months and options.
  2. Refuse to order if total_price_cents exceeds your budget or if errors is not empty.
  3. Send the order with a fresh idempotency_key and the same parameters. Set "use_balance": true to pay from the wallet; check payment_required and amount_due_cents in the response.
  4. Compare total_price_cents in the order response with the quote, and alert on any difference.

Important: If you need a hard guarantee that you never pay more than the quoted total, place composite orders through the MCP tool order_composite with expected_total_cents.

Generate idempotency keys

  • Use a random UUID per purchase intent, optionally with a readable prefix: order-7f3c2a9e-....
  • Generate the key once, when you decide to buy, and store it with your own order record before sending the request. A key that exists only in memory is lost on a crash, and the retry would become a new purchase.
  • Keep keys within 128 characters.
  • Never reuse a key for a different purchase.
import { randomUUID } from 'node:crypto';

const idempotencyKey = `order-${randomUUID()}`;
import uuid

idempotency_key = f"order-{uuid.uuid4()}"

Retries and timeouts

What happenedWhat to do
Timeout or network error, no responseRetry with the same key and the same body. You get either the original result or a fresh, single execution.
429 or 503Back off and retry with the same key. See Rate limits.
Price mismatch (MCP isError, REST 409)Nothing was charged. Quote again, confirm, and order with the new price.
402 insufficient fundsNothing was charged. Top up, then retry with the same key.
409 IDEMPOTENCY_KEY_REUSEDYou reused a key for a different order. Check your key generation; use a new key only if this really is a new purchase.
422 validation errorFix the request. Nothing was charged.

After an uncertain outcome, you can also check what happened before retrying: list your services (GET /api/v1/customer/services) and the wallet ledger (GET /api/v1/customer/wallet/ledger), where every debit appears with its service_id.

Next steps