Skip to content

Order activities

Each order keeps an activity log: one row for each thing that happened to it, such as the order being created, an item being added, a checkout session opening or expiring, or a payment succeeding. Use the log to show a support agent or a buyer the order's history, and to work out what happened when an order looks wrong.

The log tells the story; the resources hold the facts. Each row has a description to display and, when it is about one specific resource, that resource's ID. For anything you act on, read the resource:

To knowRead
What the order costs, what's paid, and what's owedThe order's pricing_amounts and settlement_amounts
Whether a payment succeeded, failed, or needs the buyerThe PaymentIntent in payment_intent_id
Whether a refund went through, and for how muchThe refund in refund_id
Whether checkout is still openThe checkout session in checkout_session_id

Three things the log isn't:

  • A trigger for your code. To act when an order changes or a payment succeeds, subscribe to webhooks. Rows are for reading on demand, not for polling.
  • A ledger. Don't add up balance_delta_money to get the order's balance. The order's settlement_amounts has it.
  • A request log. For the API requests and webhook deliveries that touched an order, use its resource timeline. The activity log records what happened to the order; the timeline records what your integration and Flint's webhooks did.

Read an order's history#

The log is newest first by default. For a timeline that reads top to bottom, pass sort_direction=asc:

cURL
curl "https://api.withflintpay.com/v1/orders/ord_01KWJZ8ZD3EDT7F78T82TZ6JXD/activities?sort_direction=asc" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response
{
  "data": [
    {
      "order_activity_id": "oact_01KQM9S346Q3D25VT4F5V37E3S",
      "activity_type": "created",
      "balance_delta_money": { "amount": 4500, "currency": "USD" },
      "running_balance_money": { "amount": 4500, "currency": "USD" },
      "description": "Order created with 2 line item(s)",
      "created_at": "2026-10-20T15:02:11Z"
    },
    {
      "order_activity_id": "oact_01KQ3E28JT97KB6CQ643DZVMXX",
      "activity_type": "line_item_added",
      "balance_delta_money": { "amount": 500, "currency": "USD" },
      "running_balance_money": { "amount": 5000, "currency": "USD" },
      "description": "Line item added: Gift wrap (qty: 1)",
      "order_line_item_id": "li_01KQQKFBF5KZNWJ47TAN9ZT24M",
      "created_at": "2026-10-20T15:04:40Z"
    },
    {
      "order_activity_id": "oact_01KQNPZX45HY43KWJRP1XPA7Z3",
      "activity_type": "checkout_session_created",
      "balance_delta_money": { "amount": 0, "currency": "USD" },
      "running_balance_money": { "amount": 5000, "currency": "USD" },
      "description": "Checkout session created",
      "checkout_session_id": "cs_01KQDJ8FSSZ5AWSH8VHTPRE95B",
      "created_at": "2026-10-20T15:05:02Z"
    },
    {
      "order_activity_id": "oact_01KQ9EE0ZBGJ09TQM83XSSSS6Y",
      "activity_type": "checkout_session_expired",
      "balance_delta_money": { "amount": 0, "currency": "USD" },
      "running_balance_money": { "amount": 5000, "currency": "USD" },
      "description": "Checkout session expired",
      "checkout_session_id": "cs_01KQDJ8FSSZ5AWSH8VHTPRE95B",
      "created_at": "2026-10-21T15:05:02Z"
    },
    {
      "order_activity_id": "oact_01KQS3C4DWA7N36096Q14DR9GP",
      "activity_type": "checkout_session_created",
      "balance_delta_money": { "amount": 0, "currency": "USD" },
      "running_balance_money": { "amount": 5000, "currency": "USD" },
      "description": "Checkout session created",
      "checkout_session_id": "cs_01KQQY77ZXYYK596NGYA1DQ91K",
      "created_at": "2026-10-21T18:30:15Z"
    },
    {
      "order_activity_id": "oact_01KQ5GQAPENECFSECZP11HYGCP",
      "activity_type": "payment",
      "balance_delta_money": { "amount": -5000, "currency": "USD" },
      "running_balance_money": { "amount": 0, "currency": "USD" },
      "description": "Payment succeeded",
      "payment_intent_id": "pi_01KQWPQ5E6EYCNDY0YP57RCYBV",
      "created_at": "2026-10-21T18:31:48Z"
    }
  ],
  "request_id": "req_01KQN5SXS5AA819X9YP981068V"
}

Read in order, the rows answer a support question like "why did it take the buyer a day to pay?":

  1. created: the order opened with two items for $45.00. Its delta is the starting total, so the balance is $45.00.
  2. line_item_added: gift wrap added $5.00, raising the balance to $50.00. order_line_item_id names the item on the order.
  3. checkout_session_created: you sent the buyer to checkout. A delta of 0: opening checkout doesn't change what the order costs.
  4. checkout_session_expired: the buyer left without paying, and the session expired.
  5. checkout_session_created: a second session, with a new checkout_session_id.
  6. payment: the buyer paid $50.00 and the balance reached 0. Read the PaymentIntent in payment_intent_id for the amount captured and how the buyer paid.

There is no next_page_token, so there are no more rows. Every row carries order_activity_id, description, balance_delta_money, and running_balance_money.

Balance delta and running balance#

Both are signed amounts in minor units, as money and amounts describes.

  • running_balance_money is the order's balance just after the row: what was still owed, less any credit held beyond the total. It is the difference between settlement_amounts.outstanding_money and settlement_amounts.overpaid_money at that moment. Use it to show the balance next to each row.
  • balance_delta_money is how much the row changed what the buyer owes. Rows that change what the order costs carry that change: created carries the starting total, and line item, discount, tax, tip, charge, and order_updated rows carry their own effect. A payment row is negative by the amount collected plus any debt discharged by that payment's final capture. For example, a final capture of $1.50 from a $2.00 hold can discharge the remaining $0.50, giving the row a delta of -$2.00. Released money is not collected money. Rows that record a step or a failure carry 0: payment_failed, refund_failed, checkout session rows, fulfillment rows, and closed.

For the balance now, read the order. A later row, such as a refund or a write-off, can change the balance, and the order always reports its current settlement_amounts.

Page through a long log#

An order that was edited many times or sent through checkout repeatedly can have more rows than one page. page_size defaults to 20 and goes up to 100. When next_page_token is present, pass it as page_token, with the same sort_direction and activity_type, to get the next page. Rows with the same created_at come back in order_activity_id order, so pages don't skip or repeat rows. Pagination covers the token rules.

JavaScript
async function listOrderActivities(orderId) {
  const rows = [];
  let pageToken;
  do {
    const params = new URLSearchParams({ sort_direction: "asc", page_size: "100" });
    if (pageToken) params.set("page_token", pageToken);
    const response = await fetch(
      `https://api.withflintpay.com/v1/orders/${orderId}/activities?${params}`,
      { headers: { Authorization: `Bearer ${process.env.FLINT_API_KEY}` } },
    );
    if (!response.ok) throw new Error(`Flint returned ${response.status}`);
    const page = await response.json();
    rows.push(...page.data);
    pageToken = page.next_page_token;
  } while (pageToken);
  return rows;
}

Filter by type#

To show only some rows, such as payments and refunds on a support screen, pass activity_type. Repeat it or separate values with commas; a row matches if it has any of the types you list.

cURL
curl "https://api.withflintpay.com/v1/orders/ord_01KWJZ8ZD3EDT7F78T82TZ6JXD/activities?activity_type=payment,payment_failed,refund,refund_failed" \
  -H "Authorization: Bearer YOUR_API_KEY"
cURL
curl "https://api.withflintpay.com/v1/orders/ord_01KWJZ8ZD3EDT7F78T82TZ6JXD/activities?activity_type=checkout_session_created&activity_type=checkout_session_expired&activity_type=checkout_session_invalidated" \
  -H "Authorization: Bearer YOUR_API_KEY"

The filter accepts only the types in the table below. An empty or unknown value is rejected before anything is read.

Activity types#

Each row carries at most one reference ID, for the resource it is about. Rows about the order as a whole carry none, and so do rows that cover several resources at once, such as a payment split across a gift card and a card, or several fulfillments created together.

Groupactivity_typeReference field
Ordercreated, order_updated, adjustment, closedNone
Line itemsline_item_added, line_item_updated, line_item_removedorder_line_item_id
Discountsdiscount_applied, discount_removedorder_discount_id
Taxtax_updatedNone
Tipsrequested_tip_added, requested_tip_updated, requested_tip_removedorder_tip_id
Chargescharge_added, charge_updated, charge_removed, charge_fulfillment_updatedorder_charge_id
Paymentspayment, payment_failedpayment_intent_id
Refundsrefund, refund_failedrefund_id
Checkout sessionscheckout_session_created, checkout_session_expired, checkout_session_invalidatedcheckout_session_id
Fulfillmentfulfillment_created, fulfillment_updated, fulfillment_state_changedfulfillment_id

A few rows need a closer look:

  • refund records a refund Flint accepted, not one that has settled. A later refund_failed row with the same refund_id means that refund failed or only partly succeeded. The refund's status says which, and how much went back.
  • checkout_session_invalidated means something outside the session ended it: the order was paid another way, an edit closed the order or left nothing to pay, you replaced the session, or the invoice it was collecting stopped needing it. The session's terminal_reason says which, as Checkout sessions describes. Send the buyer a new session if the order still needs paying.
  • closed means the order stopped accepting payment. Discounts canceled by the close appear as their own discount_removed rows.
  • adjustment records a change to the order's recorded balance, or an inventory exception being resolved.

Render rows safely#

Write your timeline so new types and new wording can't break it:

  • Switch on activity_type, never on description. Descriptions are display text and their wording can change. They can include names you or your staff entered, such as item names, so escape them like any other user input.
  • Show a generic row for a type you don't recognize. Flint adds activity types over time. A row whose type this API version can't name has no activity_type at all, so treat a missing value the same way.
  • Link the reference you find. Check the reference fields rather than assuming one from the type, since some rows have none.
JavaScript
const REFERENCE_FIELDS = [
  "payment_intent_id",
  "refund_id",
  "checkout_session_id",
  "order_line_item_id",
  "order_discount_id",
  "order_tip_id",
  "order_charge_id",
  "fulfillment_id",
];

function timelineRow(activity, knownTypes) {
  const referenceField = REFERENCE_FIELDS.find((field) => activity[field]);
  return {
    id: activity.order_activity_id,
    at: activity.created_at,
    kind: knownTypes.has(activity.activity_type) ? activity.activity_type : "other",
    text: activity.description, // escape before inserting as HTML
    balanceChange: activity.balance_delta_money,
    balanceAfter: activity.running_balance_money,
    reference: referenceField ? { field: referenceField, id: activity[referenceField] } : null,
  };
}

Show the history to the buyer#

GET /v1/me/orders/{order_id}/activities takes the same sort_direction, activity_type, page_size, and page_token parameters and returns the same row shape, authenticated by a customer session rather than your API key. It returns only the signed-in buyer's own orders. To keep internal detail out of the buyer's view, Flint replaces some descriptions with fixed text, such as "Payment failed" or "Tax updated", and leaves out fulfillment steps that don't change the buyer's progress, such as holds. A page can hold fewer rows than page_size for that reason, so keep paging while next_page_token is present.

Errors#

  • HTTP 400
    param names the input: an empty or unknown activity_type value, a sort_direction other than asc or desc, a page_size outside 1 to 100, or a page_token that is invalid, expired, or from a request with different filters or sort. Fix the parameter and send the request again.
  • HTTP 403
    The API key or partner token has neither commerce.orders.read nor commerce.orders.write.
  • HTTP 404
    No order with that ID exists for this merchant and mode, or, on /v1/me, the order isn't the signed-in buyer's. Check the ID, and use a key in the same mode as the order, test or live.

Next steps#

Orders firstHow orders, payments, and refunds fit together, and which resource owns what.WebhooksReact to order, payment, and refund changes as they happen.Debugging requestsTrace the API requests and webhook deliveries behind an order.

Was this helpful?