Skip to content

Paddle API

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

Paddle API

Paddle is the client class exported from @tundraconnect/paddle. It extends RESTler, so the usual RESTler options (timeout, maxRetryWait, defaultRetryWait, headers, …) also apply.

Configuration

import { Paddle } from '@tundraconnect/paddle';

const paddle = new Paddle({
  auth: { type: 'BEARER', token: 'pdl_sdbx_apikey_...' },
  environment: 'sandbox', // the default
});
Option Type Notes
auth { type: 'BEARER', token } Required. prefix defaults to Bearer.
environment 'sandbox' | 'live' Defaults to 'sandbox' (https://sandbox-api.paddle.com). 'live' is https://api.paddle.com.
baseURL string Overrides the host, e.g. for a proxy. The key-prefix check still uses environment.
timeout number Seconds. Defaults to 30.
maxRetryWait number Opt in to one retry on a 429 when Paddle's Retry-After is within this many seconds.

API keys made since May 2025 carry their environment in the prefix (pdl_sdbx_apikey_…, pdl_live_apikey_…). A key whose prefix contradicts environment throws CONFIG_ENVIRONMENT_MISMATCH at construction. Older 50-character keys have no prefix and are not checked.

Every request sends Paddle-Version: 1, exported as PADDLE_API_VERSION.

Getters

Getter Returns
environment 'sandbox' or 'live'.
vendor 'Paddle'.

The API key is never readable back off the client.

Validation

Every request body is parsed against its schema before anything is sent. A failure throws REQUEST_VALIDATION_ERROR. Request schemas are strict: an unknown or misspelt field (taxCategory for tax_category) is rejected, not silently dropped. Path ids must be non-empty and are percent-encoded.

Success bodies are validated too. A body that does not match throws RESPONSE_ERROR. Response schemas let unknown fields pass through, so a field Paddle adds later does not break a read.

Amounts

Paddle sends and accepts amounts as strings in the currency's smallest unit: "1999" is $19.99, "1000" is ¥1000. Request schemas reject decimals and negative amounts. A discount's amount is the exception: for percentage it is a percentage ("20", or "12.5").

Lists and paging

Every list* method returns one page:

type PaddlePage<T> = {
  data: T[];
  pagination: { per_page; next; has_more; estimated_total };
  requestId: string;
};

Each takes after (a Paddle id), perPage and orderBy, plus its own filters. List filters take arrays and send them comma-joined. perPage is checked against Paddle's maximum for that list: 30 for transactions, 50 for adjustments, 200 for everything else.

Each listAll* iterator takes the same filters (without after) and a maxPages cap (default DEFAULT_MAX_PAGES, 1000). It reads the after cursor out of pagination.next and re-sends your filters, so it never follows a URL to another host. It stops when has_more is false. When Paddle reports more pages but the cursor does not move, it throws PAGINATION_STALLED rather than loop.

Products and prices

createProduct(request) / getProduct(id) / updateProduct(id, request)

POST /products, GET /products/{id}, PATCH /products/{id}. Paddle never deletes a product: update it with status: 'archived'.

archiveProduct(id) / unarchiveProduct(id)

updateProduct with status: 'archived' or 'active'. Both return the product.

listProducts(options?) / listAllProducts(options?)

Filters: id, status, taxCategory, type.

findProductsByCustomData(match, options?)

Every product whose custom_data holds every entry of match, compared strictly on top-level keys. Paddle can't filter on custom_data, so this walks the product list: one request per page. Active products only unless includeArchived: true. An empty match is a REQUEST_VALIDATION_ERROR.

createPrice(request) / getPrice(id) / updatePrice(id, request)

POST /prices, GET /prices/{id}, PATCH /prices/{id}. Omit billing_cycle for a one-time price. An update cannot move a price to another product.

listPrices(options?) / listAllPrices(options?)

Filters: id, productId, status, recurring, type.

Discounts

createDiscount(request) / getDiscount(id) / updateDiscount(id, request)

flat and flat_per_seat discounts need a currency_code. Codes are 1 to 32 letters or digits; Paddle generates one when code is omitted.

archiveDiscount(id) / unarchiveDiscount(id)

updateDiscount with status: 'archived' or 'active'. An archived code stops working at checkout. Paddle never deletes a discount.

listDiscounts(options?) / listAllDiscounts(options?)

Filters: id, code, status, mode.

getDiscountByCode(code)

The one discount with the code a customer typed, from GET /discounts?code=…. Throws NOT_FOUND when there is none.

Customers and addresses

createCustomer(request) / getCustomer(id) / updateCustomer(id, request)

Emails are unique per account. A duplicate is a CONFLICT, and Paddle's detail names the existing customer.

listCustomers(options?) / listAllCustomers(options?)

Filters: id, email, status, search.

createAddress(customerId, request) / getAddress(customerId, addressId) / listAddresses(customerId, options?) / updateAddress(customerId, addressId, request)

Addresses live under /customers/{customer_id}/addresses. country_code (ISO 3166-1 alpha-2, uppercase) is the only required field. Paddle taxes by it.

createCustomerPortalSession(customerId, options?)

POST /customers/{customer_id}/portal-sessions. Pass up to 25 subscriptionIds for deep links to each. Every returned URL signs the holder in as the customer: send it only to them and never log it.

Transactions

createTransaction(request, options?)

POST /transactions. Items are { price_id, quantity } or a non-catalog { price: {...}, quantity }. With no status it is a checkout. Once ready, checkout.url is the link to send the buyer to; that needs a default payment link in your checkout settings. A manual transaction needs billing_details, and status: 'billed' issues it as an invoice. options.include embeds related entities (customer, address, discount, business, adjustments, …).

getTransaction(id, options?) / isPaid(id)

isPaid is true only for paid and completed.

listTransactions(options?) / listAllTransactions(options?)

Filters: id, customerId, subscriptionId, status, invoiceNumber, origin, collectionMode, include, and the date ranges createdAt, updatedAt and billedAt ({ lt, lte, gt, gte }, sent as created_at[GTE]=…). At most 30 per page.

updateTransaction(id, request)

Only draft and ready transactions change. status: 'canceled' also voids a billed one.

getTransactionInvoice(id, options?)

{ url } of the invoice PDF, valid for an hour. disposition: 'inline' opens it in the browser instead of downloading.

Subscriptions

Paddle creates a subscription when a checkout for a recurring price completes; there is no create call.

getSubscription(id) / listSubscriptions(options?) / listAllSubscriptions(options?)

Filters: id, customerId, addressId, priceId, status, collectionMode, scheduledChangeAction.

updateSubscription(id, request)

PATCH /subscriptions/{id}. items is the COMPLETE new list: an item you leave out is removed. Changing items or next_billed_at needs a proration_billing_mode, which the client enforces locally:

Mode Effect
prorated_immediately Charge or credit the difference now.
prorated_next_billing_period Add the difference to the next renewal.
full_immediately Charge the full new price now.
full_next_billing_period Charge the full new price at renewal.
do_not_bill Change without charging.

changePlan(id, { items, proration_billing_mode, on_payment_failure? })

updateSubscription narrowed to a plan change, with proration_billing_mode required. Paddle applies the change at once, so there is no scheduled plan change to cancel later.

removeScheduledChange(id)

Sends scheduled_change: null to drop a pending cancel, pause or resume.

undoScheduledCancellation(id)

Reads the subscription and clears scheduled_change only when it holds a cancel. Paddle keeps one slot for cancel, pause and resume, so this never drops a scheduled pause. With no scheduled cancellation it returns the subscription unchanged.

cancelSubscription(id, request?)

Cancels at the end of the paid period by default. effective_from: 'immediately' ends it now. A paused subscription can only be canceled immediately.

pauseSubscription(id, request?) / resumeSubscription(id, request?)

Pause takes effective_from, resume_at (omit to pause indefinitely) and on_resume. Resume takes effective_from ('immediately', the default, or an RFC 3339 time) and on_resume.

activateSubscription(id)

Ends a trial early and bills now. Only automatically collected trialing subscriptions can be activated.

chargeSubscription(id, request)

A one-time charge of items, immediately or at the next renewal. Paddle allows 20 immediate charges an hour and 100 a day per subscription.

getUpdatePaymentMethodTransaction(id)

A transaction to open with Paddle.js so the customer can replace their card.

Adjustments

createAdjustment(request)

A refund or credit against a billed or completed transaction. type: 'full' covers the whole transaction and takes no items. A partial adjustment (Paddle's default) needs items, and each partial item needs an amount. A refund starts pending_approval. Watch the adjustment.updated webhook for approved or rejected.

listAdjustments(options?) / listAllAdjustments(options?)

Filters: id, transactionId, subscriptionId, customerId, status, action. At most 50 per page.

getAdjustment(id)

The one adjustment with that id, from GET /adjustments?id=… (Paddle has no single-adjustment endpoint). Throws NOT_FOUND when there is none.

createRefund(request) / getRefund(id) / listRefunds(options?) / listAllRefunds(options?)

The adjustment calls with action: 'refund' filled in. getRefund throws NOT_FOUND for an adjustment that is not a refund.

getAdjustmentCreditNote(id, options?)

{ url } of the credit-note PDF, valid for an hour.

Events and webhooks

listEvents(options?) / listAllEvents(options?)

GET /events, filtered by eventType. Paddle keeps 90 days of events. Use the log to catch up on notifications your endpoint missed.

Paddle.verifyWebhook(options) (static) / paddle.verifyWebhook(options)

The instance method calls the static one. Use the static form in a webhook handler that has no API key.

Checks the Paddle-Signature header (ts=…;h1=…): HMAC-SHA256 of <ts>:<rawBody>, keyed by the destination's pdl_ntfset_… secret, in hex. Every h1 is accepted, since Paddle sends two while a secret rotates. The timestamp must be within toleranceSeconds (default 5, Paddle's own setting) in either direction. Returns the parsed EventSchema.

Option Notes
payload The raw body, from await req.text().
headers A Headers object or a plain record.
signature The header value itself, instead of headers.
secret The notification destination's secret key.
toleranceSeconds Allowed clock drift. Defaults to 5.
nowMs "Now" in milliseconds, for tests.

Paddle.webhookSignedContent(ts, body) returns the exact string that is signed.

Coming from Dodo Payments

Method names match @tundraconnect/dodo-payments wherever Paddle has the same operation: the verbs are shared, and the nouns are each vendor's own. The request and response shapes are Paddle's own.

A Dodo payment is a Paddle transaction. The methods keep Paddle's name because a Paddle transaction already carries a payments array of payment attempts, so a getPayment that returned a transaction would mislead.

Dodo Payments Paddle
isPaid isPaid (transaction paid or completed)
createPayment, getPayment, listPayments, listAllPayments createTransaction, getTransaction, listTransactions, listAllTransactions
createRefund, getRefund, listRefunds, listAllRefunds Same names
getCustomer, createCustomerPortalSession Same names
createProduct, getProduct, listProducts, listAllProducts, updateProduct, archiveProduct, unarchiveProduct Same names
findProductsByMetadata findProductsByCustomData: Paddle calls the field custom_data
createDiscount, getDiscount, getDiscountByCode, listDiscounts, listAllDiscounts, updateDiscount Same names
deleteDiscount archiveDiscount, which unarchiveDiscount reverses: Paddle never deletes
addDiscountCustomers, listDiscountCustomers, listAllDiscountCustomers, removeDiscountCustomer None: Paddle discounts can't be limited to named customers
getSubscription, listSubscriptions, listAllSubscriptions, cancelSubscription, pauseSubscription, resumeSubscription Same names
undoScheduledCancellation, changePlan Same names
createSubscription None: Paddle creates the subscription when a checkout completes
cancelScheduledPlanChange None: Paddle applies plan changes at once
createAddon, listAddons, updateAddon None: add a price to the subscription's items, or chargeSubscription
verifyWebhook verifyWebhook (instance or static)
mode: 'test' | 'live' environment: 'sandbox' | 'live'

Clone this wiki locally