> For the complete documentation index, see [llms.txt](https://docs.metamynd.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metamynd.ai/agent-controls-agentsafe/the-authorize-gate-16-ordered-checks.md). Agents can also search and read this documentation through its [MCP server](https://docs.metamynd.ai/~gitbook/mcp).

# The Authorize Gate: 16 Ordered Checks

The sixteen checks every authorize request goes through, in order. The gate stops at the first failure and returns the reason code for it.

`POST /policy/mandate/authorize` runs a request through **sixteen ordered checks**. The gate stops at the first failure and returns a specific reason code — there's no generic "denied," because a counterparty, an auditor, or the agent's own owner needs to know exactly which control fired. The one exception is an **escalate** at checks 11–12: it is carried to the end of the deterministic checks rather than returned on the spot, so it can never pre-empt a hard block further down (see *Escalation never outranks a hard block* below).

Before check 1, the request body is schema-validated. A body that fails (a missing field, a negative amount) is refused with `MALFORMED_REQUEST` in the same verdict shape as every other decision.

| #  | Check                                                                                                                                                                           | On failure                                                                                                                                            |
| -- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1  | Mandate exists for `(agentDid, action)`                                                                                                                                         | `NO_MANDATE` — or `NO_PERMISSION_FOR_ACTION` when the agent has mandates, but none for this action                                                    |
| 2  | Principal authority in force — mainnet free-tier caps; verification is reported, not required, on testnet                                                                       | `PRINCIPAL_UNVERIFIED`                                                                                                                                |
| 3  | Compliance with every enforced Standard                                                                                                                                         | `STANDARD_NONCOMPLIANT`                                                                                                                               |
| 4  | Agent exists; key proven; registered key matches the key in the DID                                                                                                             | `AGENT_NOT_FOUND` · `AGENT_KEY_UNVERIFIED` · `IDENTITY_KEY_MISMATCH`                                                                                  |
| 5  | Signature valid (see [Request Signing](https://docs.metamynd.ai/agent-protocol/request-signing-and-message-format)), then the optional envelope signature, then payload binding | `SIGNATURE_INVALID` (or `CLIENT_PROTOCOL_VERSION_UNSUPPORTED`) · `CONTEXT_SIGNATURE_INVALID` · `PAYLOAD_BINDING_INVALID` · `PAYLOAD_BINDING_REQUIRED` |
| 6  | Not contained                                                                                                                                                                   | `AGENT_SUSPENDED` · `AGENT_QUARANTINED` · `AGENT_DECOMMISSIONED`                                                                                      |
| 7  | Operating-mode **block** tier                                                                                                                                                   | `MODE_READ_ONLY`                                                                                                                                      |
| 8  | Freshness, then nonce consumed atomically; then the effective jurisdiction is resolved                                                                                          | `REQUEST_EXPIRED` · `REPLAY_DETECTED` · `JURISDICTION_MISMATCH`                                                                                       |
| 9  | Rate limit, if enabled                                                                                                                                                          | `RATE_LIMIT_EXCEEDED`                                                                                                                                 |
| 10 | Circuit breakers, if enabled                                                                                                                                                    | `CIRCUIT_BREAKER_OPEN`                                                                                                                                |
| 11 | Standard rule molecules                                                                                                                                                         | the firing molecule's code (or `CONTEXT_UNVERIFIABLE`)                                                                                                |
| 12 | SOP rule molecules; then an enforced jurisdiction rule with no effective jurisdiction                                                                                           | the firing molecule's code (or `CONTEXT_UNVERIFIABLE`) · `JURISDICTION_REQUIRED`                                                                      |
| 13 | Mandate evaluation                                                                                                                                                              | e.g. `SPEND_LIMIT_EXCEEDED`, `MERCHANT_NOT_ALLOWED`, `JURISDICTION_REQUIRED`, `JURISDICTION_NOT_ALLOWED`; success → `AUTHORIZED`                      |
| 14 | Fold in OBSERVE                                                                                                                                                                 | `allow` → `observe`                                                                                                                                   |
| 15 | Operating-mode escalate floor; reassessment floor; spend-anomaly floor (graph-backed, opt-in); runtime assurance floor (opt-in)                                                 | `MODE_*` · `REASSESSMENT_PENDING` · `SPEND_PATTERN_ANOMALY` · `AGENT_NOT_CERTIFIED` · `ASSURANCE_STALE`                                               |
| 16 | Atomic spend reservation (creates the **hold**)                                                                                                                                 | `CAP_EXCEEDED`                                                                                                                                        |

**Notes on individual checks**

* **Check 2 — principal authority.** Every mandate must name an authorizing principal. What happens next depends on the agent's network:

  * **Testnet and `did:key` agents** are never refused on principal verification. An unverified owner can build and test freely; the verdict reports the principal's status (`principalVerified`) so a counterparty can apply its own risk policy.
  * **Mainnet agents** require a principal verified by a mainnet-eligible provider to exist at all, and their authority holds only within the free-tier caps (1 mainnet agent per owner, 5 active mandates on the agent). Beyond either cap the gate refuses with `PRINCIPAL_UNVERIFIED` — a code whose name predates this model.

  See [Networks: Testnet, Mainnet & Verification](https://docs.metamynd.ai/core-concepts/networks-testnet-mainnet-and-verification).
* **Check 5 — payload binding.** Payload binding is verified immediately after the main signature, under the same key. Checking it there, and not earlier, means only the agent itself learns whether the owner requires binding (`requirePayloadBinding`). See [Payload Binding](https://docs.metamynd.ai/core-concepts/payload-binding).
* **Checks 8, 12 and 13: jurisdiction.** After the signature, the gate resolves one **effective jurisdiction**, in this order:

  1. the country the mandate's owner registered for the signed `merchant` in the payee directory, which is authoritative;
  2. otherwise the top-level `jurisdiction` the agent signed (the v2 message, see [Request Signing](https://docs.metamynd.ai/agent-protocol/request-signing-and-message-format#signed-jurisdiction-message-v2));
  3. otherwise none.

  An `itinerary` jurisdiction is removed before any rule sees the context. If the signed value contradicts the registered country, the request is refused `JURISDICTION_MISMATCH` at check 8, before any rule runs, and this applies whether or not anything restricts jurisdictions. A mandate that restricts jurisdictions fails check 13: `JURISDICTION_REQUIRED` when there is no effective jurisdiction, `JURISDICTION_NOT_ALLOWED` when it is outside the list. An enforced (non-`observe`) Standard or SOP rule that judges `jurisdiction-not-allowed` gets `JURISDICTION_REQUIRED` at the end of check 12 when there is no effective jurisdiction, because the atom alone does not fire on a missing value. All three are hard blocks and outrank a carried escalate.

  **Compatibility:** with no restriction on the mandate and no enforced jurisdiction rule, the gate behaves exactly as before for old and new clients. The one exception is `JURISDICTION_MISMATCH`, when a signed value contradicts a registered country. See [Restrict Jurisdictions](https://docs.metamynd.ai/guides/restrict-jurisdictions).
* **Checks 7 and 15 — effective risk.** The operating-mode gates judge the **effective** `riskLevel`: the maximum of the mandate owner's `riskTier`, the `amount-share` risk signal (a payment at or above 70% of the per-transaction cap), any context the gateway derived from the real request, and the agent's own claim. An agent in `supervised` mode cannot skip the high-risk escalation by claiming `low`. The rule stages also see the `new-merchant` and `context-value` signals; see [Context Provenance & Risk Floors](https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors#risk-signals-risk-metamynd-derives-from-the-request).
* **Checks 11–12 — the context-provenance floor.** A molecule containing a `risk-at-or-above` atom must not pass when `riskLevel` is missing or not one of `low`/`medium`/`high`/`critical`: it decides at least `escalate`, with `CONTEXT_UNVERIFIABLE`. The same applies when a molecule declares `requireProvenance: { field: level }` and the field's value comes from a less trusted source than required. Silence about risk is not a way past a risk rule. See [Context Provenance & Risk Floors](https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors).
* **Check 13 — authority.** Whether the mandate grants the action at all is resolved before the rule stages run, but applied most-restrictive-wins at the end, so a containment decided by a rule still persists and a refusal names the real cause.
* **Check 16 — the hold.** A permit for a value-bearing action atomically reserves the amount against the mandate's cap. That reservation is a **hold**: an executor must **claim** it (`POST /policy/mandate/authorize/{id}/effect/dispatching`) before running the action, and then capture or release it. A hold nobody claims expires and auto-voids (default 15 minutes); a claimed hold is a commitment and does not lapse. See [Settlement & Settlement Evidence](https://docs.metamynd.ai/agent-protocol/settlement-and-settlement-evidence).

**After the verdict: automated containment**

A deployment can quarantine an agent after repeated refusals; the threshold is set per deployment. When it does, the agent's `block` is lifted to `quarantine` with `REPEATED_DENIALS_CONTAINED`, and from then on check 6 refuses everything until an owner reinstates it. See [Continuous Monitoring](https://docs.metamynd.ai/the-architecture/continuous-monitoring).

**Why this order is a security property, not an accident**

* **Steps 1–3 precede signature verification** because they're questions about the *policy*, not the requester. They cost one query each and reveal nothing about the requester's identity.
* **Nonce consumption (8) must follow signature verification (5)** — otherwise a forged request could burn a victim's nonce before its signature is even checked.
* **Containment (6) precedes everything action-specific**, so a contained agent can't reach evaluation at all, regardless of what it signs.
* **The mode escalate floor (15) follows deterministic evaluation**, so a specific rule denial is reported instead of a generic mode reason.
* **Escalation never outranks a hard block.** A Standard or SOP molecule that escalates at 11–12 — including `CONTEXT_UNVERIFIABLE` for a missing `riskLevel` — does not end evaluation: the SOP stage and the mandate evaluation (13) still run, and any `block`, `suspend` or `quarantine` there (an SOP per-transaction cap, the mandate's per-transaction or total cap, an action the mandate never granted) is the verdict. The escalate is returned, with its own reason code, only when everything after it would otherwise permit. So escalation can lift a would-be permit to human review but never downgrade a block — otherwise an agent could turn any hard cap into a review by leaving out a field.
* **Approving an escalation re-runs the gate, as of the approval.** Approval (and a reviewer's MODIFY, which re-enters the gate) re-runs checks 1–4, 6, 7 and 9–13 on the escalated request with the inputs as they stand at approval — the mandate still active and current (`MANDATE_REVOKED` / `MANDATE_SUPERSEDED`), the current rate window and `callCount`, breakers, committed spend, the counterparty's current trust score, the signed `resource`, and the stored signed `jurisdiction` resolved again against the payee registry as it stands now (a country changed since the review opened can make it `JURISDICTION_MISMATCH`; no effective jurisdiction under a jurisdiction restriction is `APPROVAL_INPUT_UNAVAILABLE`). Only the transport checks (5, 8) are not repeated. Any block refuses the approval with its own code and the review stays pending for the reviewer to deny; an input that cannot be read refuses with `APPROVAL_INPUT_UNAVAILABLE`. Escalates are ignored — they are what the reviewer is approving. See [Escalation & Resume](https://docs.metamynd.ai/agent-protocol/escalation-and-resume).
* **The spend-anomaly floor (15, opt-in)** only ever *lifts* a permit to escalate, never downgrades a stricter verdict. It answers a different question than rate limits (9) or circuit breakers (10): those enforce a threshold a human pre-set; this flags a deviation from the agent's *own* recorded history, which no fixed threshold could have anticipated.
* **The runtime assurance floor (15, opt-in)** escalates on a `blocked` or expired deployment-assurance certificate (issued out-of-band; the certificate itself is not part of the MAGP spec). Same precedence discipline: it only ever lifts an otherwise-permit verdict to escalate, never a hard block — an agent that has been operating isn't cut off the instant its certificate lapses; a human reviews before the *next* action refuses outright. An agent that was never issued a certificate is unaffected.
* **Reservation (16) is last and atomic** — it's the only step that mutates shared budget, and a lost race must return `CAP_EXCEEDED`.
* **Steps 9 and 10, the spend-anomaly floor and the assurance lookup are secondary controls.** A deployment chooses whether they fail open or closed when they can't run; when they fail closed, the refusal is `CONTROL_UNAVAILABLE` (see [The Security Model](https://docs.metamynd.ai/the-architecture/the-security-model-defense-in-depth)).

**Response shape**

`200` on a permitting disposition (`allow`/`observe`); `403` on a refusing one (`400` for `MALFORMED_REQUEST`). Response envelope:

```json
{
  "success": true,
  "message": "Authorization allow",
  "data": {
    "decision": "allow",
    "reasonCode": "AUTHORIZED",
    "authorizationId": "…",
    "remaining": 350,
    "proofRef": "…",
    "eventId": "…",
    "expiresAt": "…",
    "escalationId": null,
    "principalVerified": false,
    "passport": { "actionPassportId": "…", "issuedAt": "…", "expiresAt": "…", "signature": "…", "issuerKeyId": "…" },
    "envelopeId": "env:…",
    "envelopeHash": "sha256:…",
    "payloadDigest": "sha256:…"
  }
}
```

* `authorizationId` identifies the hold. `eventId` is the anchored evidence event (use it with `GET /magp/evidence/:eventId/proof`).
* `principalVerified` travels on every verdict, allow or block.
* `passport` is the signed [Action Passport](https://docs.metamynd.ai/verifai-trust-layer/action-passport) for a permit (best-effort; it can be `null`).
* `payloadDigest` appears on `allow`, `observe` and `escalate` verdicts: the digest the authorization is bound to, or `null` for an unbound one. An agent that sent a digest must refuse a permit that does not echo it.
* A `SIGNATURE_INVALID` verdict may also carry a non-normative `hint`.

`decision` is one of the dispositions listed on [Dispositions](https://docs.metamynd.ai/agent-protocol/dispositions). The containment check (step 6) can also answer `decommission` for an agent whose owner has decommissioned it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.metamynd.ai/agent-controls-agentsafe/the-authorize-gate-16-ordered-checks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
