PT EN

Políticas de decisão

URL base: $BUSINESS_API

Obter uma política de decisão

Registos

GET /decision-policies/{type}

Returns the tenant's decision policy for one approval type, with its mode and current version. When the tenant has never configured that type, a default policy in human mode is returned without being saved. Requires automations:read; an unknown approval type returns 400.

Parâmetros

typestring · caminho · obrigatório

Approval type: billing_posting, price_version_publication, manual_journal_entry, supplier_payout, refund, write_off or cut_approval.

Devolve

200 Policy with its current mode, limits and version

Permissões automations:read · Funções: admin, analyst, customer_service, finance, operations, owner

curl -X GET "$BUSINESS_API/decision-policies/{type}" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200

Policy with its current mode, limits and version

Configurar uma política de decisão

Registos

PUT /decision-policies/{type}

Saves a new immutable version of the approval type's policy (mode, condition group, limits, sampling percent and explanation) and increments the policy version; the first update creates the policy. Every approval type currently has a platform minimum of human review, so any mode other than human is refused with 400. An invalid condition group or a sampling_percent outside 0 to 100 also returns 400. Requires automations:write.

Parâmetros

typestring · caminho · obrigatório

Approval type: billing_posting, price_version_publication, manual_journal_entry, supplier_payout, refund, write_off or cut_approval.

Corpo application/json

modestring · obrigatório

um de automatic, human, sampled

condition_groupobject · opcional
limitsobject · opcional
sampling_percentinteger · opcional
explanationstring · opcional

Devolve

200 Updated policy

Erros 400

Permissões automations:write · Funções: admin, finance, operations, owner

curl -X PUT "$BUSINESS_API/decision-policies/{type}" \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
  "mode": "automatic",
  "condition_group": {},
  "limits": {},
  "sampling_percent": 0,
  "explanation": "explanation"
}'
Resposta 200

Updated policy

Simular uma política de decisão

Registos

POST /decision-policies/{type}/simulate

Evaluates the current policy version against the supplied case (amount_cents and inputs) and returns the outcome: automatic, pending_human, approved or rejected. The decision is always saved to the decision log, so this call is not a dry run. When approved is set, the decision records a human approval or rejection by the caller, which also requires the write scope for that approval type (for example refund needs payments:write). Requires automations:read; an unknown approval type returns 400.

Parâmetros

typestring · caminho · obrigatório

Approval type to evaluate: billing_posting, price_version_publication, manual_journal_entry, supplier_payout, refund, write_off or cut_approval.

Corpo application/json

subject_typestring · opcional
subject_idstring · opcional
inputsobject · opcional
amount_centsinteger · opcional
approvedboolean · opcional
decided_bystring · opcional

Devolve

200 Decision with policy version, outcome and explanation

Permissões automations:read · Funções: admin, analyst, customer_service, finance, operations, owner

curl -X POST "$BUSINESS_API/decision-policies/{type}/simulate" \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
  "subject_type": "subject type",
  "subject_id": "sub_2Cg5f6gZ7W8jvEm53ICdbaeNrWe",
  "inputs": {},
  "amount_cents": 125000,
  "approved": true,
  "decided_by": "decided by"
}'
Resposta 200

Decision with policy version, outcome and explanation