Advanced: fees

Create a calculation chain

Creates a calculation chain and returns it as revision 1 with its steps expanded.

POST /calculation-chains

Creates a calculation chain and returns it as revision 1 with its steps expanded.

  • Each step references an existing operator by ID and kind. You may reference your own operators, official ones and those other users share. Every unavailable reference is listed in a 400 under details.missing, with the reason not_visible.
  • Saving checks the chain exactly as POST /calculation-chains/validate does without start_currency: any error issue (for example consecutive steps whose currencies do not line up) returns 422 with the issues under details.issues, and nothing is saved.
  • apply_to binds the new chain to marketplace slots in the same request, each with the slot sequence you read as expected_sequence. All or nothing: a stale sequence (409) or a refused step (400) leaves no chain behind and every slot unchanged. applied lists the bound slots.
  • The chain is yours and not official; set is_searchable to share it.

Usage

NameDescription
AuthenticationAPI key required
Credit costFree

Request body

FieldTypeRequiredDescription
namestring or nullNoOptional display name.
is_searchablebooleanNoShare the chain with other users: it then appears in search and can be bound and forked by anyone. Default: false.
stepsarray of FeeStepRef or ConvertStepRef or ConvertOperatorGroupStepRefNoSteps in execution order, each referencing an existing operator by ID and discriminated by kind.
input_autobooleanNoConvert a price quoted in another currency into the chain's start_currency before the first step (through the official US dollar values). Off: such a price is not covered by this chain. Default: true.
output_autobooleanNoConvert the result into the viewer's home currency after the last step. Off: the result stays in the chain's final currency. Default: true.
apply_toarray of ApplyToSlotNoMarketplace slots to bind to the new chain in the same request. Either every slot is bound and the chain is created, or nothing is: a stale expected_sequence (409) or a refused step (400) leaves no chain behind and every slot unchanged.
reasonstringNoOptional note saved with the new revision, shown in its history. Default: ``.

Responses

StatusDescriptionSchema
200Successful ResponseEnvelope_CalculationChainSavedOut_
400The request references a resource that does not exist, or carries an invalid cursorErrorEnvelope
401Authentication is missing or invalidErrorEnvelope
403The credential is valid but not allowed to call this operationErrorEnvelope
409The request conflicts with the current state of a resourceErrorEnvelope
422A parameter or the request body is invalidErrorEnvelope
429Too many requests to this endpoint; retry laterErrorEnvelope
503The service is temporarily unavailable; retry laterErrorEnvelope

Models

AppliedSlotOut

A marketplace slot the save bound to the chain.

FieldTypeRequiredDescription
website_codestringYesMarketplace code.
purposestringYesPurpose slot: deposit, sale or withdraw. Values: deposit, sale, withdraw.
calculation_chain_idintegerYesID of the bound chain.
calculation_chain_revisionintegerYesThe bound revision.
sequenceintegerYesThe slot's new sequence.

ApplyToSlot

A marketplace slot to bind to the chain being saved.

FieldTypeRequiredDescription
website_codestringYesMarketplace code, e.g. steam.
purposestringYesPurpose slot: deposit, sale or withdraw. Values: deposit, sale, withdraw.
expected_sequenceinteger or nullNoThe slot's sequence you last read (0 for a slot never written); a mismatch rejects the whole request with 409 conflict. Omit it to skip the check.

CalculationChainSavedOut

A saved calculation chain, plus the slots the request bound to it.

FieldTypeRequiredDescription
idinteger or nullYesUnique ID of the calculation chain.
namestring or nullYesDisplay name, if set.
start_currencystring or nullYesCurrency the chain expects its input in, derived from its first step that fixes one (a conversion's source, or the currency of an add/sub fee); null when no step does, i.e. the chain applies to any currency.
owner_user_idstring or nullYesID of the owning user; null for platform-owned records, which include every official record.
is_officialbooleanYesWhether this is an official chain published by the platform. Official records are read-only for users.
is_searchablebooleanYesWhether the owner shares this chain, so other users can find, reference and fork it.
ref_countintegerYesHow many times this chain is referenced (by marketplace bindings) or has been forked. Informational only.
forked_frominteger or nullYesID of the chain this one was forked from; null if it was created from scratch.
is_deprecatedbooleanYesWhether the chain is deprecated, which is final: it stays readable and can be forked, but can no longer be changed or bound.
is_deletedbooleanYesWhether the chain is deleted. Chains are never deleted any more; only very old ones can show true.
revisioninteger or nullYesRevision shown: the chain's current one when opened by ID, the requested one under /revisions/{revision}.
sequenceinteger or nullYesChange counter of the chain: rises with every saved revision and every change of sharing or lifecycle. Send it back as expected_sequence to detect concurrent changes.
input_autobooleanYesWhether a price in another currency is first converted into start_currency; otherwise this chain does not cover it.
output_autobooleanYesWhether the result is converted into the viewer's home currency after the last step.
stepsarray of FeeOperatorOut or ConvertOperatorOut or ConvertOperatorGroupOutYesSteps in execution order, each the full operator it applies, discriminated by kind.
appliedarray of AppliedSlotOutYesSlots bound by apply_to; empty without it.

ConvertOperatorGroupOut

A convert operator group: alternative conversions for the same currency pair, combined by a rule.

FieldTypeRequiredDescription
kind"convert_operator_group"YesRecord type: always convert_operator_group.
idinteger or nullYesUnique ID of the group.
namestringYesDisplay name.
rulestringYesHow the result is picked from the members that convert successfully: min, max or avg. Values: min, max, avg.
membersarray of ConvertOperatorOutYesThe member convert operators, in order, fully expanded.
owner_user_idstring or nullYesID of the owning user; null for platform-owned records, which include every official record.
is_officialbooleanYesWhether this is an official group published by the platform. Official records are read-only for users.
is_searchablebooleanYesWhether the owner shares this group, so other users can find, reference and fork it.
ref_countintegerYesHow many times this group is referenced (by calculation chain steps) or has been forked. Informational only.
forked_frominteger or nullYesID of the group this one was forked from; null if it was created from scratch.
is_deletedbooleanYesWhether the group is deleted. Deleted records are never returned again, so this is true only in a delete response.
revisioninteger or nullYesCurrent revision of the group: 1 when created, one more with every saved change. null only for an inline record.
sequenceinteger or nullYesChange counter of the group: rises with every saved revision and every change of sharing or lifecycle. Send it back as expected_sequence to detect concurrent changes.

ConvertOperatorGroupStepRef

A chain step that applies a convert operator group.

FieldTypeRequiredDescription
kind"convert_operator_group"YesStep type: convert_operator_group.
convert_operator_group_idintegerYesID of the convert operator group to apply (your own, official or shared by another user).

ConvertOperatorOut

A convert operator: converts the running amount from one currency to another.

FieldTypeRequiredDescription
kind"convert"YesRecord type: always convert.
idinteger or nullYesUnique ID of the convert operator.
namestringYesDisplay name.
fromCurrencyOutYesSource currency (fixed at creation).
toCurrencyOutYesTarget currency (fixed at creation).
modestringYesauto converts through both currencies' usd_rate; fixed multiplies by rate. Values: auto, fixed.
ratestring or nullYesUnits of the target currency per one unit of the source currency, as a decimal string; used in fixed mode.
owner_user_idstring or nullYesID of the owning user; null for platform-owned records, which include every official record.
is_officialbooleanYesWhether this is an official convert operator published by the platform. Official records are read-only for users.
is_searchablebooleanYesWhether the owner shares this convert operator, so other users can find, reference and fork it.
ref_countintegerYesHow many times this convert operator is referenced (by calculation chain steps and group memberships) or has been forked. Informational only.
forked_frominteger or nullYesID of the convert operator this one was forked from; null if it was created from scratch.
is_deletedbooleanYesWhether the convert operator is deleted. Deleted records are never returned again, so this is true only in a delete response.
revisioninteger or nullYesCurrent revision of the convert operator: 1 when created, one more with every saved change. null only for an inline record.
sequenceinteger or nullYesChange counter of the convert operator: rises with every saved revision and every change of sharing or lifecycle. Send it back as expected_sequence to detect concurrent changes.

ConvertStepRef

A chain step that applies a convert operator.

FieldTypeRequiredDescription
kind"convert"YesStep type: convert.
convert_operator_idintegerYesID of the convert operator to apply (your own, official or shared by another user).

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.

CurrencyOut

A currency and its US dollar value.

FieldTypeRequiredDescription
idinteger or nullYesUnique ID of the currency.
codestringYesCurrency code, e.g. USD.
namestring or nullYesDisplay name.
kindstringYesCurrency kind, e.g. fiat.
usd_ratestringYesValue of one unit of this currency in US dollars, as a decimal string. Used by auto conversions.
owner_user_idstring or nullYesID of the owning user; null for platform currencies, which include every official currency.
is_officialbooleanYesWhether the currency belongs to the official catalog maintained by the platform.
ref_countintegerYesNumber of convert operators that use this currency.
is_deletedbooleanYesWhether the currency is deleted. Deleted currencies are never listed, so this is true only in a delete response.

Envelope_CalculationChainSavedOut_

FieldTypeRequiredDescription
dataCalculationChainSavedOutYesThe 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.

FeeOperatorOut

A fee operator: one arithmetic step applied to the running amount.

FieldTypeRequiredDescription
kind"fee"YesRecord type: always fee.
idinteger or nullYesUnique ID of the fee operator.
namestringYesDisplay name.
operatorstringYesArithmetic applied to the running amount: add, sub, mul or div. Values: add, sub, mul, div.
valuestringYesOperand of the arithmetic, as a decimal string.
currency_codestring or nullYesCurrency of the amount for add and sub; null for mul and div.
owner_user_idstring or nullYesID of the owning user; null for platform-owned records, which include every official record.
is_officialbooleanYesWhether this is an official fee operator published by the platform. Official records are read-only for users.
is_searchablebooleanYesWhether the owner shares this fee operator, so other users can find, reference and fork it.
ref_countintegerYesHow many times this fee operator is referenced (by calculation chain steps) or has been forked. Informational only.
forked_frominteger or nullYesID of the fee operator this one was forked from; null if it was created from scratch.
is_deletedbooleanYesWhether the fee operator is deleted. Deleted records are never returned again, so this is true only in a delete response.
revisioninteger or nullYesCurrent revision of the fee operator: 1 when created, one more with every saved change. null only for an inline record.
sequenceinteger or nullYesChange counter of the fee operator: rises with every saved revision and every change of sharing or lifecycle. Send it back as expected_sequence to detect concurrent changes.

FeeStepRef

A chain step that applies a fee operator.

FieldTypeRequiredDescription
kind"fee"YesStep type: fee.
fee_operator_idintegerYesID of the fee operator to apply (your own, official or shared by another user).

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.

Download the public OpenAPI schema