---
title: Assign product plan to customer
slug: reference/assign-product-plan-to-customer
docTags: 
createdAt: 2025-03-18T18:28:02.918Z
---

{
  "id": "Z_hcFInT74hC3koopqIPx",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing"
      }
    ],
    "name": "Assign product plan to customer",
    "description": "<p>Assigns a specific product plan to a customer, controlling their pricing structure and billing behavior.\nYou can schedule the plan assignment to start immediately or at a future time using startTimeInSeconds.</p>\n<p>Use this endpoint to:</p>\n<ul>\n<li>Assign a new pricing plan to a customer</li>\n<li>Schedule future plan changes with specific start times</li>\n<li>Cancel a customer's current plan by assigning a \"default\" plan</li>\n<li>Update customer billing configuration and pricing rules</li>\n</ul>\n<p><strong>Plan Scheduling</strong>: Use startTimeInSeconds in the request body to schedule the plan assignment for a future date.\n<strong>Plan Cancellation</strong>: Create a \"default\" plan and assign it to cancel a customer's current plan.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "Customer product plan assignment including customer ID, product plan details, and optional start time scheduling",
          "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
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successfully assigned product plan to customer with confirmation details and effective timing",
        "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 plan assignment data, unsupported product plan, 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 assign customer pricing plans",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "Customer not found or specified product plan not available",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "409",
        "description": "Conflicting plan assignment or overlapping plan schedules for this customer",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "500",
        "description": "Internal server error occurred while assigning customer pricing plan",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "q1Or4bQy5VAgjDj-98PNM",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/pricing/amberflo/customer-pricing \\\n     --header 'accept: application/json'"
        },
        {
          "id": "d3jPGHyweTyhNs9ity5lJ",
          "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: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "d2U6LXQFKedT6i1AzszUI",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing\")\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\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "QQReiDV_mQOfKzMEycjjD",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing\"\n\npayload = {}\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": "q1Or4bQy5VAgjDj-98PNM"
    },
    "results": {
      "languages": [
        {
          "id": "_EGhmMHS1paWFEptwWTjb",
          "language": "200",
          "code": "// Successfully assigned product plan to customer with confirmation details and effective timing\n{\n  \"productId\": \"\",\n  \"productPlanId\": \"\",\n  \"customerId\": \"\",\n  \"startTimeInSeconds\": \"\",\n  \"endTimeInSeconds\": \"\",\n  \"relationId\": \"\",\n  \"createdTimeInSeconds\": \"\"\n}"
        },
        {
          "id": "PVto5FAHj-uId0d29o9By",
          "language": "400",
          "code": "// Invalid plan assignment data, unsupported product plan, or malformed request body\n"
        },
        {
          "id": "mdJP47DCeF-2kYnz6APF9",
          "language": "401",
          "code": "// Authentication required or invalid API key provided\n"
        },
        {
          "id": "KAm-qGs0s6Bpf4zE4efDA",
          "language": "403",
          "code": "// Insufficient permissions to assign customer pricing plans\n"
        },
        {
          "id": "ddAHzjeLPmnCmTlMXmaHx",
          "language": "404",
          "code": "// Customer not found or specified product plan not available\n"
        },
        {
          "id": "iSPG1ZRV6oMKdsvDX22Ro",
          "language": "409",
          "code": "// Conflicting plan assignment or overlapping plan schedules for this customer\n"
        },
        {
          "id": "6FRS6tMbGENCGwbkWhImU",
          "language": "500",
          "code": "// Internal server error occurred while assigning customer pricing plan\n"
        }
      ],
      "selectedLanguageId": "_EGhmMHS1paWFEptwWTjb"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}