{"openapi":"3.1.0","info":{"title":"loom-automation v4","description":"\nTurns a public AnalyzeMy.Business report into video 1 of the v4 funnel: a personalized audit under\n90 seconds in Dan's voice, ending on an \"Answer 3 questions\" card over the prospect's territory.\n\n**This is the v4 API.** It is a separate service from v1-v3, with its own API key and storage.\n\n**Auth** — send `Authorization: Bearer <API_KEY>` on `/jobs` endpoints.\n`/health`, `/docs` and `/videos/{job_id}` are unauthenticated; the video link\ncarries its own unguessable per-job token instead.\n\n**Pipeline checks** — before anything renders: the keyword is derived from the Google\ncategory and the website's own service words (a wrong report keyword is corrected automatically);\nthe territory must be open (no existing client in the same category within the radius set by the\nZIP code's population density: urban 3 mi, suburban 7 mi, rural 15 mi); the heatmap is scanned at\nthat radius. The script is Greg's fixed text filled by code.\n\n| Status | Video | Meaning |\n|---|---|---|\n| `queued` / `running` | not yet | `queued` with `reason` \"Heatmap not ready yet\" means the report's heatmap has no hotspots yet: the job retries after a wait (20 min by default), up to 3 more times, then fails |\n| `completed` | yes | every check and production gate passed (< 90 s, 1920x1080, peak <= -1.5 dB) |\n| `territory_taken` | no | a client in the same category is inside the radius |\n| `held` | no | a check couldn't complete or needs a person (see `reason`) |\n| `failed` | no | an error; submitting the report again retries it |\n\nEvery job carries `reason` (plain words for held, territory_taken and failed) and, once the checks\nran, `checks`: the keyword (`original` vs `used`), the territory (`tier`, `radius_miles`, `open`,\nany `conflict`), the Google AI and Maps results, the heatmap (`grid_points`, `grid_hits`) and the\nproduction `gates`. Finished jobs carry `metrics`: wall time and costs (`null` where unknown).\n\n**Optional names** — `business_name_phonetic` changes how the voice says the name (the\nscreen keeps the real one). `owner_first_name` is accepted but video 1 doesn't greet by name.\n\n**Prospect page** — send `watch_url` (`/watch/{id}?token=...`, same token as `video_url`) once a job is\n`completed`. A top-level page load of `video_url` (a request with `Sec-Fetch-Dest: document`, as modern\nbrowsers send) is redirected there too (`307`); any other request, including older browsers, some\nwebviews, players and scripts, gets the MP4, so always send `watch_url` to prospects. The page has the player, the 3-question gate (answers go to GHL), then the qualified or not-yet page.\nQualified prospects unlock `part_two_url`: video 2 for their category, the Ignite and Dominate plans\n(prepay / month to month, Stripe Payment Links), the service agreement box and a 72-hour comeback-bonus\ncountdown that starts at unlock and never resets.\n\n**Engagement tags** — send `\"ghl_contact_id\": \"{{contact.id}}\"` with the job and the pages tag that GHL\ncontact the first time each happens (real browsers only; link previews don't count), so workflows can\nstart follow-ups on \"tag added\": `v4-v1-opened`, `v4-v1-played`, `v4-v1-half`, `v4-v1-finished`,\n`v4-p2-opened`, `v4-video2-watched` (video 2 played), `v4-v2-finished`, `v4-checkout-clicked`, plus\n`v4-qualified` / `v4-nurture` from the form. After the form, tags go to the contact the form found or created.\nA report with no heatmap can't become a video until someone regenerates it in AnalyzeMyBusiness and resends\nthe job: its contact gets `v4-report-no-heatmap` so a workflow can alert the team.\n\n**Video 2** — one render per category (`category_plural`) and pricing version (`v4_config.json`).\n`POST /video2` queues it (`force` re-renders), `GET /video2/{slug}` reports `queued`, `running`,\n`completed` (published), `held` (rendered but not published: `reason`, e.g. a placeholder price) or\n`failed`; `GET /video2/{slug}/video` streams it for review. A part-two page renders its category's video\non first view, and again after any pricing change.\n\n`held`, `territory_taken` and `completed` are final for a report; send `\"force\": true` for a fresh\njob. Jobs survive restarts: anything still `queued`/`running` is requeued on boot, and a job waiting\non its heatmap keeps the rest of its wait.\n","version":"4.0.0"},"servers":[{"url":"https://videos.badaaas.com"}],"paths":{"/health":{"get":{"tags":["status"],"summary":"Liveness and queue depth","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/jobs":{"post":{"tags":["jobs"],"summary":"Queue a video render","operationId":"create_job_jobs_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobRequest"}}},"required":true},"responses":{"202":{"description":"Job accepted and queued","content":{"application/json":{"schema":{}}}},"401":{"description":"Missing or wrong API key"},"422":{"description":"report_url failed validation"}},"security":[{"HTTPBearer":[]}]}},"/jobs/{job_id}":{"get":{"tags":["jobs"],"summary":"Job status","operationId":"get_job_jobs__job_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}}],"responses":{"200":{"description":"queued | running | completed | failed | skipped | needs_review","content":{"application/json":{"schema":{}}}},"401":{"description":"Missing or wrong API key"},"404":{"description":"No such job"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/videos/{job_id}":{"get":{"tags":["videos"],"summary":"Redirect to the finished MP4","description":"Public but unguessable: the per-job token is the only credential, and the\nredirect target is a freshly presigned bucket URL.","operationId":"get_video_videos__job_id__get","parameters":[{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}},{"name":"token","in":"query","required":false,"schema":{"type":"string","default":"","title":"Token"}},{"name":"Range","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Range"}},{"name":"Sec-Fetch-Dest","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sec-Fetch-Dest"}}],"responses":{"200":{"description":"Permanent MP4 stream"},"206":{"description":"Partial MP4 stream for seeking"},"307":{"description":"v4 only: a browser page load goes to the watch page"},"404":{"description":"Unknown job or wrong token"},"409":{"description":"Render not finished yet"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/video2":{"post":{"tags":["video 2"],"summary":"Render video 2 for a category","description":"Queues the render at today's pricing unless it exists (`force` re-renders it). Status as GET.","operationId":"video2_render_video2_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video2Request"}}},"required":true},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/video2/{slug}":{"get":{"tags":["video 2"],"summary":"Video 2 status for a category (at today's pricing)","description":"queued | running | completed (published) | held (rendered, not published: `reason`) | failed.","operationId":"video2_get_video2__slug__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string","title":"Slug"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/video2/{slug}/video":{"get":{"tags":["video 2"],"summary":"Video 2 MP4 for review (held ones too)","operationId":"video2_review_video2__slug__video_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string","title":"Slug"}},{"name":"Range","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Range"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/prep-data":{"get":{"tags":["video 2"],"summary":"Everything a prospect was shown, for call-prep (PREP_READ_TOKEN)","description":"Jobs for a Google place_id, a GHL contact id or a report URL, newest first, plus today's pricing terms.","operationId":"prep_data_v4_prep_data_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"place_id","in":"query","required":false,"schema":{"type":"string","default":"","title":"Place Id"}},{"name":"ghl_contact_id","in":"query","required":false,"schema":{"type":"string","default":"","title":"Ghl Contact Id"}},{"name":"report_url","in":"query","required":false,"schema":{"type":"string","default":"","title":"Report Url"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"JobRequest":{"properties":{"report_url":{"type":"string","title":"Report Url"},"force":{"type":"boolean","title":"Force","default":false},"business_name_phonetic":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Business Name Phonetic"},"owner_first_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Owner First Name"},"owner_first_name_phonetic":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Owner First Name Phonetic"},"ghl_contact_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ghl Contact Id"}},"type":"object","required":["report_url"],"title":"JobRequest","examples":[{"force":false,"report_url":"https://prod.analyzemy.business/#/share/report/6aa706b170d3424bf64f8f10"}]},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"Video2Request":{"properties":{"category_plural":{"type":"string","title":"Category Plural"},"force":{"type":"boolean","title":"Force","default":false}},"type":"object","required":["category_plural"],"title":"Video2Request"}},"securitySchemes":{"HTTPBearer":{"type":"http","description":"Your API_KEY","scheme":"bearer"}}}}