👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

Jobs API

Manage your jobs running on Sanity's infrastructure.

The Jobs API lets you monitor and manage processes running inside Sanity's cloud infrastructure, such as dataset cloning. These processes are known collectively as jobs. All requests have to be authenticated.

Job Status

GET /v2021-06-07/jobs/:jobId

Accepts a job ID and returns the current status of that job.

Example

Request

curl --location --request GET 'https://api.sanity.io/v2021-06-07/jobs/<jobid>' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <token here>'

Response

// Running
{
    "id": "jacsfsmnxp",
    "state": "running",
    "authors": [
        "authorId"
    ],
    "created_at": "2020-11-09T17:34:28.071123Z",
    "updated_at": "2020-11-09T17:34:28.144826Z"
}

// Completed
{
    "id": "jarrwsdptf",
    "state": "completed",
    "authors": [
        "authorId"
    ],
    "created_at": "2020-11-09T17:07:41.304227Z",
    "updated_at": "2020-11-09T17:08:30.457692Z"
}

Listening for job status

GET /v2021-06-07/jobs/:jobId/listen

Each job has a /listen endpoint to allow you to monitor its status programmatically. While listening, event data will be sent back at intervals providing updates on the status of your job.

Example

Request

curl --location --request GET 'https://api.sanity.io/v2021-06-07/jobs/<jobid>/listen' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <token here>'

Response

event: welcome
data: {"listener_id": "ladaicdbdo"}

event: job
data: {"job_id":"jacsfsmnxp","state":"running","progress":60}

event: job
data: {"job_id":"jacsfsmnxp","state":"running","progress":80}

event: job
data: {"job_id":"jacsfsmnxp","state":"completed","progress":100}

Was this article helpful?