# PageMeet API

For connecting an ERP or any other system to PageMeet. Current version: **1.3.0** (address prefix `/api/v1`).

## How it works

- Every request goes to `https://<your PageMeet address>/api/v1/...` and returns JSON.
- Every request carries an API key in a header: `Authorization: Bearer pm_...`
- A key belongs to one company and can do what an admin of that company can do. It never sees another company's data.
- Keys are made and revoked in the admin panel (API keys tab) by an admin or the owner. A key is shown once; PageMeet stores only its fingerprint.
- Keep the key on your server. Never put it in a web page or a mobile app.
- Limit: 600 requests per minute from one address. Over the limit you get status 429.
- Times are UTC in ISO 8601 form, for example `2026-11-24T09:00:00Z`.
- List addresses accept `?days=30` (1 to 366) where it says so below.

Example:

```
curl -H "Authorization: Bearer pm_your_key" https://meet.example.com/api/v1/classes
```

## Errors

Errors come back as `{ "error": "what went wrong" }` with one of these status codes:

| Status | Meaning |
|---|---|
| 400 | Something in the request is missing or not valid |
| 401 | Key missing, wrong or revoked |
| 403 | Not allowed |
| 404 | Not found, or not in your company |
| 409 | Already exists (for example an email that is taken), or your limit of classes at the same time is reached |
| 410 | The class has ended |
| 429 | Too many requests |

## Addresses

### Check the connection
`GET /api/v1` – returns the API version, your company, the key name and the list of features. Use it to test a key.

### Classes
| Method and address | What it does |
|---|---|
| `GET /api/v1/classes` | Every class link of your company. Add `?open=1` for links that have not been closed. |
| `POST /api/v1/classes` | Make a class link for a tutor. |
| `GET /api/v1/classes/{code}` | One class, with `liveNow` (people connected at this moment). |
| `POST /api/v1/classes/{code}/close` | End the class and close its link for good. Everyone in it is disconnected. |
| `GET /api/v1/classes/{code}/attendance` | Every join and leave: name, role, country, time. |
| `GET /api/v1/classes/{code}/chat` | The chat of that class, oldest first. |

`POST /api/v1/classes` body:

```json
{ "title": "Ali – Quran Qaidah", "tutorEmail": "tutor@example.com", "startsAt": "2026-12-01T14:00:00Z", "durationMin": 30 }
```

Two kinds of class link:

- **Controlled** (the usual kind): only the teacher the class was made for, or a teacher assigned to it, can lead it.
- **Open**: add `"open": true` when making the class. Anyone who has the link can tick "I am the teacher" on the join screen and lead the class, with no account. Use it for staff meetings, or where any available teacher takes the class. Recordings of an open class are filed under the teacher the link was made for. An open link in the wrong hands gives that person teacher control, so do not use it for lessons with children unless the link is only given to people you trust.

`title` and `tutorEmail` are required; the tutor must be an active account in your company. `startsAt` and `durationMin` are optional. The answer includes `code` and `joinUrl`, the link to give the student. The tutor opens the same link while logged in.

### Sign-in links (your system checks who the person is; PageMeet trusts the link)

With these, teachers and students never log in to PageMeet separately. They click a button in your system and land in the class.

| Method and address | What it does |
|---|---|
| `POST /api/v1/classes/{code}/tutor-link` | A link that signs the class's tutor in and opens the class. Works **once**, for 5 minutes (set `validMinutes`, 1 to 60). |
| `POST /api/v1/classes/{code}/student-link` | A link that puts a student into the class under the name you give. No name form. Valid 24 hours (set `validHours`, 1 to 720). |

Any teacher of your company can teach a class, not only the one it was made for. Add `"tutorEmail": "other.teacher@example.com"` to the `tutor-link` body and that teacher is assigned to the class and signed in as its tutor. The class link, its chat and its history stay the same. Recordings are filed under the teacher who actually taught.

| Method and address | What it does |
|---|---|
| `POST /api/v1/classes/{code}/assign` | Assign another teacher to the class without making a link: `{ "tutorEmail": "..." }`. With `"remove": true` the teacher is taken off again. The answer lists the owner and everyone else who may teach it. |

How to use the tutor link: when the teacher clicks "Start class" in your system, your server asks for a tutor link at that moment and sends the browser straight to the `url` in the answer. Do not make tutor links in advance or send them by message: whoever opens one is signed in as that teacher for 12 hours. Tutor links are refused for admin accounts.

`POST /api/v1/classes/{code}/student-link` body:

```json
{ "name": "Ali Khan", "studentId": "STU-1042", "validHours": 48 }
```

`name` is required. `studentId` is your own id for the student: with it, the same student is recognised as one person in every lesson of that class, whatever device they use. The link can be opened again until it expires, so it can go to a parent in advance. Anyone holding it joins as that student, so send it only to the family.

### Limit: classes at the same time

Your plan is counted in classes running at the same moment, not in users or links. You can have any number of teachers, students and class links.

- A class counts as running while a teacher is connected to it. Students waiting without a teacher do not count.
- `GET /api/v1` shows `maxLiveClasses` (empty means no limit) and `liveClassesNow`.
- When the limit is reached, `tutor-link` answers with status 409 and a message, and a teacher opening the class sees the same message. Students already in a running class are not affected.
- The limit is set by the PageMeet owner.

### Sessions and lessons
| Method and address | What it does |
|---|---|
| `GET /api/v1/sessions?days=30` | One row per lesson: start, end, minutes, tutor, each person's device, microphone, speaker, network delay, data use, what was used (microphone, camera, screen share, whiteboard, document), alerts, supervision, recordings. |
| `GET /api/v1/lessons?days=30` | Simpler attendance view: who came to which lesson and for how long. |
| `GET /api/v1/overview?days=30` | Totals: lessons, students, recordings, storage, classes live now. |

### Recordings
| Method and address | What it does |
|---|---|
| `GET /api/v1/recordings?days=30` | Recordings with class, tutor, students, length, size, status and how often they were played. |
| `GET /api/v1/recordings/{id}/audio` | The sound file (WebM/Opus). Tutor on the left channel, students on the right for recordings with `channels: 2`. Each download is written in the listen log. |
| `GET /api/v1/recordings/{id}/pictures` | The times (milliseconds from the start) of the pictures of the teaching page. |
| `GET /api/v1/recordings/{id}/pictures/{ms}` | One picture (JPEG). |

Recordings cannot be deleted or changed through the API or any other way.

### Alerts and activity
| Method and address | What it does |
|---|---|
| `GET /api/v1/alerts?days=30` | Messages that were refused (phone numbers, emails, links, social accounts, private-contact requests, blocked words): who, when, class, text. |
| `GET /api/v1/activity?days=30` | The latest 400 log entries: joins, leaves, permissions, recording start and stop, supervision. |

### People
| Method and address | What it does |
|---|---|
| `GET /api/v1/people` | Admins, supervisors and teachers of your company. |
| `POST /api/v1/people` | Add a supervisor or teacher. |

`POST /api/v1/people` body:

```json
{ "name": "Ustad Bilal", "email": "bilal@example.com", "role": "teacher", "supervisorId": "optional id of a supervisor" }
```

The answer includes a first password, shown this one time only. Give it to the person and ask them to change it.

## What the API cannot do

- Delete or change recordings, chat, alerts or logs.
- Make or revoke API keys, or change the blocked-words list (admin panel only).
- See or change another company.
- Take part in a class itself; it manages, reports and makes sign-in links.

## Versions

| Version | Date | Changes |
|---|---|---|
| 1.3.0 | 2026-11-24 | Open class links (`open: true`): anyone with the link may lead the class. |
| 1.2.0 | 2026-11-24 | Any teacher of the company can teach a class (`tutorEmail` on `tutor-link`, and `assign`). Limit by classes running at the same time (`maxLiveClasses`, status 409 when full). |
| 1.1.0 | 2026-11-24 | Sign-in links: `tutor-link` (works once) and `student-link` (name set by your system). |
| 1.0.0 | 2026-11-24 | First version: classes (list, create, close, attendance, chat), sessions, lessons, overview, recordings (list, audio, pictures), alerts, activity, people (list, create). |

Rules for future versions: new fields and new addresses may be added to version 1 at any time, so your code should ignore fields it does not know. Anything that would break existing code will come as `/api/v2`, and `/api/v1` will keep working alongside it.
