Skip to main content

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 name
    • last_name (string, required): Customer's last name
    • email (string, required): Customer's email address
    • phone (string, optional): Customer's phone number
    • personal_address (object, optional): Customer's address
      • line1 (string, required): Street address
      • line2 (string, optional): Apartment, suite, etc.
      • city (string, required): City
      • state (string, required): State/province code
      • postal_code (string, required): ZIP/postal code
      • country (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 IDs
    • limit (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 update
  • data (object, required): Fields to update
    • first_name (string, optional): New first name
    • last_name (string, optional): New last name
    • email (string, optional): New email address
    • phone (string, optional): New phone number
    • personal_address (object, optional): New address
    • tags (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 customer
  • params (object, optional)
    • limit (number, optional): Maximum number of orders to return
    • offset (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;
}