EvaluationОценить запрос политиками

Оценить запрос политиками

Ядро policy engine (deny-overrides):

  1. Собираются все политики пользователя в Vault (через членства в группах)
  2. Фильтр: enabled=true и actionType = action
  3. Применимость: одно булево дерево condition (and/or/not/лист). condition=null → политика применима всегда
  4. Резолюция (Ф2): block → нарушенный лимит (отказ или эскалация в подпись) → требования подписи → allow → deny (default-deny). Требования СОБИРАЮТСЯ со всех применимых политик (requirements[]), а не выбирается одно с максимальным порогом — так выражается «CFO И комплаенс»

Вызывается внутренне из createAddress/createTransaction, но доступен и напрямую — для dry-run проверок из UI.

curl -X POST "https://policy-engine-rest.ezig.workers.dev/api/v1/evaluate" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "vaultId": "example_string",
  "userId": "user-1",
  "action": "transfer",
  "context": {
    "derivationPath": "m/44/195/0/0/1/1/0",
    "destinationAddress": "123 Main St",
    "destinationNetwork": "tron",
    "amount": {
      "value": "1.5",
      "asset": "usdt"
    },
    "totalSpent": {
      "value": "example_string",
      "asset": "example_string"
    },
    "tokenCode": "example_string",
    "signersConfig": {
      "mode": "example_string"
    }
  }
}'
{
  "decision": "example_string",
  "matchedPolicyIds": [
    "example_string"
  ],
  "trace": [
    {
      "policyId": "example_string",
      "policyCode": "example_string",
      "policyName": "John Doe",
      "effect": "example_string",
      "applied": true,
      "skipReason": "excluded",
      "failedSelector": {
        "conditionType": "example_string",
        "selectorType": "example_string",
        "detail": "траты у инициатора за 24 ч с учётом текущей операции — 11000 usdt, лимит 10000 usdt"
      }
    }
  ]
}
POST
/api/v1/evaluate
POST
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token
Bearer Tokenstring
Required

better-auth session token. Мобилка/сервисы. Веб использует cookie.

better-auth session token. Мобилка/сервисы. Веб использует cookie.
API Key (cookie: better-auth.session_token)
Content-Typestring
Required

The media type of the request body

Options: application/json
actionstring
Required

Тип действия, к которому применяется политика. Видимость участников СЮДА не входит: это грант (/vaults/:code/visibility-grants), а не политика

Options: transfer, create_address, counterparty_create, counterparty_update, counterparty_archive, counterparty_group_create, counterparty_group_update, counterparty_group_archive, counterparty_group_add, counterparty_group_remove
contextobject
Required

Контекст запроса — заполняются только поля, релевантные для action. Какие именно кладут боевые вызовы, закреплено метатестом tests/selectorContextParity.test.ts: селектор нельзя разрешить, если контекст его не питает (иначе политика молча перестаёт применяться)

Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. better-auth session token. Мобилка/сервисы. Веб использует cookie.

path
parameterstring
Required

API Key for authentication. Provide your API key in the cookie.

Body

application/json
userIdstring
Required
Example:
user-1
actionstring
Required

Тип действия, к которому применяется политика. Видимость участников СЮДА не входит: это грант (/vaults/:code/visibility-grants), а не политика

Allowed values:transfercreate_addresscounterparty_createcounterparty_updatecounterparty_archivecounterparty_group_createcounterparty_group_updatecounterparty_group_archivecounterparty_group_addcounterparty_group_remove
contextobject
Required

Контекст запроса — заполняются только поля, релевантные для action. Какие именно кладут боевые вызовы, закреплено метатестом tests/selectorContextParity.test.ts: селектор нельзя разрешить, если контекст его не питает (иначе политика молча перестаёт применяться)

Responses

decisionstring
Required
matchedPolicyIdsstring[]
Required
tracearray