Filtering

The ServiceM8 API supports filtering of results by providing $filter option as part of a GET query request: $filter=FIELD OPERATOR 'VALUE'

KeyDescription
FIELDA valid field name for the current endpoint/record
OPERATORThe type of comparison/operator
VALUEThe value to search for / compare against

๐Ÿ“˜

URL want to get this right

Ensure that your filter statement is URL-encoded (see examples below), otherwise the API will return all records with no filtering applied.

Operators

OperatorDescription
eqEqual
neNot Equal
gtGreater Than
ltLess Than

Examples

All Job records for a single client

$filter is company_uuid eq โ€˜10420f98-7626-4405-bf43-043f1036623bโ€™

curl -u email:password "https://api.servicem8.com/api_1.0/job.json?%24filter=company_uuid%20eq%20'10420f98-7626-4405-bf43-043f1036623b'"

All Jobs where invoiced amount was greater than $1000.00

$filter is total_invoice_amount gt โ€˜1000.00โ€™

curl -u email:password "https://api.servicem8.com/api_1.0/job.json?%24filter=total_invoice_amount%20gt%20'1000.00'"

๐Ÿ“˜

One at a time, please

The ServiceM8 API supports only a single filter parameter per request. If you need more specific filtering, choose your filter such that you get the smallest number of records that is practical, then inspect the results in your application and discard any that do not match your requirements.