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 error issues (for example a step expecting a different currency than the one the amount is in, or a fixed convert without a rate) and warning issues (for example an empty chain or a single-member group).
  • Without start_currency the chain is checked from its own start currency, exactly as saving it does: a chain with no error issue 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

NameDescription
AuthenticationAPI key required
Credit costFree

Request body

FieldTypeRequiredDescription
calculation_chainobjectYesThe 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_currencystring or nullNoCurrency 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_terminalstring or nullNoCurrency code the chain is expected to end in; a different final currency is reported as an error.

Responses

StatusDescriptionSchema
200Successful ResponseEnvelope_ValidateOut_
401Authentication is missing or invalidErrorEnvelope
403The credential is valid but not allowed to call this operationErrorEnvelope
422A parameter or the request body is invalidErrorEnvelope
429Too many requests to this endpoint; retry laterErrorEnvelope
503The service is temporarily unavailable; retry laterErrorEnvelope

Models

CreditMeta

Credit accounting for a billable request.

FieldTypeRequiredDescription
costintegerYesCredits this request costs.
remainingintegerYesEstimated credit balance left after this request. A hint rather than a ledger: concurrent requests can make it slightly off.

Envelope_ValidateOut_

FieldTypeRequiredDescription
dataValidateOutYesThe endpoint payload.
metaMetaYesRequest metadata.

ErrorBody

Details of a failed request.

FieldTypeRequiredDescription
codestringYesStable machine-readable error code. Branch on this value, not on message.
messagestringYesHuman-readable explanation. The wording may change.
detailsobject or nullNoOptional 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.

FieldTypeRequiredDescription
errorErrorBodyYesWhat went wrong.
metaMetaYesRequest metadata.

Meta

Request metadata included in every enveloped response.

FieldTypeRequiredDescription
request_idstringYesUnique identifier of this request, identical to the X-Request-ID response header. Quote it when contacting support.
billableboolean or nullNoWhether 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.
creditCreditMeta or nullNoCost of the request and your estimated remaining balance. Present only when billable is true.
pagePageMeta or nullNoPaging state. Present only on a response that lists a page.

PageMeta

Where a paged list stands after this page.

FieldTypeRequiredDescription
limitintegerYesPage size actually applied to this request.
has_nextbooleanYesWhether another page follows.
next_cursorstring or nullYesPass it back unchanged as cursor to get the next page; null once the list is complete.

ValidateIssueOut

One problem found in a calculation chain.

FieldTypeRequiredDescription
levelstringYeserror: the chain cannot compute correctly as configured. warning: suspicious but workable. Values: error, warning.
codestringYesMachine-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.
messagestringYesHuman-readable explanation.
step_indexinteger or nullNoZero-based index of the offending step; omitted for chain-level issues.
member_indexinteger or nullNoZero-based index of the offending member within a group step; omitted otherwise.

ValidateOut

Result of validating a calculation chain.

FieldTypeRequiredDescription
issuesarray of ValidateIssueOutYesProblems found, in chain order; empty when the chain is clean.

Download the public OpenAPI schema