---
title: Cancel a subscription order
slug: amberflo-api/cancel-a-subscription-order
docTags: 
createdAt: 2024-11-07T15:10:16.977Z
---

{
  "id": "tza5tD1mYcxMmAo9OT89F",
  "type": "api-oas-v2",
  "data": {
    "method": "DELETE",
    "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/subscription-orders/cancel",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/subscription-orders/cancel"
      }
    ],
    "name": "Cancel a subscription order",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "payment.pricing.customer.CustomerSubscriptionOrder.out",
            "schema": [
              {
                "name": "customerId",
                "kind": "required",
                "type": "string",
                "description": "Unique customer id.",
                "example": ""
              },
              {
                "name": "id",
                "kind": "required",
                "type": "string",
                "description": "The id of the specific instance in time where an order was applied to a customer, this id marks a unique customer order.",
                "example": ""
              },
              {
                "name": "orderItems",
                "kind": "required",
                "type": "array",
                "description": "List of individual order items that make up this order.",
                "modelRef": "#/components/schemas/payment.pricing.customer.SubscriptionOrderItem.out",
                "customType": "payment.pricing.customer.SubscriptionOrderItem.out[]",
                "schema": [
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "string",
                    "description": "Instance id associated with the order item.",
                    "example": ""
                  },
                  {
                    "name": "quantity",
                    "kind": "required",
                    "type": "number",
                    "description": "Quantity of units the customer is subscribing to for this order.",
                    "example": ""
                  },
                  {
                    "name": "resourceId",
                    "kind": "optional",
                    "type": "string",
                    "description": "Resource id that this order item is applied to.",
                    "example": ""
                  },
                  {
                    "name": "dimensions",
                    "kind": "optional",
                    "type": "map",
                    "description": "Dimension key values that this order item is associated with.",
                    "example": "",
                    "customType": "map<string, string>",
                    "schema": []
                  },
                  {
                    "name": "totalPrice",
                    "kind": "optional",
                    "type": "number",
                    "description": "Price for this order item. This is the total price for the full quantity over the order's duration, not the price per unit. If the order has a fixed duration this total price is for the entire duration. If the order has no fixed duration this total price is per billing period. If null, the price will be calculated based on the subscription plan's price per unit.",
                    "example": ""
                  }
                ]
              },
              {
                "name": "productItemId",
                "kind": "required",
                "type": "string",
                "description": "Unique product item id.",
                "example": ""
              },
              {
                "name": "productPlanId",
                "kind": "required",
                "type": "string",
                "description": "Unique product plan id.",
                "example": ""
              },
              {
                "name": "appliedTimeRange",
                "kind": "optional",
                "type": "object",
                "description": "Applied time range for the order. This defines when an order starts and ends.",
                "modelRef": "#/components/schemas/payment.common.TimeRange.out",
                "customType": "payment.common.TimeRange.out",
                "schema": [
                  {
                    "name": "startTimeInSeconds",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "example": 0
                  },
                  {
                    "name": "endTimeInSeconds",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "example": 0
                  }
                ]
              },
              {
                "name": "billingPeriods",
                "kind": "optional",
                "type": "integer<int32>",
                "description": "Optional field to indicate the number of billing periods for the order. If this field is not null the order's end time will be calculated as this number of billing periods from the start time, inclusive of the billing period the start time falls within.",
                "example": 0
              },
              {
                "name": "label",
                "kind": "optional",
                "type": "string",
                "description": "Label for the order.",
                "example": ""
              },
              {
                "name": "subscriptionSettings",
                "kind": "optional",
                "type": "object",
                "description": "Optional subscription settings to override the default subscription settings",
                "modelRef": "#/components/schemas/payment.pricing.subscription_orders.SubscriptionPriceSettings.out",
                "customType": "payment.pricing.subscription_orders.SubscriptionPriceSettings.out",
                "schema": [
                  {
                    "name": "cancellationRule",
                    "kind": "required",
                    "type": "string",
                    "description": "Whether early cancellation will prorate, charge in full, or result in no charge.",
                    "modelRef": "#/components/schemas/payment.pricing.subscription_orders.CancellationRule.out",
                    "customType": "payment.pricing.subscription_orders.CancellationRule.out",
                    "schema": []
                  },
                  {
                    "name": "chargeExecution",
                    "kind": "required",
                    "type": "string",
                    "description": "When this order's charge will be executed.",
                    "modelRef": "#/components/schemas/payment.pricing.subscription_orders.ChargeExecution.out",
                    "customType": "payment.pricing.subscription_orders.ChargeExecution.out",
                    "schema": []
                  },
                  {
                    "name": "purchaseRule",
                    "kind": "required",
                    "type": "string",
                    "description": "Whether the order will prorate or charge in full from the beginning of the billing period.",
                    "modelRef": "#/components/schemas/payment.pricing.subscription_orders.PurchaseRule.out",
                    "customType": "payment.pricing.subscription_orders.PurchaseRule.out",
                    "schema": []
                  },
                  {
                    "name": "subscriptionRate",
                    "kind": "required",
                    "type": "string",
                    "description": "The rate of the subscription. This controls the granularity of subscription pricing within the billing period.",
                    "modelRef": "#/components/schemas/payment.pricing.price.UsageGranularity.out",
                    "customType": "payment.pricing.price.UsageGranularity.out",
                    "schema": []
                  },
                  {
                    "name": "isPricedPerRate",
                    "kind": "optional",
                    "type": "boolean",
                    "description": "Whether subscription price is charged per rate or per billing period. Defaults to per billing period.",
                    "example": ""
                  },
                  {
                    "name": "isCancellable",
                    "kind": "optional",
                    "type": "boolean",
                    "description": "Whether order cancellation appears in the customer portal or not. Defaults to false.",
                    "example": ""
                  }
                ]
              },
              {
                "name": "addedTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Internally managed. When an order has been added to a pricing plan.",
                "example": 0
              },
              {
                "name": "commitmentId",
                "kind": "optional",
                "type": "string",
                "description": "Internally managed. The id of an associated commitment.",
                "example": ""
              },
              {
                "name": "prepaidUris",
                "kind": "optional",
                "type": "array",
                "description": "Internally managed. List of associated prepaid uris",
                "example": "",
                "itemType": "string",
                "customType": "string[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "removedTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Internally managed. When an order has been removed from a customer pricing plan.",
                "example": 0
              },
              {
                "name": "removalContext",
                "kind": "optional",
                "type": "map",
                "description": "Internally managed. Identifying metadata around who and why an order was removed.",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/payment.pricing.customer.CustomerSubscriptionOrder.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "SMnkJU4WcZJ6P_r5PoLxd",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request DELETE \\\n     --url https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/subscription-orders/cancel \\\n     --header 'accept: application/json'"
        },
        {
          "id": "hbAPSYBz8ZQ4mL4VAmfdG",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'DELETE',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/subscription-orders/cancel\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "3uVySNLF_m1_FmU563SJr",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/subscription-orders/cancel\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "QW61fnOPRkhnfVBdHyAOl",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/subscription-orders/cancel\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"DELETE\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "SMnkJU4WcZJ6P_r5PoLxd"
    },
    "results": {
      "languages": [
        {
          "id": "SKNNGxvDboFJxDYTYXWps",
          "language": "200",
          "code": "// Successful request\n{\n  \"customerId\": \"\",\n  \"id\": \"\",\n  \"orderItems\": [\n    {\n      \"id\": \"\",\n      \"quantity\": 0,\n      \"resourceId\": \"\",\n      \"dimensions\": \"\",\n      \"totalPrice\": 0\n    }\n  ],\n  \"productItemId\": \"\",\n  \"productPlanId\": \"\",\n  \"appliedTimeRange\": {\n    \"startTimeInSeconds\": \"\",\n    \"endTimeInSeconds\": \"\"\n  },\n  \"billingPeriods\": \"\",\n  \"label\": \"\",\n  \"subscriptionSettings\": {\n    \"cancellationRule\": \"\",\n    \"chargeExecution\": \"\",\n    \"purchaseRule\": \"\",\n    \"subscriptionRate\": \"\",\n    \"isPricedPerRate\": false,\n    \"isCancellable\": false\n  },\n  \"addedTimeInSeconds\": \"\",\n  \"commitmentId\": \"\",\n  \"prepaidUris\": [\n    \"\"\n  ],\n  \"removedTimeInSeconds\": \"\",\n  \"removalContext\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "SKNNGxvDboFJxDYTYXWps"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}