Documentation Index
Fetch the complete documentation index at: https://mintlify.com/21st-dev/1code/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Webhooks allow you to receive real-time notifications when agent tasks complete. Instead of polling the API, 1Code will send an HTTP POST request to your specified webhook URL.Setup
Provide awebhook_url when creating a task:
Webhook Events
1Code sends webhook notifications for the following events:task.completed- Task finished successfullytask.failed- Task failed with an errortask.pr_created- Pull request createdtask.pr_merged- Pull request merged (if auto-merge enabled)
Webhook Payload
When an event occurs, 1Code sends a POST request to your webhook URL:Payload Fields
Event type:
task.completed, task.failed, task.pr_created, task.pr_mergedUnique task identifier
Final task status:
completed, failedRepository URL
Pull request URL (if created)
Pull request number (if created)
Branch name created by the agent
Array of commit objects
Error message (if task failed)
ISO 8601 timestamp when task completed
ISO 8601 timestamp when task was created
Webhook Endpoint Implementation
Security
Webhook Signatures
1Code signs webhook requests with a signature in theX-1Code-Signature header. Verify this signature to ensure the webhook is from 1Code:
Webhook Secret
Your webhook secret is available in Settings > API Keys > Webhook Secret. Use it to verify webhook signatures.Retry Policy
If your webhook endpoint returns a non-2xx status code, 1Code will retry the webhook:- Retry schedule: 1min, 5min, 30min, 2h, 12h
- Max retries: 5 attempts
- Timeout: 10 seconds per request
Testing Webhooks
Local Testing
Use a tool like ngrok to expose your local server:Webhook Logs
View webhook delivery logs in your dashboard at Settings > Webhooks to debug failed deliveries.Best Practices
Respond quickly
Respond quickly
Return a 200 response immediately after receiving the webhook. Perform heavy processing asynchronously.
Handle duplicates
Handle duplicates
Webhooks may be delivered more than once. Use the
task_id to deduplicate events.Verify signatures
Verify signatures
Always verify webhook signatures to prevent spoofed requests.
Use HTTPS
Use HTTPS
Webhook URLs must use HTTPS in production to ensure secure delivery.