Documentation

Agent Attribution quickstart

Enroll a principal once, then recognize their authorized agent across participating websites without repeating identity verification.

On this page

Install the SDK and configure your site

Use SDK version 0.9.0 or later for network proofs. Create a Test API key with attribution:read in your site's workspace. Set CHITMARK_API_KEY on the server and set CHITMARK_SITE to your exact public HTTPS origin, for example https://app.example.com without a trailing slash. The SDK uses https://api.chitmark.com by default.

Give the visiting agent your workspace ID, recipient key record ID, origin, environment, purpose and data mode. Keep the bearer credential on your server. The agent sends a fresh Chitmark-Agent-Proof header for those values. The defaults are identity_attribution and hashed.

npm install @chitmark/sdk

Resolve an incoming agent request

The handlers below use a configured origin so a client-supplied Host header cannot select the site. The SDK reads the proof from the inbound request. Save the handler as attribution.mjs or attribution.py. Run node attribution.mjs or python attribution.py, then send a request to http://127.0.0.1:3000/agent-task without a proof to try the unknown branch. To try recognition, run the two-website example.

Use the recognized status and any disclosed fields on the server. Enable CHITMARK_FIXTURE_LOG=1 only for fixture data to see the two Node console values. Keep real proof headers and email out of logs.

import { createServer } from "node:http";
import { Chitmark, ChitmarkError } from "@chitmark/sdk";

const site = process.env.CHITMARK_SITE;
const apiKey = process.env.CHITMARK_API_KEY;
if (!site || !apiKey) throw new Error("Configure CHITMARK_SITE and CHITMARK_API_KEY");
const piiMode = process.env.CHITMARK_ATTRIBUTION_PII_MODE === "raw" ? "raw" : "hashed";
const chitmark = new Chitmark({ apiKey, piiMode });

createServer(async (incoming, response) => {
  if (incoming.url !== "/agent-task") {
    response.writeHead(404).end();
    return;
  }
  response.setHeader("Cache-Control", "no-store");
  try {
    const result = await chitmark.attribution.resolve({
      site,
      request: {
        url: incoming.url ?? "/",
        headers: incoming.headers as Record<string, string>,
      },
    });

    if (process.env.CHITMARK_FIXTURE_LOG === "1") {
      console.log(result.identity.recognized);
      console.log(result.principal.email);
    }

    if (!result.identity.recognized) {
      response.end("Unknown visitor");
      return;
    }
    if (result.principal.status === "previously_verified") {
      const email = result.principal.email;
      response.end(email === null
        ? "Recognized agent; verified principal; email unavailable"
        : "Recognized agent; verified principal; email authorized");
      return;
    }
    response.end("Recognized agent; principal unavailable");
  } catch (error) {
    if (!(error instanceof ChitmarkError)) throw error;
    response.writeHead(503).end("Identity evidence unavailable");
  }
}).listen(3000, "127.0.0.1");

Read the result

ResultMeaning
identity.match: noneNo usable identity evidence. Continue as an unknown visitor.
identity.match: verified_agent_accountFresh proof from a previously enrolled agent. Use the site's own identity.subject_id for continuity.
principal.status: withheldThe agent is recognized, but the recipient has no disclosed principal claims.
principal.status: previously_verifiedThe enrolled account association was disclosed. Document verification is a separate, nullable field.
Resolve throwsThe lookup failed. Treat identity as unavailable and apply your application's fallback.

An optional opaque session can return existing_session for continuity on one site. A signed site link can return verified_identity_link. Use Attribution alongside your own access checks.

Network recognition and principal disclosure are independent. Production (live) enables both: a recipient grant for the recipient and purpose discloses principal verification. Email additionally requires consent to retain the verified address and share it with the recipient, an eligible plan, a key with attribution:email, and matching raw mode on both the recipient and proof. Set CHITMARK_ATTRIBUTION_PII_MODE=raw on the recipient server and have the agent sign for that mode. When disclosure is not permitted, principal.email is null.

The three possible outcomes, taken from the verified two-website test:

Alice visits two independent websites

Alice signs in through OpenID Connect once and binds a separate agent key. The agent signs a fresh proof for Website A, then a new proof for Website B. Each site resolves with its own credential and gets its own site-scoped subject. Alice does not need to sign in again.

The responses below came from the local Test demo, which enables disclosure for its test configuration. Production (live) enables the same network recognition and grant-based disclosure under the conditions above: a recipient with an eligible plan, an attribution:email key, a current grant with email consent, and proofs signed for raw mode receives the verified email; otherwise principal.email is null. Without evidence, the visitor is unknown. Website B recognizes the agent before Alice grants it access to her account details, then receives her verified email after the grant. The subject stays the same. When Alice revokes Website A's grant, A loses access to the account details and B keeps its separate grant. Recognition and principal verification provide evidence for your app's own authorization checks.

{
  "id": "b279f88d-e830-4176-a0db-d0eeeee47d30",
  "agent": {
    "detected": false,
    "provider": null,
    "operator_verified": false
  },
  "identity": {
    "recognized": false,
    "subject_id": null,
    "scope": null,
    "match": "none"
  },
  "principal": {
    "status": "unknown",
    "email": null,
    "email_verified": null,
    "current_delegation_verified": null,
    "document_verified": null
  }
}

Next steps

Recognize one agent at two websites · Try the interactive demo · Resolve API reference · Advanced proof protocol