# Job

Manage Jobs

## Listing available jobs

> Retrieves agent jobs.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Job","description":"Manage Jobs"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agent_read"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"schemas":{"Job":{"type":"object","description":"Contains information about the job result - whether it was successful or not, what was the agent output etc.","properties":{"id":{"type":"string","description":"Unique identifier of the job."},"agentType":{"$ref":"#/components/schemas/AgentType"},"status":{"$ref":"#/components/schemas/JobStatus"},"type":{"$ref":"#/components/schemas/JobType"},"exportResult":{"$ref":"#/components/schemas/ExportResult"},"importResult":{"$ref":"#/components/schemas/ImportResult"},"sessionId":{"type":"string","description":"Unique identifier of the session."},"agentId":{"type":"string","description":"Unique identifier of the agent."},"message":{"type":"string","description":"Agent message."},"commerceEvent":{"type":"string","description":"Commerce event which triggered the job."},"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}},"AgentType":{"type":"string","description":"Type of the agent handling the request.","enum":["support","generic","complaint","anti_fraud"]},"JobStatus":{"type":"string","enum":["in_progress","success","failure"],"description":"Status of the job."},"JobType":{"type":"string","enum":["IMPORT","EXPORT","AGENT_CHAT"],"description":"Type of the job."},"ExportResult":{"type":"object","properties":{"data":{"type":"string","description":"The base64 encoded JSON value of the exported agents with related tools and MCP servers."},"checksum":{"type":"string","description":"Checksum calculated based on JSON value. Validates if importing JSON is exactly the same as the exported one."}}},"ImportResult":{"type":"object","properties":{"message":{"type":"string","description":"Short summary of the import."},"summary":{"type":"object","description":"Summary of the import.","properties":{"agents":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}},"tools":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}},"mcpServers":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}}}}}},"ImportedEntity":{"type":"object","properties":{"id":{"type":"string","description":"ID of the imported entity."},"name":{"type":"string","description":"Name of the imported entity."},"state":{"type":"string","description":"State of the imported entity.","enum":["TO_CREATE","ENABLED","DISABLED","EXISTS"]}}},"MetadataResponse":{"allOf":[{"$ref":"#/components/schemas/MetadataRequest"},{"type":"object","properties":{"createdAt":{"description":"Date and time when the object was created. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-31T13:18:02.379Z`","type":"string"},"modifiedAt":{"description":"Date and time when the object was last modified. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-31T13:18:02.379Z`","type":"string"}},"required":["version","createdAt","modifiedAt"]}]},"MetadataRequest":{"type":"object","properties":{"version":{"minimum":1,"type":"integer","description":"Version of the object. The version is required during the update operation because of the optimistic locking mechanism."}},"required":["version"]},"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}}},"paths":{"/ai-service/{tenant}/jobs":{"get":{"summary":"Listing available jobs","operationId":"GET-ai-list-jobs","responses":{"200":{"description":"List of available jobs.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Job"}}}}},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"}},"description":"Retrieves agent jobs.","tags":["Job"]}}}}
```

## Searching jobs

> Searches for agent jobs based on the provided query.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Job","description":"Manage Jobs"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agent_read"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"parameters":{"pageSize":{"schema":{"type":"string"},"in":"query","name":"pageSize","description":"The number of documents to be retrieved per page."},"pageNumber":{"schema":{"type":"string"},"in":"query","name":"pageNumber","description":"The page number to be retrieved. The size of the pages should be specified by the `pageSize` parameter."},"sort":{"schema":{"type":"string"},"in":"query","name":"sort","description":"List of properties used to sort the results, separated by colons."},"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."},"header_xTotalCount":{"schema":{"type":"boolean"},"in":"header","name":"X-Total-Count","description":"Flag indicating whether the total number of retrieved results should be returned."}},"schemas":{"Job":{"type":"object","description":"Contains information about the job result - whether it was successful or not, what was the agent output etc.","properties":{"id":{"type":"string","description":"Unique identifier of the job."},"agentType":{"$ref":"#/components/schemas/AgentType"},"status":{"$ref":"#/components/schemas/JobStatus"},"type":{"$ref":"#/components/schemas/JobType"},"exportResult":{"$ref":"#/components/schemas/ExportResult"},"importResult":{"$ref":"#/components/schemas/ImportResult"},"sessionId":{"type":"string","description":"Unique identifier of the session."},"agentId":{"type":"string","description":"Unique identifier of the agent."},"message":{"type":"string","description":"Agent message."},"commerceEvent":{"type":"string","description":"Commerce event which triggered the job."},"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}},"AgentType":{"type":"string","description":"Type of the agent handling the request.","enum":["support","generic","complaint","anti_fraud"]},"JobStatus":{"type":"string","enum":["in_progress","success","failure"],"description":"Status of the job."},"JobType":{"type":"string","enum":["IMPORT","EXPORT","AGENT_CHAT"],"description":"Type of the job."},"ExportResult":{"type":"object","properties":{"data":{"type":"string","description":"The base64 encoded JSON value of the exported agents with related tools and MCP servers."},"checksum":{"type":"string","description":"Checksum calculated based on JSON value. Validates if importing JSON is exactly the same as the exported one."}}},"ImportResult":{"type":"object","properties":{"message":{"type":"string","description":"Short summary of the import."},"summary":{"type":"object","description":"Summary of the import.","properties":{"agents":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}},"tools":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}},"mcpServers":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}}}}}},"ImportedEntity":{"type":"object","properties":{"id":{"type":"string","description":"ID of the imported entity."},"name":{"type":"string","description":"Name of the imported entity."},"state":{"type":"string","description":"State of the imported entity.","enum":["TO_CREATE","ENABLED","DISABLED","EXISTS"]}}},"MetadataResponse":{"allOf":[{"$ref":"#/components/schemas/MetadataRequest"},{"type":"object","properties":{"createdAt":{"description":"Date and time when the object was created. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-31T13:18:02.379Z`","type":"string"},"modifiedAt":{"description":"Date and time when the object was last modified. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-31T13:18:02.379Z`","type":"string"}},"required":["version","createdAt","modifiedAt"]}]},"MetadataRequest":{"type":"object","properties":{"version":{"minimum":1,"type":"integer","description":"Version of the object. The version is required during the update operation because of the optimistic locking mechanism."}},"required":["version"]},"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}},"QParamSearchBody":{"type":"object","properties":{"q":{"type":"string","description":"A standard query parameter is used to search for specific values. \n\nSee: [Standard Practices - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param)\n"}}}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"requestBodies":{"QParamSearchBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QParamSearchBody"}}}}}},"paths":{"/ai-service/{tenant}/jobs/search":{"post":{"parameters":[{"$ref":"#/components/parameters/pageSize"},{"$ref":"#/components/parameters/pageNumber"},{"$ref":"#/components/parameters/sort"},{"$ref":"#/components/parameters/fields"},{"$ref":"#/components/parameters/header_xTotalCount"}],"summary":"Searching jobs","operationId":"POST-ai-search-jobs","responses":{"200":{"description":"List of available jobs.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Job"}}}}},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"}},"requestBody":{"$ref":"#/components/requestBodies/QParamSearchBody"},"description":"Searches for agent jobs based on the provided query.","tags":["Job"]}}}}
```

## Retrieving available job

> Retrieves agent job by its ID.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Job","description":"Manage Jobs"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agent_read"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"parameters":{"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."}},"schemas":{"Job":{"type":"object","description":"Contains information about the job result - whether it was successful or not, what was the agent output etc.","properties":{"id":{"type":"string","description":"Unique identifier of the job."},"agentType":{"$ref":"#/components/schemas/AgentType"},"status":{"$ref":"#/components/schemas/JobStatus"},"type":{"$ref":"#/components/schemas/JobType"},"exportResult":{"$ref":"#/components/schemas/ExportResult"},"importResult":{"$ref":"#/components/schemas/ImportResult"},"sessionId":{"type":"string","description":"Unique identifier of the session."},"agentId":{"type":"string","description":"Unique identifier of the agent."},"message":{"type":"string","description":"Agent message."},"commerceEvent":{"type":"string","description":"Commerce event which triggered the job."},"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}},"AgentType":{"type":"string","description":"Type of the agent handling the request.","enum":["support","generic","complaint","anti_fraud"]},"JobStatus":{"type":"string","enum":["in_progress","success","failure"],"description":"Status of the job."},"JobType":{"type":"string","enum":["IMPORT","EXPORT","AGENT_CHAT"],"description":"Type of the job."},"ExportResult":{"type":"object","properties":{"data":{"type":"string","description":"The base64 encoded JSON value of the exported agents with related tools and MCP servers."},"checksum":{"type":"string","description":"Checksum calculated based on JSON value. Validates if importing JSON is exactly the same as the exported one."}}},"ImportResult":{"type":"object","properties":{"message":{"type":"string","description":"Short summary of the import."},"summary":{"type":"object","description":"Summary of the import.","properties":{"agents":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}},"tools":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}},"mcpServers":{"type":"array","items":{"$ref":"#/components/schemas/ImportedEntity"}}}}}},"ImportedEntity":{"type":"object","properties":{"id":{"type":"string","description":"ID of the imported entity."},"name":{"type":"string","description":"Name of the imported entity."},"state":{"type":"string","description":"State of the imported entity.","enum":["TO_CREATE","ENABLED","DISABLED","EXISTS"]}}},"MetadataResponse":{"allOf":[{"$ref":"#/components/schemas/MetadataRequest"},{"type":"object","properties":{"createdAt":{"description":"Date and time when the object was created. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-31T13:18:02.379Z`","type":"string"},"modifiedAt":{"description":"Date and time when the object was last modified. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-31T13:18:02.379Z`","type":"string"}},"required":["version","createdAt","modifiedAt"]}]},"MetadataRequest":{"type":"object","properties":{"version":{"minimum":1,"type":"integer","description":"Version of the object. The version is required during the update operation because of the optimistic locking mechanism."}},"required":["version"]},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}},"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""}},"responses":{"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"404_resp_common":{"description":"Example response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}}},"paths":{"/ai-service/{tenant}/jobs/{jobId}":{"get":{"parameters":[{"$ref":"#/components/parameters/fields"}],"summary":"Retrieving available job","operationId":"GET-ai-job","responses":{"200":{"description":"A job details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"},"404":{"$ref":"#/components/responses/404_resp_common"}},"description":"Retrieves agent job by its ID.","tags":["Job"]}}}}
```

## Deleting a job

> Deletes job by given ID.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Job","description":"Manage Jobs"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agent_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"404_resp_common":{"description":"Example response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"schemas":{"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}},"paths":{"/ai-service/{tenant}/jobs/{jobId}":{"delete":{"summary":"Deleting a job","operationId":"DELETE-ai-job","responses":{"204":{"description":"Given job has been deleted."},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"},"404":{"$ref":"#/components/responses/404_resp_common"}},"description":"Deletes job by given ID.","tags":["Job"]}}}}
```
