# Recalculations

Manage pick-pack recalculations

## Triggering an order recalculation

> Triggers order recalculation for a specified order list.<br>

```json
{"openapi":"3.0.0","info":{"title":"Pick-Pack Service","version":"0.0.1"},"tags":[{"name":"Recalculations","description":"Manage pick-pack recalculations"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["pickpack.pickpack_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"pickpack.pickpack_view":"Needed to retrieve information about resources in the service.","pickpack.pickpack_manage":"Needed to manage resources in the service."}}}}},"responses":{"jobCreationResponse":{"description":"Job creation response","content":{"application/json":{"schema":{"properties":{"jobId":{"type":"string"}}}}}},"BadRequest_400":{"description":"Request was syntactically incorrect. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. Details will be provided in the response payload.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"code":{"type":"integer"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}},"Conflict_409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}},"InternalServiceError_500":{"description":"Internal Service Error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}}},"schemas":{"errorMessage":{"title":"errorMessage","type":"object","properties":{"code":{"minimum":100,"maximum":599,"description":"original HTTP error code, should be consistent with the response HTTP code","type":"integer"},"message":{"pattern":"[a-z]+[a-z_]*[a-z]+","description":"classification of the error type, lower case with underscore eg validation_failure","type":"string"},"detailInfo":{"description":"More detailed information about the error","type":"string"}}},"RecalculationJobCreation":{"title":"RecalculationJobCreation","type":"object","properties":{"orderIds":{"type":"array","description":"The order identifiers requiring recalculation. This attribute is optional. In case the job type is `AUTOMATIC` the orders for recalculation will be selected automatically based on last packing events.","items":{"type":"string"}},"jobType":{"type":"string","enum":["AUTOMATIC","MANUAL"],"description":"The recalculation job types. Possible values:\n- `MANUAL` - recalculates all orders provided in the `orderIds` attribute\n- `AUTOMATIC` - finds orders that need recalculation and triggers recalculation for them"}},"required":["jobType"]}},"parameters":{"trait_tenant":{"name":"tenant","in":"path","required":true,"description":"Your Emporix tenant name.\n\n**Note**: The tenant name should always be written in lowercase.\n","schema":{"pattern":"^[a-z][a-z0-9]+$","minLength":3,"maxLength":16,"type":"string"}}}},"paths":{"/pick-pack/{tenant}/jobs/recalculations":{"post":{"tags":["Recalculations"],"responses":{"200":{"$ref":"#/components/responses/jobCreationResponse"},"400":{"$ref":"#/components/responses/BadRequest_400"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"},"409":{"$ref":"#/components/responses/Conflict_409"},"500":{"$ref":"#/components/responses/InternalServiceError_500"}},"description":"Triggers order recalculation for a specified order list.\n","parameters":[{"$ref":"#/components/parameters/trait_tenant"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecalculationJobCreation"}}}},"operationId":"POST-pick-pack-start-order-recalculations","summary":"Triggering an order recalculation"}}}}
```

## Retrieving a job

> Retrieves a specified job.<br>

```json
{"openapi":"3.0.0","info":{"title":"Pick-Pack Service","version":"0.0.1"},"tags":[{"name":"Recalculations","description":"Manage pick-pack recalculations"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["pickpack.pickpack_view"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"pickpack.pickpack_view":"Needed to retrieve information about resources in the service.","pickpack.pickpack_manage":"Needed to manage resources in the service."}}}}},"responses":{"getRecalculationJobResponse":{"description":"Recalculation job response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecalculationJob"}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. Details will be provided in the response payload.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"code":{"type":"integer"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}},"NotFound_404":{"description":"Resource has not been found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}},"InternalServiceError_500":{"description":"Internal Service Error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}}},"schemas":{"RecalculationJob":{"title":"RecalculationJob","type":"object","properties":{"id":{"type":"string"},"jobType":{"type":"string","enum":["AUTOMATIC","MANUAL"]},"orders":{"type":"array","items":{"$ref":"#/components/schemas/RecalculationJobOrder"}},"jobStatus":{"type":"string","enum":["SUCCESS","FAILURE","IN_PROGRESS"]},"startedAt":{"type":"string","format":"date-time"},"finishedAt":{"type":"string","format":"date-time"}}},"RecalculationJobOrder":{"title":"RecalculationJobOrder","type":"object","properties":{"orderId":{"type":"string"},"message":{"type":"string"},"jobOrderStatus":{"type":"string","enum":["SUCCESS","FAILURE","PENDING"]}},"description":""},"errorMessage":{"title":"errorMessage","type":"object","properties":{"code":{"minimum":100,"maximum":599,"description":"original HTTP error code, should be consistent with the response HTTP code","type":"integer"},"message":{"pattern":"[a-z]+[a-z_]*[a-z]+","description":"classification of the error type, lower case with underscore eg validation_failure","type":"string"},"detailInfo":{"description":"More detailed information about the error","type":"string"}}}},"parameters":{"trait_tenant":{"name":"tenant","in":"path","required":true,"description":"Your Emporix tenant name.\n\n**Note**: The tenant name should always be written in lowercase.\n","schema":{"pattern":"^[a-z][a-z0-9]+$","minLength":3,"maxLength":16,"type":"string"}}}},"paths":{"/pick-pack/{tenant}/jobs/recalculations/{jobId}":{"get":{"tags":["Recalculations"],"responses":{"200":{"$ref":"#/components/responses/getRecalculationJobResponse"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"},"404":{"$ref":"#/components/responses/NotFound_404"},"500":{"$ref":"#/components/responses/InternalServiceError_500"}},"description":"Retrieves a specified job.\n","parameters":[{"$ref":"#/components/parameters/trait_tenant"},{"name":"jobId","in":"path","required":true,"schema":{"pattern":"[a-zA-Z0-9_-]+","minLength":3,"maxLength":16,"type":"string"},"description":"jobId of requested order recalculation job"}],"summary":"Retrieving a job","operationId":"GET-pick-pack-retrieve-order-recalculation"}}}}
```
