# Quickstart

Embed a Coassemble course in your product and verify that a learner can complete it.

[Open the brief for your AI](/setup/embed.md)

## API base and authentication

Use `https://api.coassemble.com/api` as your API base. Send the whole key as the `Authorization` header value without a Bearer prefix.

```text
Authorization: COASSEMBLE:<workspaceId>:<secret>
```

Store the key in your server environment as `COASSEMBLE_KEY`. Keep it out of browser code, email and AI chats.

## How to start

1. ### Have a course
   
   Done when the workspace has a course. New workspaces arrive with a sample.
2. ### Create a test key
   
   Test calls never bill, and learner sessions carry a Test mode badge. AI narration and images still count toward your allowance.
   
   ### Create a production key
   
   This key issues live learner sessions. Keep it on your server.
   
   Create the key in Developer > API keys. The available key modes depend on your workspace.
3. ### Make your first call
   
   Done when a call with your key gets a 2xx response.
   
   **cURL**
   
   ```bash
   curl https://api.coassemble.com/api/v1/headless/courses \
     -H "Authorization: $COASSEMBLE_KEY"
   ```
   
   **Node**
   
   ```javascript
   const response = await fetch('https://api.coassemble.com/api/v1/headless/courses', {
       headers: { Authorization: process.env.COASSEMBLE_KEY }
   });
   if (!response.ok) throw new Error(await response.text());
   const courses = await response.json();
   ```
   
   **Python**
   
   ```python
   import os, requests
   
   response = requests.get('https://api.coassemble.com/api/v1/headless/courses',
       headers={'Authorization': os.environ['COASSEMBLE_KEY']})
   response.raise_for_status()
   courses = response.json()
   ```
   
   Choose a published course from the response and use its numeric `id` as `courseId` in the next request.
4. ### Ask for a signed link
   
   Tell us the course and who is looking at it. Reuse one test identifier while you try it.
   
   **cURL**
   
   ```bash
   curl -X POST https://api.coassemble.com/api/v1/headless/embed/course \
     -H "Authorization: $COASSEMBLE_KEY" -H "Content-Type: application/json" \
     -d '{"action":"view","courseId":"<courseId from the courses response>","identifier":"test-anna"}'
   ```
   
   **Node**
   
   ```javascript
   const response = await fetch('https://api.coassemble.com/api/v1/headless/embed/course', {
       method: 'POST',
       headers: { Authorization: process.env.COASSEMBLE_KEY, 'Content-Type': 'application/json' },
       body: JSON.stringify({"action":"view","courseId":"<courseId from the courses response>","identifier":"test-anna"})
   });
   if (!response.ok) throw new Error(await response.text());
   const url = await response.text();
   ```
   
   **Python**
   
   ```python
   import os, requests
   
   response = requests.post('https://api.coassemble.com/api/v1/headless/embed/course',
       headers={'Authorization': os.environ['COASSEMBLE_KEY']},
       json={"action":"view","courseId":"<courseId from the courses response>","identifier":"test-anna"})
   response.raise_for_status()
   url = response.text
   ```
   
   Replace the quoted course ID placeholder with that number. Use a stable identifier from your own app for each live learner.
   
   Serving several customers? Add clientIdentifier only when you intend to create a separate client.
   
   The response is the signed URL as plain text. The link expires in 3 hours. Mint it server-side per learner per page load; do not store it.
5. ### Put it on your page
   
   Done when a learner opens the link, from your page or a browser tab.
   
   ```markup
   <iframe src="{signed link}" allow="fullscreen; autoplay; presentation; clipboard-write" width="100%" height="720"></iframe>
   ```
6. ### Prove a completion
   
   Done when an identified learner finishes through your integration.
   
   [Optional: get told when someone finishes. Add a webhook](/api/webhooks)

## [Clone the example](https://github.com/coassemble/embed-starter)

A small working integration: one serverless function that holds your key, and one page that shows your course.

Use Node 24 and a published course. Set `COASSEMBLE_KEY` in `.env` before running the last command.

```bash
git clone https://github.com/coassemble/embed-starter
cd embed-starter && cp .env.example .env    # paste your key into .env
npm install && COASSEMBLE_API_BASE='https://api.coassemble.com/api' npm run dev    # opens your course
```

You can send the brief to your developer from the setup guide in your workspace.
