---
title: Create automatic cost allocation rule
slug: reference/create-automatic-cost-allocation-rule
docTags: 
createdAt: 2025-07-03T16:20:35.017Z
---

{
  "id": "1PPTOUKEa_o_3XCc2EdCq",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/business-unit/focus-allocation/automatic/rule",
    "servers": [
      {
        "url": "https://app.amberflo.io/business-unit/focus-allocation/automatic/rule"
      }
    ],
    "name": "Create automatic cost allocation rule",
    "description": "<p>Creates a new automatic FOCUS allocation rule at the specified position in the rule execution sequence.\nRules are applied in priority order to assign cloud costs to business units based on resource tags and metadata.</p>\n<p>Required request body fields:</p>\n<ul>\n<li><code>provider</code>: Cloud provider for the rule (AWS, AZURE, GOOGLE_CLOUD)</li>\n<li><code>predicate</code>: Matching conditions that determine when the rule applies</li>\n</ul>\n<p>Optional request body fields:</p>\n<ul>\n<li><code>tagName</code>: FOCUS tag name for cost allocation (defaults to 'businessUnitId')</li>\n<li><code>tagValue</code>: Specific tag value to match (used with tagName)</li>\n<li><code>businessUnitId</code>: Target business unit for cost assignment</li>\n<li><code>label</code>: Display name for rule management</li>\n<li><code>description</code>: Detailed explanation of rule purpose</li>\n<li><code>enabled</code>: Whether rule is active (defaults to true)</li>\n</ul>\n<p>Optional query parameters:</p>\n<ul>\n<li><code>placement</code>: Position in rule execution order (FIRST, LAST, BEFORE, AFTER)</li>\n<li><code>id</code>: Reference rule ID for relative positioning (used with BEFORE/AFTER)</li>\n</ul>\n<p>Returns created rule with system-generated ID and position metadata. Rules are processed in sequence,\nwith first matching rule allocating costs to the specified business unit.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "optional",
          "name": "placement",
          "type": "string",
          "description": "<p>Execution order position for the new rule. FIRST/LAST for absolute positioning, BEFORE/AFTER for relative positioning with reference ID.</p>"
        },
        {
          "kind": "optional",
          "name": "id",
          "type": "string<uuid>",
          "example": "0e63b938-6785-429b-a89d-c4164144fc88",
          "description": "Reference rule identifier for relative positioning. Required when using BEFORE or AFTER placement options for sequential rule ordering."
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "Input model for creating automatic FOCUS allocation rules that assign cloud costs to business units based on resource tags and metadata conditions.",
          "customType": "business_unit.focus_allocation.automatic.AutomaticMatchingRule.in",
          "schema": [
            {
              "name": "provider",
              "kind": "required",
              "type": "string",
              "description": "Cloud provider for cost allocation filtering. Supported values include AWS, AZURE, GOOGLE_CLOUD for targeted rule application.",
              "modelRef": "#/components/schemas/focus.common.FocusProvider.in",
              "customType": "focus.common.FocusProvider.in",
              "schema": []
            },
            {
              "name": "predicate",
              "kind": "required",
              "type": "object",
              "description": "Matching conditions that determine when rule applies to cost records. Defines value matrix logic for resource identification.",
              "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.predicate.GroupKeyPredicate.in",
              "customType": "business_unit.focus_allocation.automatic.predicate.GroupKeyPredicate.in",
              "schema": [],
              "complexType": "oneOf",
              "complexItems": [
                {
                  "name": "business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.in",
                  "description": "",
                  "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.in",
                  "schema": [
                    {
                      "name": "type",
                      "kind": "required",
                      "type": "string",
                      "description": "Predicate type identifier for value matrix matching logic. Always set to 'value_matrix' for matrix-based resource filtering conditions.",
                      "example": "",
                      "default": "value_matrix"
                    },
                    {
                      "name": "columns",
                      "kind": "required",
                      "type": "array",
                      "description": "FOCUS column names for matrix dimension headers. Defines resource attributes used for matching conditions in allocation rules.",
                      "example": "",
                      "itemType": "string",
                      "customType": "string[]",
                      "itemExample": "",
                      "itemDefault": ""
                    },
                    {
                      "name": "rows",
                      "kind": "required",
                      "type": "array",
                      "description": "Matrix row definitions containing value combinations for resource matching. Each row represents specific resource attribute criteria for rule application.",
                      "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.ValueMatrixRow.in",
                      "customType": "business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.ValueMatrixRow.in[]",
                      "schema": [
                        {
                          "name": "values",
                          "kind": "required",
                          "type": "array",
                          "description": "Array of string values corresponding to matrix columns for resource matching. Each element matches position in predicate column array.",
                          "example": "",
                          "itemType": "string",
                          "customType": "string[]",
                          "itemExample": "",
                          "itemDefault": ""
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "tagName",
              "kind": "optional",
              "type": "string",
              "description": "FOCUS tag key for cost allocation target. Specifies resource tag name used for business unit assignment mapping.",
              "example": ""
            },
            {
              "name": "tagValue",
              "kind": "optional",
              "type": "string",
              "description": "Specific FOCUS tag value to match for cost allocation. Must be used with tagName for targeted resource matching.",
              "example": ""
            },
            {
              "name": "businessUnitId",
              "kind": "optional",
              "type": "string",
              "description": "Target business unit identifier for cost assignment. Alternative to tagName/tagValue approach for direct business unit allocation.",
              "example": ""
            },
            {
              "name": "label",
              "kind": "optional",
              "type": "string",
              "description": "Human-readable display name for rule management and identification. Used for administrative organization and rule tracking purposes.",
              "example": ""
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "Detailed explanation of rule purpose and allocation logic. Provides context for rule configuration and business unit cost assignment.",
              "example": ""
            },
            {
              "name": "enabled",
              "kind": "optional",
              "type": "boolean",
              "description": "Rule activation status for automatic cost allocation processing. Controls whether rule participates in allocation execution sequence.",
              "example": ""
            }
          ],
          "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.AutomaticMatchingRule.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": "Complete automatic FOCUS allocation rule configuration with system-generated metadata for cost assignment to business units based on resource tag matching.",
            "customType": "business_unit.focus_allocation.automatic.AutomaticMatchingRule.out",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "System-generated unique identifier for rule tracking. Required for rule updates, deletions, and position management in execution sequence.",
                "example": "0e63b938-6785-429b-a89d-c4164144fc88"
              },
              {
                "name": "provider",
                "kind": "required",
                "type": "string",
                "description": "Cloud provider for cost allocation filtering. Supported values include AWS, AZURE, GOOGLE_CLOUD for targeted rule application.",
                "modelRef": "#/components/schemas/focus.common.FocusProvider.out",
                "customType": "focus.common.FocusProvider.out",
                "schema": []
              },
              {
                "name": "predicate",
                "kind": "required",
                "type": "object",
                "description": "Matching conditions that determine when rule applies to cost records. Defines value matrix logic for resource identification.",
                "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.predicate.GroupKeyPredicate.out",
                "customType": "business_unit.focus_allocation.automatic.predicate.GroupKeyPredicate.out",
                "schema": [],
                "complexType": "oneOf",
                "complexItems": [
                  {
                    "name": "business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.out",
                    "description": "",
                    "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.out",
                    "schema": [
                      {
                        "name": "type",
                        "kind": "required",
                        "type": "string",
                        "description": "Predicate type identifier for value matrix matching logic. Always set to 'value_matrix' for matrix-based resource filtering conditions.",
                        "example": "",
                        "default": "value_matrix"
                      },
                      {
                        "name": "columns",
                        "kind": "required",
                        "type": "array",
                        "description": "FOCUS column names for matrix dimension headers. Defines resource attributes used for matching conditions in allocation rules.",
                        "example": "",
                        "itemType": "string",
                        "customType": "string[]",
                        "itemExample": "",
                        "itemDefault": ""
                      },
                      {
                        "name": "rows",
                        "kind": "required",
                        "type": "array",
                        "description": "Matrix row definitions containing value combinations for resource matching. Each row represents specific resource attribute criteria for rule application.",
                        "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.ValueMatrixRow.out",
                        "customType": "business_unit.focus_allocation.automatic.predicate.ValueMatrixPredicate.ValueMatrixRow.out[]",
                        "schema": [
                          {
                            "name": "values",
                            "kind": "required",
                            "type": "array",
                            "description": "Array of string values corresponding to matrix columns for resource matching. Each element matches position in predicate column array.",
                            "example": "",
                            "itemType": "string",
                            "customType": "string[]",
                            "itemExample": "",
                            "itemDefault": ""
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "name": "tagName",
                "kind": "optional",
                "type": "string",
                "description": "FOCUS tag key for cost allocation target. Specifies resource tag name used for business unit assignment mapping.",
                "example": ""
              },
              {
                "name": "tagValue",
                "kind": "optional",
                "type": "string",
                "description": "Specific FOCUS tag value to match for cost allocation. Must be used with tagName for targeted resource matching.",
                "example": ""
              },
              {
                "name": "businessUnitId",
                "kind": "optional",
                "type": "string",
                "description": "Target business unit identifier for cost assignment. Alternative to tagName/tagValue approach for direct business unit allocation.",
                "example": ""
              },
              {
                "name": "label",
                "kind": "optional",
                "type": "string",
                "description": "Human-readable display name for rule management and identification. Used for administrative organization and rule tracking purposes.",
                "example": ""
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "Detailed explanation of rule purpose and allocation logic. Provides context for rule configuration and business unit cost assignment.",
                "example": ""
              },
              {
                "name": "enabled",
                "kind": "optional",
                "type": "boolean",
                "description": "Rule activation status for automatic cost allocation processing. Controls whether rule participates in allocation execution sequence.",
                "example": ""
              },
              {
                "name": "createTimeInMillis",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Rule creation timestamp in Unix time milliseconds. Tracks when automatic allocation rule was first established in system.",
                "example": 0
              },
              {
                "name": "updateTimeInMillis",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Rule modification timestamp in Unix time milliseconds. Tracks when automatic allocation rule configuration was last changed.",
                "example": 0
              }
            ],
            "modelRef": "#/components/schemas/business_unit.focus_allocation.automatic.AutomaticMatchingRule.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "-rvmCphXeVzg3a-Q9OQPu",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/business-unit/focus-allocation/automatic/rule \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"provider\": \"\",\n     \"predicate\": {\n     \"type\": \"value_matrix\",\n     \"columns\": [],\n     \"rows\": [\n     {\n     \"values\": []\n     }\n     ]\n     }\n     }'"
        },
        {
          "id": "B8WEaE1ao8x0UujHqN8XI",
          "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   \"provider\": \"\",\n   \"predicate\": {\n      \"type\": \"value_matrix\",\n      \"columns\": [],\n      \"rows\": [\n         {\n            \"values\": []\n         }\n      ]\n   }\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/business-unit/focus-allocation/automatic/rule\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "3lmaupUU3t-k32PRSyvcS",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/business-unit/focus-allocation/automatic/rule\")\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   \"provider\": \"\",\n   \"predicate\": {\n      \"type\": \"value_matrix\",\n      \"columns\": [],\n      \"rows\": [\n         {\n            \"values\": []\n         }\n      ]\n   }\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "Tdj-oou5yUsjQUGvC_VPJ",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/business-unit/focus-allocation/automatic/rule\"\n\npayload = json.dumps({\n   \"provider\": \"\",\n   \"predicate\": {\n      \"type\": \"value_matrix\",\n      \"columns\": [],\n      \"rows\": [\n         {\n            \"values\": []\n         }\n      ]\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": "-rvmCphXeVzg3a-Q9OQPu"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful request\n{\n  \"id\": \"0e63b938-6785-429b-a89d-c4164144fc88\",\n  \"provider\": \"\",\n  \"predicate\": {},\n  \"tagName\": \"\",\n  \"tagValue\": \"\",\n  \"businessUnitId\": \"\",\n  \"label\": \"\",\n  \"description\": \"\",\n  \"enabled\": false,\n  \"createTimeInMillis\": \"\",\n  \"updateTimeInMillis\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": "",
      "id": "JdstMZYGeKYrw86H2RLY8"
    }
  ]
}