API and MCP
Jobs
The work a project runs: surveys, uploads and reports, with their progress and outcome
List jobs
GET /api/v1/project/{projectId}/v1/job
Credentials: API token or dashboard sign-in.
The project's jobs, newest first by default. Filter with jobType, one or more of INVENTORY_SURVEY, RUNTIME_SURVEY, REPORT, UPLOAD, INSTANCE_STARTUP, PORTFOLIO_SNAPSHOT and PORTFOLIO_BACKFILL, comma separated, and status, one of PENDING, RUNNING, COMPLETED, FAILED or SKIPPED. topLevel=true returns one row per survey with its steps nested, and deleted surveys are left out unless showDeleted=true. sortBy accepts only createdAt, the default, and sortDir is asc or desc (default desc). Page with limit, 1 to 10000 and 1000 by default, and the cursors after or before, taking pagination.lastId or pagination.firstId from the previous page. Requires project:view.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
projectId required | path | string (uuid) | The project's id. |
jobType | query | string | Only jobs of these types, comma-separated: INVENTORY_SURVEY, RUNTIME_SURVEY, REPORT, UPLOAD, INSTANCE_STARTUP, PORTFOLIO_BACKFILL or PORTFOLIO_SNAPSHOT (any case) |
status | query | string | Only jobs in this status: PENDING, RUNNING, COMPLETED, FAILED or SKIPPED (any case) |
limit | query | string | Page size, 1 to 10000 (default 1000) |
sortBy | query | string | Sort field; only createdAt (the default) |
sortDir | query | string | asc or desc (default desc) |
after | query | string | Job ID cursor: rows after it. Not together with before |
before | query | string | Job ID cursor: rows before it. Not together with after |
topLevel | query | boolean | One row per survey with its steps under steps (default false: every job as its own row) |
showDeleted | query | boolean | Include deleted surveys (default false) |
Responses
| Status | Description | Body |
|---|---|---|
200 | The matching jobs in jobs, with pagination cursors. | JobPage |
400 | A filter value is unknown, status names more than one value, sortBy is not createdAt, limit is out of range, a cursor is invalid, or both cursors are given. | Error |
401 | The token is missing, expired, revoked or of the wrong kind. | Error |
403 | The token is valid but not allowed to do this. | Error |
500 | A fault on our side. | Error |
503 | The project's data is temporarily unreachable; code says why. | Error |
Example
curl -X GET "https://api.spicelabs.io/api/v1/project/<projectId>/v1/job" \
-H "Authorization: Bearer $SPICE_API_TOKEN" Get a job
GET /api/v1/project/{projectId}/v1/job/{jobId}
Credentials: API token or dashboard sign-in.
One job by id: its type, status, progress, message, timestamps and metadata. A survey includes its steps in steps; a deleted survey carries deleted_at. Requires project:view.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
projectId required | path | string (uuid) | The project's id. |
jobId required | path | string (uuid) | The job ID |
Responses
| Status | Description | Body |
|---|---|---|
200 | The job. | Job |
401 | The token is missing, expired, revoked or of the wrong kind. | Error |
403 | The token is valid but not allowed to do this. | Error |
404 | No job with this id exists in this project. | Error |
500 | A fault on our side. | Error |
503 | The project's data is temporarily unreachable; code says why. | Error |
Example
curl -X GET "https://api.spicelabs.io/api/v1/project/<projectId>/v1/job/<jobId>" \
-H "Authorization: Bearer $SPICE_API_TOKEN" Stream job updates
GET /api/v1/project/{projectId}/v1/job/stream
Credentials: API token or dashboard sign-in.
A text/event-stream of this project's job changes. Each job-update event carries the changed job in the same shape as GET .../v1/job/{jobId}. The stream opens with a connected comment, sends a heartbeat comment every 25 seconds, and closes after one hour; reconnect to keep listening. Requires project:view.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
projectId required | path | string (uuid) | The project's id. |
Responses
| Status | Description | Body |
|---|---|---|
200 | An open event stream: a connected comment first, then a job-update event whose data is the changed job as JSON each time a job changes, with a heartbeat comment every 25 seconds. | string |
401 | The token is missing, expired, revoked or of the wrong kind. | Error |
403 | The token is valid but not allowed to do this. | Error |
406 | The request's Accept header does not allow text/event-stream. | Error |
500 | A fault on our side. | Error |
503 | The project's data is temporarily unreachable; code says why. | Error |
Example
curl -X GET "https://api.spicelabs.io/api/v1/project/<projectId>/v1/job/stream" \
-H "Authorization: Bearer $SPICE_API_TOKEN" Render a report again
POST /api/v1/project/{projectId}/v1/report/{jobId}/render
Credentials: API token or dashboard sign-in.
Produces a report's documents again from the results it already has, without a new upload, analysis or report version: use it when only the document formatting changed. jobId is a completed report: a survey's REPORT step or a posture report. The answer lists the new render steps by format in renderSubJobIds; follow them as jobs. Requires project:edit.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
projectId required | path | string (uuid) | The project's id. |
jobId required | path | string (uuid) | The report's job ID: a survey's report step, or a posture report |
Responses
| Status | Description | Body |
|---|---|---|
202 | Rendering has started; renderSubJobIds maps each format to its job id. | RenderStarted |
401 | The token is missing, expired, revoked or of the wrong kind. | Error |
403 | The token is valid but not allowed to do this. | Error |
404 | No job with this id exists in this project. | Error |
409 | The job is not a completed report, so there is nothing to render from. | Error |
500 | A fault on our side. | Error |
503 | The project's data is temporarily unreachable; code says why. | Error |
Example
curl -X POST "https://api.spicelabs.io/api/v1/project/<projectId>/v1/report/<jobId>/render" \
-H "Authorization: Bearer $SPICE_API_TOKEN" Delete a survey
DELETE /api/v1/project/{projectId}/v1/survey/{jobId}
What it changes: The survey and its reports leave the default job list, and bringing them back with Restore a survey needs `project:admin`.
Credentials: API token or dashboard sign-in.
Hides a survey from the default job listing and stamps it with deleted_at. Nothing is erased: the survey and its steps stay readable by id and with showDeleted=true, and POST .../v1/survey/{jobId}/restore, which requires project:admin, brings it back. Only a survey can be deleted, not one of its steps. Deleting an already deleted survey changes nothing. Requires project:edit.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
projectId required | path | string (uuid) | The project's id. |
jobId required | path | string (uuid) |
Responses
| Status | Description | Body |
|---|---|---|
200 | The survey as it now stands, with deleted_at set. | Job |
400 | The job is a step or another job type, not a survey. | Error |
401 | The token is missing, expired, revoked or of the wrong kind. | Error |
403 | The token is valid but not allowed to do this. | Error |
404 | No job with this id exists in this project. | Error |
500 | A fault on our side. | Error |
503 | The project's data is temporarily unreachable; code says why. | Error |
Example
curl -X DELETE "https://api.spicelabs.io/api/v1/project/<projectId>/v1/survey/<jobId>" \
-H "Authorization: Bearer $SPICE_API_TOKEN" Restore a survey
POST /api/v1/project/{projectId}/v1/survey/{jobId}/restore
Credentials: API token or dashboard sign-in.
Undoes a delete: clears the survey's deleted_at so it appears in the default job listing again. Restoring a survey that is not deleted changes nothing. Requires project:admin.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
projectId required | path | string (uuid) | The project's id. |
jobId required | path | string (uuid) |
Responses
| Status | Description | Body |
|---|---|---|
200 | The survey as it now stands, without deleted_at. | Job |
400 | The job is a step or another job type, not a survey. | Error |
401 | The token is missing, expired, revoked or of the wrong kind. | Error |
403 | The token is valid but not allowed to do this. | Error |
404 | No job with this id exists in this project. | Error |
500 | A fault on our side. | Error |
503 | The project's data is temporarily unreachable; code says why. | Error |
Example
curl -X POST "https://api.spicelabs.io/api/v1/project/<projectId>/v1/survey/<jobId>/restore" \
-H "Authorization: Bearer $SPICE_API_TOKEN"