---
agentTools:
  projectIndex: https://kosmo.readme.io/llms.txt
---

# Cancel order

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "contact": {
      "email": "developer@kosmo.delivery",
      "name": "Kosmo API Support"
    },
    "description": "Kosmo API Reference v2",
    "termsOfService": "https://www.kosmo.delivery/",
    "title": "Kosmo API Reference v2",
    "version": "2.0"
  },
  "paths": {
    "/v2/orders/{orderId}/cancel": {
      "post": {
        "operationId": "cancelOrder",
        "parameters": [
          {
            "in": "path",
            "name": "orderId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelDeliveryRequest"
              }
            }
          },
          "description": "Cancel delivery body",
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelDeliveryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/kosmoerr.ErrorPayloadDTO"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/kosmoerr.ErrorPayloadDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/kosmoerr.ErrorPayloadDTO"
                }
              }
            }
          }
        },
        "summary": "Cancel order",
        "tags": [
          "Orders"
        ]
      }
    }
  },
  "servers": [
    {
      "url": "https://api.kosmo.delivery",
      "description": "Kosmo API URL"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "token"
      }
    },
    "schemas": {
      "CancelDeliveryRequest": {
        "description": "Cancel a delivery.",
        "properties": {
          "cancellationReason": {
            "$ref": "#/components/schemas/CancellationReason"
          }
        },
        "type": "object"
      },
      "CancelDeliveryResponse": {
        "description": "Cancel a delivery.",
        "required": [
          "orderStatus"
        ],
        "properties": {
          "status": {
            "description": "Status of the cancellation",
            "type": "string",
            "example": "cancelled"
          }
        },
        "type": "object"
      },
      "CancellationReason": {
        "description": "The reason for cancellation.",
        "type": "string",
        "enum": [
          "no_longer_need_service",
          "waited_too_long_for_driver",
          "need_to_change_order_details",
          "others"
        ]
      },
      "kosmoerr.ErrorPayloadDTO": {
        "properties": {
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/kosmoerr.ErrorDetailDTO"
            }
          },
          "key": {
            "description": "Error key.",
            "type": "string",
            "example": "invalid_request_error"
          },
          "message": {
            "description": "Error message.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "kosmoerr.ErrorDetailDTO": {
        "properties": {
          "key": {
            "description": "Error key.",
            "type": "string",
            "example": "invalid_phone_number"
          },
          "message": {
            "description": "Error message.",
            "type": "string",
            "example": "invalid phone number: Phone"
          },
          "field": {
            "description": "Error field.",
            "type": "string",
            "example": "CreateQuotesRequest.Dropoffs[0].Receiver.Phone"
          }
        },
        "type": "object"
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true,
    "samples-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 99,
      "1": 136,
      "2": 86,
      "3": 191,
      "4": 139,
      "5": 245,
      "6": 189,
      "7": 0,
      "8": 16,
      "9": 17,
      "10": 176,
      "11": 113
    }
  }
}
```