---
title: Assign a product plan to the customer
slug: reference/assign-a-product-plan-to-the-customer
docTags: 
createdAt: 2024-09-30T17:03:00.667Z
---

{
  "id": "vRF-kuPobURvnnm5u-C4q",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/customer-portal/pricing-plan",
    "servers": [
      {
        "url": "https://app.amberflo.io/customer-portal/pricing-plan"
      }
    ],
    "name": "Assign a product plan to the customer",
    "description": "<p>Use this endpoint to allow a customer to assign himself a plan.</p>\n<p>The plan assignment can be scheduled to start at some point in the future by specifying a <code>startTimeInSeconds</code>.</p>\n<p>If you'd like to cancel a customer's current plan, you should define a \"default\" plan and then use this API to assign it to the customer.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "required",
          "name": "sessionToken",
          "type": "string",
          "description": "<p>A required session token used to authenticate API calls made on behalf of a customer. This token is obtained from the <code>Create a session</code> endpoint and must be included with every request to authorize access.</p>"
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "amberflo-customer-pricing-request",
          "schema": [
            {
              "name": "endTimeInSeconds",
              "kind": "optional",
              "type": "integer",
              "description": "UTC time in seconds. At the time specified, the plan will revert back to the account default plan. To specify an end time, the account must have a default plan defined. Setting a new plan will automatically update the last plan's end time to match the new plan's start time.",
              "example": 0,
              "default": null
            },
            {
              "name": "productId",
              "kind": "optional",
              "type": "string",
              "description": "Product ID as defined in account pricing. Change from default only if you have multiple products.",
              "example": "",
              "default": "1"
            },
            {
              "name": "productPlanId",
              "kind": "required",
              "type": "string",
              "description": "productPlanId as defined in account pricing and belongs to the provided productId.",
              "example": ""
            },
            {
              "name": "startTimeInSeconds",
              "kind": "optional",
              "type": "integer",
              "description": "UTC time in seconds. If null then the service will try to replace the current plan with the new one in the upcoming hour (if no current plan exists it will create a new plan starting from today UTC).",
              "example": 0,
              "default": null
            }
          ],
          "modelRef": "#/components/schemas/amberflo-customer-pricing-request",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "api_key",
          "name": "x-api-key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful response",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "amberflo-customer-pricing-response",
            "schema": [
              {
                "name": "customerId",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "endTimeInSeconds",
                "kind": "optional",
                "type": "integer",
                "example": 0
              },
              {
                "name": "productId",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "productPlanId",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "relationId",
                "kind": "optional",
                "type": "string",
                "description": "relationId is the unique ID of the relationship between the customer and the specific instance of the customer product plan.",
                "example": ""
              },
              {
                "name": "createdTimeInSeconds",
                "kind": "optional",
                "type": "integer",
                "description": "The time in epoch seconds which the plan was assigned to the customer (might be later than the createdTimeInSeconds).",
                "example": 0
              },
              {
                "name": "startTimeInSeconds",
                "kind": "optional",
                "type": "integer",
                "description": "The start time of the plan in epoch seconds (might be later than the createdTimeInSeconds).",
                "example": 0
              }
            ],
            "modelRef": "#/components/schemas/amberflo-customer-pricing-response",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "Q3I8UosHS9ZlPZyzwcdE-",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url 'https://app.amberflo.io/customer-portal/pricing-plan?sessionToken=string' \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"productId\": \"1\",\n     \"productPlanId\": \"\"\n     }'"
        },
        {
          "id": "9NimzyuhmJ0ACLTzhz-wy",
          "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   \"productId\": \"1\",\n   \"productPlanId\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/customer-portal/pricing-plan?sessionToken=string\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "SAYKow74_Pas7k9td2YU0",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/customer-portal/pricing-plan?sessionToken=string\")\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   \"productId\": \"1\",\n   \"productPlanId\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "d54dCNskAbmn0uk8Kawzt",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/customer-portal/pricing-plan?sessionToken=string\"\n\npayload = json.dumps({\n   \"productId\": \"1\",\n   \"productPlanId\": \"\"\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": "Q3I8UosHS9ZlPZyzwcdE-"
    },
    "results": {
      "languages": [
        {
          "id": "hscT6N1rntwRataSQCpGG",
          "language": "200",
          "code": "// Successful response\n{\n  \"customerId\": \"\",\n  \"endTimeInSeconds\": 0,\n  \"productId\": \"\",\n  \"productPlanId\": \"\",\n  \"relationId\": \"\",\n  \"createdTimeInSeconds\": 0,\n  \"startTimeInSeconds\": 0\n}"
        }
      ],
      "selectedLanguageId": "hscT6N1rntwRataSQCpGG"
    }
  },
  "children": [
    {
      "id": "n-rUJ7kn7ISLNJWuTazSW",
      "type": "paragraph",
      "children": [
        {
          "text": "Use this endpoint to allow a customer to assign himself a plan.",
          "id": "71fOy4m5FeuUEd6fSu6ir"
        }
      ]
    },
    {
      "id": "8euT3UN5klPPnx-s1otAd",
      "type": "paragraph",
      "children": [
        {
          "text": "The plan assignment can be scheduled to start at some point in the future by specifying a ",
          "id": "eOTmFmsX1uHe_0bN2NERS"
        },
        {
          "text": "startTimeInSeconds",
          "highlight": true,
          "id": "3ZiIwbHjaOIm62xXYNwge"
        },
        {
          "text": ".",
          "id": "JKT0hVHfduES5ImNbNBi-"
        }
      ]
    },
    {
      "id": "Nk3d7JzY6tjx0feuDtaoi",
      "type": "paragraph",
      "children": [
        {
          "text": "If you'd like to cancel a customer's current plan, you should define a \"default\" plan and then use this API to assign it to the customer.",
          "id": "AahjHU-k0jOzFh73S-TDo"
        }
      ]
    }
  ]
}