Developer API
Build on the same APIs Troute runs on
A REST API over HTTPS and JSON for payments, customers, billing, booking, and reporting, with signed webhooks and a free sandbox.
// Runs on your server. Never send the secret key to a browser.
const auth = Buffer.from(
`${process.env.TROUTE_USERNAME}:${process.env.TROUTE_SECRET_KEY}`
).toString("base64");
const response = await fetch("https://secure.troute.io/query/charges", {
method: "POST",
headers: {
Authorization: `Basic ${auth}`,
"Content-Type": "application/json",
"Idempotency-Key": order.id, // safe to retry
},
body: JSON.stringify({
amount: 42.50, // dollars, including tax and surcharge
payment_method_id: customer.savedCardId,
customer_id: customer.trouteId,
}),
});
const data = await response.json();
// "partial", "review", and "failed" are not a completed payment.
if (data.result !== "success") {
throw new Error(data.message ?? `Charge ${data.result}`);
}
console.log(data.charge.id, data.charge.status_text); // "succeeded"What you can build
Each area links to its reference, with request and response examples.
- Charges and tokensCharge a token, saved payment method, or Apple Pay wallet. Authorize now and capture later.
- Refunds and voidsRefund settled payments and void ones that have not settled.
- Atlas CheckoutCreate embedded or hosted checkouts with an expiry, cancel them, and look up their status.
- CustomersCustomer records, contact and billing details, and saved payment methods.
- Products and couponsYour catalog, prices, images, and promotional codes.
- InvoicesCreate, send, and track itemized invoices.
- Recurring billingSchedules on saved payment methods, with pause, resume, and line-item changes.
- BookingServices, staff, availability, and appointments for your own booking flow.
- Transactions and payoutsTransaction history and payout data for your reporting tools.
- Disputes and evidenceAttach receipts, photos, signatures, and PDFs to transactions.
- In-person paymentsTap to Pay on iPhone and MagTek card readers.
- OrganizationsGroup merchant accounts and manage access across them.
Authentication
Send your merchant username and secret key with each request, either as HTTP Basic auth or as x_login and x_tran_key in the JSON body. Use one method per request, not both.
Credentials belong on your server. For browser checkout, your server creates an Atlas checkout and passes only the returned checkout token or URL to the page.
Authentication reference →Conventions
- Amounts are in U.S. dollars, for example
42.50. - Every response has a
result:success,partial,review, orfailed, with amessagewhen it fails. - Send an
Idempotency-Keyheader so a retried request is not charged twice. - List endpoints support filtering, sorting, pagination, and field selection.
- There are no client SDKs. Any language with an HTTP client can call the API.
Webhooks
Subscribe an endpoint to the events you need. Each delivery carries an Expi-Signature header, an HMAC-SHA256 of the timestamp and raw body made with your endpoint secret, so you can verify it came from Troute. Failed deliveries are retried, and you can see delivery history and resend any event.
Some of the events
- charge.created
- charge.captured
- charge.failed
- refund.created
- invoice.paid
- recurring.payment_succeeded
- recurring.payment_failed
- recurring.paused
- booking.created
- dispute.updated
Try it in the sandbox
Sign up with your email, verify it, and set up sandbox API credentials. No merchant account needed.