Skip to main content
AgentsNew

Webhook Triggers

Every agent gets a unique webhook URL that external services can POST to. Connect Zapier, Make, GitHub Actions, cron jobs, or any HTTP client to trigger your agents without writing integration code.

One URL per agent, zero integration code

Each active agent has a trigger URL: POST /agents/trigger/<agentId>. Send a JSON body with your input and get back the agent's response. Authentication uses the same API key you already have.

Trigger URL Format

The trigger URL for any agent follows this pattern:

bash
POST https://us-central1-agentlify-prod.cloudfunctions.net/agentTrigger/agents/trigger/{agentId}

You can find this URL in the Settings tab of your agent editor, under the Webhook Trigger panel.

Authentication

Authenticate with your Agentlify API key in the Authorization header:

bash
Authorization: Bearer mp_YOUR_API_KEY

Request Body

The trigger accepts two input formats. Use whichever is simpler for your integration.

Simple input (recommended)

json
{
  "input": "Summarize today's top Hacker News stories"
}

Full messages format

json
{
  "messages": [
    { "role": "system", "content": "You are a helpful news summarizer." },
    { "role": "user", "content": "Summarize today's top stories" }
  ]
}

Response

Triggers always return a simple, flat JSON response:

json
{
  "id": "exec_a1b2c3d4-...",
  "output": "Here are today's top stories...",
  "status": "completed",
  "usage": {
    "tokens": 1523,
    "cost": 0.0034,
    "latency_ms": 2340,
    "steps": 2
  }
}

Optional Headers

HeaderDescription
X-Trigger-SourceLabel the source (e.g. "zapier", "github-actions", "cron"). Appears in trigger logs.
Content-TypeMust be application/json

Examples

cURL

bash
curl -X POST "https://us-central1-agentlify-prod.cloudfunctions.net/agentTrigger/agents/trigger/my-agent" \
  -H "Authorization: Bearer mp_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Trigger-Source: cron" \
  -d '{"input": "Generate daily report"}'

GitHub Actions

yaml
name: Daily Agent Run
on:
  schedule:
    - cron: '0 9 * * *'  # 9am UTC daily

jobs:
  trigger:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger agent
        run: |
          curl -X POST "$TRIGGER_URL" \
            -H "Authorization: Bearer $API_KEY" \
            -H "Content-Type: application/json" \
            -H "X-Trigger-Source: github-actions" \
            -d '{"input": "Generate daily report"}'
        env:
          TRIGGER_URL: ${{ secrets.AGENT_TRIGGER_URL }}
          API_KEY: ${{ secrets.AGENTLIFY_API_KEY }}

Node.js / fetch

javascript
const response = await fetch(
  'https://us-central1-agentlify-prod.cloudfunctions.net/agentTrigger/agents/trigger/my-agent',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer mp_YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ input: 'Summarize the latest data' }),
  }
);

const result = await response.json();
console.log(result.output);

Error Codes

StatusCodeDescription
401unauthorizedMissing or invalid API key
402insufficient_creditsAccount has insufficient credits
404not_foundAgent ID not found
400agent_disabledAgent is not active