# Draft API: your own form, our checks

> Your own form, with the same live checks and questions.

Already have a release form? Keep it, and drive the same live checks and artist questions the embedded builder uses
through a server-side **draft**. The hosted builder, the embed and your own form all work on the same draft, so you
can mix them: start a draft in your form and let an artist finish it in the embed.

## 1. Create a draft

```bash
curl -X POST $ACTIVQC_BASE_URL/v1/release_drafts \
  -H "Authorization: Bearer $ACTIVQC_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "external_ref": "rel-2026-042",
    "end_user_ref": "artist-8842",
    "payload": {
      "release": { "title": "Neon Monsoon", "upc": "036000291452" },
      "tracks": [
        { "track_number": 1, "title": "Track 1", "isrc": "INA262600001", "duration_s": 213.4 }
      ]
    }
  }'
# -> 201 Created { "id": "rd_7fK2...", "lock_version": 0, "status": "editing", ... }
```

Leave `release_type` out: single, EP or album is worked out from the tracks (7 tracks or 30 minutes is an album; up to 3
tracks, none of 10 minutes, is a single; anything else an EP). Send each track's length in seconds as `duration_s`; a length
we measure is used in its place. Where a length is missing and the number of tracks does not decide, the type is left unset
and nothing is said about it. One you send is kept, and noted where the tracks cannot be that; nobody is asked about it.

## 2. Patch fields as the artist edits

Send `lock_version` and RFC 6902 `patch` ops (or a full editable `payload`). Any attempt to patch `/qc_answers`
directly returns `422 invalid_patch`; a stale `lock_version` returns `409 draft_conflict` with the current `draft`.

```bash
curl -X PATCH $ACTIVQC_BASE_URL/v1/release_drafts/rd_7fK2... \
  -H "Authorization: Bearer $ACTIVQC_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "lock_version": 0,
    "patch": [
      { "op": "replace", "path": "/release/title", "value": "Neon Monsoon" },
      { "op": "add", "path": "/release/release_date", "value": "2026-08-15" }
    ]
  }'
# -> 200 OK { "id": "rd_7fK2...", "lock_version": 1, ... }
```

## 3. Validate and read open questions

```bash
curl -X POST $ACTIVQC_BASE_URL/v1/release_drafts/rd_7fK2.../validate \
  -H "Authorization: Bearer $ACTIVQC_KEY"

curl $ACTIVQC_BASE_URL/v1/release_drafts/rd_7fK2.../questions \
  -H "Authorization: Bearer $ACTIVQC_KEY"
# -> 200 OK { "object": "list", "open_questions": 1, "data": [{ "question_key": "P15:release:", "options": [...] }] }
```

A check is complete unless you ask for less: `"checks": "fast"` in the body of `validate` or `answers` (and of
`POST /v1/qc/validate`) answers at once with everything that is not a model's judgement. `model_check` is then `pending`
while a model has not read these titles, names and credits yet; validate again without `checks` for its findings. What it
said of the same text before is in the fast answer already. The embedded builder uses both.

## 4. Answer a question

An option with a patch applies it automatically; an option with `"patch": null` ("correct as submitted") writes the
answer into `payload.qc_answers` so the submitted run routes to a reviewer without asking the artist twice.

```bash
curl -X POST $ACTIVQC_BASE_URL/v1/release_drafts/rd_7fK2.../answers \
  -H "Authorization: Bearer $ACTIVQC_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "question_key": "P15:release:", "option_id": "release_title", "lock_version": 1 }'
# -> 200 OK { "object": "qc.validation", "verdict": "pass", "draft_id": "rd_7fK2...", "lock_version": 2, ... }
```

### Fields and documents your account requires

What you made required under **Builder set-up** is checked on validate and on submit. A missing field is a question with
a rule id starting `RF`, at the field's own path; a missing document is one starting `RD`, answered with the `id` of an
uploaded document. Both can also be answered "there is none", which sends the release to a person. Documents are kept in
the payload as `documents` on the release or the track: `{ "<document id>": "<upload id>" }`.

## 5. Submit the draft

```bash
curl -X POST $ACTIVQC_BASE_URL/v1/release_drafts/rd_7fK2.../submit \
  -H "Authorization: Bearer $ACTIVQC_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "tier": 2 }'
# -> 202 Accepted { "id": 42, "object": "qc.run", "status": "queued", ... }
```

A second submit on the same draft returns the same `qc.run` without creating a duplicate run.

## 6. Consume the signed webhook

Subscribe to `release_draft.submitted` (fires immediately when the draft turns into a run) and `qc.run.completed`
(fires when the fast-lane verdict lands). Verify `X-Wqc-Signature` with HMAC-SHA256 before trusting the body
([Webhooks](https://activqc.wavbee.com/docs/webhooks.md)):

```json
{
  "id": "evt_7c1e9a...",
  "type": "release_draft.submitted",
  "created_at": "2026-11-23T09:41:16Z",
  "livemode": true,
  "data": {
    "draft_id": "rd_7fK2...",
    "external_ref": "rel-2026-042",
    "end_user_ref": "artist-8842",
    "run_id": 42,
    "tier": 2,
    "profile": "apple",
    "submitted_at": "2026-11-23T09:41:16Z"
  }
}
```
