---
name: habify-english-author
description: Step-by-step API workflow for authoring HELP v1.0 lessons, uploading assets, dry-run validation, submitting to Sandbox Preview, and iterating on reviewer feedback via /api/v1/agent/*.
homepage: https://english.dev.habifyhub.com/ai-agents
metadata:
  category: workflow
  version: "1.0.0"
---

# Habify English Authoring Workflow & Agent API

Base URL: `https://english.dev.habifyhub.com`  
Header: `Authorization: Bearer ${HABIFY_ENGLISH_AGENT_TOKEN}` (or `X-Agent-Token`)

---

## 1. Check Token Scope (`GET /api/v1/agent/whoami`)

Returns whether your token is **`platform`** scoped (creates `public_platform` drafts) or **`center`** scoped (strictly locked to `owner_scope = "center"`, `visibility = "center_private"`, and R2 prefix `habify-english/centers/{center_id}/...`).

```bash
curl -fsS -H "Authorization: Bearer ${HABIFY_ENGLISH_AGENT_TOKEN}" \
  "https://english.dev.habifyhub.com/api/v1/agent/whoami"
```

---

## 2. Fetch Live Schemas & Curated Voice Catalog (`GET /api/v1/agent/spec`)

Always read this endpoint at the start of an authoring session. It returns:
- `schemas.manifest` (`manifest.schema.json`)
- `schemas.lesson` (`lesson.schema.json`)
- `tts_voices[]` (active curated voice codes + accents + default speeds)
- `age_bands[]` and `heps_tiers[]`
- `taxonomy` (existing topics and concept tags for consistency)

---

## 3. Upload Assets (`POST /api/v1/agent/assets/upload`)

- **Form fields:** `file` (binary), `asset_kind` (`image | audio | lottie`), optional `filename`.
- **Magic-byte inspection:** Images max **2 MB** (`webp`, `png`, `jpg`); Audio max **5 MB** (`mp3`, `ogg`, `wav`, `m4a`); Lottie max **2 MB** (`.json`).
- **Response:** Returns `asset_ref` (e.g. `"assets/images/mango.webp"`) and `asset_entry` to include in `assets_map`.

```bash
curl -fsS -X POST "https://english.dev.habifyhub.com/api/v1/agent/assets/upload" \
  -H "Authorization: Bearer ${HABIFY_ENGLISH_AGENT_TOKEN}" \
  -F "asset_kind=image" \
  -F "file=@./mango.webp"
```

---

## 4. Dry-Run Validate (`POST /api/v1/agent/lessons/validate`)

Send JSON `{ "manifest": {...}, "lesson": {...} }` OR multipart `package=@lesson.zip`.
- **200 OK:** `{ "valid": true, "estimated_tts_cues": 12 }`
- **422 Unprocessable:** Exact JSON paths & error messages in `errors[]`.

---

## 5. Submit to Sandbox Preview (`POST /api/v1/agent/lessons/submit-preview`)

Send JSON `{ "manifest": {...}, "lesson": {...}, "assets_map": {...} }` OR multipart `package=@lesson.zip`.
- Forces `status = "draft"` and `review_status = "pending_review"` (never publishes directly).
- Enqueues dual-accent (`en-US`, `en-GB`) TTS pre-bake via `ai-gateway`.
- Returns `201 Created` with `lesson_id`, `lesson_version_id`, and human **`preview_url`**.

---

## 6. Poll Reviewer Feedback (`GET /api/v1/agent/lessons/{lessonId}/feedback`)

Inspect `review_status` (`pending_review | changes_requested | approved`), `reviewer_notes`, `prebake_status`, and any cue-level errors. If changes are requested, bump `manifest.semver` (e.g. `1.0.0` -> `1.0.1`) and resubmit to `submit-preview`.

---

## 7. Hard Denylist Security Rules

An `eng_agt_*` token will ALWAYS receive `403 AGENT_HARD_DENIED` if it calls:
- `/api/v1/admin/lessons/*/publish` or `/api/v1/center/studio/lessons/*/publish`
- Any `/api/v1/children/*`, `/api/v1/kid/*`, `/api/v1/parent/*`, `/api/v1/billing/*`, `/api/v1/system/*`, `/api/v1/teacher/*`, or `/api/v1/center/members/*` route.
