Pre-authorization

We strongly recommend standard checkout over pre-authorization. Use pre-authorization only when you can't know the final amount until the work is done.

Pre-authorization flow

1. Surface Titus as a payment option

There are a number of ways you can introduce Titus as a payment method including:

  • Adding Titus as a payment option in a multi-select next to your existing payment methods, and then when the customer submits the order with Titus selected as a payment method, calling the Titus API to create an authorization entity.

  • Introducing Titus as a payment button that, when clicked, calls the Titus API to create an authorization.

See Design Guidance for more detail

2. Create an Authorization

When a customer chooses to pay with Titus, call POST /v1/authorizations from your server with the API key and base URL from 1. Set Up. Never call the API from the browser, because that would expose your API key.

Example

const response = await fetch(`${process.env.TITUS_API_BASE_URL}/v1/authorizations`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.TITUS_API_KEY,
  },
  body: JSON.stringify({
    orderId: order.id, // the order or invoice number in your system
    // Retrying with the same key returns the first authorization, even if other fields changed.
    idempotencyKey: `order-${order.id}`,
    // Send at least one of estimatedAmount and maxAmount, each in dollars from 1 to 50,000.
    estimatedAmount: 1500.0, // shown to the customer
    // The most you can capture. If omitted, Titus sets it when the customer authorizes.
    maxAmount: 2000.0,
    description: 'Listing photography package', // shown to the customer
    successUrl: `https://yourapp.com/orders/${order.id}/complete`,
    cancelUrl: `https://yourapp.com/orders/${order.id}`,
    // Optional but recommended: the listing address and the person the project is for.
    project: {
      address: {
        addressLine1: '123 Main St',
        city: 'San Francisco',
        state: 'CA', // uppercase 2-letter state code
        zip: '94102', // 5-digit ZIP code
      },
      contact: {
        firstName: 'Jane',
        lastName: 'Doe',
        phone: '5555555555', // digits only
      },
    },
  }),
});

if (!response.ok) {
  // Error body: { "error": "Bad Request", "message": "..." }
  const { error, message } = await response.json();
  throw new Error(`Titus authorization failed (${response.status}): ${message ?? error}`);
}

const { data } = await response.json();
// Save data.id with your order. You need it to capture or void the authorization.
const { id, url } = data;

The response's data is the authorization. You'll redirect the customer to data.url in the next step.

3. Redirect the customer

Once you've created an authorization, redirect the customer to the url returned by the Titus API.

This URL will take the user to a secure, Titus-hosted flow where they will:

  • Select a payment method by:

    • applying for financing (aka "pay at close")

    • entering a credit/debit card (if the vendor is approved for card payments)

  • Authorize the payment

  • Be redirected back to your successUrl or cancelUrl

You must not treat the redirect alone as confirmation of payment; always verify the payment via webhook events or API requests. In some cases the user may need to await manual financing approval before they can complete their payment.

4. Capture the payment

An authorization lasts 30 days from when you create it, until its expiresAt. After that, it can't be captured.

When you're ready to settle (e.g., the service has been delivered), capture the final amount. Only an active authorization can be captured.

const response = await fetch(
  `${process.env.TITUS_API_BASE_URL}/v1/authorizations/${authorizationId}/capture`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.TITUS_API_KEY,
    },
    body: JSON.stringify({
      amount: 1750.0, // final amount, from 1 to the authorization's maxAmount
    }),
  },
);

if (!response.ok) {
  const { error, message } = await response.json();
  throw new Error(`Titus capture failed (${response.status}): ${message ?? error}`);
}

const { data } = await response.json();
// Save data.checkoutId with your order. Checkout webhooks for this payment use it as payload.id.
const { checkoutId } = data;

The authorization moves to captured, and Titus creates a checkout for the payment. Its id is the authorization's checkoutId.

If nothing is owed, void the authorization with POST /v1/authorizations/{id}/void instead. Only a pending or active authorization can be voided. Voiding releases any loan balance it reserved.

5. Handle webhook events to track payment status

An authorization moves through these statuses:

Status Meaning
pending The customer hasn't authorized yet.
active The customer authorized. You can capture or void it.
captured You captured it. Track the payment through its checkout.
voided You voided it.
expired It passed its expiresAt without a capture.

Subscribe to authorization.updated to learn when the authorization is active and ready to capture. After capture, track the payment with checkout.updated: its payload.id is the authorization's checkoutId. See Choose your events for checkout statuses and the webhook setup.

Example authorization.updated payload: the customer authorized, and you can capture.

{
  "type": "authorization.updated",
  "payload": {
    "id": "auth_123",
    "orderId": "order_123",
    "status": "active",
    "maxAmount": 2000,
    "expiresAt": "2026-01-30T18:00:00.000Z",
    "checkoutId": null,
    ...
  }
}

Example checkout.updated payload: the payment for a captured authorization succeeded.

{
  "type": "checkout.updated",
  "payload": {
    "id": "chk_456",
    "orderId": "order_123",
    "status": "succeeded",
    ...
  }
}

Use the orderId to correlate with your internal system.