> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 4.9.1 Report jobs

> Report jobs for ReportGeneratorTool.

These OpenAPI extracts describe the proposed `/v1` contract for Report Automation Tool. They are specification examples, not evidence that these endpoints are deployed.

## List report jobs

> List this workspace's jobs newest first. Keep filters unchanged when using a cursor.

```json theme={null}
{"openapi":"3.1.0","info":{"title":"ReportGeneratorTool API","version":"1.0.0"},"tags":[{"name":"jobs"}],"servers":[{"url":"https://api.reportgenerator.example.com","description":"Production example"},{"url":"https://api.staging.reportgenerator.example.com","description":"Staging example"}],"security":[{"WorkspaceApiKey":[]}],"components":{"securitySchemes":{"WorkspaceApiKey":{"type":"http","scheme":"bearer","description":"Workspace API key issued by your administrator."}},"parameters":{"Limit":{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},"Cursor":{"name":"cursor","in":"query","description":"Opaque cursor, scoped to the workspace and filters; expires in 15 minutes.","schema":{"type":"string"}}},"schemas":{"ReportJobList":{"type":"object","required":["data","nextCursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ReportJob"}},"nextCursor":{"type":["string","null"]}}},"ReportJob":{"type":"object","required":["id","status","createdAt","updatedAt"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["queued","running","cancelling","succeeded","failed","cancelled"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"reportId":{"type":["string","null"],"description":"Set after the PDF is stored, including when initial email subsequently fails."},"error":{"oneOf":[{"$ref":"#/components/schemas/JobError"},{"type":"null"}]}}},"JobError":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["portal_login_failed","portal_unavailable","report_generation_failed","email_delivery_failed","internal_error"]},"message":{"type":"string","description":"Sanitized worker error."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","requestId"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"details":{"type":"array","items":{"$ref":"#/components/schemas/ErrorDetail"}}}}}},"ErrorDetail":{"type":"object","required":["field","message"],"properties":{"field":{"type":"string"},"message":{"type":"string"}}}},"responses":{"Error400":{"description":"Invalid JSON, query parameter or cursor.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error401":{"description":"Missing or invalid workspace API key.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error403":{"description":"Insufficient permission.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error429":{"description":"Workspace rate or concurrency limit reached.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error500":{"description":"Unexpected service failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error503":{"description":"Temporary dependency failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/v1/report-jobs":{"get":{"tags":["jobs"],"operationId":"ListReportJobs","summary":"List report jobs","description":"List this workspace's jobs newest first. Keep filters unchanged when using a cursor.","parameters":[{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/Cursor"},{"name":"status","in":"query","schema":{"type":"string","enum":["queued","running","cancelling","succeeded","failed","cancelled"]}}],"responses":{"200":{"description":"A page of jobs.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportJobList"}}}},"400":{"$ref":"#/components/responses/Error400"},"401":{"$ref":"#/components/responses/Error401"},"403":{"$ref":"#/components/responses/Error403"},"429":{"$ref":"#/components/responses/Error429"},"500":{"$ref":"#/components/responses/Error500"},"503":{"$ref":"#/components/responses/Error503"}}}}}}
```

## Create a report job

> Validate before queueing one report. Initial processing includes PDF generation and email delivery.

```json theme={null}
{"openapi":"3.1.0","info":{"title":"ReportGeneratorTool API","version":"1.0.0"},"tags":[{"name":"jobs"}],"servers":[{"url":"https://api.reportgenerator.example.com","description":"Production example"},{"url":"https://api.staging.reportgenerator.example.com","description":"Staging example"}],"security":[{"WorkspaceApiKey":[]}],"components":{"securitySchemes":{"WorkspaceApiKey":{"type":"http","scheme":"bearer","description":"Workspace API key issued by your administrator."}},"parameters":{"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":true,"description":"Required key for 24-hour deduplication. A changed body with the same key returns 409.","schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[A-Za-z0-9._-]+$"}}},"schemas":{"CreateReportJobRequest":{"type":"object","required":["client","url","devices","fromDate","toDate","sentTo"],"properties":{"client":{"$ref":"#/components/schemas/Client"},"url":{"type":"string","description":"Allowlisted HTTPS portal URL.","format":"uri","pattern":"^https://"},"devices":{"type":"array","minItems":1,"maxItems":1,"items":{"$ref":"#/components/schemas/ReportDevice"}},"fromDate":{"type":"string","description":"UTC RFC 3339 timestamp ending in Z.","format":"date-time","pattern":"Z$"},"toDate":{"type":"string","description":"Later than fromDate and within 31 days.","format":"date-time","pattern":"Z$"},"sentTo":{"type":"array","minItems":1,"maxItems":20,"uniqueItems":true,"items":{"type":"string","format":"email"}}},"additionalProperties":false},"Client":{"type":"object","required":["name","username","password"],"properties":{"name":{"type":"string","minLength":1,"maxLength":100},"username":{"type":"string","minLength":1,"maxLength":256},"password":{"type":"string","format":"password","writeOnly":true,"minLength":1,"maxLength":4096},"logo":{"type":"string","description":"Optional HTTPS logo on an approved host.","format":"uri","pattern":"^https://"}},"additionalProperties":false},"ReportDevice":{"type":"object","required":["device_id","temp_threshold"],"properties":{"device_id":{"type":"string","minLength":1,"maxLength":128},"temp_threshold":{"$ref":"#/components/schemas/TemperatureThreshold"}},"additionalProperties":false},"TemperatureThreshold":{"type":"object","required":["min","max"],"properties":{"min":{"type":"number","description":"Inclusive low threshold in degrees Celsius; less than max."},"max":{"type":"number","description":"Inclusive high threshold in degrees Celsius; greater than min."}},"additionalProperties":false},"ReportJob":{"type":"object","required":["id","status","createdAt","updatedAt"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["queued","running","cancelling","succeeded","failed","cancelled"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"reportId":{"type":["string","null"],"description":"Set after the PDF is stored, including when initial email subsequently fails."},"error":{"oneOf":[{"$ref":"#/components/schemas/JobError"},{"type":"null"}]}}},"JobError":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["portal_login_failed","portal_unavailable","report_generation_failed","email_delivery_failed","internal_error"]},"message":{"type":"string","description":"Sanitized worker error."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","requestId"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"details":{"type":"array","items":{"$ref":"#/components/schemas/ErrorDetail"}}}}}},"ErrorDetail":{"type":"object","required":["field","message"],"properties":{"field":{"type":"string"},"message":{"type":"string"}}}},"responses":{"Error400":{"description":"Invalid JSON, query parameter or cursor.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error401":{"description":"Missing or invalid workspace API key.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error403":{"description":"Insufficient permission.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error409":{"description":"Resource state or idempotency conflict.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error413":{"description":"Request exceeds 256 KiB.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error415":{"description":"Use application/json.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error422":{"description":"The request contains invalid fields.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error429":{"description":"Workspace rate or concurrency limit reached.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error500":{"description":"Unexpected service failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error503":{"description":"Temporary dependency failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/v1/report-jobs":{"post":{"tags":["jobs"],"operationId":"CreateReportJob","summary":"Create a report job","description":"Validate before queueing one report. Initial processing includes PDF generation and email delivery.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateReportJobRequest"}}}},"responses":{"202":{"description":"Job accepted.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Location":{"schema":{"type":"string"},"description":"Relative URL /v1/report-jobs/{jobId}."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportJob"}}}},"400":{"$ref":"#/components/responses/Error400"},"401":{"$ref":"#/components/responses/Error401"},"403":{"$ref":"#/components/responses/Error403"},"409":{"$ref":"#/components/responses/Error409"},"413":{"$ref":"#/components/responses/Error413"},"415":{"$ref":"#/components/responses/Error415"},"422":{"$ref":"#/components/responses/Error422"},"429":{"$ref":"#/components/responses/Error429"},"500":{"$ref":"#/components/responses/Error500"},"503":{"$ref":"#/components/responses/Error503"}}}}}}
```

## Get job status

> Poll every five seconds until succeeded, failed or cancelled. Email failure can leave an available reportId.

```json theme={null}
{"openapi":"3.1.0","info":{"title":"ReportGeneratorTool API","version":"1.0.0"},"tags":[{"name":"jobs"}],"servers":[{"url":"https://api.reportgenerator.example.com","description":"Production example"},{"url":"https://api.staging.reportgenerator.example.com","description":"Staging example"}],"security":[{"WorkspaceApiKey":[]}],"components":{"securitySchemes":{"WorkspaceApiKey":{"type":"http","scheme":"bearer","description":"Workspace API key issued by your administrator."}},"schemas":{"ReportJob":{"type":"object","required":["id","status","createdAt","updatedAt"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["queued","running","cancelling","succeeded","failed","cancelled"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"reportId":{"type":["string","null"],"description":"Set after the PDF is stored, including when initial email subsequently fails."},"error":{"oneOf":[{"$ref":"#/components/schemas/JobError"},{"type":"null"}]}}},"JobError":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["portal_login_failed","portal_unavailable","report_generation_failed","email_delivery_failed","internal_error"]},"message":{"type":"string","description":"Sanitized worker error."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","requestId"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"details":{"type":"array","items":{"$ref":"#/components/schemas/ErrorDetail"}}}}}},"ErrorDetail":{"type":"object","required":["field","message"],"properties":{"field":{"type":"string"},"message":{"type":"string"}}}},"responses":{"Error401":{"description":"Missing or invalid workspace API key.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error403":{"description":"Insufficient permission.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error404":{"description":"Resource not found in this workspace.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error429":{"description":"Workspace rate or concurrency limit reached.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error500":{"description":"Unexpected service failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error503":{"description":"Temporary dependency failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/v1/report-jobs/{jobId}":{"get":{"tags":["jobs"],"operationId":"GetReportJob","summary":"Get job status","description":"Poll every five seconds until succeeded, failed or cancelled. Email failure can leave an available reportId.","parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Current job state.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportJob"}}}},"401":{"$ref":"#/components/responses/Error401"},"403":{"$ref":"#/components/responses/Error403"},"404":{"$ref":"#/components/responses/Error404"},"429":{"$ref":"#/components/responses/Error429"},"500":{"$ref":"#/components/responses/Error500"},"503":{"$ref":"#/components/responses/Error503"}}}}}}
```

## Request cancellation

> Accept queued or running jobs. Repeating for cancelling or cancelled returns the current state. Succeeded or failed returns 409. Cannot recall submitted email.

```json theme={null}
{"openapi":"3.1.0","info":{"title":"ReportGeneratorTool API","version":"1.0.0"},"tags":[{"name":"jobs"}],"servers":[{"url":"https://api.reportgenerator.example.com","description":"Production example"},{"url":"https://api.staging.reportgenerator.example.com","description":"Staging example"}],"security":[{"WorkspaceApiKey":[]}],"components":{"securitySchemes":{"WorkspaceApiKey":{"type":"http","scheme":"bearer","description":"Workspace API key issued by your administrator."}},"schemas":{"ReportJob":{"type":"object","required":["id","status","createdAt","updatedAt"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["queued","running","cancelling","succeeded","failed","cancelled"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"reportId":{"type":["string","null"],"description":"Set after the PDF is stored, including when initial email subsequently fails."},"error":{"oneOf":[{"$ref":"#/components/schemas/JobError"},{"type":"null"}]}}},"JobError":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["portal_login_failed","portal_unavailable","report_generation_failed","email_delivery_failed","internal_error"]},"message":{"type":"string","description":"Sanitized worker error."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","requestId"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"details":{"type":"array","items":{"$ref":"#/components/schemas/ErrorDetail"}}}}}},"ErrorDetail":{"type":"object","required":["field","message"],"properties":{"field":{"type":"string"},"message":{"type":"string"}}}},"responses":{"Error401":{"description":"Missing or invalid workspace API key.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error403":{"description":"Insufficient permission.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error404":{"description":"Resource not found in this workspace.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error409":{"description":"Resource state or idempotency conflict.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error429":{"description":"Workspace rate or concurrency limit reached.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error500":{"description":"Unexpected service failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Error503":{"description":"Temporary dependency failure.","headers":{"X-Request-Id":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer","minimum":1},"description":"Seconds to wait before retrying."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/v1/report-jobs/{jobId}/cancel":{"post":{"tags":["jobs"],"operationId":"CancelReportJob","summary":"Request cancellation","description":"Accept queued or running jobs. Repeating for cancelling or cancelled returns the current state. Succeeded or failed returns 409. Cannot recall submitted email.","parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Already cancelled.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportJob"}}}},"202":{"description":"Cancellation pending.","headers":{"X-Request-Id":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportJob"}}}},"401":{"$ref":"#/components/responses/Error401"},"403":{"$ref":"#/components/responses/Error403"},"404":{"$ref":"#/components/responses/Error404"},"409":{"$ref":"#/components/responses/Error409"},"429":{"$ref":"#/components/responses/Error429"},"500":{"$ref":"#/components/responses/Error500"},"503":{"$ref":"#/components/responses/Error503"}}}}}}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.