Get customers list

Retrieves a paginated list of customers with optional subscription data

📘

API Refs

Request parameters

NameTypeDescriptionRequired
limitnumberMaximum number of customers to return (default: 50, max: 100)no
offsetnumberNumber of customers to skip for pagination (default: 0)no
include_subscriptionsbooleanWhether to include subscription data for each customer (default: false)no

Response body

Success Response (200 OK)

FieldTypeDescription
dataarrayList of customer objects
paginationobjectPagination information

Customer Object Structure

FieldTypeDescription
idstringCustomer ID
emailstringCustomer email
firstNamestringCustomer first name
lastNamestringCustomer last name
phonestringCustomer phone number
stripeCustomerIdstringStripe customer ID
hasActiveSubscriptionbooleanWhether customer has active subscription
subscriptionsarrayCustomer subscriptions (only when include_subscriptions=true)
createdAtstringCustomer creation date (ISO 8601)
updatedAtstringLast update date (ISO 8601)

Subscription Object Structure (when included)

FieldTypeDescription
idstringSubscription ID
statusstringSubscription status (active, past_due, canceled, etc.)
currentPeriodStartstringCurrent billing period start (ISO 8601)
currentPeriodEndstringCurrent billing period end (ISO 8601)
planobjectPlan details (nullable)

Plan Object Structure

FieldTypeDescription
stripePriceIdstringStripe price ID
namestringPlan name
amountnumberPlan amount in cents
currencystringPlan currency
intervalstringBilling interval (month, year)

Pagination Object Structure

FieldTypeDescription
totalnumberTotal number of customers
limitnumberApplied limit per page
offsetnumberApplied offset for pagination
hasMorebooleanWhether more results are available

Response

{
  "data": [
    {
      "id": "123",
      "email": "[email protected]",
      "firstName": "John",
      "lastName": "Doe",
      "phone": "+1234567890",
      "stripeCustomerId": "cus_ExampleCustomerID123",
      "hasActiveSubscription": true,
      "subscriptions": [
        {
          "id": "sub_ExampleSubscription123",
          "status": "active",
          "currentPeriodStart": "2024-01-01T00:00:00.000Z",
          "currentPeriodEnd": "2024-02-01T00:00:00.000Z",
          "plan": {
            "stripePriceId": "price_ExamplePriceID456",
            "name": "Premium Plan",
            "amount": 4999,
            "currency": "usd",
            "interval": "month"
          }
        }
      ],
      "createdAt": "2023-12-01T00:00:00.000Z",
      "updatedAt": "2024-01-15T00:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 150,
    "limit": 10,
    "offset": 0,
    "hasMore": true
  }
}

Pagination Usage

To retrieve the next page of results, increment the offset by the limit value:

GET /api/public/customers?limit=10&offset=10

Important Notes

  1. hasActiveSubscription Field: This field is always included and properly calculated when include_subscriptions=true. It considers subscriptions with status "active" or "trialing" as active.

  2. Performance Consideration: Including subscription data (include_subscriptions=true) may increase response time. Only request subscription data when needed.

  3. Default Pagination:

    • Default limit: 50 customers
    • Maximum limit: 100 customers
    • Default offset: 0
  4. Subscription Data: The subscriptions array is only included when include_subscriptions=true is specified.

Error Responses

  • 400 Bad Request: Invalid limit or offset parameters
  • 401 Unauthorized: Invalid or missing authorization token
  • 403 Forbidden: Insufficient permissions

Use Cases

  1. Customer Dashboard: Use without subscription data for quick customer list display
  2. Subscription Management: Include subscription data to show active/inactive customers
  3. Billing Reports: Use with subscription data to analyze customer billing status