Skip to content
Niu DocsNiu 牛元文档
Dashboard控制台

Publish an immutable Credits purchase rule

Generated from the checked-in source. Do not edit this reference by hand.

POST /api/v1/platform/units/rules

Requires platform administration. Configuration publication alone does not activate Credits billing, convert monetary balances, issue units or change consumption tariffs. Revisions and conversion components use exact decimal strings. Writes serialize on the installation configuration revision. Identical idempotent retries return the original publication even after later changes; different input with the same key conflicts. Purchase rules are reduced exact positive ratios and must reference the latest unit definition. Publishing a new definition requires explicit purchase-rule publication for new purchases; historical rules are retained. No procurement data is returned.

Operation: publishCustomerUnitPurchaseRule.

Use the credential and permission scope described above. Each object below is an alternative; schemes within one object are required together.

JSON
[
{
"bearerAuth": []
}
]

Set NIU_ORIGIN to your installation origin (without /v1). Replace path, query and header placeholders with the required values. Query examples use curl 7.87 or newer to encode values with --url-query. Use the credential scope described above; a bearer token must have the authority required by this operation.

Shell
curl --fail-with-body -X POST "$NIU_ORIGIN/api/v1/platform/units/rules" \
-H "Authorization: Bearer $NIU_BEARER_TOKEN" \
-H 'Content-Type: application/json' \
--data @request.json

No path, query, or header parameters are declared.

Required.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"definition_revision",
"payment_currency",
"numerator",
"denominator",
"expected_revision",
"idempotency_key"
],
"properties": {
"definition_revision": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"payment_currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"numerator": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"denominator": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"expected_revision": {
"type": "string",
"pattern": "^(0|[1-9][0-9]{0,18})$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"idempotency_key": {
"type": "string",
"format": "uuid"
}
}
}

Saved configuration or original idempotent publication

Content type: application/json.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"data"
],
"properties": {
"data": {
"type": "object",
"additionalProperties": false,
"required": [
"revision",
"definition_revision",
"payment_currency",
"numerator",
"denominator"
],
"properties": {
"revision": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"definition_revision": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"payment_currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"numerator": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
},
"denominator": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Canonical nonnegative decimal integer, at most 9223372036854775807."
}
}
}
}
}

Invalid exact integer or configuration

Authentication required

Platform administration required

Stale revision or conflicting idempotency input

Malformed request body

Storage unavailable

Requires platform administration. Configuration publication alone does not activate Credits billing, convert monetary balances, issue units or change consumption tariffs. Revisions and conversion components use exact decimal strings. Writes serialize on the installation configuration revision. Identical idempotent retries return the original publication even after later changes; different input with the same key conflicts. Purchase rules are reduced exact positive ratios and must reference the latest unit definition. Publishing a new definition requires explicit purchase-rule publication for new purchases; historical rules are retained. No procurement data is returned.

Supported scope: implemented