> For the complete documentation index, see [llms.txt](https://docs.decisionrules.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decisionrules.io/doc/~/changes/1017/api/jobs-api.md). Agents can also search and read this documentation through its [MCP server](https://docs.decisionrules.io/doc/~gitbook/mcp).

# Jobs API

The Jobs API is a secure REST API that manage jobs.

### Request authorization

{% hint style="info" %}
To authenticate your requests, you must use a Bearer token with a valid **Solver API key**.
{% endhint %}

For example:

```
Authorization: Bearer YOUR_SOLVER_API_KEY
```

## Cancel a job.

> Attempts to cancel a specific job by its ID. The job must belong to the requesting space.

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"servers":[{"url":"https://api.decisionrules.io/job"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"ApiKey"}},"schemas":{"Job":{"type":"object","properties":{"jobId":{"type":"string"},"correlationId":{"type":"string"},"inputData":{"type":"object","additionalProperties":true},"output":{"type":"object","additionalProperties":true,"nullable":true},"ruleReference":{"$ref":"#/components/schemas/JobRuleReference"},"context":{"$ref":"#/components/schemas/JobContext"},"status":{"$ref":"#/components/schemas/JobStatus"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"claimedAt":{"type":"string","format":"date-time"},"endedAt":{"type":"string","format":"date-time","nullable":true},"apiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"nullable":true},"solverVersion":{"type":"string","enum":["v1","v2"],"description":"Solver version the job runs on."}}},"JobRuleReference":{"type":"object","properties":{"baseId":{"type":"string","description":"The ID of the rule."},"version":{"type":"number","description":"The version of the rule."},"type":{"type":"string","description":"The type of the rule (e.g., IntegrationFlow)."}}},"JobContext":{"type":"object","properties":{"spaceId":{"type":"string"},"billingUserId":{"type":"string"},"executorUser":{"type":"object","nullable":true},"usedApiKeyId":{"type":"string","nullable":true}}},"JobStatus":{"type":"object","properties":{"state":{"$ref":"#/components/schemas/JobState"},"code":{"$ref":"#/components/schemas/JobStatusCode"},"message":{"type":"string","description":"A human-readable message for the status."}}},"JobState":{"type":"string","enum":["WAITING","RUNNING","COMPLETED","CANCELING","CANCELED","ERROR"]},"JobStatusCode":{"type":"string","enum":["JOB_SUCCESS","JOB_ERROR","JOB_TIMEOUT","JOB_QUOTA_EXCEEDED","JOB_EXECUTION_ERROR","JOB_VALIDATION_ERROR","JOB_USER_CANCELED","JOB_SYSTEM_CANCELED","ZOMBIE_PROCESS","JOB_INITIALIZED","JOB_RUNNING","JOB_WAITING"]}}},"paths":{"/cancel/{jobId}":{"post":{"summary":"Cancel a job.","description":"Attempts to cancel a specific job by its ID. The job must belong to the requesting space.","operationId":"cancelJob","parameters":[{"name":"jobId","in":"path","required":true,"description":"The ID of the job to cancel.","schema":{"type":"string"}}],"responses":{"200":{"description":"Job canceled successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Business error."},"401":{"description":"Unauthorized. Invalid or missing API key."}}}}}}
```

## Cancel all waiting jobs for a space.

> Cancels all jobs that are in a \`WAITING\` state for a specific space.

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"servers":[{"url":"https://api.decisionrules.io/job"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"ApiKey"}}},"paths":{"/cancelAll/space/{spaceId}":{"post":{"summary":"Cancel all waiting jobs for a space.","description":"Cancels all jobs that are in a `WAITING` state for a specific space.","operationId":"cancelAllWaitingJobsForSpace","parameters":[{"name":"spaceId","in":"path","required":true,"description":"The ID of the space.","schema":{"type":"string"}}],"responses":{"200":{"description":"The number of waiting jobs that were canceled.","content":{"application/json":{"schema":{"type":"object","properties":{"canceledCount":{"type":"number","description":"The total count of jobs that were canceled."}}}}}},"400":{"description":"Business error."},"401":{"description":"Unauthorized. Invalid or missing API key."}}}}}}
```

## Get job details.

> Retrieves detailed information about a specific job, including its status and output. The job must belong to the requesting space.

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"servers":[{"url":"https://api.decisionrules.io/job"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"ApiKey"}},"schemas":{"Job":{"type":"object","properties":{"jobId":{"type":"string"},"correlationId":{"type":"string"},"inputData":{"type":"object","additionalProperties":true},"output":{"type":"object","additionalProperties":true,"nullable":true},"ruleReference":{"$ref":"#/components/schemas/JobRuleReference"},"context":{"$ref":"#/components/schemas/JobContext"},"status":{"$ref":"#/components/schemas/JobStatus"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"claimedAt":{"type":"string","format":"date-time"},"endedAt":{"type":"string","format":"date-time","nullable":true},"apiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"nullable":true},"solverVersion":{"type":"string","enum":["v1","v2"],"description":"Solver version the job runs on."}}},"JobRuleReference":{"type":"object","properties":{"baseId":{"type":"string","description":"The ID of the rule."},"version":{"type":"number","description":"The version of the rule."},"type":{"type":"string","description":"The type of the rule (e.g., IntegrationFlow)."}}},"JobContext":{"type":"object","properties":{"spaceId":{"type":"string"},"billingUserId":{"type":"string"},"executorUser":{"type":"object","nullable":true},"usedApiKeyId":{"type":"string","nullable":true}}},"JobStatus":{"type":"object","properties":{"state":{"$ref":"#/components/schemas/JobState"},"code":{"$ref":"#/components/schemas/JobStatusCode"},"message":{"type":"string","description":"A human-readable message for the status."}}},"JobState":{"type":"string","enum":["WAITING","RUNNING","COMPLETED","CANCELING","CANCELED","ERROR"]},"JobStatusCode":{"type":"string","enum":["JOB_SUCCESS","JOB_ERROR","JOB_TIMEOUT","JOB_QUOTA_EXCEEDED","JOB_EXECUTION_ERROR","JOB_VALIDATION_ERROR","JOB_USER_CANCELED","JOB_SYSTEM_CANCELED","ZOMBIE_PROCESS","JOB_INITIALIZED","JOB_RUNNING","JOB_WAITING"]}}},"paths":{"/{jobId}":{"get":{"summary":"Get job details.","description":"Retrieves detailed information about a specific job, including its status and output. The job must belong to the requesting space.","operationId":"getJobsDetail","parameters":[{"name":"jobId","in":"path","required":true,"description":"The ID of the job to retrieve details for.","schema":{"type":"string"}}],"responses":{"200":{"description":"Job details retrieved successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Business error."},"401":{"description":"Unauthorized. Invalid or missing API key."}}}}}}
```

## The JobState object

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"components":{"schemas":{"JobState":{"type":"string","enum":["WAITING","RUNNING","COMPLETED","CANCELING","CANCELED","ERROR"]}}}}
```

## The JobStatusCode object

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"components":{"schemas":{"JobStatusCode":{"type":"string","enum":["JOB_SUCCESS","JOB_ERROR","JOB_TIMEOUT","JOB_QUOTA_EXCEEDED","JOB_EXECUTION_ERROR","JOB_VALIDATION_ERROR","JOB_USER_CANCELED","JOB_SYSTEM_CANCELED","ZOMBIE_PROCESS","JOB_INITIALIZED","JOB_RUNNING","JOB_WAITING"]}}}}
```

## The JobStatus object

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"components":{"schemas":{"JobStatus":{"type":"object","properties":{"state":{"$ref":"#/components/schemas/JobState"},"code":{"$ref":"#/components/schemas/JobStatusCode"},"message":{"type":"string","description":"A human-readable message for the status."}}},"JobState":{"type":"string","enum":["WAITING","RUNNING","COMPLETED","CANCELING","CANCELED","ERROR"]},"JobStatusCode":{"type":"string","enum":["JOB_SUCCESS","JOB_ERROR","JOB_TIMEOUT","JOB_QUOTA_EXCEEDED","JOB_EXECUTION_ERROR","JOB_VALIDATION_ERROR","JOB_USER_CANCELED","JOB_SYSTEM_CANCELED","ZOMBIE_PROCESS","JOB_INITIALIZED","JOB_RUNNING","JOB_WAITING"]}}}}
```

## The JobRuleReference object

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"components":{"schemas":{"JobRuleReference":{"type":"object","properties":{"baseId":{"type":"string","description":"The ID of the rule."},"version":{"type":"number","description":"The version of the rule."},"type":{"type":"string","description":"The type of the rule (e.g., IntegrationFlow)."}}}}}}
```

## The Job object

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"components":{"schemas":{"Job":{"type":"object","properties":{"jobId":{"type":"string"},"correlationId":{"type":"string"},"inputData":{"type":"object","additionalProperties":true},"output":{"type":"object","additionalProperties":true,"nullable":true},"ruleReference":{"$ref":"#/components/schemas/JobRuleReference"},"context":{"$ref":"#/components/schemas/JobContext"},"status":{"$ref":"#/components/schemas/JobStatus"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"claimedAt":{"type":"string","format":"date-time"},"endedAt":{"type":"string","format":"date-time","nullable":true},"apiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"nullable":true},"solverVersion":{"type":"string","enum":["v1","v2"],"description":"Solver version the job runs on."}}},"JobRuleReference":{"type":"object","properties":{"baseId":{"type":"string","description":"The ID of the rule."},"version":{"type":"number","description":"The version of the rule."},"type":{"type":"string","description":"The type of the rule (e.g., IntegrationFlow)."}}},"JobContext":{"type":"object","properties":{"spaceId":{"type":"string"},"billingUserId":{"type":"string"},"executorUser":{"type":"object","nullable":true},"usedApiKeyId":{"type":"string","nullable":true}}},"JobStatus":{"type":"object","properties":{"state":{"$ref":"#/components/schemas/JobState"},"code":{"$ref":"#/components/schemas/JobStatusCode"},"message":{"type":"string","description":"A human-readable message for the status."}}},"JobState":{"type":"string","enum":["WAITING","RUNNING","COMPLETED","CANCELING","CANCELED","ERROR"]},"JobStatusCode":{"type":"string","enum":["JOB_SUCCESS","JOB_ERROR","JOB_TIMEOUT","JOB_QUOTA_EXCEEDED","JOB_EXECUTION_ERROR","JOB_VALIDATION_ERROR","JOB_USER_CANCELED","JOB_SYSTEM_CANCELED","ZOMBIE_PROCESS","JOB_INITIALIZED","JOB_RUNNING","JOB_WAITING"]}}}}
```

## The JobContext object

```json
{"openapi":"3.0.0","info":{"title":"Job API","version":"1.0.0"},"components":{"schemas":{"JobContext":{"type":"object","properties":{"spaceId":{"type":"string"},"billingUserId":{"type":"string"},"executorUser":{"type":"object","nullable":true},"usedApiKeyId":{"type":"string","nullable":true}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decisionrules.io/doc/~/changes/1017/api/jobs-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
