Skip to main content
When you create a new conversation and authorize a client session you can set custom metadata and custom headers on the session webhook configuration (either on the agent itself or per-session via a config override).

1) Set metadata and headers via session_webhook config

Add them to your agent’s session_webhook config, or send a one-off override in the config field when calling POST /v1/agents/web/authorize_session (see REST API docs). Both fields must be plain JSON objects. For agent.webhook plugin requests, set custom_headers / custom_metadata in the plugin options to have them included on every agent webhook call.
Next.js app/api/authorize/route.ts

2) Read the metadata in your webhook handler

Every webhook invocation now includes the metadata you provided:

3) Inspect custom headers on receipt

Layercode prepends two headers to every webhook call: Content-Type: application/json and layercode-signature. Your custom headers are then appended.
webhook-handler.ts