Set up filters
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 |
in | field is included in value (must be an array) |
not_in | field is not included in value (must be an array) |
start_with | search text (ILIKE '123%') |
Example #1 : Filter the invoices per date
Let's say you want to retrieve all invoices from the 2024-01-01. You need the field date, with operator gteq, with value set to 2024-01-01.
filters = [
{
field: 'date',
operator: 'gteq',
value: '2024-01-01'
},
].to_json
Example #2 : Filter the invoices per multiple customer id
Now, let's say you want to retrieve all invoices from 2025 of two customers with id is ONE_CUSTOMER_ID and TWO_CUSTOMER_ID. You need 2 filters. When filtering by customer_id, the
in
operator will return the invoices with customer_id
similar to the passed values. See the following example with two filters :filters = [
{
field: 'date',
operator: 'gteq',
value: '2025-01-01',
},
{
field: 'customer_id',
operator: 'in',
value: '[ONE_CUSTOMER_ID, TWO_CUSTOMER_ID]',
},
].to_json
Updated 2 months ago