RailbedDocs

Customers

A customer is one buyer's email address in one mode, with the contact details and addresses their orders brought. Read customers to see who bought what, and find one by email.

On this page

The customer object

FieldTypeDescription
idstringThe customer's id, cus_…
objectstring"customer"
livemodebooleanfalse for Test mode, true for Live mode
emailstring or nullTheir email, lowercased. Null after you delete their details
namestring or nullTheir name, from their latest order that had one
phonestring or nullTheir phone number, as your store sent it
shipping_addressobject or nullTheir latest shipping address, in the order's address shape
billing_addressobject or nullTheir latest billing address
store_accountsarrayTheir ids in your stores, one per store: platform, store_id, store_name and customer_id (the customer.id you sent). Empty when you sent none
orders_countintegerHow many orders they have, paid or not
paid_orders_countintegerHow many of those are paid
spentobjectWhat their paid payments add up to, by currency, such as { "USD": "135.31" }. Empty until a payment is paid
createdintegerWhen they first appeared, in Unix seconds
last_order_atinteger or nullWhen their latest order was created, in Unix seconds
erasedbooleantrue once you've deleted their details

spent adds up the amount of each of their payments that's paid, in its currency: what they paid, including a part-payment on an order that's held, and both payments when they paid one order twice. paid_orders_count counts only orders that are paid. What reached your wallet is on each payment.

A customer
{
  "id": "cus_Hc7nQ2wVz9KpT4mRb1Ye",
  "object": "customer",
  "livemode": true,
  "email": "maya@example.com",
  "name": "Maya Okafor",
  "phone": "+1 503 555 0142",
  "shipping_address": {
    "name": "Maya Okafor",
    "line1": "418 Linden Avenue",
    "line2": "Apt 3B",
    "city": "Portland",
    "region": "OR",
    "postal_code": "97214",
    "country": "US"
  },
  "billing_address": null,
  "store_accounts": [],
  "orders_count": 3,
  "paid_orders_count": 2,
  "spent": { "USD": "224.31" },
  "created": 1787702525,
  "last_order_at": 1790380525,
  "erased": false
}
200 OK

How customers are made

  • One customer per email address, in each mode. Case doesn't matter: Maya@Example.com and maya@example.com are one customer. Test and Live customers are separate.
  • The email comes from the session. A session's customer_email (or customer.email) makes or finds the customer when it's created; a session created without one gets its customer from the email given when it starts. Railbed's checkouts and payment links use the email the buyer enters, or the one you set on the link.
  • The latest details win. Each order's customer.name, customer.phone and addresses replace the saved ones. Details an order leaves out keep their earlier value.
  • Details wait for the email. A session created without an email keeps its name, phone and addresses on the order, and saves them to the customer once the buyer gives their email and starts paying.
  • Orders follow the email. When a session starts with a different email from the one it was created with, its order moves to the customer with the new email.

The API doesn't create, edit or delete customers: they change only through orders. The dashboard lets you keep a private note on each customer, which is never returned by the API or sent in webhooks.

Deleted customers

When a buyer asks you to delete their data, open the customer in the dashboard's Customers and choose Delete customer data. It removes their name, email, phone and addresses from the customer, from their orders and payments, and from the bodies stored in your webhook delivery log. Their orders, amounts and payments stay for your records. It can't be undone.

  • The customer keeps its id, with erased: true and its contact details and addresses null. Their orders keep customer_id, and their payments' customer_email becomes null.
  • Their email is no longer on file, so listing by email doesn't find them, and the same email later starts a new customer.
  • Webhooks already delivered can't be recalled. Delete the details from your own systems too.

Retrieve a customer

GET/v1/customers/:id

Returns a customer of yours in the key's mode. Another account's customer, or one in the other mode, is 404 not_found.

curl https://pay.railbed.io/v1/customers/cus_Hc7nQ2wVz9KpT4mRb1Ye \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY"

The response is the customer object. An order's customer_id leads here; for their orders, list orders with customer_id.

List customers

GET/v1/customers

Returns your customers in the key's mode, newest first by created. Pass email to find one buyer.

ParameterTypeDescription
limitinteger1–100. Default 20
starting_afterstringA customer id from the previous page's next_cursor
emailstringOnly the customer with this email, in any letter case. Matches the whole address
curl -G https://pay.railbed.io/v1/customers \
  --data-urlencode "email=maya@example.com" \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY"
Response (trimmed)
{
  "data": [
    {
      "id": "cus_Hc7nQ2wVz9KpT4mRb1Ye",
      "object": "customer",
      "email": "maya@example.com",
      "name": "Maya Okafor",
      "paid_orders_count": 2
    }
  ],
  "has_more": false,
  "next_cursor": null
}
200 OK

Each item is a full customer object (trimmed here). With email, the list has at most one customer; an empty data means no customer has that email in this mode. Page through the whole list with next_cursor as on List payments. An invalid limit is 400 invalid_limit; a cursor that isn't one of your customers in this mode is 400 invalid_cursor.

Updated · This page as Markdown