A filtering system is available on listing endpoints to let you get resources according to your needs.
How does it work ?
You need to add a filter parameter to your GET request. This parameter has to be a JSON array of objects.
A filter object is always a combination of the three following keys :
Name | Description |
---|---|
field | The field of the concerned resource you want to filter by |
operator | The operator you want to compare by |
value | The value of the given field you want to filter by |
Available operators
Operator | Description |
---|---|
eq | equal to |
not_eq | not equal to |
lt | lesser than |
lteq | lesser than or equal to |
gt | greater than |
gteq | greater than or equal to |
Let's say you want to retrieve all invoices from Stripe. You need the field source, with operator eq, with value set to stripe.
filters = [
{
field: 'source',
operator: 'eq',
value: 'stripe'
},
].to_json
Now, let's say you want to retrieve all pending estimates for the customer whose id is MY_CUSTOMER_ID. You need 2 filters. When filtering by customer_id, the
eq
operator will return the invoices with a customer_id
similar to the passed value. If you want an exact match, you can use the match
operator. See the following example with two filters :filters = [
{
field: 'status',
operator: 'eq',
value: 'estimate_pending_status',
},
{
field: 'customer_id',
operator: 'match',
value: 'MY_CUSTOMER_ID',
},
].to_json