Canary Tokens
Embed invisible tripwires inside your agent's context. When an attacker reads or exfiltrates your agent's system prompt or tool outputs, Trappr detects it instantly — before any damage is done.
What are canary tokens?
A canary token is a unique, trackable value embedded silently inside data that should never be read by external parties. When that value appears in an outgoing request, a log, or a response — you know something accessed it that shouldn't have.
Trappr generates canary tokens scoped to your agent and embeds them transparently. You don't change your agent logic. Trappr watches the traffic and alerts you the moment a token is seen outside its intended boundary.
How it works
When your agent sends a request through the Trappr AI Gateway, canary tokens are embedded at the right moment and watched on every subsequent call.
Point your LLM calls at the Trappr endpoint. The gateway is fully compatible with the OpenAI SDK and other provider SDKs — no code changes needed beyond the base URL.
On each qualifying request, Trappr silently adds a uniquely generated token — invisible to your agent and transparent to the LLM model.
Every response, tool call, and downstream API call is checked. If a canary value appears where it shouldn't, it's flagged immediately.
Alerts fire via Slack, email, or webhook with the exact context: which token was triggered, in which execution, at what timestamp.
Prerequisites
- A Trappr account with at least one API key
- An app created in the Trappr dashboard
- Your agent routed through the AI Gateway
Setup
Step 1 — Create a canary token in the dashboard
Go to Dashboard → Canary Tokens → New token. Give it a name (e.g. system-prompt-guard) and select the app it belongs to. The dashboard generates a unique token string.
Step 2 — Route LLM calls through the Gateway
Update your agent to use the Trappr Gateway endpoint. The gateway is API-compatible with OpenAI, Anthropic, and most providers.
import openai
client = openai.OpenAI(
base_url="https://gateway.trappr.net/v1",
api_key="<your-trappr-api-key>",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Summarize this document."},
],
)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://gateway.trappr.net/v1",
apiKey: "<your-trappr-api-key>",
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Summarize this document." },
],
});curl -X POST https://gateway.trappr.net/v1/chat/completions \
-H "Authorization: Bearer <your-trappr-api-key>" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Summarize this document."}
]
}'Step 3 — Verify the token is active
After routing at least one request through the gateway, go to Dashboard → Canary Tokens. You should see your token listed as Active with a last-seen timestamp.
Step 4 — Configure alerts
Under Settings → Alerts, connect a Slack channel, email address, or webhook URL. When a canary is triggered, you'll receive a notification within seconds. See the Slack alerts guide for setup.
What triggers a canary alert?
A canary alert fires when a monitored value is detected in any of the following:
| Trigger location | Example scenario |
|---|---|
| LLM response content | Model echoes or references the token in its reply |
| Tool call arguments | Agent passes the token value to a downstream tool or API |
| Outgoing HTTP calls | Token appears in a URL, header, or body sent to an external service |
| Workflow node outputs | Token flows through an n8n or Make workflow node into an external step |
Viewing triggered incidents
All triggered canary events are logged under Dashboard → Incidents. Each incident shows the full execution trace, the message where the token appeared, and a timestamp. You can acknowledge or investigate incidents directly from the dashboard.