Create a customer
In this quickstart you record a company you bill as a customer in Paid, in a sandbox organization, where nothing is ever charged. Every invoice, event and order in Paid belongs to a customer, so they are the first thing an integration sets up.
Litware runs an AI support agent and has just signed Northwind Traders. By the end, Litware will have:
- Northwind Traders as a customer, named by Litware’s own ID
- a way to look it up, change its details, and page through every customer on the account
Before you start
- Set up your account: a sandbox organization and an API key starting
paid_sk_test_, exported asPAID_API_KEY. - Make your first request: check that the key works.
- Have
curlto hand. Paid’s SDKs don’t supportapi.paid.ai/v1yet, so the steps below call it over HTTP.
1. Create a customer
Customers are in the customers=v1 beta: send Paid-Beta: customers=v1 with each customer request.
Create a customer for Northwind Traders with its billing details, which Paid shows on invoices and uses for tax. externalId is Litware’s own ID for the company, from its CRM. Every write also sends an Idempotency-Key, so retrying it after a timeout can never create two customers. Save the request body from the API tab below as northwind.json, then send it:
From here on, each step shows only the method, path and body. Send the same headers with each one.
API
Dashboard
livemode is false because the customer is in a sandbox organization. Store the cus_ ID where you can: it never changes. externalId is unique on your account, so creating a second customer with northwind returns 409 resource_exists.
2. Look a customer up
Anywhere the API asks for a customer, it takes Paid’s cus_ ID or your externalId, so a service that only knows Litware’s CRM ID never needs to store Paid’s. Retrieve the customer by its externalId:
The response is the same customer object the create returned.
3. Keep its details current
When Northwind changes its billing contact, update the customer. Send only the fields that change:
The response is the whole customer with the new email. metadata holds your own key-value pairs; Paid stores them and never acts on them.
4. List your customers
List customers to sync them with your CRM. Lists return the newest customers first, a page at a time, and filters narrow them, such as email:
The response is a list object with the customers in data. When hasMore is true, send its nextCursor as cursor to get the next page. Read Pagination for a loop that reads every page.
5. Archive a customer
When a company stops being your customer, archive it. The request has no body:
An archived customer stays readable and on its invoices, and keeps its externalId reserved, but can’t be put on new orders. Lists leave it out unless you pass includeArchived=true. Archiving fails while the customer still has an active order.
Next steps
- Customers: what a customer represents, identifying customers, and draft customers.
- Customers API Reference: every field and filter.
- Versioning: how
Paid-Versionworks, and how to upgrade. - Idempotency: retry writes safely.
- Errors: every error code and what to do about it.