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

Prepare a durable noncash gift intent

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

POST /api/v1/organizations/{organization}/billing/accounts/{currency}/grants/prepare

Explicit platform administration only. Saves immutable amount, reason, currency, policy, authenticated actor and company-scoped idempotency key. Preparation posts no funds, revenue, receipt, debt application or reservation. Exact retries return the same intent; changed reuse conflicts. Existing matching grants can be recovered as issued. Publish through grantCustomerBalance with this saved input and original key. Prepared is not proof that an in-flight publication failed. Never invent another key because a response was lost. No automatic issuance. Internal references are not product labels.

Operation: prepareCustomerBalanceGrant.

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/accounts/{currency}/grants/prepare" \
-H "Authorization: Bearer $NIU_BEARER_TOKEN" \
-H 'Content-Type: application/json' \
--data @request.json

Location: path. Required.

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

Location: path. Required.

JSON
{
"type": "string",
"pattern": "^[A-Z]{3}$"
}

Required.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"amount_nanos",
"reason",
"idempotency_key"
],
"properties": {
"application_policy": {
"type": "string",
"enum": [
"future_only",
"unpaid_credit_first"
],
"default": "future_only"
},
"amount_nanos": {
"type": "string",
"pattern": "^[1-9][0-9]{0,18}$",
"description": "Positive exact currency nanounits, maximum 9223372036854775807."
},
"reason": {
"type": "string",
"minLength": 1,
"maxLength": 500,
"description": "Trimmed justification without control characters."
},
"idempotency_key": {
"type": "string",
"format": "uuid"
}
}
}

Durable intent state

Content type: application/json.

JSON
{
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"id",
"idempotency_key",
"currency",
"amount_nanos",
"reason",
"created_at",
"application_policy",
"status",
"result"
],
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"idempotency_key": {
"type": "string",
"format": "uuid"
},
"currency": {
"type": "string"
},
"amount_nanos": {
"type": "string"
},
"reason": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"application_policy": {
"type": "string",
"enum": [
"future_only",
"unpaid_credit_first"
]
},
"status": {
"type": "string",
"enum": [
"prepared",
"issued"
]
},
"result": {
"type": [
"object",
"null"
],
"required": [
"id",
"application_policy",
"applied_to_credit_nanos",
"retained_for_future_consumption_nanos"
],
"properties": {
"application_policy": {
"type": "string",
"enum": [
"future_only",
"unpaid_credit_first"
]
},
"applied_to_credit_nanos": {
"type": "string",
"pattern": "^[0-9]+$"
},
"retained_for_future_consumption_nanos": {
"type": "string",
"pattern": "^[0-9]+$",
"description": "Original grant amount retained for future consumption at issuance, not current spendable balance."
},
"id": {
"type": "string",
"format": "uuid"
}
}
}
}
}
}
}

Invalid amount, currency or page

Authentication required

Platform administration required

Intent conflict, unknown company or invalid cursor

Malformed body or unsupported application policy

Explicit platform administration only. Saves immutable amount, reason, currency, policy, authenticated actor and company-scoped idempotency key. Preparation posts no funds, revenue, receipt, debt application or reservation. Exact retries return the same intent; changed reuse conflicts. Existing matching grants can be recovered as issued. Publish through grantCustomerBalance with this saved input and original key. Prepared is not proof that an in-flight publication failed. Never invent another key because a response was lost. No automatic issuance. Internal references are not product labels.

Supported scope: implemented