Filtering
Filters narrow a list to the objects you need, such as successful payments of $50 or more in a date range. Every list endpoint accepts a filters parameter, and its reference lists the fields it can filter on.
A filter object maps fields to conditions. An object matches when every condition matches.
Over HTTP, filters is a URL-encoded JSON query parameter. The SDKs encode it for you.
Combine conditions with and and or
or takes a list of filter objects and matches objects that meet any of them. and takes a list of filter objects and or groups and matches objects that meet all of them.
A single field also takes or with a list of conditions on that field, such as { amount: { or: [{ lt: 500 }, { gt: 10000 }] } }.
Conditions
Each field takes one kind of condition, shown in its type. A plain value matches exactly. An object of operators matches when all of its operators match.
Equality filters
ID and enum fields, such as customer, status and type.
| Operator | Matches |
|---|---|
eq | The value. |
not_eq | Anything but the value. |
in | Any value in the list. |
not_in | Any value not in the list. |
exists | true if the field is set, false if it’s null. |
not_eq and not_in don’t match objects where the field is null.
Number filters
Amounts and counts, such as amount and amount_refunded. Amounts are in cents.
| Operator | Matches |
|---|---|
eq | The value. |
gt, gte, lt, lte | Greater than, at least, less than, at most. |
exists | true if the field is set, false if it’s null. |
Timestamp filters
Dates, such as created_at, in milliseconds since the Unix epoch. The operators are the same as for number filters.
String filters
Text fields, such as a customer’s name or email. A plain string matches exactly, including case. Operators ignore case unless case_sensitive is true.
| Operator | Matches |
|---|---|
eq | The value. |
contains | Text containing the value. |
starts_with | Text starting with the value. |
ends_with | Text ending with the value. |
case_sensitive | true to match case. |
exists | true if the field is set, false if it’s null. |
A condition uses only one of eq, contains, starts_with and ends_with. To combine them, use and or or.
Boolean filters
Fields that are true or false. They take the value, or { eq: value }.