---
title: Process customer product plan cancellation
slug: reference/process-customer-product-plan-cancellation
docTags: 
createdAt: 2025-03-18T18:28:02.918Z
---

{
  "id": "GkRWJR5ufVPLL5DLT5opl",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/product-plan-cancellation",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/product-plan-cancellation"
      }
    ],
    "name": "Process customer product plan cancellation",
    "description": "<p>Handles customer product plan cancellation requests with specific business logic and timing rules.\nUse this endpoint to process formal plan cancellations that may have different behavior than simple plan deletion.</p>\n<p>Use this endpoint to:</p>\n<ul>\n<li>Process customer-initiated plan cancellations</li>\n<li>Handle plan cancellations with specific business rules</li>\n<li>Apply cancellation policies and timing constraints</li>\n<li>Transition customers through proper cancellation workflows</li>\n</ul>\n<p><strong>Difference from DELETE</strong>: This endpoint applies business-specific cancellation logic,\nwhile the DELETE endpoint simply removes future plan assignments.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "Product plan cancellation request including customer details, cancellation timing, and business rules to apply",
          "customType": "payment.pricing.ProductPlanCancellationRequest.in",
          "schema": [
            {
              "name": "customerId",
              "kind": "required",
              "type": "string",
              "description": "The unique ID for the customer.",
              "example": ""
            },
            {
              "name": "newProductPlanId",
              "kind": "required",
              "type": "string",
              "description": "The new product plan id",
              "example": ""
            },
            {
              "name": "startTimeInSeconds",
              "kind": "optional",
              "type": "integer<int64>",
              "description": "The start time for the new pricing plan.",
              "example": 0
            }
          ],
          "modelRef": "#/components/schemas/payment.pricing.ProductPlanCancellationRequest.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successfully processed plan cancellation and returns the resulting customer product plan state",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Assignment of a specific product plan to a customer for a defined time period, establishing pricing rules for billing.",
            "customType": "payment.pricing.customer.CustomerProductPlan.in",
            "schema": [
              {
                "name": "productId",
                "kind": "optional",
                "type": "string",
                "description": "Identifier of the product for which this plan assignment applies.",
                "example": ""
              },
              {
                "name": "productPlanId",
                "kind": "optional",
                "type": "string",
                "description": "Unique identifier of the specific pricing plan assigned to the customer.",
                "example": ""
              },
              {
                "name": "customerId",
                "kind": "optional",
                "type": "string",
                "description": "Unique identifier of the customer who has this product plan assignment.",
                "example": ""
              },
              {
                "name": "startTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Unix timestamp when this product plan assignment becomes active, must be at least one hour before end time.",
                "example": 0
              },
              {
                "name": "endTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Optional unix timestamp when this product plan assignment expires, allowing plan transitions over time.",
                "example": 0
              },
              {
                "name": "relationId",
                "kind": "optional",
                "type": "string",
                "description": "Unique base64-encoded identifier for customer-product plan relationship, computed automatically for external system integration.",
                "example": ""
              },
              {
                "name": "createdTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Unix timestamp when this product plan assignment was originally created, automatically set during creation.",
                "example": 0
              }
            ],
            "modelRef": "#/components/schemas/payment.pricing.customer.CustomerProductPlan.in",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid cancellation request, unsupported cancellation type, or malformed request body",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "401",
        "description": "Authentication required or invalid API key provided",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "Insufficient permissions to process customer plan cancellations",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "Customer or product plan not found for cancellation",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "409",
        "description": "Plan cancellation conflicts with existing commitments or billing cycles",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "500",
        "description": "Internal server error occurred while processing plan cancellation",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "X9FuxlM51kDwIvumCSoXe",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/product-plan-cancellation \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"customerId\": \"\",\n     \"newProductPlanId\": \"\"\n     }'"
        },
        {
          "id": "CuuuwJml1C5GFeqqtdQNC",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"customerId\": \"\",\n   \"newProductPlanId\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/product-plan-cancellation\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "4mx9AUiOFQWR4I7gZu4O8",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/product-plan-cancellation\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"customerId\": \"\",\n   \"newProductPlanId\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "i2805X9LvN_mAh0YfsKtr",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/product-plan-cancellation\"\n\npayload = json.dumps({\n   \"customerId\": \"\",\n   \"newProductPlanId\": \"\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "X9FuxlM51kDwIvumCSoXe"
    },
    "results": {
      "languages": [
        {
          "id": "_QoWWn_NQvEzDBRs035GC",
          "language": "200",
          "code": "// Successfully processed plan cancellation and returns the resulting customer product plan state\n{\n  \"productId\": \"\",\n  \"productPlanId\": \"\",\n  \"customerId\": \"\",\n  \"startTimeInSeconds\": \"\",\n  \"endTimeInSeconds\": \"\",\n  \"relationId\": \"\",\n  \"createdTimeInSeconds\": \"\"\n}"
        },
        {
          "id": "LdEU8jbckpIxmOdkHFtCU",
          "language": "400",
          "code": "// Invalid cancellation request, unsupported cancellation type, or malformed request body\n"
        },
        {
          "id": "LCJp3Es8xUp9q57x-jOu6",
          "language": "401",
          "code": "// Authentication required or invalid API key provided\n"
        },
        {
          "id": "wjylLpoRnqz6DIWBBmp-4",
          "language": "403",
          "code": "// Insufficient permissions to process customer plan cancellations\n"
        },
        {
          "id": "Wy7_xs7p5lb_rLNXGhhDr",
          "language": "404",
          "code": "// Customer or product plan not found for cancellation\n"
        },
        {
          "id": "FMhJLnHeTGuKflW1RAcI7",
          "language": "409",
          "code": "// Plan cancellation conflicts with existing commitments or billing cycles\n"
        },
        {
          "id": "vjBNa12w3cMEYk2nKVkFF",
          "language": "500",
          "code": "// Internal server error occurred while processing plan cancellation\n"
        }
      ],
      "selectedLanguageId": "_QoWWn_NQvEzDBRs035GC"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}