API reference

Forypay REST API

Plain JSON over HTTPS with bearer authentication. Two endpoints cover the whole payment lifecycle; a third verifies a single transaction you already have a hash for.

Build with AI

Using an AI coding assistant such as Claude, ChatGPT, Cursor or Copilot? Copy this prompt into it inside your project. It describes the whole API, the webhook signature and the safety rules, and asks the assistant to build the checkout, the webhook handler, the database fields and the tests for you.

  1. Create an API key under Projects, and set your webhook URL and signing secret under Settings.
  2. Copy the prompt and fill in the "About my project" lines, or let the assistant ask you.
  3. Paste it into your assistant with your codebase open, then review its plan before it writes code.
AI integration prompt
You are a senior engineer integrating Forypay USDT payments into my application. Forypay watches the blockchain for a USDT transfer to my wallet address and tells my server when it arrives. Work in my existing codebase and follow its conventions.

## About my project (fill in or ask me)
- Language / framework: <e.g. Next.js, Laravel, Django, Express>
- Where orders live: <e.g. Postgres "orders" table>
- Networks I accept: <bsc, tron, or both>
- My receiving wallet address(es): <0x… for BSC, T… for TRON>

If anything above is missing, inspect the codebase first, then ask me before writing code.

## Forypay API — authoritative facts (do not invent anything beyond these)

Base URL: https://forypay.com
Auth: every request sends `Authorization: Bearer <API key>`. Keys start with `fp_test_` or `fp_live_` and are created in the Forypay dashboard → Projects. An fp_test_ key creates TEST payments: never watched on chain, never billed, and no real transfer can settle them — move them with POST /api/v1/payments/{id}/simulate instead. An fp_live_ key creates live payments, monitored on the real BSC/TRON mainnets. The key is a server-side secret: never ship it to a browser or mobile app.
All requests and responses are JSON. Amounts are always decimal STRINGS such as "25.00" — never floats or numbers.
Stablecoins accepted per network — bsc: USDT · tron: USDT · polygon: USDT, USDC · base: USDC. Pass `token` to choose one; omit it for the network's default (the first listed).

### POST /api/v1/payments — create a payment
Body:
- network (required): "bsc" | "tron" | "polygon" | "base"
- token (optional): "USDT" | "USDC" — must be one the network accepts (see above); default is the network's first
- receiver (required): my wallet address on that network (BSC, Polygon, Base: checksummed 0x address; TRON: base58 address starting with T)
- amount (required): decimal string, e.g. "25.00"
- order_id (optional): my order reference, max 191 chars
- expires_in (optional): integer seconds, minimum 60
- expected_sender (optional): payer's address, same network format
Header `Idempotency-Key: <unique per order>` makes retries safe: repeating it returns the existing payment instead of creating a second one.
Response 200:
{ "id", "order_id", "network", "token": "USDT", "amount", "receiver", "status": "PENDING", "expires_at", "usage": {...} }
IMPORTANT: the returned `amount` can be slightly HIGHER than requested (e.g. "25.0001"). Forypay nudges it so that two open payments to the same address never share an amount — that is how it tells customers apart. Store the returned amount and show the payer exactly that figure, with all its decimals. A transfer of any other amount will not settle the payment.

### GET /api/v1/payments/{id} — fetch one payment
Returns: id, order_id, network, token, expected_amount, detected_amount, status, transaction_hash, sender, receiver, created_at, detected_at, confirmed_at, transfers[]. 404 → PAYMENT_NOT_FOUND.

Every payment response also carries checkout_url: a hosted page (/pay/{id}) showing the payer the exact amount, address, QR code and live status. Redirect the customer there instead of building your own payment screen if you prefer; it shows no order or merchant details. Pass return_url (https, include your order reference) on create and the page sends the payer back to it once the payment settles — but still treat only the webhook / GET status as proof of payment, never the arrival on return_url.

### GET /api/v1/payments?limit=N&cursor=C — list payments, newest first
Returns { "data": [...], "has_more": bool, "next_cursor": string|null }. limit 1–100 (default 20). To page, pass next_cursor back as cursor until has_more is false. An invalid cursor → 400 INVALID_CURSOR.

### POST /api/v1/payments/{id}/simulate — test mode only
Body: { "action": "pay" | "underpay" | "overpay" | "expire" }. Only with an fp_test_ key and only for a payment created with one (live key → 403 FORBIDDEN; live payment → 409 NOT_TEST_PAYMENT; settled/expired → 409 PAYMENT_NOT_OPEN). pay sends exactly what is owed (→ CONFIRMED), underpay sends half (→ DETECTED), overpay sends the remainder + 1 token, expire ends a PENDING payment (→ EXPIRED). The real webhooks fire, so this is how to test the webhook handler end to end. Every payment response and webhook payload carries test_mode (true/false): in production, never fulfil an order whose payment has test_mode true.

### POST /api/v1/verify — verify one transaction hash I already have
Body: { "network", "transaction_hash", "receiver" }. Returns { valid, status, network, transaction_hash, sender, receiver, amount, ... }. Each call is billed, so do not poll it; it is not needed for the normal checkout flow.

### Payment statuses
PENDING → waiting for the transfer
DETECTED → money was seen but the payment is not settled: either underpaid, or the full amount is still waiting for network confirmations. Do NOT fulfil.
CONFIRMED → paid in full. Fulfil the order.
OVERPAID → more than the amount arrived. Fulfil the order and flag it for review.
EXPIRED → expires_in elapsed without payment. Do not fulfil.
Settlement is immediate on detection; there is no confirmation-count wait.

### Webhooks
Configured in the dashboard → Settings (webhook URL + signing secret). The URL must be public HTTPS; redirects are not followed; the request times out after 10 seconds.
Events: payment.detected, payment.confirmed, payment.expired.
Each delivery is a POST with these headers:
- X-Forypay-Event: event name
- X-Forypay-Delivery: delivery id, stable across retries — use it to dedupe
- X-Forypay-Timestamp: unix seconds
- X-Forypay-Signature: sha256=<hex>
Body example: { "event": "payment.confirmed", "data": { "payment_id", "order_id", "network", "token", "amount", "transaction_hash", "status" } }
Signature = "sha256=" + hex(HMAC-SHA256(secret, timestamp + "." + rawBody)), where rawBody is the exact received bytes BEFORE any JSON parsing. Compare in constant time. Reject if |now − timestamp| > 300 seconds.
Any 2xx response acknowledges the delivery. Otherwise Forypay retries after 1m, 5m, 15m, 1h, 6h and 24h, so the handler must be idempotent.

### Errors
Shape: { "error": { "code", "message", "request_id" } }. Branch on `code`, never on `message`. Log `request_id`.
400 INVALID_REQUEST (message names the bad field) · 400 INVALID_AMOUNT · 400 INVALID_TOKEN · 401 INVALID_API_KEY · 402 QUOTA_EXCEEDED / INSUFFICIENT_CREDITS (plan limit reached — show a clear error, do not retry) · 403 ACCOUNT_DISABLED · 404 PAYMENT_NOT_FOUND · 429 RATE_LIMITED · 5xx (retry with backoff).

## What to build
1. Configuration: read FORYPAY_API_KEY, FORYPAY_WEBHOOK_SECRET, FORYPAY_BASE_URL (default https://forypay.com) and the receiving address(es) from environment variables. Add them to the example env file. Never hard-code secrets.
2. A small server-side Forypay client: createPayment, getPayment. Timeouts; retry only on 429/5xx/network errors with exponential backoff, always reusing the same Idempotency-Key.
3. Persistence: add to my order model (with a migration) forypay_payment_id, network, pay_amount (string/decimal — not float), receiver, payment_status, expires_at, paid_at, transaction_hash.
4. Checkout: when the customer picks "Pay with USDT", create the payment with Idempotency-Key = my order id and order_id = my order id, save the response, then show a payment page with: network name, receiver address (with copy button and a QR code of the address), the exact returned amount (with copy button), a countdown to expires_at, and a clear warning to send USDT on the correct network only.
5. Webhook endpoint: read the RAW body, verify the signature and timestamp (reject with 401 otherwise), dedupe on X-Forypay-Delivery, then re-fetch the payment with GET /api/v1/payments/{id} and act on THAT status — not on the webhook body alone. Mark the order paid exactly once (CONFIRMED or OVERPAID), cancel/release it on EXPIRED. Return 2xx quickly; do slow work asynchronously. Make sure no body-parsing middleware alters the raw body for this route, and that CSRF protection excludes it.
6. Fallback: the payment page polls MY backend every ~10 seconds, and my backend reads its stored status (refreshing from GET /api/v1/payments/{id} if the payment is still open), so the order still completes if a webhook is delayed.
7. Tests: signature verification (valid, wrong secret, tampered body, stale timestamp), idempotent webhook handling (same delivery twice), the status → order-state mapping, and that a payment with test_mode true is never fulfilled when running with a live key.
8. Finish with a short README section: env vars, how to set the webhook URL in the Forypay dashboard, and how to test end to end without real money: create a payment with the fp_test_ key, then call POST /api/v1/payments/{id}/simulate with pay, underpay, overpay and expire (or use the buttons on the checkout page) and watch the webhook update the order.

## Rules
- Never use floating-point numbers for money anywhere.
- Never expose the API key or webhook secret to the client.
- Never mark an order paid from a browser redirect or client-side check — only from a verified webhook or a server-side GET.
- Do not invent endpoints, fields or statuses not listed above. If you need something that is not here, ask me.
- Work in small steps and show me the plan before making large changes.

Never paste your keys into the chat

The prompt asks for environment variable names only. Keep your API key and webhook secret in your .env file — not in the conversation, and not in code.

Authentication

All endpoints below are paths relative to this base URL. Send requests over HTTPS with a JSON body.

Base URL
https://forypay.com/api/v1

Every request carries a project API key as a bearer token. Keys are created in the dashboard, on the project they belong to — see Projects — are shown once at creation, and are stored only as a hash — if you lose one, revoke it and issue another.

Header
Authorization: Bearer fp_live_9f2c…

Keys are secrets

Call the API from your server, never from browser or mobile code. A key in a client bundle can create payments against your project.

Create a payment

POST/api/v1/payments

Registers the payment you expect to receive and starts chain monitoring. The response tells you when the window closes.

Every payment also gets a hosted payment page. Send your customer to the checkout_url in the response and they see the exact amount, address, QR code and live status — with no order or merchant details — instead of a screen you build yourself.

Try it
Request body fields for creating a payment
FieldTypeDescription
networkrequired"bsc" | "tron" | "polygon" | "base"Chain the payer will send on.
tokenoptional"USDT" | "USDC"Stablecoin to receive. Optional — omitted means the network's default (the first listed). Accepted per network: bsc: USDT · tron: USDT · polygon: USDT, USDC · base: USDC
receiverrequiredstringYour receiving address. 0x… on BSC, Polygon and Base; T… on TRON.
amountrequiredstringDecimal amount as a string, e.g. "25.00". Sent as a string to avoid float rounding.
order_idoptionalstringYour own reference, up to 191 characters. Echoed back on every webhook.
expires_inoptionalintegerSeconds until the payment window closes. Minimum 60. Omit for no expiry — the payment then stays open until the exact amount arrives.
expected_senderoptionalstringRestricts matching to transfers from this address.
return_urloptionalstringhttps URL the hosted checkout page sends the payer to once the payment settles, after showing them its host for a few seconds. Include your own order reference in it. Shown publicly on the checkout page.

Pass an Idempotency-Key header to make retries safe: a repeat call with the same key returns the original payment instead of creating a second one.

Exact amount, while the payment is open

A payment settles only when a transfer for exactly the requested amount arrives while it is open — from creation until expires_in elapses, or indefinitely when omitted. A transfer for any other amount is recorded and held for manual review, never credited to the order. Tell payers to send the exact figure, with network and exchange fees paid on top of it.
Request
curl -X POST https://forypay.com/api/v1/payments \
  -H "Authorization: Bearer $FP_API_KEY" \
  -H "Idempotency-Key: ORDER-1042" \
  -H "Content-Type: application/json" \
  -d '{
    "order_id": "ORDER-1042",
    "network": "bsc",
    "receiver": "0x2f1a…9c3e",
    "amount": "25.00",
    "expires_in": 1800
  }'
200 Response
{
  "id": "pay_8Fq2mZx1LrKd",
  "order_id": "ORDER-1042",
  "network": "bsc",
  "token": "USDT",
  "amount": "25.00",
  "receiver": "0x2f1a…9c3e",
  "status": "PENDING",
  "expires_at": "2026-08-17T14:35:00.000Z"
}

Retrieve a payment

GET/api/v1/payments/{id}

Returns the current state plus every matched transfer. Use this to reconcile, or as a fallback if your webhook endpoint was unreachable.

Try it
Request
curl https://forypay.com/api/v1/payments/pay_8Fq2mZx1LrKd \
  -H "Authorization: Bearer $FP_API_KEY"
200 Response
{
  "id": "pay_8Fq2mZx1LrKd",
  "order_id": "ORDER-1042",
  "network": "bsc",
  "token": "USDT",
  "expected_amount": "25.00",
  "detected_amount": "25.00",
  "status": "CONFIRMED",
  "transaction_hash": "0x9d4c…7b21",
  "sender": null,
  "receiver": "0x2f1a…9c3e",
  "created_at": "2026-08-17T14:05:00.000Z",
  "detected_at": "2026-08-17T14:05:12.000Z",
  "confirmed_at": "2026-08-17T14:05:21.000Z",
  "transfers": [ /* … */ ]
}

List payments

GET/api/v1/payments

Returns recent payments, newest first, wrapped in a data array. Pass limit to change the page size — the default is 20 and the maximum is 100.

When has_more is true, pass the returned next_cursor back as the cursor parameter to fetch the next, older page. Cursors are opaque; an invalid one answers 400 INVALID_CURSOR.

Try it
Request
curl "https://forypay.com/api/v1/payments?limit=50" \
  -H "Authorization: Bearer $FP_API_KEY"

Test mode

POST/api/v1/payments/{id}/simulate

A payment created with an fp_test_ key is a test payment: it is never watched on chain, is never billed, and no real transfer can settle it. Act as the payer with this endpoint instead — the payment moves through exactly the statuses and webhooks a real transfer would produce, so your webhook handler is tested end to end. The hosted checkout page and the dashboard offer the same actions as buttons.

Try it
Simulate request body
FieldTypeDescription
actionrequired"pay" | "underpay" | "overpay" | "expire"pay sends exactly what is still owed; underpay sends half of it (the payment stays DETECTED); overpay sends the remainder plus 1 token; expire ends a payment nothing has arrived for.
Request
curl -X POST https://forypay.com/api/v1/payments/$PAYMENT_ID/simulate \
  -H "Authorization: Bearer $FP_TEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": "pay" }'
Response
{
  "id": "8c1e…",
  "status": "CONFIRMED",
  "expected_amount": "25.5",
  "detected_amount": "25.5",
  "transaction_hash": "0x5133…",
  "test_mode": true
}

Only test payments, only with a test key

A live key gets 403 FORBIDDEN, and a payment created with a live key answers 409 NOT_TEST_PAYMENT whoever asks. A settled or expired payment answers 409 PAYMENT_NOT_OPEN. Simulated transaction hashes start with 0x5133 and exist on no chain. Every response and webhook payload carries test_mode, so your code can refuse to fulfil a test payment in production.

Verify a transaction

POST/api/v1/verify

A one-shot check for a hash you already have. This reads the chain directly and does not create or update a payment record — useful for manual reconciliation and for migrating historical orders.

Try it
Request body fields for verifying a transaction
FieldTypeDescription
networkrequired"bsc" | "tron" | "polygon" | "base"Chain to read.
tokenoptional"USDT" | "USDC"Token the transfer moved. Optional — omitted means the network's default. Accepted per network: bsc: USDT · tron: USDT · polygon: USDT, USDC · base: USDC
transaction_hashrequiredstringHash of the transfer to inspect.
receiverrequiredstringAddress the transfer must have credited.
Request
curl -X POST https://forypay.com/api/v1/verify \
  -H "Authorization: Bearer $FP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "network": "bsc",
    "transaction_hash": "0x9d4c…7b21",
    "receiver": "0x2f1a…9c3e"
  }'
200 Response
{
  "valid": true,
  "status": "CONFIRMED",
  "network": "bsc",
  "transaction_hash": "0x9d4c…7b21",
  "sender": "0x8f2a…1b4e",
  "receiver": "0x2f1a…9c3e",
  "amount": "25.00"
}

Payment statuses

A payment starts at PENDING and moves forward only. These are the states you will see in webhooks, API responses and the dashboard.

Payment status values and what they mean
StatusMeaning
PendingCreated and waiting for a matching transfer on chain.
DetectedA matching transfer was seen: either only part of the amount, or the full amount still waiting for network confirmations. Do not fulfil yet.
ConfirmedSettled: the full amount is confirmed on chain. Safe to fulfil the order.
OverpaidSettled, but the payer sent more than the expected amount.
ExpiredThe window closed before a matching transfer arrived.

Webhooks

Set a webhook URL on the project and we POST JSON as the payment progresses. Events are queued and retried with exponential backoff until your endpoint returns a 2xx, so treat handlers as idempotent — the same event may arrive twice.

  • payment.detected — a matching transfer appeared on chain (not yet confirmed)
  • payment.confirmed — the full amount is confirmed on chain and the payment is settled (status CONFIRMED or OVERPAID)
  • payment.expired — the window closed unpaid

Each delivery carries an HMAC-SHA256 signature derived from the project webhook secret, computed over the timestamp header and the raw request body joined by a dot. Compare it with a constant-time comparison before trusting the payload, refuse anything older than five minutes, and rotate the secret from project settings if it is ever exposed.

Example delivery
POST /your/webhook
Content-Type: application/json
X-Forypay-Event: payment.confirmed
X-Forypay-Delivery: whk_3Kd9vQ2mTz
X-Forypay-Timestamp: 1755820800
X-Forypay-Signature: sha256=6f1b…a92c

{
  "event": "payment.confirmed",
  "data": {
    "payment_id": "pay_8Fq2mZx1LrKd",
    "order_id": "ORDER-1042",
    "status": "CONFIRMED",
    "transaction_hash": "0x9d4c…7b21",
    "test_mode": false
  }
}

In production, never fulfil a test payment

A payment created with an fp_test_ key can be marked paid by anyone holding its checkout link — the checkout page shows simulate buttons, and no money moves. Its webhooks are real and signed, and carry "test_mode": true. If a test key ever ends up in your live shop, a customer could "pay" without paying. So your production handler must ignore any event whose test_mode is true, even when the signature is valid, and only a live key belongs in production.
Production webhook handler
// after verifying the signature
const { event, data } = JSON.parse(rawBody);
if (process.env.NODE_ENV === 'production' && data.test_mode) {
  return res.status(200).end(); // acknowledge, but never fulfil
}

Errors

Errors use conventional HTTP status codes and a consistent body. The request_id is worth logging — quote it when asking for help and we can find the exact request.

400 Response
{
  "error": {
    "code": "INVALID_AMOUNT",
    "message": "Invalid amount",
    "request_id": "req_7bQ1xKp0Za"
  }
}
Error codes returned by the API
CodeHTTPCause
INVALID_REQUEST400Body failed schema validation. The message names the field.
INVALID_AMOUNT400Amount was not a plain decimal string.
INVALID_TOKEN400Token is not enabled for that network.
INVALID_API_KEY401Missing, malformed, revoked or unknown bearer token.
PAYMENT_NOT_FOUND404No payment with that id.
UNKNOWN_TOKEN_DECIMALS500Token metadata is incomplete on our side.
VERIFICATION_ERROR500The chain read failed — retry, then contact us.

Try it without writing code

The playground sends a real request to any documented endpoint with a key you paste in, and shows the raw response.

Open API playground