DelegusDocsv0.2

Docs/Integrate

Getting started

Integrate Delegus as a relying party

This page is for the engineer whose service is about to receive an action from an AI agent it has never seen. It describes the integration surface that v0.2 of the protocol specifies. The production service is serving and the SDK is published on npm; nothing here is a measured figure or a guarantee.

Availability. The production API at api.delegus.ai is serving. Sign up for a verify key: the sandbox is free with no card, and production starts with a 14-day free trial; the quickstart walks through your first signed decision. The sandbox on this site runs on a development environment, where nothing is a production identity.

What arrives with the request#

An agent acting for a company sends two extra headers with its HTTP request:

HeaderContentsSigned by
Delegus-GrantThe Grant: what this agent may do, for which company, until when. Spec §3.The company (the Principal), with a key in its DID document
Delegus-ProofA Proof bound to this Grant, this recipient, this exact action, and this moment. Spec §4.The agent

You do not parse either. You forward them, together with your own description of the action, to Delegus.

Install#

bash
npm install @delegus/sdk

The SDK bundles the CLI (npx delegus) and pulls in the pure engine @delegus/core. Both are Apache-2.0.

The one call#

This is the complete relying-party integration as spec §15 gives it:

ts
import { Delegus } from "@delegus/sdk";
const delegus = new Delegus({ apiKey: process.env.DELEGUS_API_KEY, publicBaseUrl: "https://seller.example" });

app.post("/orders", async (req, res) => {
  const d = await delegus.verify({
    grant: req.header("Delegus-Grant"),
    proof: req.header("Delegus-Proof"),
    action: { type: "commerce:purchase", resource: req.body.orderId, amount: req.body.amountMinor, currency: req.body.currency },
    request: { method: req.method, path: req.path },
  });
  if (d.decision !== "ALLOW") return res.status(403).json({ reason: d.reason });
  // proceed; persist d.receipt with the order
});

The Proof carries the method and URL the agent signed for (spec §4). /verify doesn't compare them with your request; the SDK does, before it calls Delegus, when you pass request, and throws ProofBindingError on a mismatch. publicBaseUrl is the origin the agent addressed; the SDK joins request.path to it. amount is an integer in minor units; the protocol never uses decimals.

What comes back#

decision is ALLOW or DENY. On DENY, reason is the first check that failed, in the fixed order the profile document lays down, for example GRANT_EXPIRED, AUTHORITY_REVOKED, PROOF_REPLAYED or AMOUNT_EXCEEDS_AUTHORITY. The full list and its order are in the delegus-base-v1 profile and spec §5.

v0.2 specifies that Delegus fails closed: an unknown, missing, ambiguous or unavailable input is a DENY, never an ALLOW. If Delegus itself cannot answer, the SDK surfaces SERVICE_UNAVAILABLE, and your service decides what to do with a request it could not verify.

Keep the receipt#

Every decision, ALLOW and DENY alike, comes with a signed Decision Receipt (spec §6). It pins hashes of the Grant, the request, the company's DID document as it stood, the revocation list as it stood, the profile that was applied, and the evaluation time. Store it with the order. You can also list and search your decisions later with GET /decisions (newest first, filters by time, decision, reason, Principal or Grant). Later, anyone holding the receipt can re-run the open checks against the preserved artifacts (spec §8) and reach the same result without calling Delegus.

Before you can call it#

If you are the company issuing Grants#

The other side of the protocol is the Principal: the company whose agent acts. v0.2 specifies that it proves control of its domain (spec §2.1), signs Grants with a key in its DID document (spec §3), and can revoke a Grant at any moment (spec §7). The SDK's delegus.org.create(), agent.create() and grant.create() cover that path (spec §15).

Try it against the sandbox#

This runs the real verify path in a sandbox, with a sandbox company and agent that exist only there. The receipts are real; the identities are not production ones (spec §2.0 keeps them apart). No key leaves the server: the sandbox verifies as its own relying party.

One order, four outcomes

Checking whether the sandbox is reachable…

Rate limited to 30 requests a minute per client. Each mint creates a real one-hour Grant with its own status entry. The order of outcomes in step 6 is why revocation is checked at P6, before the replay write at T5: a revoked Grant denies as revoked even when the Proof was already used.