Customers
Register, find, read, list, change and remove your customers with the SDK.
Each business you serve is a customer org under your account. You address it with your own id for it:
const customer = fastn.customer("acme_customer_42");You do not have to register a customer before you create a setup link for it: the link creates the customer on first use. Register first when you want to set its name yourself.
Create
customer.register({ name })
name (required): display name. Optional: slug (made from the name when left out), plan, tier, limits, domain.
The customer. Calling it again for the same id returns the existing customer instead of a second one.
Look up
customer.find()
None
The customer row, or undefined when fastn does not know this id.
Read
customer.get()
None
{ data: customer }
List all
fastn.orgs.listOrgs({ parent_id })
Optional: parent_id (your own org id, from fastn.me()), type (end_org for customers), include_usage: "true" (adds usage numbers per customer).
{ data: [customer, …] }
Change
customer.update({ name?, status? })
name: a new display name. status: active or suspended.
The updated customer.
Remove
customer.remove()
None
Nothing. See the warning below.
Trace a request
customer.callLog(correlationId)
The correlationId you sent on a call.
One entry per app call fastn made for that request.
const customer = fastn.customer("acme_customer_42");
await customer.register({ name: "Acme Dental" });
const row = await customer.find(); // undefined when unknown
const { data } = await customer.get();
console.log(data.name, data.status);A customer
id
fastn's own id for the customer; you can ignore it. Match the customer by your own id, in the next row.
orgId, externalRef
Your id for the customer (the same value). Use it to match the customer.
parentId
Your own org: the account the customer belongs to.
type
end_org for a customer.
status
active, suspended, pending_review or blocked. customer.update() can set only active or suspended.
Rows from customer.find() and listOrgs carry two more fields, connectionsCount and tierId. With include_usage: "true", listOrgs rows also carry executions, events, storage_gb, overage, credits, integrations and users.
List your customers
customer.find() and every other customer method only look at customers under your own org, so they never return another account's customer.
Change a customer, trace a request
Remove a customer
See also Customers for the same customers in the dashboard.
Last updated
Was this helpful?

