Overview
The CustomersClient provides full CRUD operations for managing end-user (customer) records in your application.
Methods
identify()
Identify (upsert) a customer. Creates the customer if not found, or updates it if a record with the same customerId already exists.
const customer = await revstack.customers.identify(params);
params
IdentifyCustomerParams
required
Customer identification parameters.
Unique customer identifier within your system.Example: "user-123"
Customer display name.Example: "John Doe"
Arbitrary metadata to attach to the customer.Example: { segment: "enterprise", referral: "partner" }
The created or updated customer record.
Unique identifier with usr_ prefix.
Environment this customer belongs to.
Customer’s email address.
UID from external auth provider (e.g. Firebase, Auth0).
Whether this customer was created anonymously.
External payment gateway customer ID (e.g. Stripe cus_...).
Arbitrary key-value metadata.
ISO 8601 timestamp of creation.
Example:
const customer = await revstack.customers.identify({
customerId: "user-123",
email: "[email protected]",
name: "John Doe",
metadata: { segment: "enterprise" },
});
get()
Retrieve a customer by ID.
const customer = await revstack.customers.get(customerId);
The customer’s unique identifier.Example: "usr_abc123"
Example:
const customer = await revstack.customers.get("usr_abc123");
console.log(customer.email); // "[email protected]"
list()
List customers with optional pagination.
const response = await revstack.customers.list(params);
Pagination parameters.
Maximum number of records to return.Default: 100
Number of records to skip.Default: 0
response
PaginatedResponse<Customer>
A paginated list of customer records.
Array of customer records.
Total number of records matching the query.
Whether more records exist beyond this page.
Example:
const { data: customers, hasMore } = await revstack.customers.list({
limit: 50,
offset: 0,
});
console.log(`Found ${customers.length} customers`);
update()
Update an existing customer’s profile.
const customer = await revstack.customers.update(customerId, params);
The customer’s unique identifier.
params
UpdateCustomerParams
required
Fields to update.
Metadata fields to merge with existing metadata.
The updated customer record.
Example:
const customer = await revstack.customers.update("usr_abc123", {
email: "[email protected]",
metadata: { verified: true },
});
delete()
Delete a customer and all associated data.
const result = await revstack.customers.delete(customerId);
The customer’s unique identifier.
Confirmation of deletion.
Example:
const { success } = await revstack.customers.delete("usr_abc123");
if (success) {
console.log("Customer deleted successfully");
}