# Search customers

Returns a paginated list of customers that match the specified filters, ordered newest first. Results are eventually consistent, so new and updated records are not immediately searchable. Do not use this endpoint for read-after-write flows. To get the current state of a customer, use get customer.

Endpoint: POST /customers/search
Version: 2.0.0
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer asec_xxx

## Request fields (application/json):

  - `filters` (object)
    Filters for customers. All filters must match.

  - `filters.type` (object)
    Operator and value for customer type filter.

  - `filters.type.operator` (string, required)
    Comparison operator.
    Enum: "EQ"

  - `filters.type.value` (string, required)
    One allowed value of the field for `EQ` and `NEQ`, or a comma-separated list of them for `IN`.
    Example: ACTIVE

  - `filters.status` (object)
    Operator and value for customer status filter.

  - `filters.status.operator` (string, required)
    Comparison operator.
    Enum: "EQ"

  - `filters.email` (object)
    Operator and value for an email address filter. `EQ` takes a full email address, `STARTS_WITH` takes its beginning. Both ignore case.
    Example: {"operator":"EQ","value":"jane.doe@example.com"}

  - `filters.email.operator` (string, required)
    Comparison operator. `EQ` matches the full email address, ignoring case.
    Enum: "EQ"

  - `filters.email.value` (string, required)
    Email address.
    Example: jane.doe@example.com

  - `filters.email.operator` (string, required)
    Comparison operator. `STARTS_WITH` matches email addresses that start with the given value, ignoring case.
    Enum: "STARTS_WITH"

  - `filters.email.value` (string, required)
    Beginning of the email address. Leading and trailing spaces are ignored.
    Example: jane.doe@ex

  - `filters.merchant_reference` (object)
    Operator and value for merchant-defined reference filter.

  - `filters.merchant_reference.operator` (string, required)
    Comparison operator. Use `EQ` for a single value or `IN` for multiple values.
    Enum: "EQ", "IN"

  - `filters.merchant_reference.value` (string, required)
    Text to match. One value for `EQ`, `NEQ` and `CONTAINS`, or a comma-separated list for `IN`, with a comma inside a value escaped as `\,`. It cannot be empty or contain only spaces.
    Example: john

  - `filters.metadata` (object)
    Conditions on metadata, keyed by metadata key. All conditions must match, and keys must match exactly. `EQ` matches the full value, while `STARTS_WITH` matches the beginning of the value. Both ignore case and leading and trailing spaces. `EXISTS` matches any value for the key.
    Example: {"env":{"operator":"EQ","value":"prod"},"utm.source":{"operator":"STARTS_WITH","value":"goo"},"campaign":{"operator":"EXISTS"}}

  - `filters.created_at` (object)
    Operator and value for a date and time filter. `GTE` and `LTE` take a single date and time, `RANGE` takes an inclusive range.
    Example: {"operator":"RANGE","value":{"from":"2024-01-01T10:00:00.000000Z","to":"2024-01-31T10:00:00.000000Z"}}

  - `filters.created_at.operator` (string, required)
    Comparison operator. `GTE` matches values at or after the date and time, `LTE` at or before it.
    Enum: "GTE", "LTE"

  - `filters.created_at.value` (string, required)
    Date and time value.
    Example: 2024-01-01T10:00:00.000000Z

  - `filters.created_at.operator` (string, required)
    Comparison operator. `RANGE` matches values within the inclusive range.
    Enum: "RANGE"

  - `filters.created_at.value` (object, required)
    Inclusive range of dates and times.

  - `filters.created_at.value.from` (string, required)
    Date and time value.
    Example: 2024-01-01T10:00:00.000000Z

  - `filters.created_at.value.to` (string, required)
    Date and time value.
    Example: 2024-01-01T10:00:00.000000Z

  - `pagination` (object)
    Pagination details.

  - `pagination.page_size` (integer, required)
    Number of items returned in this response.
    Example: 20

  - `pagination.next_page_token` (string)
    Token to retrieve the next page of results. Omitted when no pages remain.
    Example: eyJMYXN0SUQiOiIxYTYyYjQ0Ni01ZDM0LTRiYTQtOGRlZS02NTM5NTU0NjY2MTQifQ==

## Response 200:

  - `200` (unknown)
    OK

## Response 200 fields (application/json):

  - `items` (array)
    List of customers for the current page.

  - `items.id` (string, required)
    Unique customer identifier.
    Example: cust_01KMG2ABYPF6XS5DMJQ817C429

  - `items.email` (string, required)
    Customer email.
    Example: customer@example.com

  - `items.first_name` (string)
    Customer first name.
    Example: John

  - `items.last_name` (string)
    Customer last name.
    Example: Doe

  - `items.phone` (string)
    Customer phone number.
    Example: +1234567890

  - `items.merchant_reference` (string)
    Merchant-defined reference for the customer.
    Example: 12345

  - `items.address` (object)
    Customer address.

  - `items.address.city` (string)
    City name.
    Example: Anytown

  - `items.address.country` (string)
    Country according to the ISO-3166 alpha-3 country code.
    Example: USA

  - `items.address.line1` (string)
    Address line 1.
    Example: 123 Main St

  - `items.address.line2` (string)
    Address line 2.
    Example: Suite 456

  - `items.address.state` (string)
    State or province.
    Example: CA

  - `items.address.postal_code` (string)
    Postal or ZIP code.
    Example: 12345

  - `items.tax` (object, required)
    Provides customer tax information.

  - `items.tax.taxability` (string, required)
    Indicates if the customer is subject to tax.
The list of enum values may be extended without notice.
    Enum: "EXEMPT", "TAXABLE"

  - `items.tax.registrations` (array)
    Tax registrations associated with the customer.
    Example: [{"scheme":"VAT","id":"DE123456789","country":"DEU","validation":{"status":"VALID","validated_at":"2024-01-15T10:30:00.000000Z","source":"VIES"}}]

  - `items.tax.registrations.scheme` (string, required)
    Tax registration scheme.
The list of enum values may be extended without notice.
    Enum: "VAT"

  - `items.tax.registrations.id` (string, required)
    Tax registration number for the specified scheme.
    Example: DE123456789

  - `items.tax.registrations.country` (string, required)
    ISO 3166-1 alpha-3 country code.
    Example: DEU

  - `items.tax.registrations.validation` (object, required)
    Validation result for tax registration.

  - `items.tax.registrations.validation.status` (string, required)
    Status of the tax registration validation.
    Enum: "VALID", "INVALID", "PENDING", "FAILED"

  - `items.tax.registrations.validation.validated_at` (string)
    Date and time when the validation completed. Absent while `status` is `PENDING` or `FAILED`.
    Example: 2024-01-15T10:30:00.000000Z

  - `items.tax.registrations.validation.source` (string, required)
    Method or external system used for validation.
The list of enum values may be extended without notice.
    Enum: "VIES", "MANUAL"

  - `items.status` (string, required)
    Customer status.
The list of enum values may be extended without notice.
    Enum: "ACTIVE", "INACTIVE"

  - `items.configuration` (object)
    Customer-level configuration settings.

  - `items.configuration.default_billing_currency` (string)
    ISO 4217 currency code used as default for billing.
    Example: USD

  - `items.configuration.default_payment_instrument_id` (string)
    Unique identifier of the default payment instrument for this customer.
    Example: pi_01J1Z2X3Y4W5V6U7T8S9R0

  - `items.configuration.preferred_locales` (array)
    Ordered list of preferred locales as BCP 47 tags.
    Example: ["en-US","de-DE"]

  - `items.metadata` (object)
    Arbitrary key-value metadata set by merchant.
    Example: {"internal_ref":"cust-123","segment":"enterprise"}

  - `items.balances` (array)
    Customer balances.
    Example: [{"currency":"USD","amount":1000}]

  - `items.balances.currency` (string, required)
    ISO 4217 currency code.
    Example: USD

  - `items.balances.amount` (integer, required)
    Available balance amount in minor units.
    Example: 1000

  - `items.created_at` (string, required)
    Date and time when the customer was created.
    Example: 2024-01-01T10:00:00.000000Z

  - `items.updated_at` (string, required)
    Date and time when the customer was updated.
    Example: 2024-01-02T15:00:00.000000Z

  - `items.type` (string, required)
    Customer type.
    Enum: "INDIVIDUAL"

  - `items.type` (string, required)
    Customer type.
    Enum: "BUSINESS"

  - `items.business_details` (object)
    Business-specific details for a customer profile.

  - `items.business_details.name` (string)
    Legal business name.
    Example: Acme Corporation

  - `items.business_details.legal_address` (object)
    Registered legal address of the business. `postal_code` is required unless the country has no postal codes, and `state` is required in countries with states. Each option below lists its countries.

  - `items.business_details.legal_address.city` (string, required)
    City name.
    Example: Anytown

  - `items.business_details.legal_address.country` (string, required)
    Country according to the ISO-3166 alpha-3 country code.
    Enum: "AUS", "BRA", "CAN", "CHN", "IND", "KOR", "MEX", "MYS", "NZL", "USA"

  - `items.business_details.legal_address.line1` (string, required)
    Address line 1.
    Example: 123 Main St

  - `items.business_details.legal_address.line2` (string)
    Address line 2.
    Example: Suite 456

  - `items.business_details.legal_address.state` (string, required)
    State or province.
    Example: CA

  - `items.business_details.legal_address.postal_code` (string, required)
    Postal or ZIP code.
    Example: 12345

  - `items.business_details.legal_address.country` (string, required)
    Country according to the ISO-3166 alpha-3 country code.
    Example: DEU

  - `items.business_details.legal_address.country` (string, required)
    Country according to the ISO-3166 alpha-3 country code, one whose addresses have no postal code.
    Enum: "ABW", "AGO", "ANT", "ARE", "ATA", "ATF", "ATG", "BDI", "BEN", "BES", "BFA", "BHS", "BLZ", "BOL", "BVT", "BWA", "CAF", "CIV", "CMR", "COD", "COG", "COK", "COM", "CUW", "DJI", "DMA", "ERI", "FJI", "GAB", "GHA", "GMB", "GNQ", "GRD", "GUY", "HKG", "JAM", "KIR", "KNA", "LBY", "LCA", "MAC", "MLI", "MRT", "MSR", "MWI", "NIU", "NRU", "PAN", "PSE", "QAT", "RWA", "SLB", "SLE", "SSD", "STP", "SUR", "SXM", "SYC", "SYR", "TCD", "TGO", "TKL", "TLS", "TON", "TUV", "UGA", "VUT", "WSM", "YEM", "ZWE"

  - `pagination` (object)
    Pagination details.

  - `pagination.page_size` (integer, required)
    Number of items returned in this response.
    Example: 20

  - `pagination.next_page_token` (string)
    Token to retrieve the next page of results. Omitted when no pages remain.
    Example: eyJMYXN0SUQiOiIxYTYyYjQ0Ni01ZDM0LTRiYTQtOGRlZS02NTM5NTU0NjY2MTQifQ==

## Response 400:

  - `400` (unknown)
    Bad request

## Response 400 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "VALIDATION"

  - `message` (string, required)
    Message describing the error.
    Example: One or more fields failed validation due to constraints

  - `context` (object, required)
    Additional context about the validation error, including specific constraints.
    Example: {"constraints":{"email":{"type":"TYPE","message":"The 'email' field must be a valid email address"},"age":{"type":"MIN","message":"The 'age' field must be a number greater than or equal to 18"}}}

  - `context.constraints` (object, required)
    Failed constraints keyed by the field name.

## Response 401:

  - `401` (unknown)
    Unauthenticated

## Response 401 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "UNAUTHENTICATED"

  - `message` (string, required)
    Message describing the error.
    Example: Credentials are invalid or missing

## Response 403:

  - `403` (unknown)
    Unauthorized

## Response 403 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "PERMISSION_DENIED"

  - `message` (string, required)
    Message describing the error.
    Example: Permission denied

## Response 429:

  - `429` (unknown)
    Too many requests

## Response 429 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "RATE_LIMIT"

  - `message` (string, required)
    Message describing the error.
    Example: Rate limit exhausted

  - `context` (object)
    Additional context about the error.

  - `context.next_try_at` (string)
    Timestamp indicating when to retry the request.
    Example: 2024-12-31T23:59:59.000000Z

