Naalya Handbook
School features

Enquiries

Public website enquiries, signed-in applicant threads, staff updates, and the WhatsApp enquiry link.

Use this page to call the enquiry routes or to see which caller each one accepts. Admission applications are a different resource. See Admissions.

All paths are under /api/v1; errors use the shared error shape. EnquiryController carries @RequireFeature(Feature.ADMISSIONS). The website submit is @Public(), so the decorator skips it, but EnquiryService.create checks the flag itself and throws Feature not enabled: admissions (FEATURE_DISABLED).

Submit from a website

POST /api/v1/enquiry

operationIdsubmitEnquiry
Authx-api-key. ApiKeyAuth('secret', 'publishable'). A publishable key must send an allowed Origin.
Feature flagNot applied. The method is public.
Success201, EnquiryDto
LimitsApiKeyRateLimitGuard: 60 a minute per key, plus 10 a minute per IP for publishable keys, counted in Redis so every API copy shares them

Body (CreateEnquiryDto):

FieldRequiredWhat the API does with it
nameyesStored as the enquirer's name. Any string.
phoneyesStored as sent. The WhatsApp follow link goes to this number, which is normalised to E.164 when the link is sent.
subjectyesStored as the enquiry's subject. Any string.
messageyesStored as the first message. Any string.
emailnoMust be an email address. Stored, but never used to match an existing account, because the form does not prove it.
classnoStored as free text. It is not checked against the school's classes.
typenoenquiry, contact, or admission. Omitted means the column default, admission.
referralCodenoStored as sent. Spaces are removed and letters are upper-cased for the lookup. A match links the enquiry to that referrer. An unknown code is kept and links nothing.

The four required strings are @IsString() only, so an empty string passes and there is no length limit. The school comes from the API key, not the body.

Documented errors: 400 validation, 401 missing or unknown key, 403 wrong key kind or origin, 429 rate limit.

Unexecuted example. YOUR_API_KEY is a placeholder.

curl --silent --show-error \
  --request POST 'https://api.example.com/api/v1/enquiry' \
  --header 'content-type: application/json' \
  --header 'x-api-key: YOUR_API_KEY' \
  --data '{"name":"Amal O.","phone":"+256700000000","subject":"S1 admission","message":"We would like a prospectus.","type":"admission"}'

Signed-in applicant

These three require a bearer token and userType guest or guardian. They are not @Public(), so the admissions feature flag runs.

Method and pathoperationIdBodySuccess
POST /api/v1/enquiry/minesubmitMyEnquirysubject (string, max 160), message (string, max 4000), optional type (same enum; the DTO says it defaults to enquiry)201 EnquiryDto
GET /api/v1/enquiry/minelistMyEnquiriesnone200, array of MyEnquiryDto
POST /api/v1/enquiry/mine/:id/repliesreplyToMyEnquirybody, string, required, max 4000. Blank after trim is Reply cannot be empty.201 EnquiryThreadEntryDto
POST /api/v1/enquiry/mine/:id/typingsignalMyEnquiryTypingnone204

submitMyEnquiry takes the name, phone, and email from the account. Do not send them in the body.

Staff

Bearer token. Permissions are on enquiry.

Method and pathoperationIdWhoSuccess
GET /api/v1/enquirylistEnquirieslist200 EnquiryListResponseDto
GET /api/v1/enquiry/:idgetEnquiryread200 EnquiryDto. 404 Enquiry not found.
POST /api/v1/enquiry/:id/repliesreplyToEnquirystaff, and update201 thread entry
POST /api/v1/enquiry/:id/typingsignalEnquiryTypingstaff, and read204
PATCH /api/v1/enquiry/:id/assignassignEnquiryupdate200. Body field assignedToId.
PATCH /api/v1/enquiry/:id/statusupdateEnquiryStatusupdate200. Body field status.
GET /api/v1/enquiry/:id/status-historygetEnquiryStatusHistoryreadThe handler returns the service value. No response DTO is declared on the method.
PATCH /api/v1/enquiry/:id/priorityupdateEnquiryPriorityupdate200. Body field priority.
PATCH /api/v1/enquiry/:id/notesaddEnquiryNotesupdate200. Body field notes.
DELETE /api/v1/enquiry/:iddeleteEnquirydelete200 { "message": "Enquiry deleted successfully" }. The operation says this soft-deletes the enquiry and its conversation.
StatusEffect
newDefault. A staff reply moves it to contacted
contactedSet by a staff reply to a new enquiry, or by a status change. Replies are still accepted
completedStamps resolvedAt; replies refused with This enquiry is completed
closedStamps closedAt; replies refused with This enquiry is closed

Any status can be set from any other. A change adds a status-history row and an empty staff entry in the thread; setting the current status does nothing. Priority is low, medium or high.

Replies are trimmed; a blank one is Reply cannot be empty. Applicant replies don't change status. Another user's enquiry looks like Enquiry not found. The owner is notified of staff replies, without WhatsApp if they're watching the thread.

Assign writes assignedToId, assignedById (the caller) and assignedAt, without checking the target staff exists. Delete soft-deletes only the enquiry row; the thread rows stay, although the operation text says the conversation is deleted too.

List query (ListEnquiriesFilterDto extends the cursor query):

QueryConstraint
statusoptional enum above
assignedTooptional UUID
userIdoptional UUID. The DTO describes this as the enquirer’s account.
priorityoptional enum above
sortoptional newest, oldest, priority, or status. Omitted means newest.

The shared cursor filters JSON also works, limited to ENQUIRY_FILTER_FIELDS (status, priority, type, assignedToId, whatsappConfirmed, eq only). EnquiryService.list applies both, together with the cursor search.

Counts

Three analytics routes, each needing read on analytics. All count non-deleted enquiries created in the date window (default the last 30 days, end date inclusive). The operation text mentions a campus filter, but applyStatsFilters ignores it.

RouteServiceReturns
GET /analytics/enquiriesgetStatstotal, unassignedCount, averageResolutionTimeSeconds (resolved minus created, or 0), byStatus, byPriority, dailyTimeline; plus newThisMonth and recent (five newest), which ignore the window
GET /analytics/enquiries/by-periodgetStatsByPeriod{ period, data: [{ date, count }] }, period default daily
GET /analytics/enquiries/by-staffgetStatsByStaffPer assigned staff member: assignedCount, resolvedCount, resolutionRate; unassigned rows skipped

EnquiryLinkController is @Controller('enquiry/link'). Both methods are @Public(), use ClientIpThrottlerGuard, and take { "token": "..." } (EnquiryLinkTokenDto, non-empty string). The operation text says the token is hashed before lookup and that the route is POST only.

Method and pathoperationIdThrottle on the methodSuccess
POST /api/v1/enquiry/link/verifyverifyEnquiryLink10 per 60 seconds200 VerifyEnquiryLinkResponseDto
POST /api/v1/enquiry/link/resendresendEnquiryLink5 per 60 seconds200 RequestMagicLinkResponseDto

verify response:

FieldWhen
statussigned_in, used, or expired
enquiryIdalways, on this DTO
accessToken, refreshTokenthe DTO says only when status is signed_in
maskedPhonethe DTO says only when the link is used or expired. It is the last three digits, not the full number.
channeloptional 'email', when the link was sent by email
Link stateverify answers
Unused, under 30 days old200, signed_in, with session tokens. The link is used up
Already used, or lost a race to claim it200, used, with maskedPhone (last three digits) or channel: email; no tokens
Over 30 days old (ENQUIRY_LINK_TTL_DAYS)200, expired
Unknown token, or the account is inactive, in another school, or not a guest or guardian401 This link is not valid

Tokens are looked up by SHA-256 hash. resend sends a fresh magic link for any known token, used or not, except email-channel links (Sign in with your email address to see your enquiry.). See Authentication.

On this page