Skip to Content
AgentShield
API Reference

Authentication

How to authenticate API calls. Ed25519 signature headers for the gateway, bearer sessions for the control plane.

Agent signatures

Gateway runtime routes authenticate each request with four headers:

HeaderFormat
X-AgentShield-Agent-IdAgent UUID
X-AgentShield-TimestampUnix seconds, within 60 s of the gateway clock
X-AgentShield-Nonce^[A-Za-z0-9_-]{16,128}$, never reused within 130 s
X-AgentShield-SignatureUnpadded base64url Ed25519 signature of timestamp.nonce.hex(sha256(body))
import secrets, time, urllib.request
from agentshield_sdk import sign
from agentshield_sdk.jsonenc import encode_json

body = encode_json({"decision_id": DECISION_ID, "idempotency_key": IDEMPOTENCY_KEY})  # serialize once
timestamp, nonce = int(time.time()), secrets.token_urlsafe(16)
request = urllib.request.Request(
    "http://127.0.0.1:8081/api/v1/runtime/execute",
    data=body, method="POST",
    headers={
        "Content-Type": "application/json",
        "X-AgentShield-Agent-Id": AGENT_ID,
        "X-AgentShield-Timestamp": str(timestamp),
        "X-AgentShield-Nonce": nonce,
        "X-AgentShield-Signature": sign(seed, timestamp, nonce, body),
    },
)

In practice, use Client from the SDK, which does this for both authorize and execute. Full specification: Request signing.

FailureResponse
Authorization header present401 unauthenticated "human sessions are not accepted by the gateway"
Missing signature headers401 unauthenticated "agent signature headers are required"
Unknown agent, bad signature, bad nonce shape, timestamp outside 60 s401 unauthenticated "authentication failed"
Nonce reused401 unauthenticated "nonce already used"

Bearer sessions

Control plane routes accept Authorization: Bearer <token>, where the token is 20–200 characters of base64url alphabet. Create one with email and password:

POST/api/v1/sessions

Create a human session

No authenticationoperationId: createSession

Checks the email and password of a bootstrapped user. There is no public registration route. The token is returned once and only its SHA-256 is stored. Agent signature headers are rejected.

Request body · required

  • emailstring (email)required
  • passwordstringrequired

    min length 12 · max length 128

Responses

  • 201Session

    Session token

  • 401ErrorBody

    Error

  • 403ErrorBody

    Error

curl -X POST "http://127.0.0.1:8080/api/v1/sessions" \
  -H "Content-Type: application/json" \
  --data-binary @body.json

Examples are generated from the schema. Values are placeholders.

PropertyValue
Lifetime12 hours
Server storageSHA-256 of the token only
RevocationDELETE /api/v1/sessions/current; password change revokes other sessions; disabling a member revokes all
Temporary password sessionsOnly GET/DELETE /api/v1/sessions/current and POST /api/v1/sessions/current/password; everything else is 403 password_change_required

Inspect and end a session

GET/api/v1/sessions/current

The caller's user, organization, role, and session expiry

Bearer sessionoperationId: getCurrentSession

Responses

  • 200CurrentSession

    Current session

  • 401ErrorBody

    Error

curl -X GET "http://127.0.0.1:8080/api/v1/sessions/current" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN"

Examples are generated from the schema. Values are placeholders.

DELETE/api/v1/sessions/current

End the session that made this request

Bearer sessionoperationId: revokeCurrentSession

Responses

  • 204no body

    Session ended. The token is refused from now on.

curl -X DELETE "http://127.0.0.1:8080/api/v1/sessions/current" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN"

Examples are generated from the schema. Values are placeholders.

POST/api/v1/sessions/current/password

Change the caller's password and end their other sessions

Bearer sessionoperationId: changeOwnPassword

Request body · required

  • current_passwordstringrequired
  • new_passwordstringrequired

    min length 12 · max length 128

Responses

  • 204no body

    Password changed. The calling session stays valid.

  • 403ErrorBody

    The current password is wrong

curl -X POST "http://127.0.0.1:8080/api/v1/sessions/current/password" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @body.json

Examples are generated from the schema. Values are placeholders.

Cross-plane refusal

Sent toWithResult
Gateway runtime routeAuthorization header401
Control plane /api/ routeX-AgentShield-Signature or X-AgentShield-Agent-Id401 "agent signatures are not accepted on the control plane"

Roles

After authentication, each control plane route checks the member's role. A role that is not allowed receives 403 forbidden ("insufficient role"). The role matrix is in Authentication.

Was this page helpful?

On this page