# Bloop Agent API

HTTP-first contract so **any AI agent** (Custom GPTs, Claude Actions, LangChain, Cursor, n8n) can create skits and trigger exports. MCP wraps the same endpoints for Cursor / Claude Desktop.

Base URL: `https://usebloop.studio`

## Schema

- JSON Schema: https://usebloop.studio/schemas/bloop-scene.v1.json
- Agent skill: https://usebloop.studio/agents/SKILL.md
- Source of truth: `version: 1` + `template` + matching payload (`imessage` | `whatsapp` | `social` | `lockscreen` | `email`)
- `email` (Email Story) is a photo carousel of slides (`kind: "email" | "word" | "excel"`). Optionally framed in TikTok photo-post UI. `?export=png` downloads a zip of PNGs; `?export=video` records a slide-advance video.

### Minimal iMessage example

```json
{
  "version": 1,
  "template": "imessage",
  "exportMode": "device",
  "imessage": {
    "contactName": "Alex",
    "darkMode": false,
    "bubbles": [
      { "type": "timestamp", "text": "Today 9:41 AM" },
      { "type": "received", "text": "we need a skit by tonight" },
      { "type": "sent", "text": "already drafting in Bloop", "status": "read", "color": "blue" }
    ]
  }
}
```

## Endpoints

### `POST /api/scenes`

Creates a scene (stored ~30 days). Rate limit: 60/hour/IP. Max body ~900KB.

**Response**

```json
{
  "ok": true,
  "id": "a1b2c3d4e5f6g7h8",
  "studioUrl": "https://usebloop.studio/studio?scene=…",
  "exportPngUrl": "https://usebloop.studio/studio?scene=…&export=png&mode=device",
  "exportVideoUrl": "https://usebloop.studio/studio?scene=…&export=video&mode=device"
}
```

### `GET /api/scenes/{id}`

Returns the scene JSON plus the same URLs.

## Studio deep-links

| Param | Values | Effect |
|-------|--------|--------|
| `scene` | scene id | Hydrate Studio from API |
| `export` | `png` \| `video` | Auto-download after hydrate |
| `mode` | `device` \| `screen` \| `bubbles` | Export crop |

Manual import: Studio navbar **Import** pastes raw `bloop-scene.v1` JSON.

## MCP

Tools call these HTTP endpoints:

| Tool | Description |
|------|-------------|
| `create_skit` | POST scene JSON → studio + export URLs |
| `get_skit` | GET scene by id |
| `export_skit` | Build `?scene=&export=&mode=` deep-link |

OpenAPI: https://usebloop.studio/docs/openapi-scenes.yaml
