Skip to content

Reference

API reference

Every endpoint and object, with each call in curl and Node.

View as Markdown

Base URL: https://pay.perly.io/api/v1v1.0.0

Authenticate with your secret key as a bearer token: sk_test_… works in test mode, sk_live_… in live. The key decides the mode. A key stops working when the team member who made it leaves or may no longer manage keys: make your server's key as an owner, or make a new one then.

Send an Idempotency-Key with every POST: a retry with the same key returns the first answer for 24 hours. The SDKs do it for you.

An error answers { "error": { "type", "code", "message", "param" } } with a 4xx or 5xx. A call from a place Perly Pay can't be used, your own server's included, gets 451 with code region_blocked (Sanctions and risk). Amounts in fiat are integers in cents; on-chain amounts are integer strings in the asset's smallest unit.

curl https://pay.perly.io/api/v1/invoices \
  -H "Authorization: Bearer sk_test_…"

The calls below use these clients: pay (Node) and $perly (PHP). See SDKs.

Invoices

GET/invoices

List invoices

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
status (query)
string
customer (query)
stringA customer id, cus_….
subscription (query)
stringA subscription id, sub_….

Returnsa page of Invoice

curl "https://pay.perly.io/api/v1/invoices?status=paid&limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/invoices

Create an invoice

Lines are prices ({ price, quantity }) or your own ({ description, amount, quantity }), in one currency. For a single amount, amount + description is short for one line. customer is an id or { email }. A price line may carry its own description ("Seat #12"), and discount takes an amount off this invoice alone. The buyer pays at url, choosing bitcoin or a stablecoin there. Live mode: a new invoice is refused with 403 bill_overdue while a Perly Pay bill is unpaid past its 14 days, until it is paid in the dashboard's Billing; invoices already made are still paid.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

line_items
object[]
amount
integerOne amount instead of line_items in minor units (cents), an integer.
description
stringWith amount: what it is for.
currency
"USD" | "EUR"For lines without a price. Default: your account's currency.
customer
string | objectA customer id, or { email } to find or make one.
customer_email
stringWithout customer: finds or makes the customer by email.
coupon
string
discount
integerA one-off amount off this invoice (a credit you owe the buyer; not with coupon) in minor units (cents), an integer.
subscription
stringA subscription id, sub_….
return_url
stringWhere the buyer's page sends them back.
expires_in_minutes
integerUntil when a rail may be chosen.
locale
string
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsInvoice

curl https://pay.perly.io/api/v1/invoices \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "line_items": [
      {
        "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
        "quantity": 1
      }
    ],
    "customer_email": "ada@example.com",
    "metadata": {
      "order_id": "1042"
    }
  }'
GET/invoices/{id}

Retrieve an invoice

Parameters

idrequired
string

ReturnsInvoice

curl https://pay.perly.io/api/v1/invoices/inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/invoices/{id}/cancel

Cancel an invoice

Only while nothing has arrived. Money that arrives later is still seen (the address stays watched) and lands in review.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

ReturnsInvoice

curl https://pay.perly.io/api/v1/invoices/inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/cancel \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'

Test mode

POST/invoices/{id}/simulate

Simulate a payment (test mode only)

Test keys only. full pays the amount due: the invoice turns paid and is fulfilled — entitlements, license keys, a receipt, and the events your webhooks get. short sends half (underpaid), over a tenth more (overpaid); those two need the buyer's chain and asset chosen first. For full, an invoice with no chain yet gets one: chain and asset if given, else the first stablecoin offered (refund terms count as accepted).

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

outcome
"full" | "short" | "over"Default full.
chain
string
asset
"BTC" | "USDC" | "USDT"

ReturnsInvoice

curl https://pay.perly.io/api/v1/invoices/inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/simulate \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"outcome":"full"}'

Checkout sessions

GET/checkout_sessions

List checkout sessions

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
status (query)
"open" | "complete" | "expired"
customer (query)
stringA customer id, cus_….

Returnsa page of CheckoutSession

curl "https://pay.perly.io/api/v1/checkout_sessions?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/checkout_sessions

Create a checkout session

A cart of 1–20 prices in one currency. Send the buyer to url, or open it in an overlay with pay.js (data-session="cs_…"). The buyer comes back to return_url after paying, cancel_url if they leave. Live mode: a new session is refused with 403 bill_overdue while a Perly Pay bill is unpaid past its 14 days.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

line_itemsrequired
object[]
return_url
stringAn http(s) URL.
cancel_url
stringAn http(s) URL.
customer
stringA customer id, cus_….
customer_email
string
coupon
stringA coupon code.
expires_in_minutes
integerDefault 1440 (24 hours).
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsCheckoutSession

curl https://pay.perly.io/api/v1/checkout_sessions \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "line_items": [
      {
        "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
        "quantity": 1
      }
    ],
    "return_url": "https://shop.example/thanks",
    "cancel_url": "https://shop.example/cart",
    "metadata": {
      "order_id": "1042"
    }
  }'
GET/checkout_sessions/{id}

Retrieve a checkout session

Parameters

idrequired
string

ReturnsCheckoutSession

curl https://pay.perly.io/api/v1/checkout_sessions/cs_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/checkout_sessions/{id}/expire

Expire a checkout session

The buyer can no longer pay it. Only an open session.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

ReturnsCheckoutSession

curl https://pay.perly.io/api/v1/checkout_sessions/cs_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/expire \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'
GET/embed/checkout_sessions/{id}no key needed

Open a checkout session's page

Public. Redirects (302) to the session's hosted checkout. pay.js uses it; origin (your page's origin) marks it as embedded so the page can talk back to pay.js.

Parameters

idrequired
string
origin (query)
string
  • 302A redirect (Location) to the page.
curl
curl https://pay.perly.io/api/v1/embed/checkout_sessions/cs_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50

Products

GET/products

List products

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
active (query)
"true" | "false"

Returnsa page of Product

curl "https://pay.perly.io/api/v1/products?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/products

Create a product

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

namerequired
string
description
string
image_url
string
issues_license
booleanIssue a license key with every purchase.
license_activation_limit
integerInstances a key may be active on.
active
boolean
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsProduct

curl https://pay.perly.io/api/v1/products \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pro plan",
    "description": "Everything in Pro, for a year."
  }'
GET/products/{id}

Retrieve a product

Parameters

idrequired
string

ReturnsProduct

curl https://pay.perly.io/api/v1/products/prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/products/{id}

Update a product

Set active: false to stop selling it; products are never deleted (invoices point at them).

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

name
string
description
string | null
image_url
string | null
issues_license
booleanIssue a license key with every purchase.
license_activation_limit
integer | nullInstances a key may be active on.
active
boolean
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsProduct

curl https://pay.perly.io/api/v1/products/prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"description":"Everything in Pro, for a year, with support."}'

Prices

GET/prices

List prices

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
product (query)
stringA product id, prod_….
model (query)
"one_time" | "pay_what_you_want" | "fixed_term" | "subscription" | "lifetime" | "credit_pack"
active (query)
"true" | "false"

Returnsa page of Price

curl "https://pay.perly.io/api/v1/prices?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/prices

Create a price

Every model: one_time, pay_what_you_want (with a minimum), fixed_term (N days of access), subscription (interval, trial, grace, prepay), lifetime (optional cap and cohort tiers), credit_pack. Amounts are immutable; make a new price to change one.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

productrequired
stringA product id, prod_….
currency
"USD" | "EUR"USD or EUR. Default: your account's currency.
nickname
string
refunds
objectRefund terms the buyer accepts at checkout.
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.
modelrequired
"one_time"
unit_amountrequired
integerAmount in minor units (cents), an integer.

ReturnsPrice

curl https://pay.perly.io/api/v1/prices \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "model": "one_time",
    "unit_amount": 4900,
    "currency": "USD"
  }'
GET/prices/{id}

Retrieve a price

Parameters

idrequired
string

ReturnsPrice

curl https://pay.perly.io/api/v1/prices/price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/prices/{id}

Update a price

Nickname, active, refund terms (refunds replaces them whole; what you leave out takes its default) and metadata. Amounts and the model never change.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

nickname
string | null
active
boolean
refunds
objectRefund terms the buyer accepts at checkout.
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsPrice

curl https://pay.perly.io/api/v1/prices/price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"nickname":"Launch price"}'

Customers

GET/customers

List customers

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
email (query)
string
external_id (query)
string

Returnsa page of Customer

curl "https://pay.perly.io/api/v1/customers?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/customers

Create a customer

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

email
string
name
string
external_id
stringYour own id for this buyer (unique).
country
stringISO 3166-1 alpha-2.
locale
string
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsCustomer

curl https://pay.perly.io/api/v1/customers \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "ada@example.com",
    "name": "Ada Lovelace",
    "external_id": "user_42"
  }'
GET/customers/{id}

Retrieve a customer

Parameters

idrequired
string

ReturnsCustomer

curl https://pay.perly.io/api/v1/customers/cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/customers/{id}

Update a customer

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

email
string | null
name
string | null
external_id
stringYour own id for this buyer (unique).
country
stringISO 3166-1 alpha-2.
locale
string
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsCustomer

curl https://pay.perly.io/api/v1/customers/cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"name":"Ada King"}'

Subscriptions

GET/subscriptions

List subscriptions

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
status (query)
string
customer (query)
stringA customer id, cus_….
price (query)
stringA price id, price_….

Returnsa page of Subscription

curl "https://pay.perly.io/api/v1/subscriptions?status=active&limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/subscriptions

Create a subscription

Renewed by invoice: the customer pays each period themselves. Without a trial the first invoice opens now (latest_invoice); the subscription turns active when it is paid.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

customerrequired
stringA customer id, cus_….
pricerequired
stringA subscription price.
quantity
integer
coupon
string
trial_days
integerDefault: the price's.
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsSubscription

curl https://pay.perly.io/api/v1/subscriptions \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50"
  }'
GET/subscriptions/{id}

Retrieve a subscription

Parameters

idrequired
string

ReturnsSubscription

curl https://pay.perly.io/api/v1/subscriptions/sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/subscriptions/{id}

Update a subscription

price: change plan — an upgrade applies now (prorated), a downgrade at the period end (pending_price). cancel_at_period_end: stop renewing, or take that back.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

price
stringA price id, price_….
cancel_at_period_end
boolean
metadata
mapYour own key–value pairs (≤ 50 keys, values ≤ 500 characters). On an update they are merged in; an empty value removes its key.

ReturnsSubscription

curl https://pay.perly.io/api/v1/subscriptions/sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"cancel_at_period_end":true}'
POST/subscriptions/{id}/cancel

Cancel a subscription

Now, or with at_period_end: true when the paid period runs out.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

at_period_end
boolean

ReturnsSubscription

curl https://pay.perly.io/api/v1/subscriptions/sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/cancel \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"at_period_end":true}'
POST/subscriptions/{id}/pause

Pause a subscription

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

ReturnsSubscription

curl https://pay.perly.io/api/v1/subscriptions/sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/pause \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'
POST/subscriptions/{id}/resume

Resume a paused subscription

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

ReturnsSubscription

curl https://pay.perly.io/api/v1/subscriptions/sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/resume \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'
POST/subscriptions/{id}/prepay

Invoice several periods ahead

Opens one invoice for periods periods (up to the price's prepay_max_periods); paying it moves the period on.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

periodsrequired
integer

ReturnsInvoice

curl https://pay.perly.io/api/v1/subscriptions/sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/prepay \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"periods":3}'

Coupons

GET/coupons

List coupons

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
active (query)
"true" | "false"
code (query)
string

Returnsa page of Coupon

curl "https://pay.perly.io/api/v1/coupons?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/coupons

Create a coupon

Give percent_off, or amount_off with its currency.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

coderequired
stringWhat the buyer types. Case does not matter.
percent_off
integer
amount_off
integerAmount off in minor units (cents), an integer.
currency
"USD" | "EUR"USD or EUR.
duration
"once" | "repeating" | "forever"For subscriptions: once (default), repeating, forever.
duration_periods
integerWith duration repeating.
max_redemptions
integer
products
string[]Only these products. Empty: every product.
expires_at
string

ReturnsCoupon

curl https://pay.perly.io/api/v1/coupons \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"code":"WELCOME10","percent_off":10}'
GET/coupons/{id}

Retrieve a coupon

Parameters

idrequired
string

ReturnsCoupon

curl https://pay.perly.io/api/v1/coupons/cpn_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/coupons/{id}

Update a coupon

Turn it off, move its end, or change how many may use it. What it takes off never changes.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

active
boolean
expires_at
string | null
max_redemptions
integer | null

ReturnsCoupon

curl https://pay.perly.io/api/v1/coupons/cpn_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"max_redemptions":100}'

Entitlements

GET/entitlements/check

Check access

One call: may this customer use this product now? Name the customer by customer, customer_email or customer_external_id, and the product by product (or price).

Parameters

customer (query)
stringA customer id, cus_….
customer_email (query)
string
customer_external_id (query)
string
product (query)
stringA product id, prod_….
price (query)
stringA price id, price_….

ReturnsEntitlementCheck

curl "https://pay.perly.io/api/v1/entitlements/check?customer_email=ada%40example.com&product=prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50" \
  -H "Authorization: Bearer sk_test_…"
GET/entitlements

List entitlements

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
customer (query)
stringA customer id, cus_….
product (query)
stringA product id, prod_….
subscription (query)
stringA subscription id, sub_….

Returnsa page of Entitlement

curl "https://pay.perly.io/api/v1/entitlements?limit=10" \
  -H "Authorization: Bearer sk_test_…"
GET/entitlements/{id}

Retrieve an entitlement

Parameters

idrequired
string

ReturnsEntitlement

curl https://pay.perly.io/api/v1/entitlements/ent_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/entitlements/{id}/consume

Spend credits

Spends credits from one credit pack, atomically. Refused when fewer are left. action labels the spend for your reports; with an Idempotency-Key a retry never spends twice. To spend from a customer's packs together, use POST /credits/consume.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

creditsrequired
integer
action
stringYour label for what the credits paid for.

ReturnsEntitlement

curl https://pay.perly.io/api/v1/entitlements/ent_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/consume \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"credits":1,"action":"chat"}'

Credits

GET/credits/balance

Retrieve a credit balance

What a customer has left to spend — on one product's credit packs (product), or on all of them — with the buyer's own top_up_url: a stable page where they choose a pack and pay. Show it, or send it when low.

Parameters

customer (query)
stringA customer id, cus_….
customer_email (query)
string
customer_external_id (query)
string
product (query)
stringA product id, prod_….

ReturnsCreditBalance

curl "https://pay.perly.io/api/v1/credits/balance?customer_external_id=user_42&product=prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50" \
  -H "Authorization: Bearer sk_test_…"
POST/credits/consume

Spend credits

Spends credits from the customer's packs — of product, or of any — oldest first, atomically, never below zero. Refused with insufficient_credits (409) when fewer are left; nothing is spent then. Send an Idempotency-Key: a retry with it returns the first spend and never spends twice, however late it comes. Crossing the product's low-balance threshold sends credits.low; reaching zero, credits.depleted.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

customer
stringA customer id, cus_….
customer_email
string
customer_external_id
string
creditsrequired
integer
product
stringA product id, prod_….
action
stringYour label for what the credits paid for (chat, image.hd, api/search). Shows in your dashboard by action.

ReturnsCreditUsage

curl https://pay.perly.io/api/v1/credits/consume \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"customer_external_id":"user_42","credits":1,"action":"chat"}'
GET/credits/usage

List credit spends

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
customer (query)
stringA customer id, cus_….
product (query)
stringA product id, prod_….
action (query)
stringYour label for what the credits paid for (chat, image.hd, api/search). Shows in your dashboard by action.

Returnsa page of CreditUsage

curl "https://pay.perly.io/api/v1/credits/usage?customer=cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50&action=chat&limit=10" \
  -H "Authorization: Bearer sk_test_…"

License keys

POST/license_keys/validateno key needed

Validate a license key

Public: call it from your app with the license key and your product, no secret key. product is required (parameter_missing without it): a key of any other product or account answers wrong_product. With instance (an activation id) or instance_name, also checks that this instance is activated.

Body

keyrequired
stringXXXXX-XXXXX-XXXXX-XXXXX
product
stringYour product, prod_…. Required unless you call with your secret key: a key for any other product, or from another account, is refused.
merchant
stringYour account's slug. Only needed if two accounts ever share a key (practically never).
livemode
booleanOptional: true accepts only a live key, false only a test-mode one. Your product's own mode either way.
instance
stringAn activation id, act_….
instance_name
stringYour name for the machine or site, e.g. a hostname.

ReturnsLicenseCheck

curl https://pay.perly.io/api/v1/license_keys/validate \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PERLY-8KQ2-X7LM-4N9P",
    "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50"
  }'
POST/license_keys/activateno key needed

Activate a license key on an instance

Public, with the license key and your product (required). Activating the same instance_name again returns its activation. Refused (limit_reached) when the key is active on as many instances as it allows.

Body

keyrequired
stringXXXXX-XXXXX-XXXXX-XXXXX
product
stringYour product, prod_…. Required unless you call with your secret key: a key for any other product, or from another account, is refused.
merchant
stringYour account's slug. Only needed if two accounts ever share a key (practically never).
livemode
booleanOptional: true accepts only a live key, false only a test-mode one. Your product's own mode either way.
instance_namerequired
stringYour name for the machine or site, e.g. a hostname.

ReturnsLicenseCheck

curl https://pay.perly.io/api/v1/license_keys/activate \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PERLY-8KQ2-X7LM-4N9P",
    "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "instance_name": "ada-laptop"
  }'
POST/license_keys/deactivateno key needed

Deactivate a license key on an instance

Public, with the license key and your product (required). Frees a seat: give the activation id (instance) or the instance_name.

Body

keyrequired
stringXXXXX-XXXXX-XXXXX-XXXXX
product
stringYour product, prod_…. Required unless you call with your secret key: a key for any other product, or from another account, is refused.
merchant
stringYour account's slug. Only needed if two accounts ever share a key (practically never).
livemode
booleanOptional: true accepts only a live key, false only a test-mode one. Your product's own mode either way.
instance
string
instance_name
stringYour name for the machine or site, e.g. a hostname.

ReturnsLicenseCheck

curl https://pay.perly.io/api/v1/license_keys/deactivate \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PERLY-8KQ2-X7LM-4N9P",
    "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "instance_name": "ada-laptop"
  }'
GET/license_keys

List license keys

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
customer (query)
stringA customer id, cus_….
product (query)
stringA product id, prod_….
status (query)
"active" | "suspended" | "revoked" | "expired"

Returnsa page of LicenseKey

curl "https://pay.perly.io/api/v1/license_keys?limit=10" \
  -H "Authorization: Bearer sk_test_…"
GET/license_keys/{id}

Retrieve a license key

Parameters

idrequired
string

ReturnsLicenseKey

curl https://pay.perly.io/api/v1/license_keys/lic_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/license_keys/{id}/revoke

Revoke a license key

For good: validation answers revoked from now on.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

ReturnsLicenseKey

curl https://pay.perly.io/api/v1/license_keys/lic_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/revoke \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'

Buyer portal

POST/portal_sessions

Create a buyer-portal link

A one-hour link where your customer sees their subscriptions, receipts and license keys. Make one when they click "Billing" in your app and redirect them to url.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

customerrequired
stringA customer id, cus_….
return_url
stringWhere "Back" goes.

ReturnsPortalSession

curl https://pay.perly.io/api/v1/portal_sessions \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "return_url": "https://shop.example/account"
  }'

Payments

GET/payments

List payments

Transfers seen on chain into addresses we handed out, newest first.

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
invoice (query)
stringA invoice id, inv_….
asset (query)
"BTC" | "USDC" | "USDT"

Returnsa page of Payment

curl "https://pay.perly.io/api/v1/payments?limit=10" \
  -H "Authorization: Bearer sk_test_…"
GET/payments/{id}

Retrieve a payment

Parameters

idrequired
string

ReturnsPayment

curl https://pay.perly.io/api/v1/payments/pay_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"

Refunds

GET/refunds/quote

Quote a refund

What a refund of this invoice would be now: the amount left, today's network fee, what you would send.

Parameters

invoice (query)required
stringA invoice id, inv_….

ReturnsRefundQuote

curl "https://pay.perly.io/api/v1/refunds/quote?invoice=inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50" \
  -H "Authorization: Bearer sk_test_…"
GET/refunds

List refunds

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
invoice (query)
stringA invoice id, inv_….
status (query)
"requested" | "awaiting_address" | "ready_to_send" | "sent" | "confirmed" | "canceled"

Returnsa page of Refund

curl "https://pay.perly.io/api/v1/refunds?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/refunds

Open a refund

Starts a refund in the asset that was paid. We email the buyer a link to give an address; the link is never returned, since whoever holds it decides where the money goes. With no email on the invoice, the owner makes one in the dashboard. When the address is checked, the refund is ready_to_send with amount_to_send. Refused with sanctioned_sender when money on the invoice came from an address on a sanctions list, or one the coin's issuer froze: sending it back may itself be prohibited, so nothing refunds it — leave it and talk to a lawyer.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

invoicerequired
stringA invoice id, inv_….
amount
stringIn the paid asset's smallest unit. Default: everything still refundable.
reason
string

ReturnsRefund

curl https://pay.perly.io/api/v1/refunds \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"invoice":"inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50"}'
GET/refunds/{id}

Retrieve a refund

Parameters

idrequired
string

ReturnsRefund

curl https://pay.perly.io/api/v1/refunds/re_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/refunds/{id}/mark_sent

Record the refund's transaction

After you sent amount_to_send to refund_address. We read that transaction on the network: it must pay the refund address the amount to send. Then the refund is sent (or confirmed, with its receipt, when already deep). This is the only way a refund moves on: a transfer we merely see at the address may be someone else's, so it never counts by itself.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

txidrequired
stringThe transaction hash.

ReturnsRefund

curl https://pay.perly.io/api/v1/refunds/re_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/mark_sent \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "txid": "0x9f1c3e5a7b2d4f6081a3c5e7f9b1d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c3e5b7"
  }'

Receipts

GET/receipts

List receipts

One for every fulfilled payment and every confirmed refund, newest first.

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
invoice (query)
stringA invoice id, inv_….
kind (query)
"payment" | "refund"

Returnsa page of Receipt

curl "https://pay.perly.io/api/v1/receipts?limit=10" \
  -H "Authorization: Bearer sk_test_…"
GET/receipts/{id}

Retrieve a receipt

Parameters

idrequired
string

ReturnsReceipt

curl https://pay.perly.io/api/v1/receipts/rcpt_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
GET/receipts/{id}/pdf

Download a receipt as PDF

Parameters

idrequired
string
locale (query)
string

Returnsapplication/pdf

curl https://pay.perly.io/api/v1/receipts/rcpt_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/pdf \
  -H "Authorization: Bearer sk_test_…" \
  -o receipt.pdf

Events

GET/events

List events

What happened in the last 30 days, newest first. type filters (invoice.paid, or invoice.*).

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.
type (query)
string
object (query)
stringOnly events about this object (inv_…, sub_…).

Returnsa page of Event

curl "https://pay.perly.io/api/v1/events?type=invoice.fulfilled&limit=10" \
  -H "Authorization: Bearer sk_test_…"
GET/events/{id}

Retrieve an event

Parameters

idrequired
string

ReturnsEvent

curl https://pay.perly.io/api/v1/events/evt_1042 \
  -H "Authorization: Bearer sk_test_…"

Webhook endpoints

GET/webhook_endpoints

List webhook endpoints

Parameters

limit (query)
integerHow many objects to return, 1–100. Default 10.
cursor (query)
stringnext_cursor from the previous page.

Returnsa page of WebhookEndpoint

curl "https://pay.perly.io/api/v1/webhook_endpoints?limit=10" \
  -H "Authorization: Bearer sk_test_…"
POST/webhook_endpoints

Create a webhook endpoint

The response carries secret — the only time you see it. Keep it to verify Perly-Signature.

Parameters

Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

urlrequired
string
enabled_events
"*" | string[]Event types to send, or ["*"] for every one.
description
string

ReturnsWebhookEndpoint

curl https://pay.perly.io/api/v1/webhook_endpoints \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://shop.example/webhooks/perly",
    "enabled_events": [
      "invoice.fulfilled",
      "refund.confirmed"
    ]
  }'
GET/webhook_endpoints/{id}

Retrieve a webhook endpoint

Parameters

idrequired
string

ReturnsWebhookEndpoint

curl https://pay.perly.io/api/v1/webhook_endpoints/we_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/webhook_endpoints/{id}

Update a webhook endpoint

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

url
string
enabled_events
"*" | string[]Event types to send, or ["*"] for every one.
description
string | null
disabled
booleanStop sending without deleting it.

ReturnsWebhookEndpoint

curl https://pay.perly.io/api/v1/webhook_endpoints/we_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled_events": [
      "invoice.fulfilled",
      "invoice.expired",
      "refund.confirmed"
    ]
  }'
DELETE/webhook_endpoints/{id}

Delete a webhook endpoint

Parameters

idrequired
string

ReturnsDeleted

curl -X DELETE https://pay.perly.io/api/v1/webhook_endpoints/we_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50 \
  -H "Authorization: Bearer sk_test_…"
POST/webhook_endpoints/{id}/roll_secret

Roll the signing secret

A new secret from now on; the old one stops at once. The response carries the new secret.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

ReturnsWebhookEndpoint

curl https://pay.perly.io/api/v1/webhook_endpoints/we_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/roll_secret \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'
POST/webhook_endpoints/{id}/claim

Claim a delivery

Takes this endpoint's delivery of event once and answers the event. A second claim answers 409 already_claimed; an event never sent to this endpoint answers 404 not_delivered. For apps that cannot verify Perly-Signature themselves, and against replays.

Parameters

idrequired
string
Idempotency-Key (header)
stringAny unique string (a UUID). A retry with the same key returns the first response for 24 hours.

Body

eventrequired
stringThe delivered event's id.

ReturnsEvent

curl https://pay.perly.io/api/v1/webhook_endpoints/we_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50/claim \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"event":"evt_1042"}'

Objects

What the API answers with. Lists wrap them as { "object": "list", "data": […], "has_more", "next_cursor" }; pass next_cursor back as cursor.

Customer

Fields

id
stringcus_…
object
"customer"
livemode
boolean
email
string | null
name
string | null
external_id
string | nullYour own id for this buyer.
country
string | null
locale
string | null
metadata
map
created
stringISO 8601
Customer · JSON
{
  "id": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "customer",
  "livemode": false,
  "email": "ada@example.com",
  "name": "Pro plan",
  "external_id": "user_42",
  "country": "PT",
  "locale": "en",
  "metadata": {
    "order_id": "1042"
  },
  "created": "2026-10-19T09:41:00Z"
}

Product

Fields

id
stringprod_…
object
"product"
livemode
boolean
name
string
description
string | null
image_url
string | null
issues_license
boolean
license_activation_limit
integer | null
active
boolean
metadata
map
created
stringISO 8601
updated
stringISO 8601
Product · JSON
{
  "id": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "product",
  "livemode": false,
  "name": "Pro plan",
  "description": "Everything in Pro, for a year.",
  "image_url": "https://shop.example/thanks",
  "issues_license": true,
  "license_activation_limit": 1,
  "active": true,
  "metadata": {
    "order_id": "1042"
  },
  "created": "2026-10-19T09:41:00Z",
  "updated": "2026-10-19T09:41:00Z"
}

Price

Fields

id
stringprice_…
object
"price"
livemode
boolean
product
stringprod_…
model
"one_time" | "pay_what_you_want" | "fixed_term" | "subscription" | "lifetime" | "credit_pack"
currency
"USD" | "EUR"
nickname
string | null
active
boolean
unit_amount
integer | nullNull for pay-what-you-want and tiered lifetime prices.
custom_amount
object | null
term_days
integer | null
recurring
object | null
lifetime
object | null
credits
integer | null
refunds
object
metadata
map
created
stringISO 8601
Price · JSON
{
  "id": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "price",
  "livemode": false,
  "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "model": "one_time",
  "currency": "USD",
  "nickname": "Launch price",
  "active": true,
  "unit_amount": 4900,
  "custom_amount": {
    "minimum": 4900,
    "suggested": 4900
  },
  "term_days": 14,
  "recurring": {
    "interval": "day",
    "interval_days": 14,
    "trial_days": 14,
    "grace_days": 14,
    "prepay_max_periods": 1,
    "keep_renewal_price": true
  },
  "lifetime": {
    "quantity_cap": 1,
    "tiers": [
      {
        "id": "tier_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
        "position": 1,
        "name": "Pro plan",
        "seats": 1,
        "unit_amount": 4900
      }
    ]
  },
  "credits": 1,
  "refunds": {
    "allowed": true,
    "window_days": 14,
    "network_fee_payer": "buyer"
  },
  "metadata": {
    "order_id": "1042"
  },
  "created": "2026-10-19T09:41:00Z"
}

Coupon

Fields

id
stringcpn_…
object
"coupon"
livemode
boolean
code
string
percent_off
integer | null
amount_off
integer | nullMinor units (cents).
currency
"USD" | "EUR" | null
duration
"once" | "repeating" | "forever"
duration_periods
integer | null
max_redemptions
integer | null
times_redeemed
integer
products
string[]Empty means every product.
expires_at
string | nullISO 8601
active
boolean
created
stringISO 8601
Coupon · JSON
{
  "id": "cpn_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "coupon",
  "livemode": false,
  "code": "WELCOME10",
  "percent_off": 0,
  "amount_off": 0,
  "currency": "USD",
  "duration": "once",
  "duration_periods": 1,
  "max_redemptions": 1,
  "times_redeemed": 1,
  "products": [
    "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50"
  ],
  "expires_at": "2026-10-19T09:41:00Z",
  "active": true,
  "created": "2026-10-19T09:41:00Z"
}

CheckoutSession

Fields

id
stringcs_…
object
"checkout_session"
livemode
boolean
url
stringSend the buyer here, or open it with pay.js.
status
"open" | "complete" | "expired"
currency
"USD" | "EUR"
line_items
object[]
subtotal
integerMinor units (cents).
discount
integerMinor units (cents).
total
integerMinor units (cents).
customer
string | nullcus_…
customer_email
string | null
coupon
string | nullcpn_…
payment_link
string | nullplink_…
return_url
string | null
cancel_url
string | null
invoice
string | nullinv_…
expires_at
stringISO 8601
metadata
map
created
stringISO 8601
CheckoutSession · JSON
{
  "id": "cs_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "checkout_session",
  "livemode": false,
  "url": "https://pay.perly.io/c/cs_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "status": "open",
  "currency": "USD",
  "line_items": [
    {
      "id": "csl_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "quantity": 1,
      "custom_amount": 4900,
      "unit_amount": 4900,
      "amount": 4900
    }
  ],
  "subtotal": 4900,
  "discount": 0,
  "total": 4900,
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "customer_email": "ada@example.com",
  "coupon": "cpn_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "payment_link": "plink_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "return_url": "https://shop.example/thanks",
  "cancel_url": "https://shop.example/cart",
  "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "expires_at": "2026-10-19T09:41:00Z",
  "metadata": {
    "order_id": "1042"
  },
  "created": "2026-10-19T09:41:00Z"
}

Invoice

Fields

id
stringinv_…
object
"invoice"
livemode
boolean
url
stringThe buyer's payment page.
status
string
kind
"checkout" | "payment_link" | "subscription" | "manual" | "api" | "plan"
number
string | null
customer
string | nullcus_…
customer_email
string | null
customer_name
string | null
description
string | null
currency
"USD" | "EUR"
subtotal
integerMinor units (cents).
discount
integerMinor units (cents).
total
integerMinor units (cents).
total_usd
integerWhat is settled, in US cents, locked when the invoice opened.
received_usd
integerMinor units (cents).
pending_usd
integerMinor units (cents).
amount_received
stringInteger string in the asset's smallest unit.
payment
object | nullThe chain and asset the buyer chose; null until then.
lines
object[]
subscription
string | nullsub_…
checkout_session
string | nullcs_…
payment_link
string | nullplink_…
coupon
string | nullcpn_…
receipt_number
string | null
review_reason
string | null
due_at
string | nullISO 8601
paid_at
string | nullISO 8601
fulfilled_at
string | nullISO 8601
canceled_at
string | nullISO 8601
metadata
map
created
stringISO 8601
Invoice · JSON
{
  "id": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "invoice",
  "livemode": false,
  "url": "https://pay.perly.io/i/0b6f2c1e-8d4a-4f3e-9a7b-5c2d1e0f8a9b",
  "status": "open",
  "kind": "checkout",
  "number": "KS-2026-000142",
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "customer_email": "ada@example.com",
  "customer_name": null,
  "description": "Everything in Pro, for a year.",
  "currency": "USD",
  "subtotal": 4900,
  "discount": 0,
  "total": 4900,
  "total_usd": 4900,
  "received_usd": 4900,
  "pending_usd": 4900,
  "amount_received": "49000000",
  "payment": {
    "chain": "base",
    "asset": "USDC",
    "address": "0x7a3f…1e0b",
    "amount_due": "49000000",
    "decimals": 6,
    "btc_usd_cents": 6800000,
    "opened_at": "2026-10-19T09:41:00Z",
    "expires_at": "2026-10-19T09:41:00Z"
  },
  "lines": [
    {
      "id": "il_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "description": "Everything in Pro, for a year.",
      "quantity": 1,
      "unit_amount": 4900,
      "amount": 4900,
      "period_start": "2026-10-19T09:41:00Z",
      "period_end": "2026-10-19T09:41:00Z"
    }
  ],
  "subscription": "sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "checkout_session": "cs_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "payment_link": "plink_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "coupon": "cpn_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "receipt_number": null,
  "review_reason": null,
  "due_at": "2026-10-19T09:41:00Z",
  "paid_at": "2026-10-19T09:41:00Z",
  "fulfilled_at": "2026-10-19T09:41:00Z",
  "canceled_at": "2026-10-19T09:41:00Z",
  "metadata": {
    "order_id": "1042"
  },
  "created": "2026-10-19T09:41:00Z"
}

Subscription

Fields

id
stringsub_…
object
"subscription"
livemode
boolean
status
string
customer
stringcus_…
price
stringprice_…
quantity
integer
current_period_start
stringISO 8601
current_period_end
stringISO 8601
trial_end
string | nullISO 8601
grace_days
integer
cancel_at_period_end
boolean
canceled_at
string | nullISO 8601
ended_at
string | nullISO 8601
paused_at
string | nullISO 8601
pending_price
string | nullA downgrade waiting for the period end.
kept_price
integer | nullThe renewal price this subscriber keeps.
latest_invoice
string | nullinv_…
coupon
string | nullcpn_…
metadata
map
created
stringISO 8601
Subscription · JSON
{
  "id": "sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "subscription",
  "livemode": false,
  "status": "trialing",
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "quantity": 1,
  "current_period_start": "2026-10-19T09:41:00Z",
  "current_period_end": "2026-10-19T09:41:00Z",
  "trial_end": "2026-10-19T09:41:00Z",
  "grace_days": 14,
  "cancel_at_period_end": true,
  "canceled_at": "2026-10-19T09:41:00Z",
  "ended_at": "2026-10-19T09:41:00Z",
  "paused_at": "2026-10-19T09:41:00Z",
  "pending_price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "kept_price": 4900,
  "latest_invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "coupon": "cpn_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "metadata": {
    "order_id": "1042"
  },
  "created": "2026-10-19T09:41:00Z"
}

Entitlement

Fields

id
stringent_…
object
"entitlement"
livemode
boolean
active
booleanStarted, not ended, not revoked.
customer
string | nullcus_…
product
string | nullprod_…
price
string | nullprice_…
model
"one_time" | "pay_what_you_want" | "fixed_term" | "subscription" | "lifetime" | "credit_pack"
subscription
string | nullsub_…
invoice
stringinv_…
starts_at
stringISO 8601
ends_at
string | nullNull = for ever.
credits_total
integer | null
credits_used
integer
credits_remaining
integer | null
tier
string | nulltier_…
seat_number
integer | null
revoked_at
string | nullISO 8601
created
stringISO 8601
Entitlement · JSON
{
  "id": "ent_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "entitlement",
  "livemode": false,
  "active": true,
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "model": "one_time",
  "subscription": "sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "starts_at": "2026-10-19T09:41:00Z",
  "ends_at": "2026-10-19T09:41:00Z",
  "credits_total": 4900,
  "credits_used": 1,
  "credits_remaining": 1,
  "tier": "tier_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "seat_number": 1,
  "revoked_at": "2026-10-19T09:41:00Z",
  "created": "2026-10-19T09:41:00Z"
}

EntitlementCheck

Fields

object
"entitlement_check"
has_access
boolean
customer
string | nullcus_…
product
string | nullprod_…
ends_at
string | nullThe latest end among active entitlements; null = for ever (or none).
credits_remaining
integer | null
entitlements
Entitlement[]
EntitlementCheck · JSON
{
  "object": "entitlement_check",
  "has_access": true,
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "ends_at": "2026-10-19T09:41:00Z",
  "credits_remaining": 1,
  "entitlements": [
    {
      "id": "ent_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "object": "entitlement",
      "livemode": false,
      "active": true,
      "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "price": "price_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "model": "one_time",
      "subscription": "sub_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "starts_at": "2026-10-19T09:41:00Z",
      "ends_at": "2026-10-19T09:41:00Z",
      "credits_total": 4900,
      "credits_used": 1,
      "credits_remaining": 1,
      "tier": "tier_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
      "seat_number": 1,
      "revoked_at": "2026-10-19T09:41:00Z",
      "created": "2026-10-19T09:41:00Z"
    }
  ]
}

CreditBalance

Fields

object
"credit_balance"
livemode
boolean
customer
stringcus_…
product
string | nullNull = every product's credits together.
balance
integerCredits left on active packs.
low_balance_threshold
integer | nullThe product's threshold; null = none set.
low
booleanAt or under the threshold (or zero).
top_up_url
stringThe buyer's own top-up page: stable, safe to email or show in your app.
CreditBalance · JSON
{
  "object": "credit_balance",
  "livemode": false,
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "balance": 1,
  "low_balance_threshold": 1,
  "low": true,
  "top_up_url": "https://shop.example/thanks"
}

CreditUsage

Fields

id
stringcu_…
object
"credit_usage"
livemode
boolean
customer
string | nullcus_…
product
string | nullprod_…
entitlement
string | nullSet when one pack was named.
credits
integer
action
string | nullYour label for what was done (chat, image.hd, …).
balance
integerWhat was left right after.
created
stringISO 8601
CreditUsage · JSON
{
  "id": "cu_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "credit_usage",
  "livemode": false,
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "entitlement": "ent_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "credits": 1,
  "action": null,
  "balance": 1,
  "created": "2026-10-19T09:41:00Z"
}

LicenseKey

Fields

id
stringlic_…
object
"license_key"
livemode
boolean
key
string
status
"active" | "suspended" | "revoked" | "expired"
product
string | nullprod_…
customer
string | nullcus_…
entitlement
stringent_…
activation_limit
integer | null
activations
integer
expires_at
string | nullISO 8601
created
stringISO 8601
LicenseKey · JSON
{
  "id": "lic_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "license_key",
  "livemode": false,
  "key": "PERLY-8KQ2-X7LM-4N9P",
  "status": "active",
  "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "entitlement": "ent_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "activation_limit": 1,
  "activations": 1,
  "expires_at": "2026-10-19T09:41:00Z",
  "created": "2026-10-19T09:41:00Z"
}

LicenseCheck

Fields

object
"license_check"
valid
boolean
reason
string | null
license_key
object | null
activation
object | null
LicenseCheck · JSON
{
  "object": "license_check",
  "valid": true,
  "reason": "not_found",
  "license_key": {
    "key": "PERLY-8KQ2-X7LM-4N9P",
    "livemode": false,
    "status": "active",
    "product": "prod_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "activation_limit": 1,
    "activations": 1,
    "expires_at": "2026-10-19T09:41:00Z"
  },
  "activation": {
    "id": "act_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
    "instance_name": "ada-laptop",
    "active": true,
    "created": "2026-10-19T09:41:00Z"
  }
}

PortalSession

Fields

id
stringbps_…
object
"portal_session"
livemode
boolean
customer
stringcus_…
url
stringShown once. Valid until expires_at.
return_url
string | null
expires_at
stringISO 8601
created
stringISO 8601
PortalSession · JSON
{
  "id": "bps_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "portal_session",
  "livemode": false,
  "customer": "cus_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "url": "https://pay.perly.io/portal/session",
  "return_url": "https://shop.example/thanks",
  "expires_at": "2026-10-19T09:41:00Z",
  "created": "2026-10-19T09:41:00Z"
}

Payment

Fields

id
stringpay_…
object
"payment"
livemode
boolean
invoice
string | nullinv_…
chain
string
asset
"BTC" | "USDC" | "USDT"BTC, USDC or USDT. On arbitrum and optimism, USDT is USDT0 (LayerZero's omnichain USDT); show it as USDT0 there.
token
string | null
txid
string
position
integer
amount
stringInteger string in the asset's smallest unit.
decimals
integer
usd_cents
integer | null
from_address
string | null
to_address
string
block_number
integer | null
confirmations
integer
arrived_at
stringISO 8601
confirmed_at
string | nullISO 8601
dropped_at
string | nullISO 8601
created
stringISO 8601
Payment · JSON
{
  "id": "pay_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "payment",
  "livemode": false,
  "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "chain": "base",
  "asset": "USDC",
  "token": null,
  "txid": "0x9f1c…e5b7",
  "position": 1,
  "amount": "49000000",
  "decimals": 6,
  "usd_cents": 4900,
  "from_address": null,
  "to_address": "…",
  "block_number": 1,
  "confirmations": 3,
  "arrived_at": "2026-10-19T09:41:00Z",
  "confirmed_at": "2026-10-19T09:41:00Z",
  "dropped_at": "2026-10-19T09:41:00Z",
  "created": "2026-10-19T09:41:00Z"
}

Refund

Fields

id
stringre_…
object
"refund"
livemode
boolean
invoice
stringinv_…
payment
string | nullpay_…
status
"requested" | "awaiting_address" | "ready_to_send" | "sent" | "confirmed" | "canceled"
chain
string
asset
"BTC" | "USDC" | "USDT"BTC, USDC or USDT. On arbitrum and optimism, USDT is USDT0 (LayerZero's omnichain USDT); show it as USDT0 there.
decimals
integer
amount
stringInteger string in the asset's smallest unit.
network_fee
string | nullInteger string in the asset's smallest unit.
network_fee_payer
"buyer" | "merchant"
amount_to_send
string | nullInteger string in the asset's smallest unit.
reason
string | null
refund_address
string | null
txid
string | nullThe transaction you named with mark_sent. Only it confirms the refund.
sent_at
string | nullISO 8601
confirmed_at
string | nullISO 8601
canceled_at
string | nullISO 8601
created
stringISO 8601
Refund · JSON
{
  "id": "re_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "refund",
  "livemode": false,
  "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "payment": "pay_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "status": "requested",
  "chain": "base",
  "asset": "USDC",
  "decimals": 6,
  "amount": "49000000",
  "network_fee": "49000000",
  "network_fee_payer": "buyer",
  "amount_to_send": "49000000",
  "reason": "requested_by_customer",
  "refund_address": "0x4b1e…9c2d",
  "txid": "0x9f1c…e5b7",
  "sent_at": "2026-10-19T09:41:00Z",
  "confirmed_at": "2026-10-19T09:41:00Z",
  "canceled_at": "2026-10-19T09:41:00Z",
  "created": "2026-10-19T09:41:00Z"
}

RefundQuote

Fields

object
"refund_quote"
invoice
stringinv_…
refundable
boolean
reason
string | null
chain
string | null
asset
"BTC" | "USDC" | "USDT" | nullBTC, USDC or USDT. On arbitrum and optimism, USDT is USDT0 (LayerZero's omnichain USDT); show it as USDT0 there.
decimals
integer | null
amount
string | nullWhat can still be refunded.
network_fee
string | nullInteger string in the asset's smallest unit.
network_fee_payer
"buyer" | "merchant" | null
amount_to_send
string | nullInteger string in the asset's smallest unit.
RefundQuote · JSON
{
  "object": "refund_quote",
  "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "refundable": true,
  "reason": "requested_by_customer",
  "chain": "base",
  "asset": "USDC",
  "decimals": 6,
  "amount": "49000000",
  "network_fee": "49000000",
  "network_fee_payer": "buyer",
  "amount_to_send": "49000000"
}

Receipt

Fields

id
stringrcpt_…
object
"receipt"
livemode
boolean
kind
"payment" | "refund"
number
string
invoice
stringinv_…
refund
string | nullre_…
url
stringThe public receipt page.
pdf
stringThis API's PDF of it.
customer_email
string | null
currency
"USD" | "EUR"
amount
integerMinor units (cents).
asset
"BTC" | "USDC" | "USDT" | nullBTC, USDC or USDT. On arbitrum and optimism, USDT is USDT0 (LayerZero's omnichain USDT); show it as USDT0 there.
asset_amount
string | nullInteger string in the asset's smallest unit.
decimals
integer | null
issued_at
stringISO 8601
emailed_at
string | nullISO 8601
Receipt · JSON
{
  "id": "rcpt_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "receipt",
  "livemode": false,
  "kind": "payment",
  "number": "KS-2026-000142",
  "invoice": "inv_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "refund": "re_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "url": "https://pay.perly.io/r/KS-2026-000142",
  "pdf": "…",
  "customer_email": "ada@example.com",
  "currency": "USD",
  "amount": 4900,
  "asset": "USDC",
  "asset_amount": "49000000",
  "decimals": 6,
  "issued_at": "2026-10-19T09:41:00Z",
  "emailed_at": "2026-10-19T09:41:00Z"
}

Event

Fields

id
stringevt_…
object
"event"
livemode
boolean
type
string<object>.<verb>, e.g. invoice.paid.
object_type
string
object_id
string | null
data
mapobject: the object the event is about, as the API shows it now; plus what the event recorded.
created
stringISO 8601
Event · JSON
{
  "id": "evt_1042",
  "object": "event",
  "livemode": false,
  "type": "invoice.fulfilled",
  "object_type": "invoice",
  "object_id": null,
  "data": {},
  "created": "2026-10-19T09:41:00Z"
}

WebhookEndpoint

Fields

id
stringwe_…
object
"webhook_endpoint"
livemode
boolean
url
string
description
string | null
enabled_events
string[]* is every event.
status
"enabled" | "disabled"
secret_prefix
string
secret
stringThe signing secret, whsec_…. Only when created or rolled.
created
stringISO 8601
WebhookEndpoint · JSON
{
  "id": "we_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "object": "webhook_endpoint",
  "livemode": false,
  "url": "https://shop.example/webhooks/perly",
  "description": "Everything in Pro, for a year.",
  "enabled_events": [
    "…"
  ],
  "status": "enabled",
  "secret_prefix": "…",
  "secret": "whsec_3f2a9c1e8b7d4a6f9e0c5b1a2d3e4f50",
  "created": "2026-10-19T09:41:00Z"
}

Deleted

Fields

id
string
object
string
deleted
true
Deleted · JSON
{
  "id": "…",
  "object": "…",
  "deleted": true
}