---
title: Create or update a cost item price using a cost item price template
slug: amberflo-api/lHZc-create-or-update-a-cost-item-price-using-a-cost-item-price-template
docTags: 
createdAt: 2024-11-07T15:10:16.974Z
---

{
  "id": "L5Jfea2aZzNy-jHuKaJlf",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/pricing/amberflo/account-pricing/cost-item-price/template/cost_item_usage_based_dimension",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/pricing/amberflo/account-pricing/cost-item-price/template/cost_item_usage_based_dimension"
      }
    ],
    "name": "Create or update a cost item price using a cost item price template",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment.pricing.cost.UsageBasedDimensionCostItemPriceGenerator.in",
          "schema": [
            {
              "name": "dimensionKeys",
              "kind": "required",
              "type": "array",
              "description": "Keys associated with dimension values.",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "id",
              "kind": "required",
              "type": "string",
              "description": "Id associated with the price.",
              "example": ""
            },
            {
              "name": "priceTiers",
              "kind": "required",
              "type": "array",
              "description": "Price for each tier.",
              "modelRef": "#/components/schemas/payment.pricing.price.generators.TieredPriceGroupInfo.in",
              "customType": "payment.pricing.price.generators.TieredPriceGroupInfo.in[]",
              "schema": [
                {
                  "name": "dimensionValues",
                  "kind": "optional",
                  "type": "array",
                  "example": "",
                  "itemType": "string",
                  "customType": "string[]",
                  "itemExample": "",
                  "itemDefault": ""
                },
                {
                  "name": "priceTiers",
                  "kind": "optional",
                  "type": "array",
                  "description": "",
                  "modelRef": "#/components/schemas/payment.pricing.price.PriceTier.in",
                  "customType": "payment.pricing.price.PriceTier.in[]",
                  "schema": [
                    {
                      "name": "startAfterUnit",
                      "kind": "optional",
                      "type": "integer<int64>",
                      "example": 0
                    },
                    {
                      "name": "batchSize",
                      "kind": "optional",
                      "type": "integer<int64>",
                      "example": 0
                    },
                    {
                      "name": "pricePerBatch",
                      "kind": "optional",
                      "type": "number",
                      "example": ""
                    }
                  ]
                },
                {
                  "name": "leafNodeType",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                }
              ]
            },
            {
              "name": "meterApiName",
              "kind": "required",
              "type": "string",
              "description": "Meter API name id associated with the price.",
              "example": ""
            },
            {
              "name": "groupDimensions",
              "kind": "optional",
              "type": "array",
              "description": "Dimensions to group the invoice by.",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "costItemPriceName",
              "kind": "optional",
              "type": "string",
              "description": "Name of the price machine. Useful for displaying to users.",
              "example": ""
            },
            {
              "name": "scalar",
              "kind": "optional",
              "type": "number",
              "description": "Optional scalar for scaling usage",
              "example": ""
            },
            {
              "name": "startDateInSeconds",
              "kind": "required",
              "type": "integer<int64>",
              "description": "The date when the cost item takes effective.",
              "example": 0
            },
            {
              "name": "expirationDateInSeconds",
              "kind": "optional",
              "type": "integer<int64>",
              "description": "The date when the cost item expires.",
              "example": 0
            },
            {
              "name": "type",
              "kind": "optional",
              "type": "string",
              "description": "Type of template, automatically populated.",
              "example": "",
              "default": "cost_item_usage_based_dimension"
            },
            {
              "name": "useAverageReducer",
              "kind": "optional",
              "type": "string",
              "description": "Usage granularity if using average.",
              "modelRef": "#/components/schemas/payment.pricing.price.UsageGranularity.in",
              "customType": "payment.pricing.price.UsageGranularity.in",
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/payment.pricing.cost.UsageBasedDimensionCostItemPriceGenerator.in",
          "isExpanded": true
        }
      ],
      "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.cost.UsageBasedDimensionCostItemPriceGenerator.out",
            "schema": [
              {
                "name": "dimensionKeys",
                "kind": "required",
                "type": "array",
                "description": "Keys associated with dimension values.",
                "example": "",
                "itemType": "string",
                "customType": "string[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "id",
                "kind": "required",
                "type": "string",
                "description": "Id associated with the price.",
                "example": ""
              },
              {
                "name": "priceTiers",
                "kind": "required",
                "type": "array",
                "description": "Price for each tier.",
                "modelRef": "#/components/schemas/payment.pricing.price.generators.TieredPriceGroupInfo.out",
                "customType": "payment.pricing.price.generators.TieredPriceGroupInfo.out[]",
                "schema": [
                  {
                    "name": "dimensionValues",
                    "kind": "optional",
                    "type": "array",
                    "example": "",
                    "itemType": "string",
                    "customType": "string[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "priceTiers",
                    "kind": "optional",
                    "type": "array",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.pricing.price.PriceTier.out",
                    "customType": "payment.pricing.price.PriceTier.out[]",
                    "schema": [
                      {
                        "name": "startAfterUnit",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      },
                      {
                        "name": "batchSize",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      },
                      {
                        "name": "pricePerBatch",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      }
                    ]
                  },
                  {
                    "name": "leafNodeType",
                    "kind": "required",
                    "type": "string",
                    "example": ""
                  }
                ]
              },
              {
                "name": "meterApiName",
                "kind": "required",
                "type": "string",
                "description": "Meter API name id associated with the price.",
                "example": ""
              },
              {
                "name": "groupDimensions",
                "kind": "optional",
                "type": "array",
                "description": "Dimensions to group the invoice by.",
                "example": "",
                "itemType": "string",
                "customType": "string[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "costItemPriceName",
                "kind": "optional",
                "type": "string",
                "description": "Name of the price machine. Useful for displaying to users.",
                "example": ""
              },
              {
                "name": "scalar",
                "kind": "optional",
                "type": "number",
                "description": "Optional scalar for scaling usage",
                "example": ""
              },
              {
                "name": "startDateInSeconds",
                "kind": "required",
                "type": "integer<int64>",
                "description": "The date when the cost item takes effective.",
                "example": 0
              },
              {
                "name": "expirationDateInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "The date when the cost item expires.",
                "example": 0
              },
              {
                "name": "type",
                "kind": "optional",
                "type": "string",
                "description": "Type of template, automatically populated.",
                "example": "",
                "default": "cost_item_usage_based_dimension"
              },
              {
                "name": "useAverageReducer",
                "kind": "optional",
                "type": "string",
                "description": "Usage granularity if using average.",
                "modelRef": "#/components/schemas/payment.pricing.price.UsageGranularity.out",
                "customType": "payment.pricing.price.UsageGranularity.out",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/payment.pricing.cost.UsageBasedDimensionCostItemPriceGenerator.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "fj_vgZjBcKD62LiEpovqH",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/pricing/amberflo/account-pricing/cost-item-price/template/cost_item_usage_based_dimension \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"dimensionKeys\": [],\n     \"id\": \"\",\n     \"priceTiers\": [\n     {\n     \"leafNodeType\": \"\"\n     }\n     ],\n     \"meterApiName\": \"\",\n     \"startDateInSeconds\": 0,\n     \"type\": \"cost_item_usage_based_dimension\"\n     }'"
        },
        {
          "id": "gsnecXuT-dr6H3swng_68",
          "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   \"dimensionKeys\": [],\n   \"id\": \"\",\n   \"priceTiers\": [\n      {\n         \"leafNodeType\": \"\"\n      }\n   ],\n   \"meterApiName\": \"\",\n   \"startDateInSeconds\": 0,\n   \"type\": \"cost_item_usage_based_dimension\"\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/account-pricing/cost-item-price/template/cost_item_usage_based_dimension\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "A01zk4OIKoUNWL7XLcltv",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/pricing/amberflo/account-pricing/cost-item-price/template/cost_item_usage_based_dimension\")\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   \"dimensionKeys\": [],\n   \"id\": \"\",\n   \"priceTiers\": [\n      {\n         \"leafNodeType\": \"\"\n      }\n   ],\n   \"meterApiName\": \"\",\n   \"startDateInSeconds\": 0,\n   \"type\": \"cost_item_usage_based_dimension\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "FpVyYQuqV7ciolcXcRwXQ",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/pricing/amberflo/account-pricing/cost-item-price/template/cost_item_usage_based_dimension\"\n\npayload = json.dumps({\n   \"dimensionKeys\": [],\n   \"id\": \"\",\n   \"priceTiers\": [\n      {\n         \"leafNodeType\": \"\"\n      }\n   ],\n   \"meterApiName\": \"\",\n   \"startDateInSeconds\": 0,\n   \"type\": \"cost_item_usage_based_dimension\"\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": "fj_vgZjBcKD62LiEpovqH"
    },
    "results": {
      "languages": [
        {
          "id": "17TCGbSyUuFof6NTa632M",
          "language": "200",
          "code": "// Successful request\n{\n  \"dimensionKeys\": [\n    \"\"\n  ],\n  \"id\": \"\",\n  \"priceTiers\": [\n    {\n      \"dimensionValues\": [\n        \"\"\n      ],\n      \"priceTiers\": [\n        {\n          \"startAfterUnit\": \"\",\n          \"batchSize\": \"\",\n          \"pricePerBatch\": 0\n        }\n      ],\n      \"leafNodeType\": \"\"\n    }\n  ],\n  \"meterApiName\": \"\",\n  \"groupDimensions\": [\n    \"\"\n  ],\n  \"costItemPriceName\": \"\",\n  \"scalar\": 0,\n  \"startDateInSeconds\": \"\",\n  \"expirationDateInSeconds\": \"\",\n  \"type\": \"\",\n  \"useAverageReducer\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "17TCGbSyUuFof6NTa632M"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}