Consent Server

Example requests

Copy these to set policies, ask for a decision and request consent. Open a response to see what comes back.

All paths are under your organization: https://consent.scrambleid.com/orgs/{orgCode}/api/v1. The examples use org acme.

Send a ScrambleID M2M token. Its orgCode must match the path. Each section names the scopes it needs.

The guide explains how it all works, and the API reference lists every field and error.

Section 1 of 3

Policies

Policies decide what happens when an agent wants to call an action on a service: allow it, deny it, or ask for consent first. You set them at three levels, and every level takes the same body.

Scopes: policy.write to set or remove a policy, policy.read to read one.

The levels

LevelPathApplies to
Organization/orgs/acme/api/v1/policyEvery call in the organization that nothing below decides
Service/orgs/acme/api/v1/services/{service}/policyEvery action on that service that has no policy of its own
Action/orgs/acme/api/v1/services/{service}/actions/{action}/policyThat action on that service, with optional rules on its parameters

The most specific level that is set decides: a rule whose conditions hold, then the action, then the service, then the organization. If none is set, the call is denied: POST /decisions answers deny. An agent can only ask for consent on such a call by naming the approvers itself, which needs consent.request.notify.

Every level takes { "outcome", "notify"?, "quorum"? }. outcome is allow, deny or consent. notify (who is asked) and quorum (how many must approve, default 1) only go with consent. Actions also take rules.

PUT sets a level, replacing whatever was there. GET reads it (404 when it is not set). DELETE removes it, so the level above decides.

1. Organization default

Ask the security team about anything that has no policy of its own:

PUT/orgs/acme/api/v1/policy

{
  "outcome": "consent",
  "notify": { "groups": ["Security"] }
}
Response 200
{
  "data": {
    "outcome": "consent",
    "notify": { "groups": [{ "displayName": "Security" }] },
    "quorum": null
  }
}

This is the safety net for the whole organization. Without it, calls that no service or action policy covers are denied. While you are trying things out, { "outcome": "allow" } lets everything through instead.

2. Service default

Let every action on invoice-service through, unless the action has a policy of its own:

PUT/orgs/acme/api/v1/services/invoice-service/policy

{
  "outcome": "allow"
}
Response 200
{ "data": { "outcome": "allow", "notify": null, "quorum": null } }

A call to lookup on invoice-service is now allowed, while a call on hr-service still falls back to the organization default. A service is any stable id you choose, such as invoice-service. Use the same id in calls and policies; a policy for one service never applies to another.

3. Action default with a rule

Payments need Finance's approval, except small ones:

PUT/orgs/acme/api/v1/services/invoice-service/actions/payment/policy

{
  "outcome": "consent",
  "notify": { "groups": ["Finance"] },
  "quorum": 1,
  "rules": [
    { "when": [ { "parameter": "amount", "operator": "lt", "value": 1000 } ], "outcome": "allow" }
  ]
}
Response 200
{
  "data": {
    "outcome": "consent",
    "notify": { "groups": [{ "displayName": "Finance" }] },
    "quorum": 1,
    "rules": [
      {
        "id": "pol_r00_aef12e7a...",
        "when": [ { "parameter": "amount", "operator": "lt", "value": 1000 } ],
        "outcome": "allow",
        "notify": null,
        "quorum": null
      }
    ]
  }
}

The top-level outcome (with its notify and quorum) is the action default: what happens to a call of payment on invoice-service when no rule holds. Each rule overrides it for the calls whose parameters meet its conditions.

amountResultWhy
500allowedThe rule holds
5,000consent, 1 of FinanceNo rule holds: the action default
missingconsent, 1 of FinanceAn allow rule never holds on doubt

At the organization and service paths the same top-level fields are that level's default, and there are no rules.

The top-level outcome is optional on an action. With rules only, calls that no rule matches fall through to the service default, then the organization default.

4. A rule with its own approvers

Large payments need two of the CFO and CEO instead of Finance. The rule names its approvers inline, next to "outcome": "consent":

PUT/orgs/acme/api/v1/services/invoice-service/actions/payment/policy

{
  "outcome": "consent",
  "notify": { "groups": ["Finance"] },
  "rules": [
    { "when": [ { "parameter": "amount", "operator": "lt", "value": 1000 } ], "outcome": "allow" },
    { "when": [ { "parameter": "amount", "operator": "gte", "value": 50000 } ],
      "outcome": "consent", "notify": { "users": ["cfo", "ceo"] }, "quorum": 2 }
  ]
}
amountWho is asked
500Nobody, allowed (first rule)
5,0001 of Finance (action default)
75,0002 of cfo and ceo (second rule)

notify takes up to three lists: users (usernames), emails (primary emails) and groups (group display names), for example { "users": ["alice"], "emails": ["bob@acme.com"], "groups": ["Finance"] }.

Check and remove

Read the organization default (404 when it is not set). The same GET works on the service and action paths:

GET/orgs/acme/api/v1/policy

Admins can also see and change it on their organization's Policy page, /orgs/acme/policy, at the top under Organization default.

See what applies to an action when no rule holds, and every level on the way:

GET/orgs/acme/api/v1/services/invoice-service/actions/payment/policy?effective=true

Remove a level, so the one above decides:

DELETE/orgs/acme/api/v1/services/invoice-service/actions/payment/policy
Response 200
{ "data": { "service": "invoice-service", "action": "payment", "deleted": true } }

↑ Back to topNext: Decisions →

Section 2 of 3

Decisions

Ask what should happen to one exact call, as your gateway does. Nothing is stored. Scope: policy.evaluate.

POST/orgs/acme/api/v1/decisions

{
  "service": "invoice-service",
  "action": "payment",
  "parameters": { "amount": 5000 }
}
Response 200: consent needed
{
  "data": {
    "decision": "consent",
    "level": "action",
    "approvers": { "users": [], "emails": [], "groups": ["Finance"], "quorum": 1, "inherited": false }
  }
}
Response 200: allowed
{ "data": { "decision": "allow", "level": "rule" } }
Response 200: denied
{ "data": { "decision": "deny", "level": "rule" } }

With a consent token

Pass the agent's consent token and ScrambleID checks it against the call, so your gateway needs no matching logic. It is good for one call.

POST/orgs/acme/api/v1/decisions

{
  "service": "invoice-service",
  "action": "payment",
  "parameters": { "amount": 75000 },
  "consentToken": "eyJhbGciOiJFUzI1NiIs..."
}
Response 200: exact match
{
  "data": {
    "decision": "allow",
    "level": "rule",
    "consent": { "requestId": "cr_01M6KS830FJEB3JMBSGRBABYNK", "accepted": true }
  }
}
Response 403: parameters differ
{ "error": { "code": "CONSENT_PARAM_MISMATCH", "message": "The parameters differ from what was approved" } }
Response 403: token expired
{ "error": { "code": "TOKEN_EXPIRED", "message": "The consent token has expired" } }

↑ Back to topNext: Consent requests →


Next: the guide explains how it all works, and the API reference lists every field and error.