Dry-run the policy gate for an action
POST /v1/policies/check
See https://ordan.io/docs/authentication and https://ordan.io/docs/errors for authority, scopes and retries. Paid usage reports customer charges; preview usage reports provider-cost allowance consumption. Money fields use the units specified in their schemas.
Operation ID: post__v1_policies_check.
Authentication
Use one of these authentication alternatives. Schemes on the same line are required together:
bearerAgent(bearer token)
Organization roles, key scopes, grant capabilities, policy and spend limits still apply. See Authentication.
Request
Header parameters
| Parameter | Type | Required | Description / constraints |
|---|---|---|---|
Idempotency-Key | string | No | One key per logical operation; reuse only with identical body. Retrieve committed resources after ambiguous outcomes. |
Body (required)
Content type: application/json
Type: object
Required means required within its containing object, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.
| Field | Type | Presence | Description / constraints |
|---|---|---|---|
action | call.outbound, sms.send, call.transfer, purchase | Required | — |
amount_cents | integer | Optional | minimum: 1. maximum: 10000000 |
body | string | Optional | maxLength: 1600 |
call | string | Optional | Public call_… reference (not a UUID). pattern: ^call_[0-7][0-9A-HJKMNP-TV-Z]{25}$ |
category | string | Optional | maxLength: 60 |
line | string | Optional | Public line_… reference (not a UUID). pattern: ^line_[0-7][0-9A-HJKMNP-TV-Z]{25}$ |
merchant | string | Optional | — |
purpose | string | Optional | maxLength: 200 |
smart_encoding | boolean | Optional | — |
to | string | Optional | pattern: ^\+[1-9][0-9]{6,14}$ |
JSON Schema
json
{
"additionalProperties": true,
"properties": {
"action": {
"enum": [
"call.outbound",
"sms.send",
"call.transfer",
"purchase"
],
"type": "string"
},
"amount_cents": {
"maximum": 10000000,
"minimum": 1,
"type": "integer"
},
"body": {
"maxLength": 1600,
"type": "string"
},
"call": {
"description": "Public call_… reference (not a UUID)",
"pattern": "^call_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
"type": "string"
},
"category": {
"maxLength": 60,
"type": "string"
},
"line": {
"description": "Public line_… reference (not a UUID)",
"pattern": "^line_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
"type": "string"
},
"merchant": {
"type": "string"
},
"purpose": {
"maxLength": 200,
"type": "string"
},
"smart_encoding": {
"type": "boolean"
},
"to": {
"examples": [
"+12125550101"
],
"pattern": "^\\+[1-9][0-9]{6,14}$",
"type": "string"
}
},
"required": [
"action"
],
"type": "object"
}Request examples
These are request templates, not executed requests. Replace REPLACE_… and <…> placeholders, set the credential environment variables, and supply any conditional fields your action needs. JSON values are illustrative, not live records. Use a stable idempotency key per logical operation.
bash
curl --request POST --url 'https://api.ordan.io/v1/policies/check' \
--header "Authorization: Bearer $ORDAN_AGENT_TOKEN" \
--header "Idempotency-Key: $ORDAN_IDEMPOTENCY_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"action": "call.outbound"
}'js
const response = await fetch("https://api.ordan.io/v1/policies/check", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.ORDAN_AGENT_TOKEN,
"Idempotency-Key": "" + process.env.ORDAN_IDEMPOTENCY_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"action": "call.outbound"
}),
});
const text = await response.text();
if (!response.ok) throw new Error(`${response.status}: ${text}`);
const result = text ? JSON.parse(text) : null;python
import json
import os
from urllib.request import Request, urlopen
request = Request("https://api.ordan.io/v1/policies/check",
method="POST",
headers={
"Authorization": "Bearer " + os.environ["ORDAN_AGENT_TOKEN"],
"Idempotency-Key": "" + os.environ["ORDAN_IDEMPOTENCY_KEY"],
"Content-Type": "application/json",
},
data="{\n \"action\": \"call.outbound\"\n}".encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
text = response.read().decode("utf-8")
result = json.loads(text) if text else NoneResponses
| Status | Meaning |
|---|---|
400 | Invalid request; device token polling uses RFC 8628 string errors |
402 | spend_limit_exceeded: inspect details.scope (org/grant/line) and outstanding_micros |
403 | Missing authority, policy_violation, approval_required (details.approval_request), limit_reached, destination_not_supported or feature_disabled (details.feature) |
409 | Conflict, idempotency in progress, or a2p_registration_pending; retrieve state instead of duplicating work |
422 | validation_error: the request is not valid; details name each field |
429 | Rate limited; back off and retain the same idempotency key |
502 | provider_error: unknown routes need verified quotes; ambiguous operations retain resource references and cost holds |
2XX | Success (created objects use 201) |
default | Error |
Status ranges such as 2XX are retained exactly as declared. See Errors and recovery for retries and pending outcomes.
400 response
Content type: application/json
Type: Error
Required means required within its containing object, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.
| Field | Type | Presence | Description / constraints |
|---|---|---|---|
error | object | Required | Additional properties allowed |
error.code | string | Required | — |
error.details | object | Optional | Additional properties allowed |
error.message | string | Required | — |
JSON Schema
json
{
"$ref": "#/components/schemas/Error"
}2XX response
Content type: application/json
Type: PolicyDecision
Required means required within its containing object, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.
| Field | Type | Presence | Description / constraints |
|---|---|---|---|
decision | allow, block, require_approval | Optional | — |
estimated_cost_micros | anyOf: string; null | Optional | — |
estimated_provider_cost_micros | anyOf: string; null | Optional | — |
matched_rules | Array of string | Optional | — |
reasons | Array of string | Optional | — |
sms | object | Optional | Additional properties allowed |
sms.encoding | GSM-7, UTF-16 | Optional | — |
sms.segments | integer | Optional | minimum: 1 |
sms.units | integer | Optional | minimum: 0 |
JSON Schema
json
{
"$ref": "#/components/schemas/PolicyDecision"
}Illustrative response template
Placeholder values show the shape, not a live response. Nullable costs remain null rather than implying zero usage.
json
{
"decision": "allow",
"estimated_cost_micros": null,
"estimated_provider_cost_micros": null,
"matched_rules": [
"<matched_rules>"
],
"reasons": [
"<reasons>"
],
"sms": {
"encoding": "GSM-7",
"segments": 1,
"units": 0
}
}default response
Content type: application/json
Type: Error
Required means required within its containing object, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.
| Field | Type | Presence | Description / constraints |
|---|---|---|---|
error | object | Required | Additional properties allowed |
error.code | string | Required | — |
error.details | object | Optional | Additional properties allowed |
error.message | string | Required | — |
JSON Schema
json
{
"$ref": "#/components/schemas/Error"
}