# Webhooks and alerts API for viral video, creator and trend events

> The lulubanana webhooks API sends signed events to your server when a tracked creator's post breaks out, a tracked creator posts, a trend is detected or moves stage, a research job finishes or fails, an analysis is ready, a search opportunity job finds clear Google or YouTube gaps or the weekly digest is out, with retries, a 30-day delivery log, one-call resend and adjustable alert thresholds.

lulubanana is a content research platform and API for short-form video (TikTok, YouTube Shorts and Instagram Reels). Base address: https://lulubanana.com/api/v1. Authentication: `Authorization: Bearer lb_...`. Reads are free; collection is priced like the app.

## 6 things you can do with the webhooks API for viral videos

1. Subscribe to the events alert, creator, trend, run, analysis, search and digest; each delivery's type names the exact event (video.new_outlier, creator.new_video, trend.detected or trend.stage_changed, research.completed or research.failed, analysis.completed, search.gap_found, digest.weekly)
2. Verify signatures (HMAC-SHA256 of the raw body)
3. De-duplicate with the unique delivery id
4. Read deliveries with your server's replies, and resend one
5. Send a test event
6. Set the breakout threshold (1.5-50x usual views)

## How it works

1. POST /webhooks with your https address and events (any of alert, creator, trend, run, analysis, search, digest; all when left out); keep the secret.
2. Verify X-Lulubanana-Signature on every request.
3. Use the delivery id to drop duplicates; resend with /webhooks/deliveries/{id}/retry.

## Key terms

- **Event you subscribe to**: What you send in events: alert, creator, trend, run, analysis, search or digest.
- **Delivered type**: The type field of each delivery: alert -> video.new_outlier, creator -> creator.new_video, trend -> trend.detected (a new or newly rising trend) or trend.stage_changed (a trend moved stage; a topic trend at most once a day), run -> research.completed or research.failed, analysis -> analysis.completed, search -> search.gap_found (a search opportunity job found a Google or YouTube gap score of 60+), digest -> digest.weekly. trend.stage_changed and search.gap_found carry an event_id.

## Endpoints

### POST /api/v1/webhooks

Add a webhook (or Slack/Discord) for events: digest, alert (breakout video), trend (trend.detected for a new or newly rising trend, trend.stage_changed when a trend moves stage), run (research finished or failed), creator (new post by a tracked creator), analysis (an analysis job finished), search (search.gap_found: a search opportunity job found clear Google or YouTube gaps). Webhook bodies are signed: X-Lulubanana-Signature = sha256 HMAC of the raw body with the secret returned once here. Each delivery has a unique id (X-Lulubanana-Delivery) to de-duplicate retries.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `url` (required) | body | string | https:// address that receives the events |
| `events` | body | array | Any of digest, alert, trend, run, creator, analysis, search (default all) |
| `kind` | body | webhook, slack, discord | webhook (default), slack or discord |

```bash
curl -X POST "https://lulubanana.com/api/v1/webhooks" \
  -H "Authorization: Bearer $LULUBANANA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/hooks/lulubanana","events":["alert","run","analysis"]}'
```

Example reply:

```json
{
  "data": {
    "id": 12,
    "kind": "webhook",
    "url": "https://example.com/.../cana",
    "events": [
      "alert",
      "run",
      "analysis"
    ],
    "active": true,
    "secret": "9f2c...(shown once)",
    "signature": "X-Lulubanana-Signature: sha256=HMAC_SHA256(secret, raw body)"
  }
}
```

### GET /api/v1/webhooks

Your webhooks and their delivery health.

Cost: free.

```bash
curl "https://lulubanana.com/api/v1/webhooks" \
  -H "Authorization: Bearer $LULUBANANA_KEY"
```

### GET /api/v1/webhooks/{id}

One webhook.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `id` (required) | path | string | The id in the path |

```bash
curl "https://lulubanana.com/api/v1/webhooks/42" \
  -H "Authorization: Bearer $LULUBANANA_KEY"
```

### PATCH /api/v1/webhooks/{id}

Change a webhook's address, events, or switch it on or off.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `id` (required) | path | string | The id in the path |
| `url` | body | string | New https:// address |
| `events` | body | array | Any of digest, alert, trend, run, creator, analysis, search |
| `active` | body | boolean | On or off |

```bash
curl -X PATCH "https://lulubanana.com/api/v1/webhooks/42" \
  -H "Authorization: Bearer $LULUBANANA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"events":["alert"]}'
```

### DELETE /api/v1/webhooks/{id}

Remove a webhook.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `id` (required) | path | string | The id in the path |

```bash
curl -X DELETE "https://lulubanana.com/api/v1/webhooks/42" \
  -H "Authorization: Bearer $LULUBANANA_KEY"
```

### POST /api/v1/webhooks/{id}/reenable

Switch a webhook back on after it was switched off for 5 failed deliveries in a row.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `id` (required) | path | string | The id in the path |

```bash
curl -X POST "https://lulubanana.com/api/v1/webhooks/42/reenable" \
  -H "Authorization: Bearer $LULUBANANA_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### POST /api/v1/webhooks/{id}/test

Send a test event (type "test") within a few seconds; see the result in /webhooks/{id}/deliveries.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `id` (required) | path | string | The id in the path |

```bash
curl -X POST "https://lulubanana.com/api/v1/webhooks/42/test" \
  -H "Authorization: Bearer $LULUBANANA_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### GET /api/v1/webhooks/{id}/deliveries

Recent deliveries (kept 30 days) with your server's reply status; failed ones can be sent again.

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `id` (required) | path | string | The id in the path |
| `limit` | query | string | Results per page, 1-100 (default 25) |
| `cursor` | query | string | next_cursor from the previous page |

```bash
curl "https://lulubanana.com/api/v1/webhooks/42/deliveries" \
  -H "Authorization: Bearer $LULUBANANA_KEY"
```

### POST /api/v1/webhooks/deliveries/{delivery_id}/retry

Send one delivery again (same payload, a new delivery id that names the original in retry_of).

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `delivery_id` (required) | path | string | delivery_id |

```bash
curl -X POST "https://lulubanana.com/api/v1/webhooks/deliveries/dlv_981/retry" \
  -H "Authorization: Bearer $LULUBANANA_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### GET /api/v1/alerts/settings

Alert thresholds: breakout alerts fire when a tracked creator's post reaches breakout_ratio x their usual views (default 3).

Cost: free.

```bash
curl "https://lulubanana.com/api/v1/alerts/settings" \
  -H "Authorization: Bearer $LULUBANANA_KEY"
```

### PUT /api/v1/alerts/settings

Change alert settings: breakout_ratio (1.5-50), breakout_alerts, trend_alerts, email_alerts. Webhooks receive the same events (subscribe in /webhooks).

Cost: free.

| Parameter | In | Type | Description |
| - | - | - | - |
| `breakout_ratio` | body | number | Alert at this many times the usual views, 1.5-50 |
| `breakout_alerts` | body | boolean | On or off |
| `trend_alerts` | body | boolean | On or off |
| `email_alerts` | body | boolean | Email as well |

```bash
curl -X PUT "https://lulubanana.com/api/v1/alerts/settings" \
  -H "Authorization: Bearer $LULUBANANA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"breakout_ratio":5}'
```

## FAQ

**How do I verify a lulubanana webhook?**
Compute HMAC-SHA256 of the raw request body with your webhook secret and compare it with the X-Lulubanana-Signature header (sha256=...).

**What happens when my server is down?**
Failed deliveries are logged; after 5 failures in a row the webhook is switched off and you are told. Re-enable it and resend any delivery from the log.

**How do I hear when a search opportunity job finds a gap?**
Subscribe to the search event. When a search opportunity job finds an opportunity whose Google or YouTube gap score is 60 or more, you get a search.gap_found delivery with its event_id, the gaps (opportunity id, topic, both gap scores) and the link to the job's opportunities.

**How do I follow trends as they change stage?**
Subscribe to the trend event. Besides trend.detected you get trend.stage_changed with event_id, trend_id, kind, from_stage and to_stage when a content trend in one of your agents moves stage, and when a topic trend moves stage (at most once a day per trend).

More: https://lulubanana.com/developers/ - all endpoints https://lulubanana.com/developers/endpoints/ - research guide https://lulubanana.com/ai-guide.txt
