Connect your agent to external services via webhooks.
Agent webhook tools vs task completion webhooks
inference shell uses webhooks in two different places. They are not interchangeable.
| Agent webhook tool (this page) | Task completion webhook | |
|---|---|---|
| Purpose | Let an agent call your HTTP endpoint as a tool during a chat | Notify your server when an app or flow task finishes |
| Configured on | Agent → Tools → Webhook Tool | webhook field on POST /run (REST or SDK) |
| When it fires | Each time the agent invokes the tool | Once per task, on terminal status (completed, failed, cancelled) |
| Your server | Receives tool args; may POST results back via callback_url | Receives {event, timestamp, data} with the task result (id, status, output, …) in data |
Use webhook tools when the agent should reach your API mid-conversation (send email, create ticket, run a script).
Use task webhooks for fire-and-forget app runs — submit work, close the client, get a POST when done.
→ Tasks API — Webhooks
→ Running Apps (SDK) — Webhooks
→ Tasks concept — Webhooks (completion notifications)
→ Webhook Tools (SDK) — define webhook tools in code
What is a Webhook Tool?
A webhook tool lets your agent call external HTTP endpoints. When the agent invokes the tool, your service receives the arguments and can return results asynchronously.
Adding a Webhook Tool
- Go to Tools tab
- Click Add Tool → Webhook Tool
- Fill in:
- Name: Tool name (e.g.,
send-email) - Description: What the agent sees
- URL: Your webhook endpoint
- Secret: Optional authentication header
- Input Schema: Optional JSON schema for parameters
- Name: Tool name (e.g.,
What Your Webhook Receives
When the agent calls the hook, your endpoint receives a POST with:
1{2 "tool_invocation_id": "abc123",3 "hook_name": "send-email",4 "chat_id": "chat_xyz",5 "agent_id": "agent_123",6 "agent_version_id": "v1",7 "callback_url": "/api/tools/abc123",8 "callback_method": "POST",9 "callback_token": "q7Xk...",10 "timestamp": "2024-01-15T10:30:00Z",11 "arguments": {12 "to": "user@example.com",13 "subject": "Hello",14 "body": "Message content"15 }16}Headers include:
Content-Type: application/jsonX-Hook-Secret: your-secret(if configured)
Responding Immediately
Return a success acknowledgment:
1{2 "success": true,3 "message": "Processing"4}The call stays in_progress until you POST the result to the callback URL.
Completing the Tool
When done, POST to the callback URL with the call's callback_token in the X-Hook-Callback-Token header:
1curl -X POST https://api.inference.sh/tools/abc123 \2 -H "Authorization: Bearer $INFERENCE_API_KEY" \3 -H "X-Hook-Callback-Token: $CALLBACK_TOKEN" \4 -H "Content-Type: application/json" \5 -d '{"result": "Email sent successfully to user@example.com"}'The token is what tells your hook's answer from one someone else posts. Without it, the result is accepted only from an API key or session of the agent's own team; anyone else who can write in the chat (a person running your published, shared or embedded agent) is refused with 403. A wrong token is refused from anyone. Each call has its own token.
The agent receives this and continues.
Input Schema
Define what parameters the agent can pass:
1{2 "type": "object",3 "properties": {4 "to": {5 "type": "string",6 "description": "Recipient email address"7 },8 "subject": {9 "type": "string", 10 "description": "Email subject line"11 },12 "body": {13 "type": "string",14 "description": "Email body content"15 }16 },17 "required": ["to", "subject", "body"]18}If not provided, the agent sends a generic data object.
Use Cases
| Hook | Purpose |
|---|---|
send-email | Send emails via your SMTP |
create-ticket | Create support tickets |
notify-slack | Post to Slack channels |
run-script | Execute custom scripts |
query-database | Run database queries |
Security
- Use the secret header to verify requests
- Send the call's
callback_tokenback inX-Hook-Callback-Token, and keep it out of logs - Validate the callback URL matches expected patterns
- Sanitize arguments before use
- Set appropriate timeouts