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 :

NameDescription
fieldThe field of the concerned resource you want to filter by
operatorThe operator you want to compare by
valueThe value of the given field you want to filter by

Available operators

OperatorDescription
eqequal to
not_eqnot equal to
ltlesser than
lteqlesser than or equal to
gtgreater than
gteqgreater than or equal to

Example #1 : Filter the invoices per source (ex: Stripe)

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

Example #2 : Filter the invoices per client id

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