メインコンテンツへスキップ

create-allocation

dci create-allocation [body]

Creates a new allocation.

Pass the request body as name: value arguments or pipe JSON on stdin — see Command structure.

Examples​

# Allocate one billing account's spend to a team, with the body read from a file.
dci create-allocation < allocation.json
# allocation.json
{"name": "Team Backyard",
"description": "Everything billed to the Backyard billing account",
"anomalyDetection": true,
"rule": {"formula": "A",
"components": [{"key": "billing_account_id", "type": "fixed", "mode": "is",
"values": ["012345-ABCDEF-678901"]}]}}
# Match by label with a two-component formula (A is the first component, B the second).
dci create-allocation name: "Backyard prod", description: "team=backyard in production", rule{formula: "A AND B", components: [{key: team, type: label, mode: is, values: [backyard]}, {key: env, type: label, mode: is, values: [prod]}]}
# Create it inside a folder and capture the new ID for a script.
dci create-allocation name: "Team Backyard", description: "Backyard spend", rule{formula: A, components: [{key: billing_account_id, type: fixed, mode: is, values: ["012345-ABCDEF-678901"]}]}, folderId: <folder-id> --output json | jq -r .id

Request​

Content-Type: application/json

FieldTypeRequiredDescription
namestringyesAllocation name.
descriptionstringyesAllocation description.
anomalyDetectionbooleanWhether anomaly detection is enabled for this allocation. Only applicable to single allocations.
ruleobjectSingle allocation rule. Components can reference other existing allocation rules by using the "allocation_rule" dimension type.
rule.componentsarray of objectyesList of allocation filter components.
rule.components[].keystringyesKey of an existing dimension. Examples: "billing_account_id", "country". When type is "allocation_rule", the key must be set to "allocation_rule". Use GET /analytics/v1/dimensions to retrieve all available dimensions.
rule.components[].typestringyesDimension filter type for allocation rule components. See DimensionsTypes for per-value meanings. Allocation components do not support allocation, attribution, or attribution_group types. One of: "datetime", "fixed", "optional", "label", "tag", "project_label", "system_label", "allocation_rule", "gke", "gke_label".
rule.components[].valuesarray of stringyesValues to filter on. When type is "allocation_rule", the values are IDs of existing allocation rules.
rule.components[].inversebooleanIf true, all selected values will be excluded. Default: false.
rule.components[].includeNullbooleanInclude null values. Default: false.
rule.components[].caseInsensitivebooleanIf true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise. Default: false.
rule.components[].modestringyesFilter mode to apply. When type is "allocation_rule", only "is" and "contains" modes are supported. One of: "is", "starts_with", "ends_with", "contains", "regexp".
rule.formulastringyesFormula for combining components (A is the first component, B is the second one, etc.).
rule.valueExtractionobjectWhen updating, omit it to keep the stored value, send null to clear it, or send an object to replace it.
rule.valueExtraction.sourcesarray of objectyesOrdered extraction sources; the first non-empty value wins.
rule.valueExtraction.sources[].typestringyesThe dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; "fixed" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable. One of: "label", "tag", "project_label", "system_label", "gke_label", "fixed".
rule.valueExtraction.sources[].keystringyesThe label/tag key, or the fixed dimension ID, whose value is extracted.
rule.valueExtraction.sources[].providersarray of stringOptional cloud providers this source applies to.
rule.valueExtraction.onMissingstringWhat happens when every source is missing or empty on a matching row. "useFallback" (default) emits the fallback value, which is required in that mode; "nextRule" lets the row fall through to the next rule in the group. One of: "useFallback", "nextRule". Default: "useFallback".
rule.valueExtraction.fallbackstringLiteral emitted when every source is missing. Required with onMissing "useFallback" (the default); not allowed with onMissing "nextRule".
rule.validityPeriodsarray of objectOrdered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.
rule.validityPeriods[].startDatestringStart date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.
rule.validityPeriods[].endDatestringEnd date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.
rulesarray of object
rules[].namestringName of the allocation rule.
rules[].descriptionstringDescription of the allocation rule.
rules[].actionstringyesAction to perform with this rule. One of: "create", "update", "select".
rules[].idstringID of existing allocation (required for 'update' or 'select' action).
rules[].componentsarray of objectList of allocation filter components (required for 'create' or 'update' action). Can include components of type "allocation_rule" to reference existing allocation rules.
rules[].components[].keystringyesKey of an existing dimension. Examples: "billing_account_id", "country". When type is "allocation_rule", the key must be set to "allocation_rule". Use GET /analytics/v1/dimensions to retrieve all available dimensions.
rules[].components[].typestringyesDimension filter type for allocation rule components. See DimensionsTypes for per-value meanings. Allocation components do not support allocation, attribution, or attribution_group types. One of: "datetime", "fixed", "optional", "label", "tag", "project_label", "system_label", "allocation_rule", "gke", "gke_label".
rules[].components[].valuesarray of stringyesValues to filter on. When type is "allocation_rule", the values are IDs of existing allocation rules.
rules[].components[].inversebooleanIf true, all selected values will be excluded. Default: false.
rules[].components[].includeNullbooleanInclude null values. Default: false.
rules[].components[].caseInsensitivebooleanIf true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise. Default: false.
rules[].components[].modestringyesFilter mode to apply. When type is "allocation_rule", only "is" and "contains" modes are supported. One of: "is", "starts_with", "ends_with", "contains", "regexp".
rules[].formulastringFormula for combining components (A is the first component, B is the second one, etc.)
rules[].valueExtractionobjectMakes the rule emit a value extracted from the first non-empty source instead of the rule name.
rules[].valueExtraction.sourcesarray of objectyesOrdered extraction sources; the first non-empty value wins.
rules[].valueExtraction.sources[].typestringyesThe dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; "fixed" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable. One of: "label", "tag", "project_label", "system_label", "gke_label", "fixed".
rules[].valueExtraction.sources[].keystringyesThe label/tag key, or the fixed dimension ID, whose value is extracted.
rules[].valueExtraction.sources[].providersarray of stringOptional cloud providers this source applies to.
rules[].valueExtraction.onMissingstringWhat happens when every source is missing or empty on a matching row. "useFallback" (default) emits the fallback value, which is required in that mode; "nextRule" lets the row fall through to the next rule in the group. One of: "useFallback", "nextRule". Default: "useFallback".
rules[].valueExtraction.fallbackstringLiteral emitted when every source is missing. Required with onMissing "useFallback" (the default); not allowed with onMissing "nextRule".
rules[].validityPeriodsarray of objectOrdered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.
rules[].validityPeriods[].startDatestringStart date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.
rules[].validityPeriods[].endDatestringEnd date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.
unallocatedCostsstringCustom label for values that do not fit into allocation (required for group type allocation).
splitsarray of objectCost splits saved on this allocation. Only group allocations may carry them. A split takes the cost of one bucket and distributes it across rules of the same allocation, and it then applies to every report that uses this allocation — no per-report configuration is needed.
splits[].modestringyesHow the origin's cost is divided. One of: "custom", "even", "proportional".
splits[].driverobjectWeights a proportional split by this metric instead of by cost, so each target takes a share matching its own consumption. Omit it to weight by cost. proportional only.
splits[].driver.typestringyesbasic for a metric every report carries, extended for an ingested one, custom for a custom metric you defined. One of: "basic", "extended", "custom".
splits[].driver.valuestringyesFor basic, one of cost, usage or savings. For extended, an extended metric key. For custom, the id of a custom metric. A metric this customer cannot use is rejected, and an empty value is rejected for extended and custom.
splits[].originobjectyesThe bucket whose cost is distributed.
splits[].origin.typestringyesunallocated is the residual cost left by the allocation's own rules. allocation_rule is one of the rules, named by id. One of: "unallocated", "allocation_rule".
splits[].origin.idstringThe rule to distribute. Required for allocation_rule, rejected for unallocated.
splits[].targetsarray of objectyesThe rules that receive the origin's cost.
splits[].targets[].typestringyesallocation_rule is one of the allocation's rules, named by id. unallocated is the residual, which carries no id. One of: "allocation_rule", "unallocated".
splits[].targets[].idstringA rule of this same allocation. Required for allocation_rule, rejected for unallocated — name the residual with type, not with an id.
splits[].targets[].valuenumber (double)Share as a fraction, so 0.3 is 30%. Required for custom mode, rejected otherwise, and must total 1.
folderIdstringIdentifier of the folder that contains the allocation. Set to "root" if the allocation is at the top level (not in a folder). Default: "root".
Raw JSON schema
{
"required": [
"name",
"description"
],
"type": "object",
"description": "Request body for creating an allocation.",
"properties": {
"name": {
"type": "string",
"description": "Allocation name."
},
"description": {
"type": "string",
"description": "Allocation description."
},
"anomalyDetection": {
"type": "boolean",
"description": "Whether anomaly detection is enabled for this allocation. Only applicable to single allocations."
},
"rule": {
"required": [
"components",
"formula"
],
"type": "object",
"description": "Single allocation rule. Components can reference other existing allocation rules by using the \"allocation_rule\" dimension type.",
"nullable": true,
"properties": {
"components": {
"type": "array",
"description": "List of allocation filter components.",
"items": {
"required": [
"key",
"type",
"values",
"mode"
],
"type": "object",
"description": "A filter component used inside allocation rules.\nWhen the type is \"allocation_rule\", the component references existing allocation rules (nested allocation rules).\nA maximum nesting depth of 3 levels is supported, and circular references are not allowed.",
"properties": {
"key": {
"type": "string",
"description": "Key of an existing dimension. Examples: \"billing_account_id\", \"country\". When type is \"allocation_rule\", the key must be set to \"allocation_rule\".\nUse `GET /analytics/v1/dimensions` to retrieve all available dimensions."
},
"type": {
"description": "Dimension filter type for allocation rule components. See `DimensionsTypes` for per-value meanings. Allocation components do not support `allocation`, `attribution`, or `attribution_group` types.",
"type": "string",
"enum": [
"datetime",
"fixed",
"optional",
"label",
"tag",
"project_label",
"system_label",
"allocation_rule",
"gke",
"gke_label"
],
"x-enumDescriptions": {
"fixed": "Standard built-in billing dimensions.",
"label": "Customer-defined resource labels; key is the label key.",
"tag": "AWS cost allocation tags; key is the tag key.",
"project_label": "Google Cloud project-level labels.",
"system_label": "DoiT- or provider-generated system labels.",
"optional": "Console grouping for label/tag keys; use a concrete subtype in filters.",
"datetime": "Time dimensions for date-based filtering.",
"allocation_rule": "Reference another allocation rule by ID.",
"gke": "Google Kubernetes Engine cost-allocation dimensions.",
"gke_label": "GKE workload labels."
}
},
"values": {
"type": "array",
"description": "Values to filter on. When type is \"allocation_rule\", the values are IDs of existing allocation rules.",
"items": {
"type": "string"
}
},
"inverse": {
"type": "boolean",
"description": "If true, all selected values will be excluded.",
"default": false
},
"includeNull": {
"type": "boolean",
"description": "Include null values.",
"default": false
},
"caseInsensitive": {
"type": "boolean",
"description": "If true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise.",
"default": false
},
"mode": {
"type": "string",
"description": "Filter mode to apply. When type is \"allocation_rule\", only \"is\" and \"contains\" modes are supported.",
"enum": [
"is",
"starts_with",
"ends_with",
"contains",
"regexp"
]
}
}
}
},
"formula": {
"type": "string",
"description": "Formula for combining components (A is the first component, B is the second one, etc.).",
"example": "A AND B"
},
"valueExtraction": {
"description": "When updating, omit it to keep the stored value, send null to clear it, or send an object to replace it.",
"nullable": true,
"allOf": [
{
"type": "object",
"nullable": true,
"required": [
"sources"
],
"description": "Makes the rule emit a value extracted from the first non-empty source instead of the rule name.",
"properties": {
"sources": {
"type": "array",
"minItems": 1,
"maxItems": 5,
"description": "Ordered extraction sources; the first non-empty value wins.",
"items": {
"type": "object",
"required": [
"type",
"key"
],
"properties": {
"type": {
"type": "string",
"description": "The dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; \"fixed\" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable.",
"enum": [
"label",
"tag",
"project_label",
"system_label",
"gke_label",
"fixed"
]
},
"key": {
"type": "string",
"description": "The label/tag key, or the fixed dimension ID, whose value is extracted."
},
"providers": {
"type": "array",
"nullable": true,
"description": "Optional cloud providers this source applies to.",
"items": {
"type": "string"
}
}
}
}
},
"onMissing": {
"type": "string",
"description": "What happens when every source is missing or empty on a matching row. \"useFallback\" (default) emits the fallback value, which is required in that mode; \"nextRule\" lets the row fall through to the next rule in the group.",
"enum": [
"useFallback",
"nextRule"
],
"default": "useFallback"
},
"fallback": {
"type": "string",
"nullable": true,
"description": "Literal emitted when every source is missing. Required with onMissing \"useFallback\" (the default); not allowed with onMissing \"nextRule\"."
}
}
}
]
},
"validityPeriods": {
"type": "array",
"nullable": true,
"description": "Ordered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.",
"items": {
"type": "object",
"description": "A date range when a rule applies. startDate and endDate are both inclusive, so a handover between two rules needs a one-day gap: the first rule's endDate the day before, the second rule's startDate the handover day. Only the first period in the list may omit startDate, and only the last may omit endDate.",
"properties": {
"startDate": {
"type": "string",
"nullable": true,
"description": "Start date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.",
"example": "2026-03-15"
},
"endDate": {
"type": "string",
"nullable": true,
"description": "End date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.",
"example": "2026-06-15"
}
}
}
}
}
},
"rules": {
"type": "array",
"items": {
"required": [
"action"
],
"type": "object",
"nullable": true,
"description": "Allocation rule for a group type allocation. Components can reference other existing allocation rules by using the \"allocation_rule\" dimension type.",
"properties": {
"name": {
"type": "string",
"description": "Name of the allocation rule."
},
"description": {
"type": "string",
"description": "Description of the allocation rule."
},
"action": {
"type": "string",
"description": "Action to perform with this rule.",
"enum": [
"create",
"update",
"select"
]
},
"id": {
"type": "string",
"description": "ID of existing allocation (required for 'update' or 'select' action)."
},
"components": {
"type": "array",
"description": "List of allocation filter components (required for 'create' or 'update' action). Can include components of type \"allocation_rule\" to reference existing allocation rules.",
"items": {
"required": [
"key",
"type",
"values",
"mode"
],
"type": "object",
"description": "A filter component used inside allocation rules.\nWhen the type is \"allocation_rule\", the component references existing allocation rules (nested allocation rules).\nA maximum nesting depth of 3 levels is supported, and circular references are not allowed.",
"properties": {
"key": {
"type": "string",
"description": "Key of an existing dimension. Examples: \"billing_account_id\", \"country\". When type is \"allocation_rule\", the key must be set to \"allocation_rule\".\nUse `GET /analytics/v1/dimensions` to retrieve all available dimensions."
},
"type": {
"description": "Dimension filter type for allocation rule components. See `DimensionsTypes` for per-value meanings. Allocation components do not support `allocation`, `attribution`, or `attribution_group` types.",
"type": "string",
"enum": [
"datetime",
"fixed",
"optional",
"label",
"tag",
"project_label",
"system_label",
"allocation_rule",
"gke",
"gke_label"
],
"x-enumDescriptions": {
"fixed": "Standard built-in billing dimensions.",
"label": "Customer-defined resource labels; key is the label key.",
"tag": "AWS cost allocation tags; key is the tag key.",
"project_label": "Google Cloud project-level labels.",
"system_label": "DoiT- or provider-generated system labels.",
"optional": "Console grouping for label/tag keys; use a concrete subtype in filters.",
"datetime": "Time dimensions for date-based filtering.",
"allocation_rule": "Reference another allocation rule by ID.",
"gke": "Google Kubernetes Engine cost-allocation dimensions.",
"gke_label": "GKE workload labels."
}
},
"values": {
"type": "array",
"description": "Values to filter on. When type is \"allocation_rule\", the values are IDs of existing allocation rules.",
"items": {
"type": "string"
}
},
"inverse": {
"type": "boolean",
"description": "If true, all selected values will be excluded.",
"default": false
},
"includeNull": {
"type": "boolean",
"description": "Include null values.",
"default": false
},
"caseInsensitive": {
"type": "boolean",
"description": "If true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise.",
"default": false
},
"mode": {
"type": "string",
"description": "Filter mode to apply. When type is \"allocation_rule\", only \"is\" and \"contains\" modes are supported.",
"enum": [
"is",
"starts_with",
"ends_with",
"contains",
"regexp"
]
}
}
}
},
"formula": {
"type": "string",
"description": "Formula for combining components (A is the first component, B is the second one, etc.)",
"example": "A AND B"
},
"valueExtraction": {
"type": "object",
"nullable": true,
"required": [
"sources"
],
"description": "Makes the rule emit a value extracted from the first non-empty source instead of the rule name.",
"properties": {
"sources": {
"type": "array",
"minItems": 1,
"maxItems": 5,
"description": "Ordered extraction sources; the first non-empty value wins.",
"items": {
"type": "object",
"required": [
"type",
"key"
],
"properties": {
"type": {
"type": "string",
"description": "The dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; \"fixed\" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable.",
"enum": [
"label",
"tag",
"project_label",
"system_label",
"gke_label",
"fixed"
]
},
"key": {
"type": "string",
"description": "The label/tag key, or the fixed dimension ID, whose value is extracted."
},
"providers": {
"type": "array",
"nullable": true,
"description": "Optional cloud providers this source applies to.",
"items": {
"type": "string"
}
}
}
}
},
"onMissing": {
"type": "string",
"description": "What happens when every source is missing or empty on a matching row. \"useFallback\" (default) emits the fallback value, which is required in that mode; \"nextRule\" lets the row fall through to the next rule in the group.",
"enum": [
"useFallback",
"nextRule"
],
"default": "useFallback"
},
"fallback": {
"type": "string",
"nullable": true,
"description": "Literal emitted when every source is missing. Required with onMissing \"useFallback\" (the default); not allowed with onMissing \"nextRule\"."
}
}
},
"validityPeriods": {
"type": "array",
"nullable": true,
"description": "Ordered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.",
"items": {
"type": "object",
"description": "A date range when a rule applies. startDate and endDate are both inclusive, so a handover between two rules needs a one-day gap: the first rule's endDate the day before, the second rule's startDate the handover day. Only the first period in the list may omit startDate, and only the last may omit endDate.",
"properties": {
"startDate": {
"type": "string",
"nullable": true,
"description": "Start date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.",
"example": "2026-03-15"
},
"endDate": {
"type": "string",
"nullable": true,
"description": "End date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.",
"example": "2026-06-15"
}
}
}
}
}
}
},
"unallocatedCosts": {
"type": "string",
"description": "Custom label for values that do not fit into allocation (required for group type allocation).",
"nullable": true
},
"splits": {
"type": "array",
"description": "Cost splits saved on this allocation. Only group allocations may carry them.\nA split takes the cost of one bucket and distributes it across rules of the\nsame allocation, and it then applies to every report that uses this\nallocation — no per-report configuration is needed.",
"items": {
"type": "object",
"required": [
"mode",
"origin",
"targets"
],
"description": "Distributes the cost of one bucket across rules of the same allocation.\nSeveral splits apply in the order they appear in `splits`.",
"properties": {
"mode": {
"type": "string",
"enum": [
"custom",
"even",
"proportional"
],
"description": "How the origin's cost is divided.",
"example": "custom"
},
"driver": {
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"basic",
"extended",
"custom"
],
"description": "`basic` for a metric every report carries, `extended` for an ingested one,\n`custom` for a custom metric you defined.",
"example": "custom"
},
"value": {
"type": "string",
"description": "For `basic`, one of `cost`, `usage` or `savings`. For `extended`, an\nextended metric key. For `custom`, the id of a custom metric. A\nmetric this customer cannot use is rejected, and an empty value is\nrejected for `extended` and `custom`.",
"example": "y5tVBMPCVlyoVH9D7mJ3"
}
},
"description": "Weights a `proportional` split by this metric instead of by cost, so each\ntarget takes a share matching its own consumption. Omit it to weight by cost.\n`proportional` only.",
"example": {
"type": "custom",
"value": "y5tVBMPCVlyoVH9D7mJ3"
}
},
"origin": {
"type": "object",
"required": [
"type"
],
"description": "The bucket whose cost is distributed.",
"properties": {
"type": {
"type": "string",
"enum": [
"unallocated",
"allocation_rule"
],
"description": "`unallocated` is the residual cost left by the allocation's own rules.\n`allocation_rule` is one of the rules, named by `id`.",
"example": "unallocated"
},
"id": {
"type": "string",
"description": "The rule to distribute. Required for `allocation_rule`, rejected for `unallocated`.",
"example": "gLMTGZn4Dmea1uyKzwzs"
}
}
},
"targets": {
"type": "array",
"minItems": 1,
"description": "The rules that receive the origin's cost.",
"items": {
"type": "object",
"required": [
"type"
],
"description": "A bucket that receives part of the origin's cost.",
"properties": {
"type": {
"type": "string",
"enum": [
"allocation_rule",
"unallocated"
],
"description": "`allocation_rule` is one of the allocation's rules, named by `id`.\n`unallocated` is the residual, which carries no `id`.",
"example": "allocation_rule"
},
"id": {
"type": "string",
"description": "A rule of this same allocation. Required for `allocation_rule`, rejected for\n`unallocated` — name the residual with `type`, not with an id.",
"example": "gLMTGZn4Dmea1uyKzwzs"
},
"value": {
"type": "number",
"format": "double",
"description": "Share as a fraction, so 0.3 is 30%. Required for `custom` mode, rejected otherwise, and must total 1.",
"example": 0.5
}
}
}
}
}
}
},
"folderId": {
"type": "string",
"description": "Identifier of the folder that contains the allocation. Set to \"root\" if the allocation is at the top level (not in a folder).",
"default": "root",
"example": "root"
}
}
}

Output​

OK - The request succeeded.

By default dci renders the result as a table. Use --output json to get the full structure described below — see Output formats.

FieldTypeDescription
idstringAllocation ID.
namestringAllocation name.
descriptionstringAllocation description.
typestringType of allocation (preset or custom).
allocationTypestringComposition type of allocation. One of: "single", "group".
createTimeinteger (int64)The time when the allocation was created (in UNIX timestamp).
updateTimeinteger (int64)Last time the allocation was modified (in UNIX timestamp).
anomalyDetectionbooleanWhether anomaly detection is enabled for this allocation. Only applicable to single allocations.
ruleobjectSingle allocation rule. Components can reference other existing allocation rules by using the "allocation_rule" dimension type.
rule.componentsarray of objectList of allocation filter components.
rule.components[].keystringKey of an existing dimension. Examples: "billing_account_id", "country". When type is "allocation_rule", the key must be set to "allocation_rule". Use GET /analytics/v1/dimensions to retrieve all available dimensions.
rule.components[].typestringDimension filter type for allocation rule components. See DimensionsTypes for per-value meanings. Allocation components do not support allocation, attribution, or attribution_group types. One of: "datetime", "fixed", "optional", "label", "tag", "project_label", "system_label", "allocation_rule", "gke", "gke_label".
rule.components[].valuesarray of stringValues to filter on. When type is "allocation_rule", the values are IDs of existing allocation rules.
rule.components[].inversebooleanIf true, all selected values will be excluded. Default: false.
rule.components[].includeNullbooleanInclude null values. Default: false.
rule.components[].caseInsensitivebooleanIf true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise. Default: false.
rule.components[].modestringFilter mode to apply. When type is "allocation_rule", only "is" and "contains" modes are supported. One of: "is", "starts_with", "ends_with", "contains", "regexp".
rule.formulastringFormula for combining components (A is the first component, B is the second one, etc.).
rule.valueExtractionobjectWhen updating, omit it to keep the stored value, send null to clear it, or send an object to replace it.
rule.valueExtraction.sourcesarray of objectOrdered extraction sources; the first non-empty value wins.
rule.valueExtraction.sources[].typestringThe dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; "fixed" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable. One of: "label", "tag", "project_label", "system_label", "gke_label", "fixed".
rule.valueExtraction.sources[].keystringThe label/tag key, or the fixed dimension ID, whose value is extracted.
rule.valueExtraction.sources[].providersarray of stringOptional cloud providers this source applies to.
rule.valueExtraction.onMissingstringWhat happens when every source is missing or empty on a matching row. "useFallback" (default) emits the fallback value, which is required in that mode; "nextRule" lets the row fall through to the next rule in the group. One of: "useFallback", "nextRule". Default: "useFallback".
rule.valueExtraction.fallbackstringLiteral emitted when every source is missing. Required with onMissing "useFallback" (the default); not allowed with onMissing "nextRule".
rule.validityPeriodsarray of objectOrdered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.
rule.validityPeriods[].startDatestringStart date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.
rule.validityPeriods[].endDatestringEnd date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.
rulesarray of object
rules[].namestringName of the allocation rule.
rules[].descriptionstringDescription of the allocation rule.
rules[].actionstringAction to perform with this rule. One of: "create", "update", "select".
rules[].idstringID of existing allocation (required for 'update' or 'select' action).
rules[].componentsarray of objectList of allocation filter components (required for 'create' or 'update' action). Can include components of type "allocation_rule" to reference existing allocation rules.
rules[].components[].keystringKey of an existing dimension. Examples: "billing_account_id", "country". When type is "allocation_rule", the key must be set to "allocation_rule". Use GET /analytics/v1/dimensions to retrieve all available dimensions.
rules[].components[].typestringDimension filter type for allocation rule components. See DimensionsTypes for per-value meanings. Allocation components do not support allocation, attribution, or attribution_group types. One of: "datetime", "fixed", "optional", "label", "tag", "project_label", "system_label", "allocation_rule", "gke", "gke_label".
rules[].components[].valuesarray of stringValues to filter on. When type is "allocation_rule", the values are IDs of existing allocation rules.
rules[].components[].inversebooleanIf true, all selected values will be excluded. Default: false.
rules[].components[].includeNullbooleanInclude null values. Default: false.
rules[].components[].caseInsensitivebooleanIf true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise. Default: false.
rules[].components[].modestringFilter mode to apply. When type is "allocation_rule", only "is" and "contains" modes are supported. One of: "is", "starts_with", "ends_with", "contains", "regexp".
rules[].formulastringFormula for combining components (A is the first component, B is the second one, etc.)
rules[].valueExtractionobjectMakes the rule emit a value extracted from the first non-empty source instead of the rule name.
rules[].valueExtraction.sourcesarray of objectOrdered extraction sources; the first non-empty value wins.
rules[].valueExtraction.sources[].typestringThe dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; "fixed" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable. One of: "label", "tag", "project_label", "system_label", "gke_label", "fixed".
rules[].valueExtraction.sources[].keystringThe label/tag key, or the fixed dimension ID, whose value is extracted.
rules[].valueExtraction.sources[].providersarray of stringOptional cloud providers this source applies to.
rules[].valueExtraction.onMissingstringWhat happens when every source is missing or empty on a matching row. "useFallback" (default) emits the fallback value, which is required in that mode; "nextRule" lets the row fall through to the next rule in the group. One of: "useFallback", "nextRule". Default: "useFallback".
rules[].valueExtraction.fallbackstringLiteral emitted when every source is missing. Required with onMissing "useFallback" (the default); not allowed with onMissing "nextRule".
rules[].validityPeriodsarray of objectOrdered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.
rules[].validityPeriods[].startDatestringStart date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.
rules[].validityPeriods[].endDatestringEnd date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.
unallocatedCostsstringCustom label for values that do not fit into allocation (required for group type allocation).
splitsarray of objectCost splits saved on this allocation.
splits[].modestringHow the origin's cost is divided. One of: "custom", "even", "proportional".
splits[].driverobjectWeights a proportional split by this metric instead of by cost, so each target takes a share matching its own consumption. Omit it to weight by cost. proportional only.
splits[].driver.typestringbasic for a metric every report carries, extended for an ingested one, custom for a custom metric you defined. One of: "basic", "extended", "custom".
splits[].driver.valuestringFor basic, one of cost, usage or savings. For extended, an extended metric key. For custom, the id of a custom metric. A metric this customer cannot use is rejected, and an empty value is rejected for extended and custom.
splits[].originobjectThe bucket whose cost is distributed.
splits[].origin.typestringunallocated is the residual cost left by the allocation's own rules. allocation_rule is one of the rules, named by id. One of: "unallocated", "allocation_rule".
splits[].origin.idstringThe rule to distribute. Required for allocation_rule, rejected for unallocated.
splits[].targetsarray of objectThe rules that receive the origin's cost.
splits[].targets[].typestringallocation_rule is one of the allocation's rules, named by id. unallocated is the residual, which carries no id. One of: "allocation_rule", "unallocated".
splits[].targets[].idstringA rule of this same allocation. Required for allocation_rule, rejected for unallocated — name the residual with type, not with an id.
splits[].targets[].valuenumber (double)Share as a fraction, so 0.3 is 30%. Required for custom mode, rejected otherwise, and must total 1.
folderIdstringIdentifier of the folder that contains the allocation. Set to "root" if the allocation is at the top level (not in a folder). Default: "root".
Raw JSON schema
{
"type": "object",
"description": "Allocation object, including rules and metadata.",
"properties": {
"id": {
"type": "string",
"description": "Allocation ID."
},
"name": {
"type": "string",
"description": "Allocation name."
},
"description": {
"type": "string",
"description": "Allocation description."
},
"type": {
"type": "string",
"description": "Type of allocation (preset or custom)."
},
"allocationType": {
"type": "string",
"description": "Composition type of allocation.",
"enum": [
"single",
"group"
]
},
"createTime": {
"type": "integer",
"description": "The time when the allocation was created (in UNIX timestamp).",
"format": "int64"
},
"updateTime": {
"type": "integer",
"description": "Last time the allocation was modified (in UNIX timestamp).",
"format": "int64"
},
"anomalyDetection": {
"type": "boolean",
"description": "Whether anomaly detection is enabled for this allocation. Only applicable to single allocations."
},
"rule": {
"required": [
"components",
"formula"
],
"type": "object",
"description": "Single allocation rule. Components can reference other existing allocation rules by using the \"allocation_rule\" dimension type.",
"nullable": true,
"properties": {
"components": {
"type": "array",
"description": "List of allocation filter components.",
"items": {
"required": [
"key",
"type",
"values",
"mode"
],
"type": "object",
"description": "A filter component used inside allocation rules.\nWhen the type is \"allocation_rule\", the component references existing allocation rules (nested allocation rules).\nA maximum nesting depth of 3 levels is supported, and circular references are not allowed.",
"properties": {
"key": {
"type": "string",
"description": "Key of an existing dimension. Examples: \"billing_account_id\", \"country\". When type is \"allocation_rule\", the key must be set to \"allocation_rule\".\nUse `GET /analytics/v1/dimensions` to retrieve all available dimensions."
},
"type": {
"description": "Dimension filter type for allocation rule components. See `DimensionsTypes` for per-value meanings. Allocation components do not support `allocation`, `attribution`, or `attribution_group` types.",
"type": "string",
"enum": [
"datetime",
"fixed",
"optional",
"label",
"tag",
"project_label",
"system_label",
"allocation_rule",
"gke",
"gke_label"
],
"x-enumDescriptions": {
"fixed": "Standard built-in billing dimensions.",
"label": "Customer-defined resource labels; key is the label key.",
"tag": "AWS cost allocation tags; key is the tag key.",
"project_label": "Google Cloud project-level labels.",
"system_label": "DoiT- or provider-generated system labels.",
"optional": "Console grouping for label/tag keys; use a concrete subtype in filters.",
"datetime": "Time dimensions for date-based filtering.",
"allocation_rule": "Reference another allocation rule by ID.",
"gke": "Google Kubernetes Engine cost-allocation dimensions.",
"gke_label": "GKE workload labels."
}
},
"values": {
"type": "array",
"description": "Values to filter on. When type is \"allocation_rule\", the values are IDs of existing allocation rules.",
"items": {
"type": "string"
}
},
"inverse": {
"type": "boolean",
"description": "If true, all selected values will be excluded.",
"default": false
},
"includeNull": {
"type": "boolean",
"description": "Include null values.",
"default": false
},
"caseInsensitive": {
"type": "boolean",
"description": "If true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise.",
"default": false
},
"mode": {
"type": "string",
"description": "Filter mode to apply. When type is \"allocation_rule\", only \"is\" and \"contains\" modes are supported.",
"enum": [
"is",
"starts_with",
"ends_with",
"contains",
"regexp"
]
}
}
}
},
"formula": {
"type": "string",
"description": "Formula for combining components (A is the first component, B is the second one, etc.).",
"example": "A AND B"
},
"valueExtraction": {
"description": "When updating, omit it to keep the stored value, send null to clear it, or send an object to replace it.",
"nullable": true,
"allOf": [
{
"type": "object",
"nullable": true,
"required": [
"sources"
],
"description": "Makes the rule emit a value extracted from the first non-empty source instead of the rule name.",
"properties": {
"sources": {
"type": "array",
"minItems": 1,
"maxItems": 5,
"description": "Ordered extraction sources; the first non-empty value wins.",
"items": {
"type": "object",
"required": [
"type",
"key"
],
"properties": {
"type": {
"type": "string",
"description": "The dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; \"fixed\" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable.",
"enum": [
"label",
"tag",
"project_label",
"system_label",
"gke_label",
"fixed"
]
},
"key": {
"type": "string",
"description": "The label/tag key, or the fixed dimension ID, whose value is extracted."
},
"providers": {
"type": "array",
"nullable": true,
"description": "Optional cloud providers this source applies to.",
"items": {
"type": "string"
}
}
}
}
},
"onMissing": {
"type": "string",
"description": "What happens when every source is missing or empty on a matching row. \"useFallback\" (default) emits the fallback value, which is required in that mode; \"nextRule\" lets the row fall through to the next rule in the group.",
"enum": [
"useFallback",
"nextRule"
],
"default": "useFallback"
},
"fallback": {
"type": "string",
"nullable": true,
"description": "Literal emitted when every source is missing. Required with onMissing \"useFallback\" (the default); not allowed with onMissing \"nextRule\"."
}
}
}
]
},
"validityPeriods": {
"type": "array",
"nullable": true,
"description": "Ordered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.",
"items": {
"type": "object",
"description": "A date range when a rule applies. startDate and endDate are both inclusive, so a handover between two rules needs a one-day gap: the first rule's endDate the day before, the second rule's startDate the handover day. Only the first period in the list may omit startDate, and only the last may omit endDate.",
"properties": {
"startDate": {
"type": "string",
"nullable": true,
"description": "Start date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.",
"example": "2026-03-15"
},
"endDate": {
"type": "string",
"nullable": true,
"description": "End date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.",
"example": "2026-06-15"
}
}
}
}
}
},
"rules": {
"type": "array",
"items": {
"required": [
"action"
],
"type": "object",
"nullable": true,
"description": "Allocation rule for a group type allocation. Components can reference other existing allocation rules by using the \"allocation_rule\" dimension type.",
"properties": {
"name": {
"type": "string",
"description": "Name of the allocation rule."
},
"description": {
"type": "string",
"description": "Description of the allocation rule."
},
"action": {
"type": "string",
"description": "Action to perform with this rule.",
"enum": [
"create",
"update",
"select"
]
},
"id": {
"type": "string",
"description": "ID of existing allocation (required for 'update' or 'select' action)."
},
"components": {
"type": "array",
"description": "List of allocation filter components (required for 'create' or 'update' action). Can include components of type \"allocation_rule\" to reference existing allocation rules.",
"items": {
"required": [
"key",
"type",
"values",
"mode"
],
"type": "object",
"description": "A filter component used inside allocation rules.\nWhen the type is \"allocation_rule\", the component references existing allocation rules (nested allocation rules).\nA maximum nesting depth of 3 levels is supported, and circular references are not allowed.",
"properties": {
"key": {
"type": "string",
"description": "Key of an existing dimension. Examples: \"billing_account_id\", \"country\". When type is \"allocation_rule\", the key must be set to \"allocation_rule\".\nUse `GET /analytics/v1/dimensions` to retrieve all available dimensions."
},
"type": {
"description": "Dimension filter type for allocation rule components. See `DimensionsTypes` for per-value meanings. Allocation components do not support `allocation`, `attribution`, or `attribution_group` types.",
"type": "string",
"enum": [
"datetime",
"fixed",
"optional",
"label",
"tag",
"project_label",
"system_label",
"allocation_rule",
"gke",
"gke_label"
],
"x-enumDescriptions": {
"fixed": "Standard built-in billing dimensions.",
"label": "Customer-defined resource labels; key is the label key.",
"tag": "AWS cost allocation tags; key is the tag key.",
"project_label": "Google Cloud project-level labels.",
"system_label": "DoiT- or provider-generated system labels.",
"optional": "Console grouping for label/tag keys; use a concrete subtype in filters.",
"datetime": "Time dimensions for date-based filtering.",
"allocation_rule": "Reference another allocation rule by ID.",
"gke": "Google Kubernetes Engine cost-allocation dimensions.",
"gke_label": "GKE workload labels."
}
},
"values": {
"type": "array",
"description": "Values to filter on. When type is \"allocation_rule\", the values are IDs of existing allocation rules.",
"items": {
"type": "string"
}
},
"inverse": {
"type": "boolean",
"description": "If true, all selected values will be excluded.",
"default": false
},
"includeNull": {
"type": "boolean",
"description": "Include null values.",
"default": false
},
"caseInsensitive": {
"type": "boolean",
"description": "If true, string matching is case-insensitive. Effective only for starts_with, ends_with, and contains modes; rejected otherwise.",
"default": false
},
"mode": {
"type": "string",
"description": "Filter mode to apply. When type is \"allocation_rule\", only \"is\" and \"contains\" modes are supported.",
"enum": [
"is",
"starts_with",
"ends_with",
"contains",
"regexp"
]
}
}
}
},
"formula": {
"type": "string",
"description": "Formula for combining components (A is the first component, B is the second one, etc.)",
"example": "A AND B"
},
"valueExtraction": {
"type": "object",
"nullable": true,
"required": [
"sources"
],
"description": "Makes the rule emit a value extracted from the first non-empty source instead of the rule name.",
"properties": {
"sources": {
"type": "array",
"minItems": 1,
"maxItems": 5,
"description": "Ordered extraction sources; the first non-empty value wins.",
"items": {
"type": "object",
"required": [
"type",
"key"
],
"properties": {
"type": {
"type": "string",
"description": "The dimension type to read the value from. Label-map types (label, tag, project_label, system_label, gke_label) extract the value of the given key; \"fixed\" extracts a raw table dimension (for example project_id, service_description, region). Derived dimensions such as credits are not extractable.",
"enum": [
"label",
"tag",
"project_label",
"system_label",
"gke_label",
"fixed"
]
},
"key": {
"type": "string",
"description": "The label/tag key, or the fixed dimension ID, whose value is extracted."
},
"providers": {
"type": "array",
"nullable": true,
"description": "Optional cloud providers this source applies to.",
"items": {
"type": "string"
}
}
}
}
},
"onMissing": {
"type": "string",
"description": "What happens when every source is missing or empty on a matching row. \"useFallback\" (default) emits the fallback value, which is required in that mode; \"nextRule\" lets the row fall through to the next rule in the group.",
"enum": [
"useFallback",
"nextRule"
],
"default": "useFallback"
},
"fallback": {
"type": "string",
"nullable": true,
"description": "Literal emitted when every source is missing. Required with onMissing \"useFallback\" (the default); not allowed with onMissing \"nextRule\"."
}
}
},
"validityPeriods": {
"type": "array",
"nullable": true,
"description": "Ordered, non-overlapping date ranges when this rule applies. Empty or absent means the rule always applies.",
"items": {
"type": "object",
"description": "A date range when a rule applies. startDate and endDate are both inclusive, so a handover between two rules needs a one-day gap: the first rule's endDate the day before, the second rule's startDate the handover day. Only the first period in the list may omit startDate, and only the last may omit endDate.",
"properties": {
"startDate": {
"type": "string",
"nullable": true,
"description": "Start date (YYYY-MM-DD, UTC), inclusive. Absent means no lower bound.",
"example": "2026-03-15"
},
"endDate": {
"type": "string",
"nullable": true,
"description": "End date (YYYY-MM-DD, UTC), inclusive. Absent means no upper bound.",
"example": "2026-06-15"
}
}
}
}
}
}
},
"unallocatedCosts": {
"type": "string",
"description": "Custom label for values that do not fit into allocation (required for group type allocation).",
"nullable": true
},
"splits": {
"type": "array",
"description": "Cost splits saved on this allocation.",
"items": {
"type": "object",
"required": [
"mode",
"origin",
"targets"
],
"description": "Distributes the cost of one bucket across rules of the same allocation.\nSeveral splits apply in the order they appear in `splits`.",
"properties": {
"mode": {
"type": "string",
"enum": [
"custom",
"even",
"proportional"
],
"description": "How the origin's cost is divided.",
"example": "custom"
},
"driver": {
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"basic",
"extended",
"custom"
],
"description": "`basic` for a metric every report carries, `extended` for an ingested one,\n`custom` for a custom metric you defined.",
"example": "custom"
},
"value": {
"type": "string",
"description": "For `basic`, one of `cost`, `usage` or `savings`. For `extended`, an\nextended metric key. For `custom`, the id of a custom metric. A\nmetric this customer cannot use is rejected, and an empty value is\nrejected for `extended` and `custom`.",
"example": "y5tVBMPCVlyoVH9D7mJ3"
}
},
"description": "Weights a `proportional` split by this metric instead of by cost, so each\ntarget takes a share matching its own consumption. Omit it to weight by cost.\n`proportional` only.",
"example": {
"type": "custom",
"value": "y5tVBMPCVlyoVH9D7mJ3"
}
},
"origin": {
"type": "object",
"required": [
"type"
],
"description": "The bucket whose cost is distributed.",
"properties": {
"type": {
"type": "string",
"enum": [
"unallocated",
"allocation_rule"
],
"description": "`unallocated` is the residual cost left by the allocation's own rules.\n`allocation_rule` is one of the rules, named by `id`.",
"example": "unallocated"
},
"id": {
"type": "string",
"description": "The rule to distribute. Required for `allocation_rule`, rejected for `unallocated`.",
"example": "gLMTGZn4Dmea1uyKzwzs"
}
}
},
"targets": {
"type": "array",
"minItems": 1,
"description": "The rules that receive the origin's cost.",
"items": {
"type": "object",
"required": [
"type"
],
"description": "A bucket that receives part of the origin's cost.",
"properties": {
"type": {
"type": "string",
"enum": [
"allocation_rule",
"unallocated"
],
"description": "`allocation_rule` is one of the allocation's rules, named by `id`.\n`unallocated` is the residual, which carries no `id`.",
"example": "allocation_rule"
},
"id": {
"type": "string",
"description": "A rule of this same allocation. Required for `allocation_rule`, rejected for\n`unallocated` — name the residual with `type`, not with an id.",
"example": "gLMTGZn4Dmea1uyKzwzs"
},
"value": {
"type": "number",
"format": "double",
"description": "Share as a fraction, so 0.3 is 30%. Required for `custom` mode, rejected otherwise, and must total 1.",
"example": 0.5
}
}
}
}
}
}
},
"folderId": {
"type": "string",
"description": "Identifier of the folder that contains the allocation. Set to \"root\" if the allocation is at the top level (not in a folder).",
"default": "root",
"example": "root"
}
}
}

Errors​

On failure, dci prints a single error message — with a hint when one is available — and exits with a typed code your scripts can branch on. See Errors and exit codes for the full contract.

HTTP status to exit code mapping
HTTP statusExit codeError codeMeaning
40030VALIDATION_ERRORThe arguments or request body were rejected. Review the command's flags and payload.
40110AUTHENTICATION_FAILEDNot signed in, or the API token is invalid. Run dci login or check DCI_API_KEY.
40311PERMISSION_DENIEDThe DoiT user or the active customer context does not have access.
40420RESOURCE_NOT_FOUNDThe requested resource does not exist. Check the identifier argument.

Aliases: createallocation