Skip to main content

Dispatch auth

What it is

Dispatch auth is the SDK module that proves an inbound A2A dispatch really came from the Svantic mesh. Every capability invocation Svantic routes to an agent can carry a svantic_auth envelope inside the DataPart. That envelope is either an HS256 JWT issued by the mesh (scheme: 'svantic_jwt') or a shared-secret comparison (scheme: 'shared_secret'). verify_dispatch_auth parses the envelope, checks the signature / secret, enforces audience binding and clock skew, and hands you a typed DispatchAuthContext you can log or pass into authorization decisions. Two key points:
  • Hosted-mode agents should enable it. Without dispatch auth, anyone who learns the agent’s public URL can invoke capabilities.
  • Connected-mode agents get it for free on the transport. The outbound WebSocket is already authenticated, so dispatch auth there is accepted but optional.
The SDK calls this for you automatically when AgentConfig.dispatch_auth is set. You only import the low-level helpers when you’re extracting auth from raw payloads yourself — e.g. a custom transport, a test harness, or a middleware before the SDK touches the request.

When to use it directly

  • You’re hosting an agent outside Agent.start() / attach() (custom transport).
  • You want an authorization check inside a capability handler based on the verified subject.
  • You’re writing a compatibility layer that consumes A2A dispatches and want the same safety guarantees.

Functional usage

See the Securing dispatches guide for setup, key rotation, and the hands-off path via AgentConfig.dispatch_auth.

verify_dispatch_auth(data, config)

Verify a dispatch. data is the DataPart payload as received by the SDK (the object your capability handler sees, before argument extraction). Supported schemes:
  • svantic_jwt — HS256 JWT signed with the agent’s signing_secret. The verifier checks iss = 'svantic-mesh', aud = agent:<instance_id>, and exp. Claims (tenant_id, agent_type, instance_id, dispatch_id, jti) are surfaced on the returned context.
  • shared_secret — opaque token compared in constant time against a locally configured secret. Supports per-credentials-ref secrets via shared_secrets map.

VerifierConfig

DispatchAuthContext

Returned by a successful verification. Only scheme and expires_at are guaranteed; JWT claims are populated for svantic_jwt only.

DispatchAuthVerifyError

Thrown for every failure. err.code is one of:

Constants

MESH_DISPATCH_JWT_ISSUER

Issuer value the mesh always sets on svantic_jwt dispatch tokens.

Example

See also