HTTP surface
The schools API prefix, error body, pagination, versioning, webhooks, and controller map as implemented on the default branch.
Use this page to find a real path and the rules that apply to every call. It is a reference. How to sign in is Authentication across the platforms. How the server is built is Architecture.
Status. Controller prefixes were collected from @Controller on Naalya-API staging at a5dff0c208d5193c274d3d1f87787b55344d5d30. Method-level parameters are not copied here for every prefix. The running server publishes OpenAPI at /docs/swagger/json when it is up. The API repository does not commit an openapi.json. The website repository does, and that file is a stale subset. See The API client.
No call in this page was executed.
Prefix and versioning
bootstrap() in apps/server/src/main.ts calls:
app.setGlobalPrefix('api/v1', { exclude: ['queues', 'queues/{*path}'] })A controller declared as @Controller('students') is /api/v1/students. /queues is Bull Board and is outside the prefix.
apps/ehr/src/main.ts sets api/v1 with no exclude.
Neither main.ts calls enableVersioning. The v1 segment is a literal. A GitHub code search for enableVersioning across Naalya-API on 11 November 2026 returned no matches. Do not document a version header or a second prefix.
Outside development, /docs, /docs/swagger, and /docs/swagger/json require HTTP Basic auth (DOCS_USERNAME, DOCS_PASSWORD). The clinic API also serves a filtered spec at /api/v1/external/openapi.json with no password (PUBLIC_SPEC_PATH). Its title is Naalya Clinic API.
operationId is set by hand on @ApiOperation. It is not generated from the method name. The README asks for a short summary. That rule was not checked on every route.
Error body
AllExceptionsFilter is the APP_FILTER in AppModule. It writes ErrorResponseDto:
| Field | When it is present |
|---|---|
statusCode | Always |
error | Always |
message | Always. Validation arrays become the message Validation failed. |
details | Validation failures |
missingFields | When the filter has them |
attachments | When the filter has them |
path | Always |
timestamp | Always |
requestId | Always |
Unknown errors become HTTP 500 with message Unexpected error. An exposed 4xx from a parser, such as a body that is too large, keeps its status.
Auth-specific messages are on the authentication page. They use this same body.
Pagination
List endpoints that use the shared helper take CursorPaginationQueryDto from libs/shared/src/database/pagination/.
| Query parameter | Constraint |
|---|---|
limit | @Min(1) and @Max(100). cursorPaginate defaults a missing or non-positive limit to 10 and caps at 100. |
afterId | Cursor. Cannot be combined with beforeId. |
beforeId | Cursor. Combining both throws BadRequestException. |
search | Optional text |
filters | Optional. Operators named on the DTO are eq and in. |
startDate, endDate | Optional bounds |
CursorPaginatedResult is the return shape. CursorPaginatedResponseDto documents the same fields for Swagger:
| Field | Meaning |
|---|---|
data | The page of rows |
totalCount | Count of matching records, as the DTO describes it |
hasMore | Whether another page exists |
nextCursor | Pass as afterId. The type allows null. |
previousCursor | Pass as beforeId. The type allows null. |
Stop when hasMore is false, or when nextCursor is null. cursorPaginate was read at API fbb63d5178bcfe171292daebb19b6cbdac025a44. The throw strings, the default of 10, and the null cursors are on Querying and pagination. No list was called.
There is no “return every row” mode in this helper. Do not drop limit and expect an unbounded list. The default page size is 10.
Idempotency
main.ts does not install an Idempotency-Key middleware. A GitHub code search on 11 November 2026 for Idempotency-Key, idempotencyKey, and idempotency-key in Naalya-API returned no matches. A broader search for idempoten hits comments and unrelated names. It did not find a general header middleware.
Two implemented cases:
SchoolPayInboundService.ingestinserts with.orIgnore()on the receipt, so a repeat can return'duplicate'.NaalyaEhrWebhookController.receiveuses headerx-naalya-event-idas the BullMQjobId.
Other POST routes were not checked. Do not assume a retry is safe.
Webhooks and callbacks
| Method and path | Controller | Check |
|---|---|---|
POST /api/v1/social-connections/webhooks/messages and .../status | SocialConnectionWebhookController | Header unipile-signature. UnipileService.verifyWebhookSignature. Failure: 401 Invalid webhook signature. |
GET /api/v1/social-connections/callback | same | Hosted-auth redirect. Not a signed webhook. |
POST /api/v1/teams/messages | TeamsInboundController | An unknown bot app id is 404 before the SDK runs. The @microsoft/teams.apps handler then requires a valid Bot Framework or Entra JWT, else 401. See Channels. |
POST /api/v1/tenants/naalya/ehr/webhook | NaalyaEhrWebhookController | Signed clinic events. The body is under Clinic webhook body. |
POST /api/v1/transactions/school-pay/inbound/:campusId | SchoolPayInboundWebhookController | verifySignature. A bad signature is logged and the HTTP status stays 200. Inbox and pull: SchoolPay inbound. |
EHR WebhooksController (webhooks) registers outbound endpoints. It is not an inbound receiver. Outbound signing is signPayload / verifySignature in apps/ehr/src/webhooks/webhook-signature.ts: header x-naalya-signature is t=<unix seconds>,v1=<hex HMAC-SHA256>, tolerance 300 seconds. Also x-naalya-event-id, x-naalya-event, x-naalya-event-time. Secret prefix whsec_.
Clinic webhook body
POST /api/v1/tenants/naalya/ehr/webhook (receiveNaalyaClinicWebhook) is public. No webhook was sent.
When naalyaEhr.webhookSecret is unset, the handler throws NotFoundException with no message of its own. The signature header is x-naalya-signature, shaped t=<unix seconds>,v1=<hex>. The hex is HMAC-SHA256 of the timestamp, a dot, and the raw body, using that secret as the key. A missing header, a timestamp more than 300 seconds off, or a mismatch is 401 Signature check failed. A failed check logs the signature and the raw body. The inbound secret is used as given. The whsec_ prefix above belongs to the clinic's outbound signer, which was not re-opened.
The raw body is parsed as JSON and not checked against a DTO. A body that is not JSON throws from that parse, and the controller does not catch it.
| Field | What the handler does with it |
|---|---|
event | patient.created.hub and patient.updated.hub are queued. Any other value is acknowledged and not queued |
payload | The job data for those two events. ClinicPatient names patientId, campusName, firstName, lastName, otherNames, email, and proposedAccessCode. The handler does not check them |
patient | Optional on the handler's type, with an id, a patient number, and an email. It is not queued |
x-naalya-event-id is the BullMQ job id, including when the header is missing. The job allows 5 attempts, with exponential backoff starting at 60 seconds. A completed job is removed. The last 100 failed jobs are kept. A signature that passes always returns a message of Received, including an event that was ignored.
The link job was read. It does nothing when the clinic school id is unset. The confirm and problem calls on the clinic client were not opened. These are the problem strings the link service returns:
| Situation | Problem |
|---|---|
| Microsoft setup is not ready | The Hub cannot make Microsoft accounts yet |
| The email is not on the school domain | Use a school email ending in @ plus that domain |
| The campus name is unknown | Campus not found in the Hub |
| A new account needs a student licence and none is preselected | No student licences left |
| The address belongs to a staff user | This email belongs to a staff member in the Hub |
| The student id belongs to someone else | This student ID belongs to plus that person's first and last name |
No Pesapal inbound controller appeared in the @Controller search. NCDC_WEBHOOK_SECRET is mapped onto the Pinecone config. NcdcDocumentsController has no webhook method in the search.
POST /api/v1/microsoft-sync/webhook is MicrosoftSyncController.webhook (operationId microsoftSyncWebhook). It is @Public(). A validationToken query is echoed as text/plain with status 200. Otherwise each item in body.value is passed to enqueueNotification, and the handler returns 202 { "accepted": true } even when a notification is skipped. The operation text says routing and the per-school clientState check happen in the service. The other methods on microsoft-sync (subscriptions, sync-users) require the system role SOFTWARE_DEVELOPER. See Webhooks and subscriptions.
The website’s committed spec lists POST /api/v1/website/webhooks/unipile. That path was not in the schools API controller list above. Do not implement a client against the website spec until you see the path in the live schools API document.
Schools API controller prefixes
Every route, with its operation id and gates, is on Route reference.
Everything in this list is under /api/v1 unless noted. An empty @Controller() on a microservice class is not an HTTP prefix. Those classes are omitted (agent-tools.controller.ts and the other RMQ handlers named in the audit). subject-class.controller.ts and subject-teacher.controller.ts use an empty class prefix. The class and stream offering paths are on Subjects. The teacher-assignment paths were not extracted.
| Area | Prefixes |
|---|---|
| Meta | GET / (getHello), GET /debug-error, health |
| Identity | auth, auth/otp, auth/magic, auth/admission-capture, users, users/:userId/roles, roles, api-keys, guardians, guardians/:guardianId/card, guardian-cards, guardian-x-student, guests, staff, staff/:staffId/classrooms, students, students/:studentId/capture-requests |
| School structure | school, campus, campus/:campusId/academic-year, campus/:campusId/academic-year/:campusAcademicYearId/term, campus/:campusId/social-connections, departments, departments/:departmentId/members, streams, class, classes/:classId/teachers, classrooms, subjects, combinations, enrollment |
| Admissions and people ops | admission-applications, enquiry, enquiry/link, job-vacancies, job-applications, referrals (two controllers), letters. Methods, bodies, and auth for enquiry and enquiry/link are on Enquiries. |
| Teaching | curriculum (two), cbt/examinations, cbt/examinations/:examinationId/questions, cbt/examinations/:examinationId/streams, cbt/student, grading/assessments, grading/configs, grading/scores, grading/templates, grades, schemes-of-work, scheme-groups, scheme-governance, lesson-plans, lesson-planning/files, records-of-work, templates, report-cards, report-card-configs, report-card-templates, student/results |
| Calendar and devices | calendars, school-calendar, timetable, campuses/:campusId/timetables, elections, elections/:electionId/positions, student/elections, device, device-pairings, device/library/:commandId |
| Library | library/campuses/:campusId (catalogue, batch, settings), .../borrow, .../desk, .../labels, .../loans, .../report |
| Money | payment-gateways, payment-items, transactions, transactions/school-pay, ledger, ledger/school-pay |
| Comms and AI | notifications, notice-board, feedback, knowledge-base, naalya-ai, naalya-ai/guest, public-ai, ai-thread, ai-thread-file (two), whatsapp-alerts, whatsapp-templates, social-connections, social-agent-questions, teams (two) |
| Microsoft and files | microsoft-sync, microsoft-provisioning, drives, staff-files, staff-files/folders, storage |
| Platform | platform, platform/schools/:id/features, platform/templates, feature-flags, analytics, audit-logs, archive, address, list-filters, realtime, short-links, ncdc/documents, pip/documents, school-report, tenants/naalya/ehr |
collab has no HTTP controller. CollabService.attach hangs a websocket server on the HTTP server. Every API response from requestIdMiddleware also sets X-Served-By to the replica name. That header, and the Redis path behind /collab, are on Several copies. Read at API fbb63d5178bcfe171292daebb19b6cbdac025a44: request-id.middleware.ts. No response was captured.
Clinic API prefixes
Under /api/v1 on the EHR process (EHR_PORT, default 8100): auth, api-keys, campuses, external, external/patients (two controllers), external/visits, health, sync, users, users/:userId/roles, webhooks. Service points use an empty class prefix and method paths campuses/:campusId/service-points, service-points/:id, service-points/:id/retire.
Directories consultations, dispensary, lab, visits, and queues have modules and entities and no controller file in the listing that was read. Do not document HTTP routes for them.
Worked call
Unexecuted. Shows the health route and a cursor page. Use a development host.
curl --silent --show-error 'https://api.example.com/api/v1'curl --silent --show-error \
--header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
'https://api.example.com/api/v1/students?limit=10'YOUR_ACCESS_TOKEN is a placeholder. limit above is the default the helper applies when you omit it. The maximum is 100.
Related pages
Authentication
Login, OTP, magic link, API keys, and status codes.
Enquiries
Website submit, applicant thread, and staff updates.
Querying and pagination
How list endpoints are built in a module.
Error handling and logging
Throwing from a service, and what the filter does with it.
Audit record
What the next pass still has to document per operation.
Sources
Naalya-APIapps/server/src/main.tsbootstrap,apps/server/src/config/swagger.config.tssetupSwagger,AllExceptionsFilter,libs/shared/src/database/pagination/CursorPaginationQueryDto,CursorPaginatedResult,CursorPaginatedResponseDto- Controller prefixes from the
@Controllersearch described on the audit record - Clinic webhook body, read at API
f57b8103547bf5f3a33214e2c814a2e3c1bf1cc0and not called:naalya-ehr-webhook.controller.ts(receive),clinic-signature.ts(verifyClinicSignature,TOLERANCE_SECONDS),naalya-ehr.constants.ts(ClinicPatient),naalya-ehr-link.service.ts(LINK_JOB_OPTIONS,link,outcome).clinic-api.client.tswas not opened.