When to use webhooks
Reach for webhooks when you need to:- Reconcile transactions in your own ledger as they clear.
- Notify a user when their card was used.
- Trigger downstream workflows on card lifecycle changes (e.g. mark a procurement as complete when a card closes).
- Detect declines and react (e.g. notify a fraud queue).
GET /api/v1/cards and GET /api/v1/cards/:id endpoints are simpler.
How it works
- You register an endpoint with the URL of your receiver and the list of events you care about.
- AgentCard returns a signing secret (
whsec_…). Store it in your receiver’s environment; if you lose it, reveal it again or rotate it (every retrieval is audited). - When an event occurs, we POST a JSON payload to your URL with two signature headers.
- Your server verifies the signature, processes the event, and returns
2xxquickly. - On any non-2xx response (or network error) we retry with backoff up to 5 attempts over ~1 hour 36 minutes.
Quickstart
Register an endpoint with the CLI:secret field. Copy it into your server’s environment as AGENTCARD_WEBHOOK_SECRET. If you lose it later, run agent-cards-admin webhooks reveal <id> (or GET /api/v1/webhook_endpoints/:id/secret).
Payload shape
Every webhook body is an event envelope:| Field | Type | Notes |
|---|---|---|
id | string | Stable event ID. Use this to dedupe. |
type | string | Event type. See Events. |
created | integer | Unix epoch seconds. |
livemode | boolean | false for events from sk_test_* keys (test mode). |
data | object | Event-specific payload. Shape depends on type. |
Next steps
Event catalog
Every event type with example payloads.
Verify signatures
Node, Python, and Go verification snippets.
Testing webhooks
Local development with ngrok and the CLI.
Best practices
Idempotency, fast 2xx, retries, and rotation.