Webhook Triggers API

Webhook triggers allow you to invoke your lil’bots from any external platform through a simple API endpoint. This documentation provides a complete reference for the webhook triggers API, including authentication, request formats, and response structures.

Authentication

All endpoints in the Webhook Triggers API require authentication via an API key. This key is specific to each trigger and is provided when you create a trigger in the lil’bots platform.

The API key should be passed in the X-Key header with each request:

X-Key: your-trigger-key

Security Note

Protect your trigger keys carefully. Anyone with access to your trigger URL and key can invoke your bot, potentially accessing any data your bot has access to and using up your credits.

How Webhook Triggers Work

  1. Create a Trigger: Set up a webhook trigger in your bot’s settings
  2. Invoke the Bot: Make a POST request to the trigger endpoint with your inputs
  3. Processing: The bot runs asynchronously in the background
  4. Check Results: Optionally wait for completion and retrieve outputs using the sync endpoint

When using the webhook API, bot inputs are passed as a JSON body in your request. These values will be available to your bot’s main function.

Rate Limits

To ensure platform stability, the webhook API has the following rate limits:

  • Maximum of 10 requests per second per trigger
  • Maximum of 100 requests per minute per account

Exceeding these limits will result in a 429 Too Many Requests response.

Example Usage

Below is a complete example of triggering a bot and waiting for its results using curl:

# Step 1: Trigger the bot
RESPONSE=$(curl -s https://www.lilbots.io/api/webhooks/YOUR_TRIGGER_ID/trigger \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-Key: YOUR_TRIGGER_KEY" \
  -d '{"query":"What is the weather today?"}')

# Step 2: Extract the invocation ID
INVOCATION_ID=$(echo $RESPONSE | jq -r .invocation.id)

# Step 3: Wait for results
curl -s https://www.lilbots.io/api/webhooks/YOUR_TRIGGER_ID/trigger/invocation/$INVOCATION_ID/sync \
  -H "X-Key: YOUR_TRIGGER_KEY"