Advanced: fees
Validate a calculation chain
Checks an inline, fully expanded calculation chain for structural problems without saving or running anything.
POST /calculation-chains/validate
Checks an inline, fully expanded calculation chain for structural problems without saving or running anything.
- Reports
errorissues (for example a step expecting a different currency than the one the amount is in, or afixedconvert without a rate) andwarningissues (for example an empty chain or a single-member group). - Without
start_currencythe chain is checked from its own start currency, exactly as saving it does: a chain with noerrorissue here can be saved. - Always returns 200 with the list of issues; an empty list means the chain is clean. A malformed payload returns 422 with the exact field path, such as
calculation_chain.steps[0].to.usd_rate. - Operator and currency IDs in the payload are not looked up.
Usage
| Name | Description |
|---|---|
| Authentication | API key required |
| Credit cost | Free |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
calculation_chain | object | Yes | The fully expanded chain to check: steps with each operator's full definition inline, in the shape a calculation chain is returned in (each currency needs at least code and usd_rate). |
start_currency | string or null | No | Currency code the amount starts in, e.g. USD. Omit it to check the chain from its own start_currency, exactly as saving it does. |
expected_terminal | string or null | No | Currency code the chain is expected to end in; a different final currency is reported as an error. |
Responses
| Status | Description | Schema |
|---|---|---|
200 | Successful Response | Envelope_ValidateOut_ |
401 | Authentication is missing or invalid | ErrorEnvelope |
403 | The credential is valid but not allowed to call this operation | ErrorEnvelope |
422 | A parameter or the request body is invalid | ErrorEnvelope |
429 | Too many requests to this endpoint; retry later | ErrorEnvelope |
503 | The service is temporarily unavailable; retry later | ErrorEnvelope |
Models
CreditMeta
Credit accounting for a billable request.
| Field | Type | Required | Description |
|---|---|---|---|
cost | integer | Yes | Credits this request costs. |
remaining | integer | Yes | Estimated credit balance left after this request. A hint rather than a ledger: concurrent requests can make it slightly off. |
Envelope_ValidateOut_
| Field | Type | Required | Description |
|---|---|---|---|
data | ValidateOut | Yes | The endpoint payload. |
meta | Meta | Yes | Request metadata. |
ErrorBody
Details of a failed request.
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Stable machine-readable error code. Branch on this value, not on message. |
message | string | Yes | Human-readable explanation. The wording may change. |
details | object or null | No | Optional structured context, such as the list of validation errors or, for credit_insufficient, the required and remaining credits. |
ErrorEnvelope
Error response: the error in error plus request metadata in meta.
Meta
Request metadata included in every enveloped response.
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Unique identifier of this request, identical to the X-Request-ID response header. Quote it when contacting support. |
billable | boolean or null | No | Whether the request is billed in credits. Present only on metered endpoints; false means the request is free, for example because it costs nothing or your subscription covers it. |
credit | CreditMeta or null | No | Cost of the request and your estimated remaining balance. Present only when billable is true. |
page | PageMeta or null | No | Paging state. Present only on a response that lists a page. |
PageMeta
Where a paged list stands after this page.
| Field | Type | Required | Description |
|---|---|---|---|
limit | integer | Yes | Page size actually applied to this request. |
has_next | boolean | Yes | Whether another page follows. |
next_cursor | string or null | Yes | Pass it back unchanged as cursor to get the next page; null once the list is complete. |
ValidateIssueOut
One problem found in a calculation chain.
| Field | Type | Required | Description |
|---|---|---|---|
level | string | Yes | error: the chain cannot compute correctly as configured. warning: suspicious but workable. Values: error, warning. |
code | string | Yes | Machine-readable issue code: empty_chain, currency_discontinuity, group_empty, group_single_member, group_edge_mismatch, fee_div_zero, fee_currency_missing, fee_currency_mismatch, convert_fixed_missing_rate, convert_fixed_rate_nonpositive or terminal_currency_mismatch. |
message | string | Yes | Human-readable explanation. |
step_index | integer or null | No | Zero-based index of the offending step; omitted for chain-level issues. |
member_index | integer or null | No | Zero-based index of the offending member within a group step; omitted otherwise. |
ValidateOut
Result of validating a calculation chain.
| Field | Type | Required | Description |
|---|---|---|---|
issues | array of ValidateIssueOut | Yes | Problems found, in chain order; empty when the chain is clean. |