# Cancel order lines **⚠️ We no longer recommend using the Orders API. Please refer to the [Payments API](payments-api) instead.** Cancel one or more order lines that were previously authorized. To cancel the entire order, please refer to the [Cancel order](cancel-order) endpoint instead. Canceling or partially canceling an order line will immediately release the authorization held for that amount. You should cancel an order line if you do not intend to (fully) ship it. If the order line was already authorized, the authorization will be released. For an order line with status `shipping`, the authorization for the quantity that is still pending will be released. Afterwards, the order line will be marked `completed`. If the order line is `paid` or already `completed`, you can create a refund using the [Create order refund](create-order-refund) endpoint instead. > 🔑 Access with > > [API key](/reference/authentication) > > [Organization access token with **orders.write**](/reference/authentication) > > [OAuth access with **orders.write**](/reference/authentication) # OpenAPI definition ```json { "openapi": "3.1.0", "info": { "title": "Receiving orders", "version": "1.0.0", "license": { "name": "Attribution-NonCommercial-ShareAlike 4.0 International", "identifier": "CC-BY-NC-SA-4.0" } }, "servers": [ { "url": "https://api.mollie.com/v2" } ], "security": [ { "apiKey": [] }, { "organizationAccessToken": [] }, { "oAuth": [] } ], "paths": { "/orders/{orderId}/lines": { "parameters": [ { "name": "orderId", "description": "Provide the ID of the related order.", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^ord_.+$", "example": "ord_5B8cwPMGnU" } } ], "delete": { "deprecated": true, "summary": "Cancel order lines", "tags": [ "Orders API" ], "operationId": "cancel-order-lines", "security": [ { "apiKey": [] }, { "organizationAccessToken": [ "orders.write" ] }, { "oAuth": [ "orders.write" ] } ], "description": "**⚠️ We no longer recommend using the Orders API. Please refer to the [Payments API](payments-api) instead.**\n\nCancel one or more order lines that were previously authorized. To cancel the entire order, please refer to the [Cancel order](cancel-order) endpoint instead.\n\nCanceling or partially canceling an order line will immediately release the authorization held for that amount. You should cancel an order line if you do not intend to (fully) ship it.\n\nIf the order line was already authorized, the authorization will be released.\n\nFor an order line with status `shipping`, the authorization for the quantity that is still pending will be released.\n\nAfterwards, the order line will be marked `completed`.\n\nIf the order line is `paid` or already `completed`, you can create a refund using the [Create order refund](create-order-refund) endpoint instead.\n\n> 🔑 Access with\n>\n> [API key](/reference/authentication)\n>\n> [Organization access token with **orders.write**](/reference/authentication)\n>\n> [OAuth access with **orders.write**](/reference/authentication)", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "lines": { "type": "array", "items": { "type": "object", "properties": { "id": { "description": "The identifier uniquely referring to this order line. Mollie assigns this identifier at order line creation time. Example: `odl_jp31jz`.", "type": "string", "pattern": "^odl_.+$", "example": "odl_5B8cwPMGnU" }, "quantity": { "type": "integer", "description": "The number of items that should be canceled for this order line. When this parameter is omitted, the whole order line will be canceled. When part of the line has been shipped, the remaining quantity will be canceled and the order line will be marked `completed`.\n\nMust be less than the number of items already shipped or canceled for this order line.", "example": 1 }, "amount": { "description": "The amount that you want to cancel. In almost all cases, Mollie can determine the amount automatically.\n\nThe amount is required only if you are *partially* canceling an order line which has a non-zero `discountAmount`.\n\nThe amount you can cancel depends on various properties of the order line and the cancel order lines request. The maximum that can be canceled is `unit price x quantity to cancel`.\n\nThe minimum amount depends on the discount applied to the line, the quantity already shipped or canceled, the amounts already shipped or canceled and the quantity you want to cancel.\n\nIf you do not send an amount, Mollie will determine the amount automatically or respond with an error if the amount cannot be determined automatically.", "type": "object", "required": [ "currency", "value" ], "properties": { "currency": { "type": "string", "description": "A three-character ISO 4217 currency code.", "example": "EUR" }, "value": { "type": "string", "description": "A string containing an exact monetary amount in the given currency.", "example": "10.00" } } } }, "required": [ "id" ] } }, "testmode": { "type": [ "boolean", "null" ], "description": "Most API credentials are specifically created for either live mode or test mode, in which case this parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting `testmode` to `true`.\n\nTest entities cannot be retrieved when the endpoint is set to live mode, and vice versa.", "writeOnly": true, "example": false } }, "required": [ "lines" ] } } } }, "responses": { "204": { "description": "An empty response.", "content": { "application/hal+json": { "schema": {}, "example": {} } } }, "404": { "description": "No entity with this ID exists.", "content": { "application/hal+json": { "schema": { "type": "object", "description": "An error response object.", "required": [ "status", "title", "detail", "_links" ], "properties": { "status": { "type": "integer", "description": "The status code of the error message. This is always the same code as the status code of the HTTP message itself.", "minimum": 400, "maximum": 599, "example": 404 }, "title": { "type": "string", "description": "The HTTP reason phrase of the error. For example, for a `404` error, the `title` will be `Not Found`.", "example": "Not Found" }, "detail": { "type": "string", "description": "A detailed human-readable description of the error that occurred.", "example": "The resource does not exist" }, "field": { "type": "string", "description": "If the error was caused by a value provided by you in a specific field, the `field` property will contain the name of the field that caused the issue.", "example": "description" }, "_links": { "type": "object", "required": [ "documentation" ], "properties": { "documentation": { "type": "object", "description": "The URL to the generic Mollie API error handling guide.", "required": [ "href", "type" ], "properties": { "href": { "type": "string", "example": "https://docs.mollie.com/errors" }, "type": { "type": "string", "example": "text/html" } } } } } } }, "example": { "status": 404, "title": "Not Found", "detail": "No entity exists with token 'uct_abcDEFghij123456789'", "_links": { "documentation": { "href": "...", "type": "text/html" } } } } } }, "422": { "description": "The request contains issues. For example, if you are trying to cancel an order line that can no longer be canceled.", "content": { "application/hal+json": { "schema": { "type": "object", "description": "An error response object.", "required": [ "status", "title", "detail", "_links" ], "properties": { "status": { "type": "integer", "description": "The status code of the error message. This is always the same code as the status code of the HTTP message itself.", "minimum": 400, "maximum": 599, "example": 404 }, "title": { "type": "string", "description": "The HTTP reason phrase of the error. For example, for a `404` error, the `title` will be `Not Found`.", "example": "Not Found" }, "detail": { "type": "string", "description": "A detailed human-readable description of the error that occurred.", "example": "The resource does not exist" }, "field": { "type": "string", "description": "If the error was caused by a value provided by you in a specific field, the `field` property will contain the name of the field that caused the issue.", "example": "description" }, "_links": { "type": "object", "required": [ "documentation" ], "properties": { "documentation": { "type": "object", "description": "The URL to the generic Mollie API error handling guide.", "required": [ "href", "type" ], "properties": { "href": { "type": "string", "example": "https://docs.mollie.com/errors" }, "type": { "type": "string", "example": "text/html" } } } } } } }, "example": { "status": 422, "title": "Unprocessable Entity", "detail": "Update authorization not allowed", "_links": { "documentation": { "href": "...", "type": "text/html" } } } } } } }, "x-readme": { "code-samples": [ { "language": "shell", "code": "curl -X DELETE https://api.mollie.com/v2/orders/ord_pbjz8x/lines \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer live_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM\" \\\n -d \"lines[0][id]=odl_dgtxyl\" \\\n -d \"lines[0][quantity]=1\" \\\n -d \"lines[1][id]=odl_jp31jz\"" }, { "language": "php", "code": "setApiKey(\"live_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM\");\n\n$mollie->orderLines->get(\"ord_pbjz8x\")->cancelLines([\n [\n \"id\" => \"odl_dgtxyl\",\n \"quantity\" => 1, // Partial line cancelation\n ],\n [\n \"id\" => \"odl_jp31jz\",\n ],\n]);", "install": "composer require mollie/mollie-api-php" }, { "language": "node", "code": "/*\nWe don't have a Node.js code example for this\nAPI call yet.\n\nIf you have some time to spare, feel free to\nshare suggestions on our Discord:\nhttps://discord.gg/VaTVkXB4aQ\n*/", "install": "npm install @mollie/api-client" }, { "language": "python", "code": "mollie_client = Client()\nmollie_client.set_api_key(\"live_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM\")\n\nmollie_client.orders.get(\"ord_8wmqcHMN4U\").lines.delete_lines({\n \"lines\": [\n {\n \"id\": \"odl_dgtxyl\",\n \"quantity\": 1, # Partial line cancelation\n },\n {\n \"id\": \"odl_jp31jz\",\n },\n ]\n})", "install": "pip install mollie-api-python" }, { "language": "ruby", "code": "# We don't have a Ruby code example for this\n# API call yet.\n#\n# If you have some time to spare, feel free to\n# share suggestions on our Discord:\n# https://discord.gg/VaTVkXB4aQ", "install": "gem install mollie-api-ruby" } ] } } } }, "components": { "securitySchemes": { "apiKey": { "type": "http", "scheme": "bearer", "x-default": "live_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" }, "organizationAccessToken": { "type": "http", "scheme": "bearer", "x-default": "access_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" }, "oAuth": { "type": "oauth2", "flows": { "authorizationCode": { "authorizationUrl": "https://my.mollie.com/oauth2/authorize", "tokenUrl": "https://api.mollie.com/oauth2/tokens", "scopes": {} } } } } }, "x-readme": { "explorer-enabled": false, "samples-languages": [ "shell", "php", "node", "python", "ruby" ] } } ```