Skip to main content

REST quickstart

This guide takes you from no access to a created job. You need to be an owner or admin of a FieldTask organization with API access enabled.

1. Create an API token​

  1. In FieldTask, open Settings → API connections. If you see Request API access, request it and wait for FieldTask to enable it.
  2. Choose Create API token and name it, for example "Quickstart".
  3. Choose Custom and select Create jobs. Read jobs and Read customers are selected automatically.
  4. Create the token and copy it. It's shown only once; choose I've saved it when you have it.

Set it and your API origin (shown in Settings → API connections) in your shell:

export FIELDTASK_API_ORIGIN="https://api.fieldtask.example" # use your own origin
read -r -s -p "FieldTask API token: " FIELDTASK_API_TOKEN && export FIELDTASK_API_TOKEN

2. Find a customer​

list-customers.sh
curl "$FIELDTASK_API_ORIGIN/public/v1/customers?page_size=5" \
--header "Authorization: Bearer $FIELDTASK_API_TOKEN"

You get up to five customers. Copy the id of the one the job is for:

{
"data": [
{ "id": "11111111-1111-4111-8111-111111111111", "name": "Example Property Services" }
],
"page": { "has_more": true, "next_cursor": "EXAMPLE_OPAQUE_CURSOR", "next_page_url": "https://api.fieldtask.example/public/v1/customers?page_size=5&cursor=EXAMPLE_OPAQUE_CURSOR" }
}

Customers have more fields than shown here; see List customers. If you have no customers yet, create one with Create a customer, which also needs Create customers.

3. Create a job​

Generate an idempotency key and keep it in your shell, so you can retry safely if the request times out:

export IDEMPOTENCY_KEY=$(python3 -c 'import uuid; print(uuid.uuid4())')

Then create an unscheduled job:

create-job.sh
curl --include --request POST "$FIELDTASK_API_ORIGIN/public/v1/jobs" \
--header "Authorization: Bearer $FIELDTASK_API_TOKEN" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: $IDEMPOTENCY_KEY" \
--data '{
"name": "Quickstart test job",
"customer_id": "11111111-1111-4111-8111-111111111111"
}'

Replace customer_id with the ID from step 2. You get 201 Created, the job in data, and headers including Location (the job's URL) and Operation-Location.

The job now appears under Jobs in FieldTask.

4. Retry safely​

Run the same command or program again in the same shell, without generating a new key. You get the same 201 response with Idempotency-Replayed: true, and no second job is created. That's how to retry after a timeout. See Idempotency and recovery.

Next steps​