Customer Management API
Manage customer records, including creating, retrieving, updating customers and accessing their related data.
Methods
createCustomer
Create a new customer.
const customer = await easy.createCustomer({
first_name: "John",
last_name: "Doe",
email: "[email protected]",
phone: "+1234567890",
personal_address: {
line1: "123 Main St",
line2: "Apt 4B",
city: "Anytown",
state: "CA",
postal_code: "12345",
country: "US",
},
tags: {
source: "website",
plan: "premium",
},
});
Parameters
data(object, required)first_name(string, required): Customer's first namelast_name(string, required): Customer's last nameemail(string, required): Customer's email addressphone(string, optional): Customer's phone numberpersonal_address(object, optional): Customer's addressline1(string, required): Street addressline2(string, optional): Apartment, suite, etc.city(string, required): Citystate(string, required): State/province codepostal_code(string, required): ZIP/postal codecountry(string, required): Two-letter country code
tags(object, optional): Custom metadata
Returns
Promise<ApiResponse<CustomerData>>;
getCustomer
Retrieve a customer by ID.
const customer = await easy.getCustomer("cust_123");
Parameters
customerId(string, required): The ID of the customer to retrieve
Returns
Promise<ApiResponse<CustomerData>>;
getCustomers
List all customers with optional pagination and filtering.
// Get all customers with pagination
const customers = await easy.getCustomers({
limit: 20,
offset: 0,
});
// Get specific customers by ID
const specificCustomers = await easy.getCustomers({
ids: ["cust_123", "cust_456"],
});
Parameters
params(object, optional)ids(string[], optional): Filter by specific customer IDslimit(number, optional): Maximum number of customers to return (default: 10, max: 100)offset(number, optional): Number of customers to skip for pagination
Returns
Promise<ApiResponse<CustomerData[]>>;
updateCustomer
Update an existing customer.
const updated = await easy.updateCustomer("cust_123", {
phone: "+0987654321",
tags: {
status: "verified",
},
});
Parameters
customerId(string, required): The ID of the customer to updatedata(object, required): Fields to updatefirst_name(string, optional): New first namelast_name(string, optional): New last nameemail(string, optional): New email addressphone(string, optional): New phone numberpersonal_address(object, optional): New addresstags(object, optional): Updated metadata
Returns
Promise<ApiResponse<CustomerData>>;
getCustomerPaymentInstruments
Get all payment instruments for a customer.
const instruments = await easy.getCustomerPaymentInstruments("cust_123");
Parameters
customerId(string, required): The ID of the customer
Returns
Promise<ApiResponse<PaymentInstrumentData[]>>;
getCustomerOrders
Get all orders for a customer.
const orders = await easy.getCustomerOrders("cust_123", {
limit: 10,
offset: 0,
});
Parameters
customerId(string, required): The ID of the customerparams(object, optional)limit(number, optional): Maximum number of orders to returnoffset(number, optional): Number of orders to skip
Returns
Promise<ApiResponse<OrderData[]>>;
Type Definitions
CustomerData
interface CustomerData {
id: string;
first_name: string;
last_name: string;
email: string;
phone?: string;
personal_address?: Address;
created_at: string;
updated_at: string;
tags?: Record<string, unknown>;
}
Address
interface Address {
line1: string;
line2?: string;
city: string;
state: string;
postal_code: string;
country: string;
}