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

Prepare an exact versioned Credits purchase quote

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

POST /api/v1/organizations/{organization}/billing/quotes

Platform administration required. A saved preview does not activate Credits, issue units, create a payment or prove processor amount eligibility. New quotes require the latest rule for its payment currency and latest definition. Inexact conversions and overflow are rejected. The quote pins amount, rule and unit definition for fifteen minutes. Identical idempotent retries retain the original quote and expiry even after rule changes or expiry; checkout must separately enforce validity. Reading historical quotes does not revalue them. No procurement data is returned.

Operation: prepareCustomerUnitQuote.

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/organizations/{organization}/billing/quotes" \
-H "Authorization: Bearer $NIU_BEARER_TOKEN" \
-H 'Content-Type: application/json' \
--data @request.json

Location: path. Required.

JSON
{
"type": "string",
"format": "uuid"
}

Required.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"rule_revision",
"payment_nanos",
"idempotency_key"
],
"properties": {
"rule_revision": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"payment_nanos": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"idempotency_key": {
"type": "string",
"format": "uuid"
}
}
}

Original immutable quote

Content type: application/json.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"data"
],
"properties": {
"data": {
"type": "object",
"additionalProperties": false,
"required": [
"rule_revision",
"definition_revision",
"payment_nanos",
"credit_atoms",
"numerator",
"denominator",
"id",
"payment_currency",
"name",
"display_precision",
"atoms_per_unit",
"created_at",
"expires_at"
],
"properties": {
"rule_revision": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"definition_revision": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"payment_nanos": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"credit_atoms": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"numerator": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"denominator": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Exact positive integer at most 9223372036854775807."
},
"id": {
"type": "string",
"format": "uuid"
},
"payment_currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"name": {
"type": "string"
},
"display_precision": {
"type": "integer",
"minimum": 0,
"maximum": 9
},
"atoms_per_unit": {
"type": "string",
"const": "1000000000"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"expires_at": {
"type": "string",
"format": "date-time"
}
}
}
}
}

Invalid amount, inexact conversion or overflow

Authentication required

Platform administration required

Quote not found in the requested organization

Stale rule, missing organization or conflicting idempotency input

Malformed request body

Storage unavailable

Platform administration required. A saved preview does not activate Credits, issue units, create a payment or prove processor amount eligibility. New quotes require the latest rule for its payment currency and latest definition. Inexact conversions and overflow are rejected. The quote pins amount, rule and unit definition for fifteen minutes. Identical idempotent retries retain the original quote and expiry even after rule changes or expiry; checkout must separately enforce validity. Reading historical quotes does not revalue them. No procurement data is returned.

Supported scope: implemented