# Delivery Plan

## Creating orders for delivery provider

> Pushes the specified orders to the delivery provider for the given tenant. If route planning fails for an order (e.g., due to an invalid address), an email is sent to the merchant.<br>

```json
{"openapi":"3.0.0","info":{"title":"Delivery Service","version":"0.0.1"},"tags":[{"name":"Delivery Plan"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{}}}}},"schemas":{"PlanRouteCommand":{"type":"object","properties":{"orderStatus":{"$ref":"#/components/schemas/OrderStatus"},"siteCode":{"type":"string"},"orderIds":{"$ref":"#/components/schemas/OrderIdList"}},"required":["siteCode"]},"OrderStatus":{"type":"string","enum":["IN_CHECKOUT","CREATED","CONFIRMED","DECLINED","SHIPPED","COMPLETED"]},"OrderIdList":{"type":"array","items":{"type":"string"}},"PlanRouteResponse":{"type":"object","properties":{"orderId":{"type":"string"},"deliveryProvider":{"type":"string"},"errorMessage":{"type":"string"}}},"ErrorMessage":{"required":["message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"},"_embedded":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string"},"path":{"type":"string"}}}}}}}}},"responses":{"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"}}}}}}}}}}}},"paths":{"/delivery-v2/{tenant}/planRoute":{"post":{"summary":"Creating orders for delivery provider","description":"Pushes the specified orders to the delivery provider for the given tenant. If route planning fails for an order (e.g., due to an invalid address), an email is sent to the merchant.\n","parameters":[{"name":"tenant","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanRouteCommand"}}}},"responses":{"200":{"description":"Route planning executed. Returned body only for unsuccessfully planned orders (QAC6GQEF in this example). Returned empty body for successfully planned orders (B7016709).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanRouteResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest_400"},"401":{"$ref":"#/components/responses/Unauthorized_401"}},"operationId":"POST-delivery-plan-orders-delivery","tags":["Delivery Plan"]}}}}
```
