Payments
Products, prices, customers, transactions, refunds and subscriptions.
Products
A product is something you sell. Its name, description and image show on the checkout. Give it to a project with project_id if you sell through more than one app or site.
curl https://billing-sandbox-api.munimtech.com/v1/products \
-H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Pro", "description": "Everything in Acme Notes", "metadata": {"plan": "pro"}}'
# Archive it: it can't be bought in new checkouts
curl https://billing-sandbox-api.munimtech.com/v1/products/pro_… \
-H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"status": "archived"}'const product = await munim.products.create({
name: 'Pro',
description: 'Everything in Acme Notes',
metadata: { plan: 'pro' },
})
// Archive it: it can't be bought in new checkouts
await munim.products.update(product.id, { status: 'archived' })namestringrequired- Shown on the checkout.
descriptionstring- Shown under the name.
image_urlstring- An https:// image.
tax_codestring- Stripe Tax code. Default
txcd_10103001(SaaS for business);txcd_10103000is SaaS for personal use,txcd_10000000digital downloads. project_idstring- prj_… the app or website it belongs to.
metadataobject- Your own key/value strings, up to 20 keys.
Prices
A price is an amount in cents for a product, one-time or recurring. A product can have many prices (monthly, yearly, lifetime). A price’s amount can’t change; make a new price and archive the old one. Existing subscribers stay on the price they bought.
# $9.99 a month with a 7-day trial
curl https://billing-sandbox-api.munimtech.com/v1/prices \
-H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"product_id": "pro_…", "unit_amount": 999, "currency": "usd",
"type": "recurring", "interval": "month", "trial_days": 7}'
# $49 once
curl https://billing-sandbox-api.munimtech.com/v1/prices \
-H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"product_id": "pro_…", "unit_amount": 4900, "currency": "usd", "type": "one_time"}'// $9.99 a month with a 7-day trial
const monthly = await munim.prices.create({
product_id: product.id,
unit_amount: 999,
currency: 'usd',
type: 'recurring',
interval: 'month',
trial_days: 7,
})
// $49 once
const lifetime = await munim.prices.create({
product_id: product.id,
unit_amount: 4900,
currency: 'usd',
type: 'one_time',
})product_idstringrequired- pro_…
unit_amountintegerrequired- Cents, at least 50 (999 = $9.99).
currencystringrequired- Only
usd. typestringrequiredone_timeorrecurring.intervalstring- Recurring:
day,week,monthoryear. interval_countinteger- Bill every N intervals. Default 1.
trial_daysinteger- Free trial days, for recurring prices.
descriptionstring- A label such as “Monthly”.
metadataobject- Up to 20 keys.
Customers
A customer is made the first time someone pays. Look one up with GET /v1/customers?email=…, and pass customer_id to a checkout to attach a purchase to an existing customer. Your own user id (app_user_id) is separate: it’s what entitlements use.
Checkouts
A checkout is a hosted payment page for one price. Create one per purchase on your server and send the customer to its url. List them with GET /v1/checkouts, filtered by status (open, completed, expired), project_id, customer_id or app_user_id. Everything about opening and styling them is on the Checkout page.
Transactions
Every payment is a transaction: one-time sales, the first payment of a subscription (kind: new), and each renewal (kind: renewal). It carries Munim’s fee and what you earn.
{
"id": "txn_…",
"object": "transaction",
"status": "completed",
"kind": "new",
"processor": "stripe",
"payment_method": "apple_pay",
"project_id": "prj_…",
"customer_id": "ctm_…",
"checkout_id": "chk_…",
"subscription_id": "sub_…",
"product_id": "pro_…",
"price_id": "pri_…",
"pricing_quote_id": null,
"amount": 999,
"currency": "usd",
"tax": 0,
"fee": 100,
"net": 899,
"refunded_amount": 0,
"metadata": {},
"created_at": 1764460800000
}| Field | Meaning |
|---|---|
amount | What the customer paid, tax included. |
tax | Sales tax or VAT inside amount. Munim remits it; it isn't part of your earnings. |
fee | Munim's fee for this sale. |
net | What you earn. |
status | completed, partially_refunded, refunded or disputed. |
payment_method | card, apple_pay, paypal, venmo, link, cashapp, … |
Filter the list by customer_id, subscription_id or project_id. Add include=customer_email to get each customer’s email inline.
Refunds
Refund all of a payment or part of it. The refunded amount comes out of your balance; Munim’s fee isn’t returned. In live mode this returns real money.
# Everything not yet refunded
curl -X POST https://billing-sandbox-api.munimtech.com/v1/transactions/txn_…/refund -H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY"
# $5.00 of it
curl https://billing-sandbox-api.munimtech.com/v1/transactions/txn_…/refund \
-H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 500}'await munim.transactions.refund('txn_…') // everything
await munim.transactions.refund('txn_…', { amount: 500 }) // $5.00The transaction comes back with refunded_amount updated, and a transaction.refunded event goes to your webhooks.
Subscriptions
A checkout for a recurring price starts a subscription. Statuses: incomplete, trialing, active, past_due, paused, canceled. Each renewal is a new transaction.
# At the end of the paid period (default)
curl -X POST https://billing-sandbox-api.munimtech.com/v1/subscriptions/sub_…/cancel -H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY"
# Right now
curl https://billing-sandbox-api.munimtech.com/v1/subscriptions/sub_…/cancel \
-H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"at_period_end": false}'
# A page where the customer manages it themselves
curl -X POST https://billing-sandbox-api.munimtech.com/v1/subscriptions/sub_…/manage_url -H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY"await munim.subscriptions.cancel('sub_…') // at period end
await munim.subscriptions.cancel('sub_…', { at_period_end: false }) // right now
const { url, expires_at } = await munim.subscriptions.manageUrl('sub_…')Canceling at period end sets cancel_at_period_end; the customer keeps access until current_period_end. The manage link opens a Munim-hosted page where the customer can see and cancel their subscription.
Lists and pagination
Lists are newest first and take limit (1 to 100, default 25) and cursor. They return { object: "list", data, has_more, next_cursor }; pass next_cursor back as cursor for the next page. In the SDK, list.all() walks every page for you.
curl "https://billing-sandbox-api.munimtech.com/v1/transactions?limit=100&project_id=prj_…" -H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY"
# Next page: ...&cursor=<next_cursor>// One page
const page = await munim.transactions.list({ limit: 100 })
// { object: 'list', data: [...], has_more: true, next_cursor: '…' }
// Every item, page by page
let total = 0
for await (const txn of munim.transactions.list.all({ limit: 100 })) {
if (txn.created_at < startOfMonth) break // newest first
total += txn.net
}