Integration
RESTAPI Reference
How the REST API works, with worked examples for the main resources. Every endpoint is listed in the Full API Reference (/docs/api). All endpoints return JSON in a { data, error } envelope.
Base URL
Endpoint paths below include the /api/v1 prefix. Use HTTPS; responses carry a Strict-Transport-Security header. Request and response bodies are JSON.
{ "data": { ... }, "error": null }// on failure{ "data": null, "error": { "code": "VALIDATION_ERROR", "message": "..." } }
Authentication
Send your secret API key in the Authorization header using the Bearer scheme, or in an x-api-key header. Only values that start with phk_ are treated as API keys; any other value is ignored and the request gets 401 UNAUTHORIZED. Create keys under Developers → API Keys in the dashboard.
Authorization: Bearer phk_live_<your_secret_key>
Secret key
phk_live_... — server-side only. Access is limited to the scopes chosen when the key was created.
Publishable key
phk_pub_... — read-only (payments:read, customers:read, products:read).
Test and live mode
Not set by the key. Your account is in test or live mode, switched with the Test/Live toggle in the dashboard header. Most list responses include a livemode flag.
Every merchant endpoint checks the key's scopes. Read endpoints need the :read scope of their group and writes need :write. Dashboard (cookie) sessions are not scope-limited.
| Scopes | Covers |
|---|---|
payments:read, payments:write | Payments, refunds, disputes, payouts, balance, checkout sessions |
customers:read, customers:write | Customers, addresses, tax IDs, saved payment methods |
subscriptions:read, subscriptions:write | Subscriptions and subscription schedules |
invoices:read, invoices:write | Invoices, credit notes, quotes |
products:read, products:write | Products, prices, coupons, features and price overage |
entitlements:read, entitlements:write | Customer entitlements, usage checks, feature usage, customer overrides, entitlement settings |
payment_links:read, payment_links:write | Hosted payment links |
billing:read, billing:write | Hosted billing page tokens and platform billing |
tax:read, tax:write | Tax rates, tax settings, tax calculation |
routing:read, routing:write | Routing rules, gateway connections, routing simulation |
webhooks:read, webhooks:write | Webhook endpoints, deliveries, events |
reports:read, reports:write | Analytics, insights, financial reports |
account:read, account:write | Merchant settings, team, API keys, notifications, audit log |
custom_domains:read, custom_domains:write | Custom checkout domains |
Creating or editing an API key (scope account:write) can grant only scopes the caller holds: a team member is limited to their role's scopes and an API key to its own. Asking for more returns 403 PRIVILEGE_ESCALATION listing the missing scopes. The account owner's dashboard session may grant any scope. Key scopes can be changed only from the dashboard.
Download API collections
Import a collection into your HTTP client, then set its apiKey variable to your phk_live_ secret key and its baseUrl variable to https://paymenthooks.com/api/v1.
Pagination
Most list endpoints accept page and pageSize (default 25, max 100) and return a meta object with the total count (limit is accepted as an alias of pageSize). Supported filters differ per endpoint and are listed on each one below. On GET /v1/payments, /v1/invoices and /v1/subscriptions a query parameter the endpoint does not support is refused with 400 VALIDATION_ERROR naming it, never ignored; a subscription's payments and invoices are at GET /v1/subscriptions/:id/payments and /v1/subscriptions/:id/invoices, and a payout's payments at GET /v1/payouts/:id/payments.
GET /api/v1/payments?page=2&pageSize=25&status=success&sortField=createdAt&sortDirection=desc
{"data": [ ... ],"meta": { "total": 42, "page": 2, "pageSize": 25 },"error": null}
Idempotency
Send an Idempotency-Key header (max 200 characters) to make a retry safe. A successful (2xx) response is stored for 24 hours and replayed for the same key with an x-idempotent-replayed: true header; error responses are not stored, so a failed request can be retried with the same key. The header is honoured on POST /checkout-sessions, /payments/:id/refund, /payments/:id/capture, /subscriptions, /subscription-schedules, /webhooks/endpoints, /custom-domains, and /disputes/:id/evidence. POST /payments takes an idempotencyKey body field instead.
On POST /payments/:id/refund the key is claimed before the gateway is called: a second request with the same key while the first is still running gets 409 IDEMPOTENCY_IN_PROGRESS and moves no money. Retry it with the same key after the first answers: a successful refund is then replayed, a failed one runs again. A claim left by a request that crashed expires after 2 minutes.
Object ids
Every object id has the form ph_<type>_<32 lowercase hex characters>, for example ph_cus_8f14e45fceea167a5a36dedd4bea2543. The type prefix tells you what an id refers to, so store ids as opaque strings and never parse the hex part. Ids assigned by a payment gateway (such as a Stripe pi_ or a Razorpay pay_ id) are returned in separate gateway fields, for example gatewayTransactionId.
| Object | Prefix |
|---|---|
| Customer | ph_cus_ |
| Product | ph_pro_ |
| Price | ph_pri_ |
| Payment | ph_pay_ |
| Refund | ph_rfd_ |
| Dispute | ph_dsp_ |
| Payout | ph_pot_ |
| Transaction | ph_txn_ |
| Checkout session | ph_cks_ |
| Payment link | ph_plk_ |
| Subscription | ph_sub_ |
| Subscription item | ph_sit_ |
| Subscription schedule | ph_sch_ |
| Invoice | ph_inv_ |
| Credit note | ph_crn_ |
| Quote | ph_qte_ |
| Coupon | ph_cpn_ |
| Tax rate | ph_tax_ |
| Feature | ph_fea_ |
| Meter | ph_mtr_ |
| Meter event | ph_mev_ |
| Payment mandate | ph_man_ |
| Customer balance transaction | ph_cbt_ |
| Business | ph_ent_ |
| Gateway connection | ph_gwc_ |
| Webhook endpoint | ph_whe_ |
| Webhook event | ph_evt_ |
| Webhook delivery | ph_whd_ |
| Import job | ph_imp_ |
| Merchant | ph_mrc_ |
Payments
Charge a customer through your connected gateways, then capture or refund. Amounts are always integers in the smallest currency unit (e.g. cents for USD). A payment returns what the gateway charged as transactionLocalCurrencyAmount in transactionLocalCurrency, and the same amount in USD cents as transactionAmountUsdCents (with transactionUsdToLocalCurrencyRate, 1 USD = X local); fee, net and refunded totals are USD cents. Create takes transactionLocalCurrencyAmount and transactionLocalCurrency; refund and capture take transactionAmountUsdCents. Statuses: success, pending, action_required, failed, refunded, disputed, dispute_lost, requires_capture. A won dispute returns the payment to success (or refunded); a lost one makes it dispute_lost and adds the disputed amount to the refunded total.
Create a payment. The gateway connection is chosen by your routing rules and routing strategy, or forced with gatewayId. An account in test mode is only routed to sandbox connections, never a live gateway. Errors: 404 NOT_FOUND when customerId is not a customer in your account; 422 GATEWAY_NOT_CONNECTED when the forced gateway has no active connection in your mode. Requires the payments:write scope. Returns 201; status reflects the gateway result, and redirectUrl is included when the gateway needs a redirect.
Retrieve a payment with its event timeline, subscriptionId (when it came from a subscription checkout), and an embedded customer summary. Requires payments:read.
Return a paginated list of payments, newest first. Requires payments:read.
Update a payment's description and metadata. These are the only editable fields; other fields are ignored, and a body with neither returns 400 VALIDATION_ERROR. Requires payments:write.
Refund all or part of a payment in status success or disputed, through the gateway that processed it. Returns 201 with the refund. Errors: 422 INVALID_STATE, 400 EXCEEDS_REFUNDABLE, 409 GATEWAY_NOT_CONNECTED, 502 GATEWAY_REJECTED, 409 IDEMPOTENCY_IN_PROGRESS (the same Idempotency-Key is still being processed). Requires payments:write; honours Idempotency-Key.
Capture a payment in status requires_capture, fully or partially. Only test-mode authorizations can be captured through the API; other gateways return 422 CAPTURE_NOT_SUPPORTED. Requires payments:write; honours Idempotency-Key.
Checkout Sessions
Hosted checkout pages for one-time payments and subscription sign-ups. The response includes a url field; redirect your customer there. Sessions expire 24 hours after creation.
Create a checkout session. itemLocalCurrency is required with any inline line; when every line names one of your prices it is their one currency. itemLocalCurrencyAmount = sum of line items + tax + convenience fee, in itemLocalCurrency's smallest unit; itemAmountUsdCents is the same total in USD cents at itemUsdToLocalCurrencyRate. taxRate alone computes the tax from the subtotal. Line items keep their unitPrice and total in itemLocalCurrency. webhookUrl must use https. Returns 201. Requires payments:write; honours Idempotency-Key.
Return a paginated list of checkout sessions, newest first. Requires payments:read.
Retrieve a checkout session. Includes paymentId once a payment has been attempted. Requires payments:read.
Public, unauthenticated read used by the hosted checkout page. Returns 410 EXPIRED after expiresAt.
Public endpoint called by the hosted checkout to pay a session. The charge is in the customer's currency when the selected gateway supports it, otherwise USD, otherwise the session's itemLocalCurrency. The response transactionLocalCurrencyAmount and transactionLocalCurrency are what the gateway charged. In test mode the payment is simulated and succeeds. Errors: 409 SESSION_ALREADY_COMPLETED, 410 EXPIRED, 400 SESSION_CLOSED, 402 FRAUD_BLOCKED, 422 UNSUPPORTED_CURRENCY, 409 PRICE_CHANGED, 400 TERMS_NOT_ACCEPTED. Fraud screening fails closed: if it is unavailable the payment is rejected with 500 INTERNAL_ERROR and no gateway is called. When 3D Secure is required, status is action_required and actionUrl is returned.
Customers
Customer records used across payments, subscriptions, and invoices. Email is unique within your account. A customer has no currency: totalSpendAmountUsdCents is what they paid and kept, in USD cents, across every currency. Requires customers:read or customers:write.
Create a customer. Returns 201. Create-only: an email that already exists in your account returns 409 DUPLICATE_EMAIL and the existing customer is left unchanged; use PUT to edit it.
Retrieve a single customer by ID.
Return a paginated list of customers, newest first. Archived customers are left out unless status=archived. An unknown query parameter returns 400 VALIDATION_ERROR naming it.
Archive a customer (customers:write, audited). History is kept; the customer is hidden from lists unless status=archived, and new checkouts, payments, subscriptions and invoices for it return 409 CUSTOMER_ARCHIVED. 409 CUSTOMER_HAS_ACTIVE_SUBSCRIPTIONS while a subscription is active, trialing or past_due. POST /api/v1/customers/:id/unarchive restores it. There is no DELETE.
Update a customer. Only the fields you send are changed. Only the fields below are accepted; unknown or server-managed fields (e.g. merchantId, totalSpendAmountUsdCents) return 400 VALIDATION_ERROR with error.fields.
Subscriptions
Recurring billing against a recurring price. Create, pause, resume, cancel, and retry missed renewals. Statuses include trialing, active, paused, past_due, and cancelled. Requires subscriptions:read or subscriptions:write.
Create a subscription for a customer in your account against a recurring price. Returns 201 with status trialing when a trial applies, otherwise active, and dispatches subscription.created. Errors: 400 VALIDATION_ERROR for an invalid trialEndAt, 404 NOT_FOUND for an unknown price or customer, 422 INVALID_STATE when the price has an unsupported billing interval, 502 SCHEDULING_FAILED when the renewal cannot be scheduled (the subscription is not created). Honours Idempotency-Key.
Return a paginated list of subscriptions, newest first. Also accepts priceId and productId filters.
Retrieve a subscription. Returns the same camelCase record as list and create (currentPeriodEnd, nextPaymentAt, ...) and embeds a customer summary.
Update a subscription's metadata, the only updatable field. Any other field (e.g. priceId, status) returns 400 VALIDATION_ERROR. To change plans, preview the cost with preview-proration; the switch itself is made from the customer billing page.
Pause an active or trialing subscription. Scheduled renewals are cancelled until it is resumed. Other statuses return 422 INVALID_STATE.
Resume a paused subscription. The renewal is rescheduled for its stored next payment date or current period end. Other statuses return 422 INVALID_STATE. If the renewal cannot be scheduled it returns 502 SCHEDULING_FAILED and the subscription stays paused.
Cancel immediately (status cancelled; unused time may be credited per your prorate-on-cancel setting) or at period end. Already-cancelled subscriptions return 422 INVALID_STATE.
Preview the credit, debit, and net amount of switching to another price. Returns prorationDate, prorationCreditLocalCurrencyAmount, prorationDebitLocalCurrencyAmount, prorationNetLocalCurrencyAmount (all in the smallest unit of itemLocalCurrency), itemLocalCurrency, and remainingDays. Does not change the subscription.
Create a new checkout session for the subscription's itemLocalCurrencyAmount in its itemLocalCurrency so the customer can pay a missed renewal. The response returns that price as itemLocalCurrencyAmount and itemLocalCurrency. Allowed for active, past_due, paused, and cancelled subscriptions. Returns 201 with the checkout URL.
Create a setup-only session for an active or trialing subscription whose automatic payments are not set up. The customer authorises a new payment method at url; the period is not charged, not advanced and the price does not change. Returns the open session again (reused: true) while it is valid. Scope subscriptions:write. 422 SETUP_NOT_AVAILABLE or NO_SETUP_GATEWAY when it cannot be offered.
Email the customer a link to set up automatic payments again (the mandate_setup_link email; your Subscription emails preference applies). Returns the url, sessionId and the email outcome. Scope subscriptions:write.
Return the subscription's own invoices (those its payments settled), newest first. Paginated with page and limit.
Return the subscription's own payments (its first checkout charge and every renewal), newest first. Paginated with page and limit.
Return transactions recorded against the subscription, newest first.
Features & Entitlements
Features describe what a plan includes (boolean, quantity or metered). Define each once, attach it to a product with its maximum, and set overage per price. Entitlements are what a customer's subscriptions grant right now, with exact usage. Feature, product-feature and price-overage endpoints need products:read / products:write; customer entitlements, usage, overrides and settings need entitlements:read / entitlements:write (keys created before these scopes existed are accepted with customers:read / customers:write). See the Usage billing guide.
Create a feature. Returns 201. key and type (and a metered feature's meterId and resetInterval) are fixed once created. Errors: 400 VALIDATION_ERROR (error.fields names each field, including unknown fields), 409 CONFLICT when the key is already used, 409 FEATURE_METER_AGGREGATION_UNSUPPORTED when the meter is not sum or count. Honours Idempotency-Key.
Return your feature catalogue, active first then by name, with meta.total, page and pageSize.
Retrieve one feature. 404 NOT_FOUND when it is not yours.
Change name, description, unit, status or metadata. Sending key, type, meterId or resetInterval answers 400 VALIDATION_ERROR (create a new feature instead). Archive with status archived; there is no DELETE.
The product's features in display order: featureId, key, name, type, unit, status, enabled, limitValue (null = unlimited) and displayOrder.
Replace the product's whole feature list in one transaction (audited). Running subscriptions keep the terms they were snapshotted with until their next period. Errors: 404 NOT_FOUND for an unknown product, 400 VALIDATION_ERROR with error.fields keyed features.N.field.
Replace the price's overage terms. GET returns the current terms with the package price in the price's currency and in USD cents. Errors: 400 VALIDATION_ERROR, 404 NOT_FOUND, 409 FEATURE_METER_BILLED_BY_PRICE.
Every feature the customer is granted: key, type, enabled, limit (null = unlimited), used, remaining, policy, overageUnits, estimated overage (local and USD cents), resetsAt and source (product, price or customer_override). policy is the price's choice above the maximum: restrict, allow or bill.
Would quantity more units be allowed now? Read-only and exact; nothing is reserved. reason is null, NO_ENTITLEMENT, ENTITLEMENT_LIMIT_REACHED or ENTITLEMENT_OVERAGE_CAP_REACHED. 404 NOT_FOUND for an unknown key or customer.
Set how many of a quantity feature are in use now. 409 ENTITLEMENT_LIMIT_REACHED above the maximum unless the price allows overage, 409 NO_ENTITLEMENT when no subscription grants it. Honours Idempotency-Key.
Create or replace a customer's override (audited); the customer's entitlements refresh at once. GET returns it (404 when none), DELETE removes it, and GET /customers/:id/feature-overrides lists them. Archived features cannot be overridden.
Change your account's usage alert and access settings (audited). Send only the fields to change; unknown fields, and the removed mode, answer 400 VALIDATION_ERROR. GET returns all five settings. Overage is set per price.
Invoices
Create, finalise, email, and settle invoices. A draft has no number. It takes the next number of your own unbroken series (prefix and next number from Invoice Settings; default INV-0001) when it is finalised (see Invoice numbers below). An invoice is issued in one itemLocalCurrency at one itemUsdToLocalCurrencyRate (1 USD = X itemLocalCurrency). Its subtotal, tax and total are each stored twice: in itemLocalCurrency's smallest unit (itemSubtotalLocalCurrencyAmount, itemTaxLocalCurrencyAmount, itemLocalCurrencyAmount) and in USD cents (itemSubtotalAmountUsdCents, itemTaxAmountUsdCents, itemAmountUsdCents). Each line item carries itemLocalCurrencyUnitAmount, itemLocalCurrencyAmount, itemUnitAmountUsdCents and itemAmountUsdCents. Requires invoices:read or invoices:write.
Create an invoice in draft status: invoiceNumber and finalizedAt are null until it is finalised. Set supplyDate when the date of supply differs from the issue date. customerId must be a customer in your account (404 NOT_FOUND otherwise). The USD cents side is converted at the live exchange rate. Returns 201.
Retrieve a single invoice including its line items and status.
Update an invoice's dueDate and notes, and a draft's supplyDate (409 INVALID_STATE once issued). These are the only editable fields. Totals and status are server-managed; any other field returns 400 VALIDATION_ERROR, and an empty body returns 400.
Return a paginated list of invoices, newest first.
Email the invoice to the customer and set its status to sent. A draft is finalised first (numbered, dated, invoice.finalized). The body is optional: { attachmentIds } adds files uploaded to the invoice after the invoice PDF. Errors: 400 VALIDATION_ERROR when an attachment id is not one of this invoice's files; 422 NO_RECIPIENT when the customer has no email; 502 EMAIL_SEND_FAILED (the invoice stays unsent).
Upload one file to attach to the invoice's emails (multipart/form-data). Up to 5 files per invoice. Errors: 400 VALIDATION_ERROR (type, content or size), 409 ATTACHMENT_LIMIT (5 files already), 413 PAYLOAD_TOO_LARGE, 415 when the body is not multipart, 422 INVALID_STATE for a paid or void invoice. Requires invoices:write. Returns 201.
List the invoice's attached files, oldest first, without their content. Requires invoices:read.
Download one attached file with its stored Content-Type. Requires invoices:read.
Remove an attached file. Emails already sent keep the copy the customer received. Requires invoices:write.
Mark an invoice paid for out-of-band payments (wire, cash, etc.) and dispatch invoice.paid. No request body. Paid, void or cancelled invoices return 422 INVALID_STATE; a concurrent change returns 409 INVALID_STATE (the invoice is settled once).
Download the invoice as a PDF (Content-Type: application/pdf).
Return the customer's current hosted invoice link as { invoiceId, url } (the same value as hostedInvoiceUrl). 404 for a draft, which has no hosted page yet. Requires invoices:read.
Revoke every hosted link of the invoice sent so far (emails, copied links, webhook hosted_invoice_url and invoice_pdf) and return the new link as { invoiceId, url }. Old links then open the Invoice unavailable page (404). Emails, webhooks and GET /api/v1/invoices/:id use the new link from then on. Cannot be undone; recorded in the activity log as invoice.hosted_link_revoked. 404 for a draft or an invoice of another account. Requires invoices:write.
Invoice numbers
Each document type has one unbroken series per merchant, as Spain, Italy, Portugal and other tax authorities require. Another account's numbers never affect yours.
- An invoice is numbered when it is finalised, not when it is created. A draft has
invoiceNumber: nullandfinalizedAt: null. Finalising happens onPOST /v1/invoices/:id/finalize,/send,/mark-paidor quote acceptance. Subscription renewal invoices are issued already numbered. - Numbers are gap-free. A number is claimed inside the transaction that issues the invoice. Concurrent issues get consecutive numbers, and an issue that fails returns its number to the series.
- A number is never reused. A voided invoice keeps its number, and the series only moves forward. A voided draft never had one.
- The prefix and next number come from Settings > Invoice Settings (
GET/PUT /v1/invoice-settings:numberPrefix,nextNumber, forward only). The default series isINV-0001. - Separate series: credit notes
CN-0001and payment receiptsRCPT-0001. A receipt is numbered when its payment is first paid. Test Mode payments use their ownTEST-RCPT-0001series, so simulations never use up live receipt numbers. - Numbers are unique per merchant. Numbers issued before 2026-11-26 are kept, and each series continues after your highest number.
Issue a draft without emailing it (Stripe's finalize). No request body. The invoice becomes open and takes the next number of your series, its issue date (finalizedAt) and, unless you set one, its date of supply (supplyDate = the issue date). invoice.finalized is sent once, by whichever call issues the draft. Finalising an issued invoice returns it unchanged (idempotent). Errors: 404 NOT_FOUND; 409 INVALID_STATE for a draft voided before it was issued. Requires invoices:write.
curl -X POST https://paymenthooks.com/api/v1/invoices/ph_inv_2b4d6f8a0c1e3b5d7f9a2c4e6b8d0f1a/finalize \
-H "Authorization: Bearer phk_live_..."Issue date and date of supply
finalizedAtis the issue date: when the invoice was finalised. It isnullon a draft. Webhooks carry it asstatus_transitions.finalized_atandeffective_at.supplyDateis the date of supply (tax point). It is one of:- the day you send on
POST /v1/invoices, or onPUT /v1/invoices/:idwhile the invoice is a draft. UseYYYY-MM-DD, at most 365 days ahead and 6 years back. It is stored as 00:00 UTC. - for subscription invoices, the end of the service period they bill.
- otherwise, the issue date.
tax_point_date.- the day you send on
- Under VAT and GST, the sale is filed in the tax report under the earliest of the date of supply, the issue date and the payment date, so a future date of supply never delays the tax. US and Canadian sales tax is filed when the invoice is paid.
EU and UK invoice content
The invoice PDF and the hosted invoice page print what Art. 226 of Directive 2006/112/EC (and UK VAT Notice 700) requires:
- The issue date and the date of supply, each shown separately. A draft preview prints "Not issued".
- The sequential invoice number from your series.
- "VAT number" for both your number and your customer's, in the EU and UK VAT areas. Other countries use GSTIN (India), ABN (Australia) or Tax ID.
- A VAT summary for each rate: the taxable amount and the VAT, in
itemLocalCurrency. - For a reverse-charged EU sale: "Reverse charge: VAT to be accounted for by the recipient (Art. 196 Directive 2006/112/EC). Customer VAT number: DE123456789." UK and other reverse charges print the statement without the EU citation.
An invoice is reverse charged only when the customer has a VAT number on file that the tax registry has verified. Registries used: VIES for EU and Monaco VAT, HMRC for UK and Isle of Man VAT, Brreg for Norway, the UID register for Switzerland, and ABN Lookup for Australia where configured. A verified answer counts for 30 days; after that the number is checked again when the invoice is taxed. A number that is unverified, rejected or not checked is charged VAT. One exception: when a registry is down, the number's format is accepted instead, but only if you turned that on in your tax settings. The same rule applies to API invoices, quotes, renewals and checkouts.
Create a draft quote in one itemLocalCurrency. Stored like an invoice: itemLocalCurrency, itemUsdToLocalCurrencyRate, and each of subtotal, tax and total in the currency's smallest unit and in USD cents. quoteNumber is the next number in your own sequence, QT-nnnn-XXXX (XXXX: the last four characters of your merchant id); quotes numbered before this keep their original QT-nnnn. Accepting it creates an invoice with the same currency, rate and amounts. Errors: 400 VALIDATION_ERROR (unsupported currency), 404 NOT_FOUND (customer), 400 PRICE_NOT_FOUND / PRICE_NOT_QUOTABLE / CURRENCY_MISMATCH / PRICE_AMOUNT_MISMATCH (lineItems[].priceId). Requires invoices:write. Returns 201.
Body { status: "accepted" | "canceled" } and/or { notes, expiresAt }, for a draft or open quote. Accepting creates the invoice (due after your payment terms) and emails it to the customer exactly like POST /api/v1/invoices/:id/send (invoice_sent, invoice marked sent with sentAt), once per quote. The response carries invoiceDelivery: { status: "sent" | "paid_by_credit" | "not_sent", invoiceId, code?, message? }. not_sent (code NO_RECIPIENT or EMAIL_SEND_FAILED) means the quote is accepted and invoiced but the invoice stays a draft and was not emailed; you get a dashboard notification and send it with POST /api/v1/invoices/:id/send. Errors: 409 INVALID_STATE / ALREADY_ANSWERED, 422 QUOTE_EXPIRED / CUSTOMER_NOT_FOUND, 400 VALIDATION_ERROR. Requires invoices:write.
Payment Links
Shareable links to a hosted payment page at /pay/{slug}. The slug is the link's url field. Requires payment_links:read or payment_links:write.
Create a payment link with status active. Unknown body fields return 400 VALIDATION_ERROR. Returns 201 and dispatches payment_link.created.
Return a paginated list of payment links, newest first.
Retrieve a single payment link by ID.
Update a payment link, e.g. to rename or deactivate it. Only the fields below are accepted; unknown or server-managed fields (e.g. paymentCount, itemLocalCurrency) return 400 VALIDATION_ERROR, and an empty body returns 400. An unknown link returns 404 NOT_FOUND; any other failure returns 500 INTERNAL_ERROR.
Public endpoint. Resolve a payment link by slug (or ID). Returns 410 LINK_INACTIVE if the link is not active.
Public endpoint called by the hosted payment page. Supports card and UPI. Returns 410 LINK_INACTIVE for inactive links.
Webhooks
Register HTTPS endpoints to receive event notifications. Deliveries are signed with HMAC-SHA256 using the endpoint's signing secret. Reads require webhooks:read; every write, including redelivery, requires webhooks:write.
Register a webhook endpoint. A whsec_ signing secret is generated and returned in full in this response only. Unknown body fields are rejected. Returns 201. Honours Idempotency-Key.
Return all webhook endpoints for your account, newest first. Not paginated. signingSecret is masked (whsec_… plus its last 4 characters); use reveal-secret for the full value.
Return one webhook endpoint (webhooks:read). signingSecret is masked. 404 NOT_FOUND when it does not exist or belongs to another account.
Return the endpoint's current signing secret in full. Requires account:write. Each reveal is recorded in the activity log as webhook_endpoint.secret_revealed. Limited to 10 per hour per person (429 RATE_LIMITED with Retry-After).
Update a webhook endpoint. Only the fields below are accepted; unknown fields return 400 VALIDATION_ERROR. signingSecret is masked in the response.
Generate a new signing secret. The previous secret stays valid for a 24-hour grace period.
Return delivery logs for your endpoints, newest first. Accepts endpointId, page, and pageSize (default 25).
Redeliver a logged event to its endpoint as a new signed delivery, keeping the original event id when the log holds the full event. Returns 200; data.success reflects the endpoint's answer. Errors: 404 NOT_FOUND when the log does not exist or belongs to another account; 409 ENDPOINT_INACTIVE when the endpoint is disabled (re-enable it first).
Same redelivery as replay, returned as the new delivery log entry (status success or failed). Same 404 NOT_FOUND and 409 ENDPOINT_INACTIVE errors.
Server-sent events (text/event-stream) of every webhook event dispatched for your account, with or without registered endpoints. Scope webhooks:read. The first message is event ready with { merchantId, livemode, signingSecret } (your CLI signing secret, created on first use); then one event webhook with { type, envelope } per event, where envelope is the exact event endpoints receive. Used by ph listen; events are not replayed after a reconnect.
Publish a sample event built by the real payload builders to your open streams only; it is never delivered to registered endpoints. Body { eventType } (a known event type, else 400 VALIDATION_ERROR). Returns 201 { eventId, type }. The sample has livemode false and metadata.simulated = 'true'. Scope webhooks:write; 20 per minute (429 RATE_LIMITED).
Replace the CLI signing secret. Returns 200 { signingSecret }. Streams opened afterwards sign with the new secret; restart running ph listen sessions. Scope webhooks:write.
Try it
Send requests from the browser. Paste a phk_live_ secret key, pick an endpoint, and edit the body. Requests run against your account in its current mode; switch the account to test mode first to avoid real charges.
API Explorer
Error Codes
2xx = success, 4xx = client error, 5xx = server or upstream fault. Errors return data: null and an error object with code and message, plus fields for validation errors. Update (PUT) endpoints accept only their documented fields: an unknown or server-managed field returns 400 VALIDATION_ERROR with that field named in fields. See the Error Codes page for every code.
| Code | Status | Description |
|---|---|---|
400 | Bad Request | Invalid parameters or body (VALIDATION_ERROR), or a state error such as SESSION_CLOSED. |
401 | Unauthorized | Missing or invalid API key or session (UNAUTHORIZED). |
402 | Payment Required | Checkout payment blocked by fraud screening (FRAUD_BLOCKED). |
403 | Forbidden | Not allowed, or the API key lacks a scope (FORBIDDEN, INSUFFICIENT_SCOPE). |
404 | Not Found | The resource does not exist or belongs to another account. |
409 | Conflict | Conflicts with current state, e.g. IDEMPOTENCY_CONFLICT, SESSION_ALREADY_COMPLETED, DUPLICATE_EMAIL, or ENDPOINT_INACTIVE. |
410 | Gone | Payment link inactive (LINK_INACTIVE) or checkout session expired (EXPIRED). |
422 | Unprocessable | Valid request that the resource's state does not allow (INVALID_STATE), or a forced gateway with no matching connection (GATEWAY_NOT_CONNECTED). |
429 | Rate Limited | Returned by endpoints with their own limiter, such as sign-in (RATE_LIMITED). |
500 | Server Error | Unexpected server error (INTERNAL_ERROR), including a fraud-screening outage, which rejects the checkout payment. Retry with backoff. |
502 | Bad Gateway | An upstream gateway or provider failed, e.g. GATEWAY_REJECTED or SCHEDULING_FAILED. |