# Exam Room Allocation (VN) API

> Allocate candidates to exam rooms: candidate numbers in Vietnamese alphabetical order by given name, seats, mixed classes, posted lists as XLSX.

- Endpoint: `POST https://apibox.io.vn/v1/vn-exam-rooms`
- Category: Data & JSON
- HTML docs: https://apibox.io.vn/docs/vn-exam-rooms/ (Vietnamese: https://apibox.io.vn/vi/docs/vn-exam-rooms/)
- Online tool: https://apibox.io.vn/tools/vn-exam-rooms/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send the candidate list as `students` (JSON array, CSV text or an uploaded CSV / XLSX `file`; Vietnamese headers such as `ho_ten`, `lop`, `ngay_sinh` are recognised) and the rooms (`rooms` as a number or `[{ name, capacity }]`, or just `capacity`, default 24). Candidates are ordered like Vietnamese class lists – by given name, then family and middle names, with the Vietnamese collation of /v1/vn-sort (An < Anh < Ánh < Bình, đ after d) – or by `order=class`, `random` (reproducible with `seed`) or `given`.

Candidate numbers (`sbd_prefix`, `sbd_start`, `sbd_digits`) follow that order; rooms are filled to capacity (`fill=sequential`) or evenly (`balanced`), and `interleave_classes=true` seats neighbours from different classes. Extra columns (subject, exam code…) are kept on each candidate.

`format=xlsx` gives the master list plus one sheet per room to post on the door and use as the signature sheet (sheets, exam code, signature, invigilators). Nothing is stored.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `students` | body | array | yes |  | Candidates: JSON `[{ ho_ten, lop, ngay_sinh, … }]`, CSV text, or `file` (CSV / XLSX). |
| `file` | body | file | no |  | CSV or XLSX list (multipart). |
| `rooms` | body | array | no |  | Number of rooms or `[{ name, capacity }]`. |
| `capacity` | body | number | no | `24` | Seats per room. |
| `order` | body | string | no | `name` | `name`, `class`, `random` (+ `seed`) or `given`. |
| `sbd_prefix` | body | string | no |  | Candidate-number prefix; `sbd_start` (1), `sbd_digits`. |
| `fill` | body | string | no | `sequential` | `sequential` or `balanced`; `interleave_classes=true` to mix classes. |
| `format` | body | string | no | `json` | `json` or `xlsx` (with `exam`, `school`). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/vn-exam-rooms" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"students":[{"ho_ten":"Nguyễn Văn Bình","lop":"9A"},{"ho_ten":"Trần Thị An","lop":"9B"},{"ho_ten":"Lê Văn Đức","lop":"9A"}],"capacity":2,"sbd_prefix":"HK1-"}'
```

## Example response

```json
{
  "count": 3,
  "rooms": [
    {
      "room": "Phòng 01",
      "capacity": 2,
      "candidates": 2,
      "sbd_from": "HK1-001",
      "sbd_to": "HK1-002"
    },
    {
      "room": "Phòng 02",
      "capacity": 2,
      "candidates": 1,
      "sbd_from": "HK1-003",
      "sbd_to": "HK1-003"
    }
  ],
  "order": "name",
  "fill": "sequential",
  "interleave_classes": false,
  "candidates": [
    {
      "sbd": "HK1-001",
      "name": "Trần Thị An",
      "class": "9B",
      "dob": null,
      "room": "Phòng 01",
      "seat": 1
    },
    {
      "sbd": "HK1-002",
      "name": "Nguyễn Văn Bình",
      "class": "9A",
      "dob": null,
      "room": "Phòng 01",
      "seat": 2
    },
    {
      "sbd": "HK1-003",
      "name": "Lê Văn Đức",
      "class": "9A",
      "dob": null,
      "room": "Phòng 02",
      "seat": 1
    }
  ],
  "privacy": "Nothing you send is stored."
}
```

## Use cases

- Prepare rooms and candidate numbers for the term exams
- Run internal company tests with mixed departments per room
- Generate the door lists and signature sheets as Excel
- Number candidates of a mock exam at a tutoring centre

## FAQ

### How are Vietnamese names sorted?

By given name first (the last word), then family and middle names, letter by letter in the Vietnamese alphabet with tone order ngang, huyền, hỏi, ngã, sắc, nặng.

### Can I keep the same random order next time?

Yes: order=random with the same seed always gives the same order.

### Is there a PDF admission card?

Not yet: use the XLSX sheets, or fill a card template with /v1/docx-template.
