Skip to main content
Version: 1.0 | Status: Final | Last updated: February 2026 (rev 3)The specification is frozen. Changes require a new version.

Abstract

Grantex defines an open protocol for delegated authorization of AI agents acting on behalf of human users. It specifies: cryptographic agent identity, a human-consent-based grant flow, a signed token format, a revocation model, an append-only audit trail schema, a policy engine for automated authorization decisions, enterprise identity federation, and anomaly detection for runtime behavioral monitoring.

1. Motivation

AI agents increasingly take autonomous actions — submitting forms, initiating payments, sending communications — on behalf of humans across third-party services. No interoperable standard exists for:
  1. Verifying that an agent is who it claims to be
  2. Confirming that a specific human authorized a specific agent to perform a specific action
  3. Revoking that authorization in real time
  4. Producing a tamper-proof record of what the agent did
Grantex fills this gap as an open, model-neutral, framework-agnostic protocol.

2. Definitions

TermDefinition
AgentAn AI-powered software process that takes autonomous actions on behalf of a Principal
PrincipalThe human user who authorizes an Agent to act on their behalf
DeveloperThe organization or individual who built and operates the Agent
ServiceAny API or platform that receives requests from an Agent
GrantA record of permission given by a Principal to an Agent for specific Scopes
Grant TokenA signed JWT representing a valid, non-revoked Grant
ScopeA named permission following the format resource:action[:constraint]
DIDDecentralized Identifier — the Agent’s cryptographic identity
PolicyA rule that auto-approves or auto-denies an authorization before the consent UI is shown
AnomalyA detected behavioral deviation from an agent’s established activity baseline

3. Agent Identity

3.1 DID Format

Every Agent registered with a Grantex-compatible Identity Service receives a DID:
did:grantex:<agent_id>
Where <agent_id> is a ULID (Universally Unique Lexicographically Sortable Identifier).

3.2 Identity Document

The DID resolves to an identity document containing:
{
  "@context": "https://grantex.dev/v1/identity",
  "id": "did:grantex:ag_01HXYZ123abcDEF456ghi",
  "developer": "org_yourcompany",
  "name": "travel-booker",
  "description": "Books flights and hotels on behalf of users",
  "declaredScopes": ["calendar:read", "payments:initiate:max_500"],
  "status": "active",
  "createdAt": "2026-02-01T00:00:00Z",
  "verificationMethod": [{
    "id": "did:grantex:ag_01HXYZ123abcDEF456ghi#key-1",
    "type": "JsonWebKey2020",
    "publicKeyJwk": { "..." : "..." }
  }]
}

3.3 Key Management

  • Identity Services MUST use RS256 (RSA + SHA-256) for signing
  • Private keys MUST never leave the Identity Service
  • Public keys MUST be published at /.well-known/jwks.json
  • Key rotation MUST be supported without changing the DID

4. Scopes

4.1 Format

resource:action[:constraint]

4.2 Standard Scope Registry

ScopeDescription
calendar:readRead calendar events
calendar:writeCreate, modify, and delete calendar events
email:readRead email messages
email:sendSend emails on the Principal’s behalf
email:deleteDelete email messages
files:readRead files and documents
files:writeCreate and modify files
payments:readView payment history and balances
payments:initiateInitiate payments of any amount
payments:initiate:max_NInitiate payments up to N in the account’s base currency
profile:readRead profile and identity information
contacts:readRead address book and contacts

4.3 Custom Scopes

Services MAY define custom scopes using reverse-domain notation:
com.stripe.charges:create:max_5000
io.github.issues:create

4.4 Scope Governance

Grantex maintains the canonical scope registry in §4.2 as normative. Implementations MUST support all standard scopes. Custom scopes MUST use reverse-domain notation.

4.5 Scope Display

Identity Services MUST maintain a human-readable description for each scope. Consent UIs MUST display human-readable descriptions, never raw scope strings.

5. Grant Flow

5.1 Overview

Developer App          Grantex                    Principal
     │                    │                           │
     │  POST /authorize    │                           │
     │  {agentId, scopes,  │                           │
     │   redirectUri}      │                           │
     │────────────────────►│                           │
     │                     │                           │
     │◄────────────────────│                           │
     │  {consentUrl}        │                           │
     │                     │                           │
     │  redirect user ─────────────────────────────►  │
     │                     │  consent UI displayed     │
     │                     │◄──────────────────────────│
     │                     │  Principal approves       │
     │                     │                           │
     │◄────────────────────────────────────────────────│
     │  redirectUri?code=AUTH_CODE                     │
     │                     │                           │
     │  POST /token        │                           │
     │  {code}             │                           │
     │────────────────────►│                           │
     │◄────────────────────│                           │
     │  {grantToken,        │                           │
     │   refreshToken}      │                           │

5.2 Authorization Request

POST /v1/authorize
Authorization: Bearer <api_key>
Content-Type: application/json

{
  "agentId": "ag_01HXYZ123abc",
  "principalId": "user_abc123",
  "scopes": ["calendar:read", "payments:initiate:max_500"],
  "expiresIn": "24h",
  "redirectUri": "https://yourapp.com/auth/callback",
  "state": "<csrf_token>",
  "audience": "https://api.targetservice.com"
}

5.3 Token Exchange

POST /v1/token
Authorization: Bearer <api_key>
Content-Type: application/json

{
  "code": "AUTH_CODE",
  "agentId": "ag_01HXYZ123abc"
}

6. Grant Token Format

6.1 Header

{
  "alg": "RS256",
  "typ": "JWT",
  "kid": "grantex-2026-02"
}

6.2 Payload

{
  "iss": "https://grantex.dev",
  "sub": "user_abc123",
  "aud": "https://api.targetservice.com",
  "agt": "did:grantex:ag_01HXYZ123abc",
  "dev": "org_yourcompany",
  "grnt": "grnt_01HXYZ...",
  "scp": ["calendar:read", "payments:initiate:max_500"],
  "iat": 1709000000,
  "exp": 1709086400,
  "jti": "tok_01HXYZ987xyz"
}

6.3 Custom Claims

ClaimTypeDescription
agtstringAgent DID
devstringDeveloper org ID
grntstringGrant ID (for revocation lookup)
scpstring[]Granted scopes

6.4 Validation Rules

Services receiving a Grant Token MUST verify:
  1. Signature using the JWKS at iss/.well-known/jwks.json
  2. exp has not passed
  3. aud matches the service’s identifier (if set)
  4. scp contains the required scopes for the requested operation
  5. (Online verification only) Token has not been revoked

7. Revocation

7.1 Revoke a Grant

DELETE /v1/grants/{grantId}
Effect: all active tokens under this Grant are immediately invalidated.

7.2 Revoke a Specific Token

POST /v1/tokens/revoke
Content-Type: application/json

{ "jti": "tok_01HXYZ987xyz" }

7.3 Online Revocation Check

POST /v1/tokens/verify
Content-Type: application/json

{ "token": "eyJhbGciOiJSUzI1NiJ9..." }

7.4 Token Lifetime Guidance

Use CaseRecommended TTL
High-stakes actions (payments, send)1 hour
Standard agent tasks8 hours
Long-running background agents24 hours (max)
Implementations caching revocation state MUST NOT cache for longer than 5 minutes.

8. Audit Trail

8.1 Log Entry Schema

{
  "entryId": "alog_01HXYZ...",
  "agentId": "did:grantex:ag_01HXYZ123abc",
  "grantId": "grnt_01HXYZ...",
  "principalId": "user_abc123",
  "developerId": "org_yourcompany",
  "action": "payment.initiated",
  "status": "success",
  "metadata": { "amount": 420, "currency": "USD" },
  "timestamp": "2026-02-01T12:34:56.789Z",
  "hash": "sha256:abc123...",
  "prevHash": "sha256:xyz789..."
}

8.2 Hash Chain

Each entry’s hash is SHA-256(canonical_json(entry) + prevHash). This makes any retrospective tampering detectable.

9. Multi-Agent Authorization

Sub-agent tokens carry delegation claims:
{
  "sub": "user_abc123",
  "agt": "did:grantex:ag_B_456",
  "parentAgt": "did:grantex:ag_A_123",
  "parentGrnt": "grnt_parentXYZ",
  "scp": ["email:read"],
  "delegationDepth": 1
}
Rules:
  • Sub-agent scopes MUST be a subset of the parent’s scopes
  • delegationDepth is incremented at each hop
  • Hard cap of 10 delegation hops
  • Revoking a root grant cascades to all descendants atomically

10. Self-Hosting Endpoints

Core Endpoints (Required)

EndpointDescription
POST /v1/agentsRegister agent
POST /v1/authorizeInitiate authorization
POST /v1/tokenExchange code for token
POST /v1/tokens/verifyVerify token online
POST /v1/tokens/revokeRevoke token
GET /v1/grantsList grants
DELETE /v1/grants/:idRevoke grant (cascades)
POST /v1/grants/delegateDelegate to sub-agent
POST /v1/audit/logWrite audit entry
GET /v1/audit/entriesQuery audit log
GET /.well-known/jwks.jsonPublic keys
GET /healthHealth check

Optional Extensions

Policy Engine, Webhooks, SCIM 2.0, SSO (OIDC), Anomaly Detection, Compliance, and Billing endpoints are optional extensions. See the full specification for details.

11. Policy Engine

Evaluates rules against each authorization request before consent UI. Deny rules are evaluated first — the first matching auto_deny wins. Then allow rules. If no rule matches, consent UI is shown.

12. Enterprise Identity (SCIM & SSO)

SCIM 2.0 user provisioning from enterprise IdPs (Okta, Azure AD). SSO via OIDC with state and nonce validation.

13. Anomaly Detection

Advisory-only runtime monitoring. Anomaly types: unusual_scope_access, high_frequency, off_hours_activity, new_principal, cascade_delegation.

14. Security Considerations

  • Tokens MUST be signed with RS256. HS256 and alg: none MUST be rejected.
  • Token replay MUST be detectable via jti tracking.
  • Consent UIs MUST validate state to prevent CSRF.
  • Redirect URIs MUST be pre-registered and exactly matched.
  • Audit logs MUST be append-only (no update or delete endpoints).
  • SCIM endpoints MUST use dedicated bearer tokens, separate from API keys.
  • SSO callbacks MUST validate state and nonce.
  • Policy engine MUST evaluate deny before allow.
  • Anomaly detection MUST NOT block token issuance.

The full specification is maintained at github.com/mishrasanjeev/grantex/blob/main/SPEC.md and is licensed under Apache 2.0.