Response Webhooks are currently in beta. If you’d like to help us test and
improve the feature, please reach out to us at contact@humanlayer.dev
Overview
Using response webhooks generally involves a few steps:- Choose a way you’ll uniquely identify the operation
- Create an operation
- Store your agent’s workflow state
- Create a webhook endpoint
- Configure webhook in HumanLayer
- Handle webhook responses
1. Choose an Operation Identifier
First, decide how you’ll uniquely identify each operation in your system. You have several options:- Use a server-generated call_id
- Use an external identifier (like OpenAI’s
tool_call_id
) - Create your own custom identifier system
2. Create the Operation
Use the appropriate creation endpoint based on your needs:3. Store Operation State
Store your agent’s workflow state so you can resume it when the webhook arrives. Common approaches include:Dictionary Storage
Database Storage
Using HumanLayer to store your state
When making function calls or human contacts, you can include a state object that will be preserved and returned in webhooks. This allows your application to be stateless while maintaining context across the request lifecycle. Example:4. Create Webhook Endpoint
Create an endpoint in your application to receive webhook notifications: Set up an endpoint on your server that will:- Receive POST requests from HumanLayer
- Validate webhook signatures
- Process the incoming webhook data
call_id
you set during creation, as well as the resolved response in status
, and any state you set in the spec
.
5. Configure Webhook in Dashboard
In the HumanLayer Dashboard:- Navigate to
Response Webhooks
- Create a new endpoint with your URL
- Subscribe to relevant events:
function_call.completed
human_contact.completed
6. Approve the request
Approve the request using any of the supported channels in HumanLayer, e.g. the web app, slack, email, etc.7. Handle the payload
The approval should trigger a webhook to your endpoint, which will include the fully completed FunctionCall or HumanContact object.Complete Example
For a complete working example including ngrok setup for local development, see our FastAPI Webhooks Example. The example demonstrates:- Setting up a FastAPI application with webhook handling
- Managing operation state
- Processing approvals and rejections
- Local development with ngrok