REST API

Use AgentShield Without an SDK

AgentShield has a REST API that works with any tool that can send an HTTP POST request — Python, JavaScript, cURL, n8n, Make, Zapier, or any other language or no-code platform. The Python SDK is optional.

Endpoint

POST https://api.agentshield.one/v1/track

Authentication

All requests require a Bearer token. Get your API key from Settings → API Keys.

Authorization: Bearer ags_live_xxxxx

Request Body

Required fields

FieldTypeDescription
agentstringUnique name for your agent or workflow. Used for grouping in the dashboard.

Optional fields

FieldTypeDescription
modelstringModel name (e.g. gpt-4o, claude-opus-4-5). Used for cost calculation.
providerstringProvider name (openai, anthropic, google, cohere). Auto-detected from model if omitted.
input_tokensintegerNumber of prompt/input tokens. Used to calculate cost.
output_tokensintegerNumber of completion/output tokens. Used to calculate cost.
cost_usdfloatOverride the calculated cost. Use if you already know the exact cost.
session_idstringGroup multiple calls into one session for Replay. Generate a UUID per user conversation.
latency_msintegerResponse latency in milliseconds. Used for latency tracking and anomaly detection.
metadataobjectAny key-value pairs you want to attach. Visible in session detail.

Response

{
  "tracked": true,
  "cost_usd": 0.0185,
  "session_id": "ses_01jbk...",
  "event_id": "evt_01jbk..."
}

Examples

cURL

curl -X POST https://api.agentshield.one/v1/track \
  -H "Authorization: Bearer ags_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "my-agent",
    "model": "gpt-4o",
    "input_tokens": 1250,
    "output_tokens": 340,
    "session_id": "ses_user_abc123"
  }'

JavaScript / Node.js

await fetch("https://api.agentshield.one/v1/track", {
  method: "POST",
  headers: {
    "Authorization": "Bearer ags_live_xxxxx",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    agent: "my-agent",
    model: "gpt-4o",
    input_tokens: completion.usage.prompt_tokens,
    output_tokens: completion.usage.completion_tokens,
    session_id: sessionId
  })
})

n8n HTTP Request Node

Method: POST
URL: https://api.agentshield.one/v1/track

Headers:
  Authorization: Bearer ags_live_xxxxx
  Content-Type: application/json

Body (JSON):
{
  "agent": "my-n8n-workflow",
  "model": "gpt-4o",
  "input_tokens": {{ $json.usage.prompt_tokens }},
  "output_tokens": {{ $json.usage.completion_tokens }}
}

Make (Integromat) HTTP Module

Module: HTTP > Make a request
URL: https://api.agentshield.one/v1/track
Method: POST
Body type: Raw / JSON

{
  "agent": "my-make-scenario",
  "model": "gpt-4o",
  "input_tokens": {{ai_module.usage.prompt_tokens}},
  "output_tokens": {{ai_module.usage.completion_tokens}}
}

Zapier Webhooks

Action: Webhooks by Zapier > POST
URL: https://api.agentshield.one/v1/track

Headers:
  Authorization: Bearer ags_live_xxxxx

Data:
  agent: my-zapier-zap
  model: gpt-4o
  input_tokens: (from previous AI step)
  output_tokens: (from previous AI step)

Error Codes

StatusErrorFix
401UnauthorizedCheck your API key. Must be a valid ags_live_ key.
422Validation erroragent field is required. Check the request body.
429Rate limitedYou are sending too many requests. Back off and retry.
402Budget cap exceededThis agent has hit its budget cap. Increase or reset it in the dashboard.
500Server errorRetry with exponential backoff. Contact support if it persists.

Need the Python SDK instead?

The SDK wraps this API with automatic session management and framework integrations. View SDK docs →