---
title: Create or update a spending limit
slug: amberflo-api/create-or-update-a-spending-limit
docTags: 
createdAt: 2024-11-07T15:10:16.977Z
---

{
  "id": "GZlMexKc9PTVFfemkdItm",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/spending-limits",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/spending-limits"
      }
    ],
    "name": "Create or update a spending limit",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment.pricing.customer.spending_limit.CustomerSpendingLimit.in",
          "schema": [
            {
              "name": "accountId",
              "kind": "optional",
              "type": "string",
              "description": "Internal managed. The ID of the account this customer belongs to",
              "example": ""
            },
            {
              "name": "customerId",
              "kind": "required",
              "type": "string",
              "description": "The ID of the customer for the spending limit",
              "example": ""
            },
            {
              "name": "id",
              "kind": "optional",
              "type": "string",
              "description": "The unique ID of the spending limit",
              "example": ""
            },
            {
              "name": "label",
              "kind": "optional",
              "type": "string",
              "description": "Label for the spending limit",
              "example": ""
            },
            {
              "name": "effectiveTimeRange",
              "kind": "required",
              "type": "object",
              "description": "The effective time range for the spending limit",
              "modelRef": "#/components/schemas/payment.common.TimeRange.in",
              "customType": "payment.common.TimeRange.in",
              "schema": [
                {
                  "name": "startTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "example": 0
                },
                {
                  "name": "endTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "example": 0
                }
              ]
            },
            {
              "name": "trueUpInput",
              "kind": "required",
              "type": "object",
              "description": "The true up configuration for the spending limit",
              "modelRef": "#/components/schemas/payment.pricing.commitments.generators.TrueUpInput.in",
              "customType": "payment.pricing.commitments.generators.TrueUpInput.in",
              "schema": [
                {
                  "name": "minimumPayment",
                  "kind": "required",
                  "type": "number",
                  "example": ""
                },
                {
                  "name": "interval",
                  "kind": "required",
                  "type": "string",
                  "description": "",
                  "modelRef": "#/components/schemas/payment.pricing.commitments.generators.TrueUpInterval.in",
                  "customType": "payment.pricing.commitments.generators.TrueUpInterval.in",
                  "schema": []
                },
                {
                  "name": "startCycle",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "example": 0
                },
                {
                  "name": "endCycle",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "example": 0
                },
                {
                  "name": "productItemIds",
                  "kind": "optional",
                  "type": "array",
                  "example": "",
                  "itemType": "string",
                  "customType": "string[]",
                  "itemExample": "",
                  "itemDefault": ""
                },
                {
                  "name": "usePriceAfterDiscounts",
                  "kind": "optional",
                  "type": "boolean",
                  "example": ""
                }
              ]
            },
            {
              "name": "createdTimeInSeconds",
              "kind": "optional",
              "type": "integer<int64>",
              "description": "Internal managed. The time when the spending limit was created",
              "example": 0
            },
            {
              "name": "updatedTimeInSeconds",
              "kind": "optional",
              "type": "integer<int64>",
              "description": "Internal managed. The time when the spending limit was updated last time",
              "example": 0
            }
          ],
          "modelRef": "#/components/schemas/payment.pricing.customer.spending_limit.CustomerSpendingLimit.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.customer.spending_limit.CustomerSpendingLimit.out",
            "schema": [
              {
                "name": "accountId",
                "kind": "optional",
                "type": "string",
                "description": "Internal managed. The ID of the account this customer belongs to",
                "example": ""
              },
              {
                "name": "customerId",
                "kind": "required",
                "type": "string",
                "description": "The ID of the customer for the spending limit",
                "example": ""
              },
              {
                "name": "id",
                "kind": "optional",
                "type": "string",
                "description": "The unique ID of the spending limit",
                "example": ""
              },
              {
                "name": "label",
                "kind": "optional",
                "type": "string",
                "description": "Label for the spending limit",
                "example": ""
              },
              {
                "name": "effectiveTimeRange",
                "kind": "required",
                "type": "object",
                "description": "The effective time range for the spending limit",
                "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": "trueUpInput",
                "kind": "required",
                "type": "object",
                "description": "The true up configuration for the spending limit",
                "modelRef": "#/components/schemas/payment.pricing.commitments.generators.TrueUpInput.out",
                "customType": "payment.pricing.commitments.generators.TrueUpInput.out",
                "schema": [
                  {
                    "name": "minimumPayment",
                    "kind": "required",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "interval",
                    "kind": "required",
                    "type": "string",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.pricing.commitments.generators.TrueUpInterval.out",
                    "customType": "payment.pricing.commitments.generators.TrueUpInterval.out",
                    "schema": []
                  },
                  {
                    "name": "startCycle",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "example": 0
                  },
                  {
                    "name": "endCycle",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "example": 0
                  },
                  {
                    "name": "productItemIds",
                    "kind": "optional",
                    "type": "array",
                    "example": "",
                    "itemType": "string",
                    "customType": "string[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "usePriceAfterDiscounts",
                    "kind": "optional",
                    "type": "boolean",
                    "example": ""
                  }
                ]
              },
              {
                "name": "createdTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Internal managed. The time when the spending limit was created",
                "example": 0
              },
              {
                "name": "updatedTimeInSeconds",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Internal managed. The time when the spending limit was updated last time",
                "example": 0
              }
            ],
            "modelRef": "#/components/schemas/payment.pricing.customer.spending_limit.CustomerSpendingLimit.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "JphFGDSy-zwFAxszih3gX",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/spending-limits \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"customerId\": \"\",\n     \"effectiveTimeRange\": {},\n     \"trueUpInput\": {\n     \"minimumPayment\": \"\",\n     \"interval\": \"\"\n     }\n     }'"
        },
        {
          "id": "zT3KlWzUEfO2mTMecU5Lz",
          "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   \"effectiveTimeRange\": {},\n   \"trueUpInput\": {\n      \"minimumPayment\": \"\",\n      \"interval\": \"\"\n   }\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/spending-limits\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "vEhmaVZN7GhvQYFVMV0Ne",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/spending-limits\")\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   \"effectiveTimeRange\": {},\n   \"trueUpInput\": {\n      \"minimumPayment\": \"\",\n      \"interval\": \"\"\n   }\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "weh0O76vlOWxSdqYsXUpM",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/pricing/amberflo/customer-pricing/spending-limits\"\n\npayload = json.dumps({\n   \"customerId\": \"\",\n   \"effectiveTimeRange\": {},\n   \"trueUpInput\": {\n      \"minimumPayment\": \"\",\n      \"interval\": \"\"\n   }\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": "JphFGDSy-zwFAxszih3gX"
    },
    "results": {
      "languages": [
        {
          "id": "lftW1OAiZNYqlV2oDiioO",
          "language": "200",
          "code": "// Successful request\n{\n  \"accountId\": \"\",\n  \"customerId\": \"\",\n  \"id\": \"\",\n  \"label\": \"\",\n  \"effectiveTimeRange\": {\n    \"startTimeInSeconds\": \"\",\n    \"endTimeInSeconds\": \"\"\n  },\n  \"trueUpInput\": {\n    \"minimumPayment\": 0,\n    \"interval\": \"\",\n    \"startCycle\": \"\",\n    \"endCycle\": \"\",\n    \"productItemIds\": [\n      \"\"\n    ],\n    \"usePriceAfterDiscounts\": false\n  },\n  \"createdTimeInSeconds\": \"\",\n  \"updatedTimeInSeconds\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "lftW1OAiZNYqlV2oDiioO"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}