Skip to main content

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.

Example server-side TypeScript that charges a customer's saved card through the Troute Charges API.
create-charge.ts
// 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"

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, or failed, with a message when it fails.
  • Send an Idempotency-Key header 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.

Webhooks reference →

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.

Start accepting payments with Troute

Tell us how you sell and we'll put together pricing and a setup plan for your business. No obligation.