# Jobs API

### 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
```

## Start a new job.

> Starts a new asynchronous job for a specific Integration Flow.\
> The \`identifier\` is the unique ID of the Integration Flow, and \`version\` is its specific version.\
> This endpoint only accepts rules of type \`IntegrationFlow\`.<br>

```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":{"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":{"/start/{identifier}/{version}":{"post":{"summary":"Start a new job.","description":"Starts a new asynchronous job for a specific Integration Flow.\nThe `identifier` is the unique ID of the Integration Flow, and `version` is its specific version.\nThis endpoint only accepts rules of type `IntegrationFlow`.\n","operationId":"startJob","parameters":[{"name":"identifier","in":"path","required":true,"description":"The unique identifier of the Integration Flow.","schema":{"type":"string"}},{"name":"version","in":"path","required":false,"description":"The specific version of the Integration Flow. If not provided, the latest published version is used.","schema":{"type":"string"}}],"requestBody":{"description":"Input data for the Integration Flow.","required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"A JSON object containing the input data for the job."}}}},"responses":{"200":{"description":"Job started successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"jobId":{"type":"string","description":"The ID of the newly created job."},"status":{"$ref":"#/components/schemas/JobStatus"}}}}}},"400":{"description":"Business error."},"401":{"description":"Unauthorized. Invalid or missing 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}}},"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."}}}}}}
```

## Cancel all waiting jobs for a rule.

> Cancels all jobs that are in a \`WAITING\` state for a specific rule identifier and an optional version.

```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/rule/{identifier}/{version}":{"post":{"summary":"Cancel all waiting jobs for a rule.","description":"Cancels all jobs that are in a `WAITING` state for a specific rule identifier and an optional version.","operationId":"cancelAllWaitingJobsForRule","parameters":[{"name":"identifier","in":"path","required":true,"description":"The identifier of the rule.","schema":{"type":"string"}},{"name":"version","in":"path","required":false,"description":"The version of the rule. If not provided, jobs for all versions of the rule will be considered.","schema":{"type":"string"}}],"responses":{"200":{"description":"The number of waiting jobs that were canceled for the rule.","content":{"application/json":{"schema":{"type":"object","properties":{"canceledCount":{"type":"number","description":"The total count of jobs that were canceled."}}}}}},"400":{"description":"Bad request. Rule identifier or version is invalid."},"401":{"description":"Unauthorized. Invalid or missing API key."},"403":{"description":"Forbidden. Insufficient permissions to cancel jobs for this rule."}}}}}}
```

## 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}}},"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}}},"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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.decisionrules.io/doc/api/jobs-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
