# Generate

Generate courses, course screens, and quizzes inside a course using Coassemble AI.

To delete source processing copies after generation, send `discardSourceDocuments: true`. See [source document retention](/source-documents) for embed inheritance, accepted requests, deletion timing and the editing trade-off.

<a id="generate-course-agent"></a>

## Generate a course with the create-course agent

Use this endpoint to run the create-course agent server-side and return a built course. Provide a `prompt`, one or more source `documents`, or both. Document-heavy courses can take several minutes.

Authenticate with your workspace API key. Required body field: `identifier` (stable course-owner id). Either `prompt` or `documents` (non-empty) is required. When exactly one document is supplied, `fidelityLevel` is required.

### Fidelity (`fidelityLevel`)

Controls how closely a single source document is followed:

- `verbatim` — 1:1 document-to-course conversion. Visible text stays as in the source; no pedagogical rewrite.
- `structured` — Follows the document’s structure and content, but reshapes it into a proper learning experience (sections, clearer wording).
- `adaptive` — Uses the document as supporting material; learning outcomes / brief drive structure and authorship.

### Documents and images

- `documents` — Array of source documents. Each item needs `name`, `url` (public or signed), and optionally `mimeType`.
- `selectedImages` — For structured/verbatim document generation: an array of document image URLs to include, or the literal string `"all"` to include every image the conversion extracts.

### Assessment (`assessment`)

Optional array of assessment opt-ins. When omitted, the agent reads the prompt for assessment requests and falls back to formative knowledge checks. A single-document `verbatim` build adds no assessments unless explicitly requested. Pass one or more of:

- `formative` — Unscored knowledge checks (single-question screens) after key concepts through the course.
- `summative` — A scored end-of-course quiz (typically before any recap).
- `flashcards` — Unscored flip-card practice screens (not knowledge checks or quizzes).
- `none` — No knowledge checks, quizzes, or flashcards.

For verbatim generation, only a summative opt-in adds an authored end-of-course quiz; formative/flashcards are not applied the same way as on adaptive/structured builds.

### Other optional fields

- `language` — Language for the course content.
- `tone` — Tone of voice for the generated course.
- `audience` — Who the course is for.
- `learningOutcomes` — Array of learning outcomes the course should cover.
- `timeEstimateMinutes` — Target course duration in minutes.
- `useBrandVoice` — Whether configured brand voice should be applied.
- `aiImages` — Set to `true` to generate AI images for screens that need one. Each image uses one generation from the workspace image allowance. Defaults to `false`, so no AI images are generated unless you ask for them.
- `folderId` — Folder ID for the generated course.
- `clientIdentifier` — Tenant/client the course belongs to.

### Example: verbatim from a document with a summative quiz

**Request body**

```json
{
  "identifier": "user@example.com",
  "fidelityLevel": "verbatim",
  "assessment": ["summative"],
  "documents": [
    {
      "name": "Kitchen Safety Induction.pdf",
      "url": "https://example.com/kitchen-safety-induction.pdf",
      "mimeType": "application/pdf"
    }
  ],
  "selectedImages": "all",
  "language": "en",
  "tone": "professional",
  "audience": "new kitchen staff",
  "timeEstimateMinutes": 20,
  "useBrandVoice": true
}
```

POST `/v1/headless/generate/course/agent`

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `prompt` | `string` | No | The topic, learning objective, or source brief for the course | — |
| `identifier` | `string` | Yes | Your stable identifier for the course owner | — |
| `clientIdentifier` | `string` | No | The client this course belongs to | — |
| `discardSourceDocuments` | `boolean` | No | Delete source documents after the build completes, is cancelled or fails. Default false. Editing cannot refer back to discarded sources. A workspace library document URL is refused with a 400. | — |
| `documents` | `object[]` | No | Source documents to ground the course in | — |
| `fidelityLevel` | `string` | No | Controls how closely generation follows the source (\`verbatim\`, \`structured\`, or \`adaptive\`), required with exactly one source document and otherwise optional with \`adaptive\` as the default. | `verbatim` `structured` `adaptive` |
| `selectedImages` | `string[] \| string` | No | Document image URLs to include when using structured/verbatim document generation. Pass the literal string "all" to include every image the conversion extracts (useful for testing image placement without pre-curating URLs). | — |
| `audience` | `string` | No | Who the course is for | — |
| `learningOutcomes` | `string[]` | No | Learning outcomes the course should cover | — |
| `language` | `string` | No | Language for the course content | — |
| `tone` | `string` | No | Tone of voice for the generated course | — |
| `timeEstimateMinutes` | `number` | No | Target course duration in minutes | — |
| `useBrandVoice` | `boolean` | No | Whether configured brand voice should be applied | — |
| `folderId` | `number` | No | Folder ID for the generated course | — |
| `aiImages` | `boolean` | No | Generate AI images for screens that need one, using the workspace image generation allowance. Defaults to false: no AI images are generated unless this is true. | — |
| `assessment` | `string[]` | No | Assessment choices are final for brief-only, Structured and Adaptive builds. Omitted or empty reads only the prompt, falling back to formative knowledge checks. Verbatim preserves source text and supports only an added scored quiz: summative (including combined choices) adds it; formative/flashcards-only, none, omitted or empty adds no assessment. Formative and flashcards are not authored in Verbatim, matching the app. | — |

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/headless/generate/course/agent" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "identifier": "user_123",
    "prompt": "Create a short onboarding course.",
    "clientIdentifier": "client_123",
    "discardSourceDocuments": true
}'
```

#### Response

**JSON response**

```json
{
  "createdInTestMode": false,
  "reviewKey": "example",
  "id": 1234,
  "title": "Workplace Safety",
  "description": "example",
  "image": "example",
  "imageAltText": "example",
  "imageSource": 1,
  "thumbnail": "example",
  "thumbnailRevision": "example",
  "thumbnailOutdated": false,
  "start": null,
  "timeEstimateMinutes": 1,
  "calculatedTimeEstimateMinutes": 1,
  "timeEstimateExcluded": [
    {
      "type": "audio",
      "count": 12
    }
  ],
  "finish": null,
  "theme": null,
  "clientId": 1234,
  "active": false,
  "identified": false,
  "private": false,
  "paid": false,
  "domain": false,
  "price": 1,
  "key": "abc123",
  "source": "example",
  "identifier": "user_123",
  "clientIdentifier": "client_123",
  "language": "en",
  "revision": "example",
  "collabSeq": 1,
  "published": "2026-01-01T00:00:00.000Z",
  "narrationsGenerated": "2026-01-01T00:00:00.000Z",
  "narrationLanguage": "en",
  "created": "2026-01-01T00:00:00.000Z",
  "updated": "2026-01-01T00:00:00.000Z",
  "type": "example",
  "legacy": false,
  "documentFlow": "example",
  "deleted": "2026-01-01T00:00:00.000Z",
  "folderId": 1234,
  "parentId": 1234,
  "themeId": 1234,
  "draftId": 1234,
  "startScreenId": 1234,
  "finishScreenId": 1234,
  "sequence": 1,
  "screens": [
    {
      "quizAttemptId": 1234,
      "id": 1234,
      "uid": "example",
      "sequence": 1,
      "title": "Workplace Safety",
      "description": "example",
      "asset": "example",
      "assetAltText": "example",
      "assetSource": 1,
      "typeId": 1234,
      "background": null,
      "courseId": 1234,
      "clientId": 1234,
      "sourceId": 1234,
      "scored": false,
      "passingGrade": 1,
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z",
      "updatedText": "2026-01-01T00:00:00.000Z",
      "narrationsGenerated": "2026-01-01T00:00:00.000Z",
      "aiGenerated": "2026-01-01T00:00:00.000Z",
      "deleted": "2026-01-01T00:00:00.000Z",
      "identifier": "user_123",
      "clientIdentifier": "client_123",
      "quizGroupUid": "example",
      "type": {
        "id": 1234,
        "name": "example",
        "title": "Workplace Safety",
        "icon": "example",
        "sequence": 1,
        "completable": false,
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z"
      },
      "questions": [
        {
          "id": 1234,
          "screenId": 1234,
          "sequence": 1,
          "text": "example",
          "typeId": 1234,
          "sourceId": 1234,
          "caseSensitive": false,
          "serverGraded": false,
          "correct": false,
          "completed": false,
          "matchOptions": [
            "example"
          ],
          "narrationAudioPath": "example",
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "questionType": {
            "id": 1234,
            "title": "Workplace Safety",
            "klass": "example",
            "template": "example",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z"
          }
        }
      ],
      "blocks": [
        {
          "id": 1234,
          "screenId": 1234,
          "uid": "example",
          "type": "example",
          "content": "example",
          "column": 1,
          "row": 1,
          "columnSpan": 1,
          "rowSpan": 1,
          "sequence": 1,
          "revision": 1,
          "questionId": 1234,
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "question": {
            "id": 1234,
            "screenId": 1234,
            "sequence": 1,
            "text": "example",
            "typeId": 1234,
            "sourceId": 1234,
            "caseSensitive": false,
            "serverGraded": false,
            "correct": false,
            "completed": false,
            "matchOptions": [
              "example"
            ],
            "narrationAudioPath": "example",
            "aiGenerated": "2026-01-01T00:00:00.000Z",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z",
            "questionType": {
              "id": 1234,
              "title": "Workplace Safety",
              "klass": "example",
              "template": "example",
              "created": "2026-01-01T00:00:00.000Z",
              "updated": "2026-01-01T00:00:00.000Z"
            }
          }
        }
      ]
    }
  ],
  "folder": {
    "id": 1234,
    "clientId": 1234,
    "name": "example",
    "colour": "example",
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z",
    "deleted": "2026-01-01T00:00:00.000Z"
  },
  "courseTheme": {
    "id": 1234,
    "name": "example",
    "logoId": 1234,
    "default": false,
    "logo": {
      "id": 1234,
      "path": "example",
      "name": "example"
    },
    "clientId": 1234,
    "clientIdentifier": "client_123",
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z"
  },
  "startScreen": {
    "quizAttemptId": 1234,
    "id": 1234,
    "uid": "example",
    "sequence": 1,
    "title": "Workplace Safety",
    "description": "example",
    "asset": "example",
    "assetAltText": "example",
    "assetSource": 1,
    "typeId": 1234,
    "background": null,
    "courseId": 1234,
    "clientId": 1234,
    "sourceId": 1234,
    "scored": false,
    "passingGrade": 1,
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z",
    "updatedText": "2026-01-01T00:00:00.000Z",
    "narrationsGenerated": "2026-01-01T00:00:00.000Z",
    "aiGenerated": "2026-01-01T00:00:00.000Z",
    "deleted": "2026-01-01T00:00:00.000Z",
    "identifier": "user_123",
    "clientIdentifier": "client_123",
    "quizGroupUid": "example",
    "type": {
      "id": 1234,
      "name": "example",
      "title": "Workplace Safety",
      "icon": "example",
      "sequence": 1,
      "completable": false,
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z"
    },
    "questions": [
      {
        "id": 1234,
        "screenId": 1234,
        "sequence": 1,
        "text": "example",
        "typeId": 1234,
        "sourceId": 1234,
        "caseSensitive": false,
        "serverGraded": false,
        "correct": false,
        "completed": false,
        "matchOptions": [
          "example"
        ],
        "narrationAudioPath": "example",
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "questionType": {
          "id": 1234,
          "title": "Workplace Safety",
          "klass": "example",
          "template": "example",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z"
        }
      }
    ],
    "blocks": [
      {
        "id": 1234,
        "screenId": 1234,
        "uid": "example",
        "type": "example",
        "content": "example",
        "column": 1,
        "row": 1,
        "columnSpan": 1,
        "rowSpan": 1,
        "sequence": 1,
        "revision": 1,
        "questionId": 1234,
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "question": {
          "id": 1234,
          "screenId": 1234,
          "sequence": 1,
          "text": "example",
          "typeId": 1234,
          "sourceId": 1234,
          "caseSensitive": false,
          "serverGraded": false,
          "correct": false,
          "completed": false,
          "matchOptions": [
            "example"
          ],
          "narrationAudioPath": "example",
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "questionType": {
            "id": 1234,
            "title": "Workplace Safety",
            "klass": "example",
            "template": "example",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z"
          }
        }
      }
    ]
  },
  "finishScreen": {
    "quizAttemptId": 1234,
    "id": 1234,
    "uid": "example",
    "sequence": 1,
    "title": "Workplace Safety",
    "description": "example",
    "asset": "example",
    "assetAltText": "example",
    "assetSource": 1,
    "typeId": 1234,
    "background": null,
    "courseId": 1234,
    "clientId": 1234,
    "sourceId": 1234,
    "scored": false,
    "passingGrade": 1,
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z",
    "updatedText": "2026-01-01T00:00:00.000Z",
    "narrationsGenerated": "2026-01-01T00:00:00.000Z",
    "aiGenerated": "2026-01-01T00:00:00.000Z",
    "deleted": "2026-01-01T00:00:00.000Z",
    "identifier": "user_123",
    "clientIdentifier": "client_123",
    "quizGroupUid": "example",
    "type": {
      "id": 1234,
      "name": "example",
      "title": "Workplace Safety",
      "icon": "example",
      "sequence": 1,
      "completable": false,
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z"
    },
    "questions": [
      {
        "id": 1234,
        "screenId": 1234,
        "sequence": 1,
        "text": "example",
        "typeId": 1234,
        "sourceId": 1234,
        "caseSensitive": false,
        "serverGraded": false,
        "correct": false,
        "completed": false,
        "matchOptions": [
          "example"
        ],
        "narrationAudioPath": "example",
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "questionType": {
          "id": 1234,
          "title": "Workplace Safety",
          "klass": "example",
          "template": "example",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z"
        }
      }
    ],
    "blocks": [
      {
        "id": 1234,
        "screenId": 1234,
        "uid": "example",
        "type": "example",
        "content": "example",
        "column": 1,
        "row": 1,
        "columnSpan": 1,
        "rowSpan": 1,
        "sequence": 1,
        "revision": 1,
        "questionId": 1234,
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "question": {
          "id": 1234,
          "screenId": 1234,
          "sequence": 1,
          "text": "example",
          "typeId": 1234,
          "sourceId": 1234,
          "caseSensitive": false,
          "serverGraded": false,
          "correct": false,
          "completed": false,
          "matchOptions": [
            "example"
          ],
          "narrationAudioPath": "example",
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "questionType": {
            "id": 1234,
            "title": "Workplace Safety",
            "klass": "example",
            "template": "example",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z"
          }
        }
      }
    ]
  },
  "translations": [
    "example"
  ],
  "translationCount": 12
}
```

<a id="generate-course"></a>

## Generate a course

Use this endpoint to create a full course from a prompt. It returns the created course using the same response shape as the legacy course generation endpoint.

POST `/v1/headless/generate/course`

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `prompt` | `string` | Yes | The topic or learning objective to generate a course from | — |
| `discardSourceDocuments` | `boolean` | No | Do not retain the source brief or generation context after completion. Default false. | — |
| `audience` | `string` | Yes | Who the course is for (e.g. "new hires") | — |
| `familiarity` | `string` | Yes | How familiar the audience is with the topic (e.g. "beginner") | — |
| `tone` | `string` | Yes | Tone of voice for the generated content (e.g. "professional") | — |
| `screenCount` | `number` | Yes | Approximate number of screens to generate | — |
| `identifier` | `string` | Yes | Your stable identifier for the course owner | — |
| `clientIdentifier` | `string` | No | The client this course belongs to | — |

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/headless/generate/course" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "prompt": "Create a short onboarding course.",
    "audience": "new hires",
    "familiarity": "beginner",
    "tone": "professional",
    "screenCount": 8,
    "identifier": "user_123"
}'
```

#### Response

**JSON response**

```json
{
  "createdInTestMode": false,
  "reviewKey": "example",
  "id": 1234,
  "title": "Workplace Safety",
  "description": "example",
  "image": "example",
  "imageAltText": "example",
  "imageSource": 1,
  "thumbnail": "example",
  "thumbnailRevision": "example",
  "thumbnailOutdated": false,
  "start": null,
  "timeEstimateMinutes": 1,
  "calculatedTimeEstimateMinutes": 1,
  "timeEstimateExcluded": [
    {
      "type": "audio",
      "count": 12
    }
  ],
  "finish": null,
  "theme": null,
  "clientId": 1234,
  "active": false,
  "identified": false,
  "private": false,
  "paid": false,
  "domain": false,
  "price": 1,
  "key": "abc123",
  "source": "example",
  "identifier": "user_123",
  "clientIdentifier": "client_123",
  "language": "en",
  "revision": "example",
  "collabSeq": 1,
  "published": "2026-01-01T00:00:00.000Z",
  "narrationsGenerated": "2026-01-01T00:00:00.000Z",
  "narrationLanguage": "en",
  "created": "2026-01-01T00:00:00.000Z",
  "updated": "2026-01-01T00:00:00.000Z",
  "type": "example",
  "legacy": false,
  "documentFlow": "example",
  "deleted": "2026-01-01T00:00:00.000Z",
  "folderId": 1234,
  "parentId": 1234,
  "themeId": 1234,
  "draftId": 1234,
  "startScreenId": 1234,
  "finishScreenId": 1234,
  "sequence": 1,
  "screens": [
    {
      "quizAttemptId": 1234,
      "id": 1234,
      "uid": "example",
      "sequence": 1,
      "title": "Workplace Safety",
      "description": "example",
      "asset": "example",
      "assetAltText": "example",
      "assetSource": 1,
      "typeId": 1234,
      "background": null,
      "courseId": 1234,
      "clientId": 1234,
      "sourceId": 1234,
      "scored": false,
      "passingGrade": 1,
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z",
      "updatedText": "2026-01-01T00:00:00.000Z",
      "narrationsGenerated": "2026-01-01T00:00:00.000Z",
      "aiGenerated": "2026-01-01T00:00:00.000Z",
      "deleted": "2026-01-01T00:00:00.000Z",
      "identifier": "user_123",
      "clientIdentifier": "client_123",
      "quizGroupUid": "example",
      "type": {
        "id": 1234,
        "name": "example",
        "title": "Workplace Safety",
        "icon": "example",
        "sequence": 1,
        "completable": false,
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z"
      },
      "questions": [
        {
          "id": 1234,
          "screenId": 1234,
          "sequence": 1,
          "text": "example",
          "typeId": 1234,
          "sourceId": 1234,
          "caseSensitive": false,
          "serverGraded": false,
          "correct": false,
          "completed": false,
          "matchOptions": [
            "example"
          ],
          "narrationAudioPath": "example",
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "questionType": {
            "id": 1234,
            "title": "Workplace Safety",
            "klass": "example",
            "template": "example",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z"
          }
        }
      ],
      "blocks": [
        {
          "id": 1234,
          "screenId": 1234,
          "uid": "example",
          "type": "example",
          "content": "example",
          "column": 1,
          "row": 1,
          "columnSpan": 1,
          "rowSpan": 1,
          "sequence": 1,
          "revision": 1,
          "questionId": 1234,
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "question": {
            "id": 1234,
            "screenId": 1234,
            "sequence": 1,
            "text": "example",
            "typeId": 1234,
            "sourceId": 1234,
            "caseSensitive": false,
            "serverGraded": false,
            "correct": false,
            "completed": false,
            "matchOptions": [
              "example"
            ],
            "narrationAudioPath": "example",
            "aiGenerated": "2026-01-01T00:00:00.000Z",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z",
            "questionType": {
              "id": 1234,
              "title": "Workplace Safety",
              "klass": "example",
              "template": "example",
              "created": "2026-01-01T00:00:00.000Z",
              "updated": "2026-01-01T00:00:00.000Z"
            }
          }
        }
      ]
    }
  ],
  "folder": {
    "id": 1234,
    "clientId": 1234,
    "name": "example",
    "colour": "example",
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z",
    "deleted": "2026-01-01T00:00:00.000Z"
  },
  "courseTheme": {
    "id": 1234,
    "name": "example",
    "logoId": 1234,
    "default": false,
    "logo": {
      "id": 1234,
      "path": "example",
      "name": "example"
    },
    "clientId": 1234,
    "clientIdentifier": "client_123",
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z"
  },
  "startScreen": {
    "quizAttemptId": 1234,
    "id": 1234,
    "uid": "example",
    "sequence": 1,
    "title": "Workplace Safety",
    "description": "example",
    "asset": "example",
    "assetAltText": "example",
    "assetSource": 1,
    "typeId": 1234,
    "background": null,
    "courseId": 1234,
    "clientId": 1234,
    "sourceId": 1234,
    "scored": false,
    "passingGrade": 1,
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z",
    "updatedText": "2026-01-01T00:00:00.000Z",
    "narrationsGenerated": "2026-01-01T00:00:00.000Z",
    "aiGenerated": "2026-01-01T00:00:00.000Z",
    "deleted": "2026-01-01T00:00:00.000Z",
    "identifier": "user_123",
    "clientIdentifier": "client_123",
    "quizGroupUid": "example",
    "type": {
      "id": 1234,
      "name": "example",
      "title": "Workplace Safety",
      "icon": "example",
      "sequence": 1,
      "completable": false,
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z"
    },
    "questions": [
      {
        "id": 1234,
        "screenId": 1234,
        "sequence": 1,
        "text": "example",
        "typeId": 1234,
        "sourceId": 1234,
        "caseSensitive": false,
        "serverGraded": false,
        "correct": false,
        "completed": false,
        "matchOptions": [
          "example"
        ],
        "narrationAudioPath": "example",
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "questionType": {
          "id": 1234,
          "title": "Workplace Safety",
          "klass": "example",
          "template": "example",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z"
        }
      }
    ],
    "blocks": [
      {
        "id": 1234,
        "screenId": 1234,
        "uid": "example",
        "type": "example",
        "content": "example",
        "column": 1,
        "row": 1,
        "columnSpan": 1,
        "rowSpan": 1,
        "sequence": 1,
        "revision": 1,
        "questionId": 1234,
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "question": {
          "id": 1234,
          "screenId": 1234,
          "sequence": 1,
          "text": "example",
          "typeId": 1234,
          "sourceId": 1234,
          "caseSensitive": false,
          "serverGraded": false,
          "correct": false,
          "completed": false,
          "matchOptions": [
            "example"
          ],
          "narrationAudioPath": "example",
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "questionType": {
            "id": 1234,
            "title": "Workplace Safety",
            "klass": "example",
            "template": "example",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z"
          }
        }
      }
    ]
  },
  "finishScreen": {
    "quizAttemptId": 1234,
    "id": 1234,
    "uid": "example",
    "sequence": 1,
    "title": "Workplace Safety",
    "description": "example",
    "asset": "example",
    "assetAltText": "example",
    "assetSource": 1,
    "typeId": 1234,
    "background": null,
    "courseId": 1234,
    "clientId": 1234,
    "sourceId": 1234,
    "scored": false,
    "passingGrade": 1,
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z",
    "updatedText": "2026-01-01T00:00:00.000Z",
    "narrationsGenerated": "2026-01-01T00:00:00.000Z",
    "aiGenerated": "2026-01-01T00:00:00.000Z",
    "deleted": "2026-01-01T00:00:00.000Z",
    "identifier": "user_123",
    "clientIdentifier": "client_123",
    "quizGroupUid": "example",
    "type": {
      "id": 1234,
      "name": "example",
      "title": "Workplace Safety",
      "icon": "example",
      "sequence": 1,
      "completable": false,
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z"
    },
    "questions": [
      {
        "id": 1234,
        "screenId": 1234,
        "sequence": 1,
        "text": "example",
        "typeId": 1234,
        "sourceId": 1234,
        "caseSensitive": false,
        "serverGraded": false,
        "correct": false,
        "completed": false,
        "matchOptions": [
          "example"
        ],
        "narrationAudioPath": "example",
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "questionType": {
          "id": 1234,
          "title": "Workplace Safety",
          "klass": "example",
          "template": "example",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z"
        }
      }
    ],
    "blocks": [
      {
        "id": 1234,
        "screenId": 1234,
        "uid": "example",
        "type": "example",
        "content": "example",
        "column": 1,
        "row": 1,
        "columnSpan": 1,
        "rowSpan": 1,
        "sequence": 1,
        "revision": 1,
        "questionId": 1234,
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "question": {
          "id": 1234,
          "screenId": 1234,
          "sequence": 1,
          "text": "example",
          "typeId": 1234,
          "sourceId": 1234,
          "caseSensitive": false,
          "serverGraded": false,
          "correct": false,
          "completed": false,
          "matchOptions": [
            "example"
          ],
          "narrationAudioPath": "example",
          "aiGenerated": "2026-01-01T00:00:00.000Z",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z",
          "questionType": {
            "id": 1234,
            "title": "Workplace Safety",
            "klass": "example",
            "template": "example",
            "created": "2026-01-01T00:00:00.000Z",
            "updated": "2026-01-01T00:00:00.000Z"
          }
        }
      }
    ]
  },
  "translations": [
    "example"
  ],
  "translationCount": 12
}
```

<a id="generate-course-screen"></a>

## Generate a course screen

Use this endpoint to generate a single screen and persist it into an existing course. The generated screen is appended to the end of the course.

POST `/v1/headless/generate/course/{id}/screen`

#### Path parameters

| Field | Description | Options |
| --- | --- | --- |
| `id` | Course ID to add the generated screen to | — |

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `type` | `string` | Yes | Screen layout type to generate | `text` `process` `checklist` `flashcards` `list` |
| `title` | `string \| null` | No | Title for the screen | — |
| `prompt` | `string \| null` | No | Prompt describing what the screen should cover | — |
| `content` | `string \| null` | No | Source content to summarise into the screen | — |

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/headless/generate/course/1234/screen" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "type": "text",
    "title": "Workplace Safety",
    "prompt": "Create a short onboarding course.",
    "content": "example"
}'
```

#### Response

**JSON response**

```json
{
  "quizAttemptId": 1234,
  "id": 1234,
  "uid": "example",
  "sequence": 1,
  "title": "Workplace Safety",
  "description": "example",
  "asset": "example",
  "assetAltText": "example",
  "assetSource": 1,
  "typeId": 1234,
  "background": null,
  "courseId": 1234,
  "clientId": 1234,
  "sourceId": 1234,
  "scored": false,
  "passingGrade": 1,
  "created": "2026-01-01T00:00:00.000Z",
  "updated": "2026-01-01T00:00:00.000Z",
  "updatedText": "2026-01-01T00:00:00.000Z",
  "narrationsGenerated": "2026-01-01T00:00:00.000Z",
  "aiGenerated": "2026-01-01T00:00:00.000Z",
  "deleted": "2026-01-01T00:00:00.000Z",
  "identifier": "user_123",
  "clientIdentifier": "client_123",
  "quizGroupUid": "example",
  "type": {
    "id": 1234,
    "name": "example",
    "title": "Workplace Safety",
    "icon": "example",
    "sequence": 1,
    "completable": false,
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z"
  },
  "questions": [
    {
      "id": 1234,
      "screenId": 1234,
      "sequence": 1,
      "text": "example",
      "typeId": 1234,
      "sourceId": 1234,
      "caseSensitive": false,
      "serverGraded": false,
      "correct": false,
      "completed": false,
      "matchOptions": [
        "example"
      ],
      "narrationAudioPath": "example",
      "aiGenerated": "2026-01-01T00:00:00.000Z",
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z",
      "questionType": {
        "id": 1234,
        "title": "Workplace Safety",
        "klass": "example",
        "template": "example",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z"
      }
    }
  ],
  "blocks": [
    {
      "id": 1234,
      "screenId": 1234,
      "uid": "example",
      "type": "example",
      "content": "example",
      "column": 1,
      "row": 1,
      "columnSpan": 1,
      "rowSpan": 1,
      "sequence": 1,
      "revision": 1,
      "questionId": 1234,
      "aiGenerated": "2026-01-01T00:00:00.000Z",
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z",
      "question": {
        "id": 1234,
        "screenId": 1234,
        "sequence": 1,
        "text": "example",
        "typeId": 1234,
        "sourceId": 1234,
        "caseSensitive": false,
        "serverGraded": false,
        "correct": false,
        "completed": false,
        "matchOptions": [
          "example"
        ],
        "narrationAudioPath": "example",
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "questionType": {
          "id": 1234,
          "title": "Workplace Safety",
          "klass": "example",
          "template": "example",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z"
        }
      }
    }
  ]
}
```

<a id="generate-course-quiz"></a>

## Generate a course quiz

Use this endpoint to generate a complete quiz screen, including quiz intro content and persisted questions, inside an existing course.

POST `/v1/headless/generate/course/{id}/quiz`

#### Path parameters

| Field | Description | Options |
| --- | --- | --- |
| `id` | Course ID to add the generated quiz to | — |

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `prompt` | `string \| null` | No | Prompt describing what the quiz should cover | — |
| `content` | `string \| null` | No | Source content to draw questions from | — |
| `questionCount` | `number` | No | How many questions to generate | — |
| `questionTypes` | `string[]` | No | Question types to use (subset of: multipleChoiceImg, multipleResponse, trueFalse, writeAnswer, dropDown, matchCorresponding, matchSequence) | — |
| `scored` | `boolean` | No | Whether the quiz contributes to a pass/fail grade | — |
| `passingGrade` | `number` | No | Pass mark (percentage 0–100) when scored is true | — |

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/headless/generate/course/1234/quiz" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "prompt": "Create a short onboarding course.",
    "content": "example",
    "questionCount": 8,
    "questionTypes": [
        "example"
    ]
}'
```

#### Response

**JSON response**

```json
{
  "quizAttemptId": 1234,
  "id": 1234,
  "uid": "example",
  "sequence": 1,
  "title": "Workplace Safety",
  "description": "example",
  "asset": "example",
  "assetAltText": "example",
  "assetSource": 1,
  "typeId": 1234,
  "background": null,
  "courseId": 1234,
  "clientId": 1234,
  "sourceId": 1234,
  "scored": false,
  "passingGrade": 1,
  "created": "2026-01-01T00:00:00.000Z",
  "updated": "2026-01-01T00:00:00.000Z",
  "updatedText": "2026-01-01T00:00:00.000Z",
  "narrationsGenerated": "2026-01-01T00:00:00.000Z",
  "aiGenerated": "2026-01-01T00:00:00.000Z",
  "deleted": "2026-01-01T00:00:00.000Z",
  "identifier": "user_123",
  "clientIdentifier": "client_123",
  "quizGroupUid": "example",
  "type": {
    "id": 1234,
    "name": "example",
    "title": "Workplace Safety",
    "icon": "example",
    "sequence": 1,
    "completable": false,
    "created": "2026-01-01T00:00:00.000Z",
    "updated": "2026-01-01T00:00:00.000Z"
  },
  "questions": [
    {
      "id": 1234,
      "screenId": 1234,
      "sequence": 1,
      "text": "example",
      "typeId": 1234,
      "sourceId": 1234,
      "caseSensitive": false,
      "serverGraded": false,
      "correct": false,
      "completed": false,
      "matchOptions": [
        "example"
      ],
      "narrationAudioPath": "example",
      "aiGenerated": "2026-01-01T00:00:00.000Z",
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z",
      "questionType": {
        "id": 1234,
        "title": "Workplace Safety",
        "klass": "example",
        "template": "example",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z"
      }
    }
  ],
  "blocks": [
    {
      "id": 1234,
      "screenId": 1234,
      "uid": "example",
      "type": "example",
      "content": "example",
      "column": 1,
      "row": 1,
      "columnSpan": 1,
      "rowSpan": 1,
      "sequence": 1,
      "revision": 1,
      "questionId": 1234,
      "aiGenerated": "2026-01-01T00:00:00.000Z",
      "created": "2026-01-01T00:00:00.000Z",
      "updated": "2026-01-01T00:00:00.000Z",
      "question": {
        "id": 1234,
        "screenId": 1234,
        "sequence": 1,
        "text": "example",
        "typeId": 1234,
        "sourceId": 1234,
        "caseSensitive": false,
        "serverGraded": false,
        "correct": false,
        "completed": false,
        "matchOptions": [
          "example"
        ],
        "narrationAudioPath": "example",
        "aiGenerated": "2026-01-01T00:00:00.000Z",
        "created": "2026-01-01T00:00:00.000Z",
        "updated": "2026-01-01T00:00:00.000Z",
        "questionType": {
          "id": 1234,
          "title": "Workplace Safety",
          "klass": "example",
          "template": "example",
          "created": "2026-01-01T00:00:00.000Z",
          "updated": "2026-01-01T00:00:00.000Z"
        }
      }
    }
  ]
}
```
