Naya People · API Specification

Condo Chatbot API v1: Integration Specification

Lets an integrator's system (a building app, a website chat widget, etc.) send a resident's messages to the condo juristic office's Q&A assistant and get back the same answers the resident would get by asking through the building's LINE Official Account.

Versionv1Updated4 Nov 2026Base URL<API_URL>/api/v1FormatJSON · UTF-8

1Overview

TopicDetails
Base URL<API_URL>/api/v1 · Naya People provides the <API_URL> value together with your API key
ProtocolHTTPS only
Data formatJSON, UTF-8 · requests with a body must send Content-Type: application/json
AuthenticationX-API-Key header (section 2)
Calling modelServer-to-server only · the API does not enable CORS
Available buildingsAs agreed with Naya People · list the place_id values your key can use with GET /places

What this API does

  • Answers questions from the rules and information the juristic office has written
  • Remembers conversation context, so follow-ups work ("what about Saturday?")
  • Asks back with options when a question is too broad
  • Sends images with an answer
  • Says so plainly when it has no information, instead of guessing

What this API does not do

  • File repair requests, take payments, book facilities or change data in any system
  • Hand questions to juristic office staff in real time
  • Access residents' conversations held over LINE
  • Accept staff commands (such as /งาน); such messages are treated as ordinary questions
  • Accept images or files from residents (text only)

2Authentication

HeaderTypeRequiredDescription
X-API-KeystringEvery requestAPI key issued by Naya People (at least 24 characters)
  • Each key belongs to one integrator (a client name such as partner-app) and may be restricted to certain buildings
  • Missing header or invalid key → 401 unauthorized · using a building the key has no rights to → 403 place_forbidden
  • Naya People delivers keys through a secure channel separate from this document · keys do not expire; they work until revoked
The API key is a server-side secret

Never embed the key in a mobile app, browser JavaScript, a repository or logs · the API does not answer CORS, so browsers cannot call it directly; apps must always go through the integrator's backend

Key rotation

(1) Naya People issues a new key while the old one still works (2) the integrator switches to the new key (3) Naya People revokes the old key · no downtime is needed, and residents' conversations are kept intact because conversations are tied to the client name, not the key

3General conventions

3.1 Path parameters

NameTypePatternDescription
place_idstring^[a-z0-9-]{1,24}$Building · values your key can use come from GET /places · unknown building → 404 place_not_found (the system never answers from another building's data instead)
user_idstring^[A-Za-z0-9_.@-]{1,128}$Resident · chosen by the integrator (see 3.2)

3.2 user_id requirements

  • Must be stable per resident. One resident = one conversation (like a 1:1 LINE chat) · changing the user_id starts a new conversation and the bot forgets earlier context
  • Should be an internal id that does not identify the person, e.g. usr_8f3a2c · do not use phone numbers, emails or national ID numbers
  • To keep separate conversations per unit for the same resident, put the unit in the id, e.g. usr_8f3a2c.r1203
  • Percent-encode it in the URL as usual (@ → %40 is accepted) · values containing / cannot be used
Conversations are fully isolated

The conversation key is built from building + client name + hash of user_id · the same user_id from two integrators is two conversations · the same resident in two buildings is two conversations · and there is no way to reach a resident's LINE conversation

3.3 Data formats

TopicRule
Timedatetime = ISO 8601 in UTC, e.g. 2026-11-04T03:12:08.114Z
Datedate = YYYY-MM-DD · a "day" in usage reports is a Bangkok-time day (UTC+7)
Message lengthCounted in characters (Unicode code points) · Thai vowels and tone marks each count separately
null vs. emptynull = could not be read, or no value · [] / 0 = read successfully and genuinely empty (never treat the two the same)

3.4 Version compatibility

  • New endpoints, new response fields or new enum values (e.g. outcome) are not breaking changes · clients must ignore fields they do not recognise
  • Breaking changes will ship as /api/v2 with advance notice

4Endpoints

MethodPathPurposeQuota counted
POST/places/{place_id}/users/{user_id}/messagesSend a message, get the answerkey + resident
GET/places/{place_id}/users/{user_id}/messagesConversation historykey
DELETE/places/{place_id}/users/{user_id}/messagesDelete conversation historykey
GET/placesBuildings the key can usekey
GET/places/{place_id}/topicsTopics the bot can answerkey
GET/usageDaily message counts + current key quotaseparate (30/min)
GET/places/{place_id}/users/{user_id}/usageCurrent quota of one residentseparate (30/min)

Every path is relative to the Base URL <API_URL>/api/v1 and every request needs X-API-Key · any endpoint may also return 401 429 503 not_configured in addition to those listed

4.1 Send a message

POST/places/{place_id}/users/{user_id}/messages

Sends one resident message and returns the answer in the same response (synchronous) · the message and the answer are saved to the conversation history

Parameters

NameInTypeRequiredDescription
place_idpathstring✓Building
user_idpathstring✓Resident
X-API-Keyheaderstring✓API key
Content-Typeheaderstring✓application/json

Request body

FieldTypeRequiredConstraintsDescription
messagestring✓1–1000 charactersThe resident's message · too long is rejected (422), never truncated · whitespace only → 422 empty_message
display_namestring–≤ 100 charactersHow to address the resident · the bot may use the name at most once per conversation and never opens a message with it · omit = no name · not saved to history
Request body
{
  "message": "ล้างแอร์วันเสาร์ได้ไหม",
  "display_name": "สมชาย"
}

Responses

StatusBodyWhen
200ChatReplyAnswer returned (including when there is no information: outcome = "no_context")
403Error place_forbiddenThis key cannot use this building
404Error place_not_foundUnknown place_id
422empty_message or ValidationErrorMalformed body
429Error rate_limitedKey or resident quota exceeded · the message was not processed
503Error upstream_unavailableAnswer generation failed · message is an apology you can show the resident · the message was saved
200 · ChatReply
{
  "reply": "ช่างล้างแอร์เข้าห้องได้เฉพาะวันจันทร์–ศุกร์ 09.00–17.00 น. ค่ะ\n\nวันเสาร์–อาทิตย์และวันหยุดนักขัตฤกษ์ยังไม่อนุญาตให้ช่างภายนอกเข้าทำงานนะคะ",
  "outcome": "answer",
  "options": [],
  "images": [],
  "latency_ms": 2140
}

4.2 Read conversation history

GET/places/{place_id}/users/{user_id}/messages

The most recent messages of the conversation, oldest first

Parameters

NameInTypeRequiredDefaultDescription
place_idpathstring✓–Building
user_idpathstring✓–Resident
limitqueryinteger–50Number of latest messages, 1–200

Responses

StatusBodyWhen
200TranscriptRead OK · messages: [] = no conversation yet
403 / 404ErrorSame as 4.1
422ValidationErrorlimit or path is malformed
503Error history_unavailableHistory temporarily unreadable (not an empty list)
200 · Transcript
{
  "messages": [
    { "role": "user",      "text": "ล้างแอร์วันเสาร์ได้ไหม",         "outcome": "answer", "created_at": "2026-11-04T03:12:08.114Z" },
    { "role": "assistant", "text": "ช่างล้างแอร์เข้าห้องได้เฉพาะ...", "outcome": "answer", "created_at": "2026-11-04T03:12:08.114Z" }
  ]
}
  • A question/answer pair shares the same created_at and outcome · outcome in history can be error (turns that got 503 upstream_unavailable)
  • The assistant text excludes what the system appends when sending (the building's app link, the juristic office phone number — section 6.1). If you need history that matches what the resident saw character for character, store reply on your side
  • Rejected messages (401/403/404/422/429) are not in history · very old history may be removed under the juristic office's retention policy

4.3 Delete conversation history

DELETE/places/{place_id}/users/{user_id}/messages

Use when a resident asks for their data to be deleted, deletes their account, or wants a fresh conversation · the next message starts with no prior context · safe to call repeatedly

Parameters

NameInTypeRequiredDescription
place_idpathstring✓Building
user_idpathstring✓Resident

Responses

StatusBodyWhen
200{ "removed": integer }Deleted · removed = number of messages deleted (0 if there was no history)
403 / 404ErrorSame as 4.1
503Error history_unavailableDeletion failed (never answered as removed: 0) · retry until you get 200
200
{ "removed": 6 }

Deleting does not affect the aggregate stats in /usage, which hold no personal data anyway

4.4 Buildings this key can use

GET/places

Use it to check your setup when integrating, or as a health check (no AI call)

Responses

StatusBodyWhen
200{ "places": string[] }The place_id values this key can use
200
{ "places": ["sample-condo"] }

4.5 Topics the bot can answer

GET/places/{place_id}/topics

Topics the juristic office has written answers for, grouped by category · use it for a "what can I ask?" page or suggested questions · contains no answer content

Parameters

NameInTypeRequiredDescription
place_idpathstring✓Building

Responses

StatusBodyWhen
200TopicsRead OK
403 / 404ErrorSame as 4.1
503Error topics_unavailableKnowledge base temporarily unreadable (not an empty list)
200 · Topics
{
  "place": "sample-condo",
  "count": 224,
  "categories": [
    {
      "name": "ช่าง",
      "topics": [
        { "topic": "เวลาช่างภายนอกเข้าห้อง", "updated_at": "2026-10-24T08:46:14.000Z" },
        { "topic": "ล้างแอร์", "updated_at": "2026-10-21T02:10:00.000Z" }
      ]
    }
  ]
}
  • Only topics the bot can currently answer from · topics change whenever the juristic office edits the knowledge base, so cache for at most 1 hour
  • Topics are written from the document's point of view, not as questions · to use them as suggested questions, turn them into a question first, e.g. "ล้างแอร์" (air-con cleaning) → "ขอข้อมูลเรื่องล้างแอร์" (tell me about air-con cleaning)

4.6 Key usage

GET/usage

Daily message counts for this key, split by building and outcome, plus the current quota status · has its own quota of 30 calls/minute, does not use the messaging quota, and works even when the messaging quota is exhausted

Parameters

NameInTypeRequiredDefaultDescription
daysqueryinteger–7Days to look back, 1–90 (including today), in Bangkok-time days

Responses

StatusBodyWhen
200UsageAlways · if stats cannot be read, daily and totals are null (not zero)
422ValidationErrordays out of range
200 · Usage
{
  "client": "partner-app",
  "rate_limits": [
    { "name": "client_per_minute", "window_seconds": 60, "limit": 120,
      "used": 3, "remaining": 117, "resets_in_seconds": 41 }
  ],
  "days": 7,
  "daily": [
    { "date": "2026-11-03", "place": "sample-condo", "messages": 12,
      "outcomes": { "answer": 9, "no_context": 2, "smalltalk": 1 } }
  ],
  "totals": { "messages": 12, "outcomes": { "answer": 9, "no_context": 2, "smalltalk": 1 } }
}
  • Counts every message the API processed, including error (got a 503 but was really handled) · rejected messages (401/403/404/422/429) are not counted
  • Days without messages do not appear in daily · daily: [] = genuinely no messages in that period

4.7 Quota of one resident

GET/places/{place_id}/users/{user_id}/usage

Current quota status of one resident (and of the key) · use it to show how many questions are left, or to find the cause of a 429 · shares the 30 calls/minute quota with /usage

Parameters

NameInTypeRequiredDescription
place_idpathstring✓Building
user_idpathstring✓Resident

Responses

StatusBodyWhen
200UserUsageAlways
403 / 404ErrorSame as 4.1
200 · UserUsage
{
  "place": "sample-condo",
  "user_id": "usr_8f3a2c",
  "rate_limits": [
    { "name": "client_per_minute", "window_seconds": 60,    "limit": 120, "used": 3, "remaining": 117, "resets_in_seconds": 41 },
    { "name": "user_per_minute",   "window_seconds": 60,    "limit": 10,  "used": 1, "remaining": 9,   "resets_in_seconds": 52 },
    { "name": "user_per_day",      "window_seconds": 86400, "limit": 200, "used": 7, "remaining": 193, "resets_in_seconds": 61200 }
  ]
}

5Data models

Types: string · integer · datetime · date · X[] = array of X · X | null = may be null · every field in these tables is always present in the response

ChatReply

FieldTypeDescription
replystringThe text to show the resident · plain text (section 6.1)
outcomestring (enum)answer · no_context · smalltalk · unclear · ambiguous (section 6.2) · new values may be added
optionsOption[]Tappable options · only set when outcome = "ambiguous", at most 3 · otherwise []
imagesImage[]Images for the answer · usually []
latency_msintegerServer-side time spent producing the answer (milliseconds)

Option

FieldTypeDescription
labelstringButton text (roughly 20 characters at most)
questionstringText to send back as a new message when the resident taps this button

Image

FieldTypeDescription
urlstringFull-size image · public HTTPS (no API key needed)
preview_urlstringThumbnail for the chat · public HTTPS

Transcript / TranscriptMessage

FieldTypeDescription
messagesTranscriptMessage[]Oldest first
messages[].rolestring (enum)user (resident) · assistant (bot)
messages[].textstringMessage text · for assistant, excludes what was appended when sending
messages[].outcomestring (enum)Same values as ChatReply.outcome, and may be error
messages[].created_atdatetimeWhen it was saved (UTC)

Topics

FieldTypeDescription
placestringBuilding
countintegerTotal number of topics
categoriesTopicCategory[]Categories
categories[].namestringCategory name (in the juristic office's language, mostly Thai)
categories[].topics[].topicstringTopic name
categories[].topics[].updated_atdatetime | nullLast edited

RateWindow

FieldTypeDescription
namestring (enum)client_per_minute · user_per_minute · user_per_day (section 8)
window_secondsintegerWindow length (60 or 86400)
limitinteger | nullCeiling · null = this limit is disabled
usedinteger | nullUsed in the current window · null when limit is null
remaininginteger | nullRemaining · null when limit is null
resets_in_secondsinteger | nullSeconds until used drops (the oldest request leaves the window) · null when nothing has been used yet

Usage

FieldTypeDescription
clientstringClient name of the key
rate_limitsRateWindow[]Key quota (client_per_minute)
daysintegerNumber of days requested
dailyUsageDay[] | nullPer day, sorted by date then building · null = stats could not be read
daily[].datedateBangkok-time day
daily[].placestringBuilding
daily[].messagesintegerNumber of messages
daily[].outcomesobject{ outcome: count } · only outcomes that occurred (including error)
totalsobject | null{ messages, outcomes } for the whole period · null = stats could not be read

UserUsage

FieldTypeDescription
placestringBuilding
user_idstringSame value you sent
rate_limitsRateWindow[]client_per_minute, user_per_minute, user_per_day, in that order

Error

FieldTypeDescription
detail.errorstringMachine-readable error code (stable — section 7)
detail.messagestringHuman-readable description (wording may change; never compare it in code)
Error
{ "detail": { "error": "rate_limited", "message": "Too many requests. Retry after 38 seconds." } }

ValidationError (422)

FieldTypeDescription
detailobject[]One entry per problem
detail[].typestringKind of problem, e.g. missing, string_too_long, string_pattern_mismatch
detail[].loc(string | integer)[]Location, e.g. ["body", "message"], ["path", "user_id"], ["query", "limit"]
detail[].msgstringDescription
ValidationError
{
  "detail": [
    { "type": "string_too_long", "loc": ["body", "message"],
      "msg": "String should have at most 1000 characters" }
  ]
}

6Displaying answers

6.1 reply

  • Plain text, no Markdown or HTML · preserve line breaks (\n) · a blank line (\n\n) separates paragraphs · list items start with •
  • When showing it on a web page, always escape it as text. Never insert it as HTML, because an answer may echo what the resident typed
  • May contain emoji
  • Regular answers and greetings are in the language the resident wrote in (Thai or English) · some canned messages (no information, system error, the end of an ask-back) contain both Thai and English in one message, separated by a blank line
  • The system may append two kinds of text, depending on each building's settings (only in reply, never in history):
    • Answers that mention the building's app → the building's app link (if the juristic office has configured one) on its own line · make the URL tappable, or replace it with in-app navigation in your own app
    • Answers that suggest contacting the juristic office → that building's juristic office phone number (as configured), if the text does not already include one · make the number a tap-to-call link
  • Never edit the content of an answer. Phone numbers, office hours, fines and so on come from the juristic office's documents

6.2 outcome

ValueMeaningWhat to do
answerAnswered from the building's informationShow reply (+ images if any)
no_contextThe building's documents have nothing on thisShow reply, which apologises and gives the juristic office contact · you may use it as a signal to open a ticket for your own staff
smalltalkGreeting, thanks or acknowledgement ("ok", "thanks")Show reply
unclearThe message could not be understoodShow reply, which asks the resident to rephrase
ambiguousBroad question matching several topics, so the bot asks backShow reply + buttons from options (section 6.3)
OtherValues added in the futureTreat as answer
Unanswerable questions are not sent to staff in real time

no_context questions coming through the API are not posted to the juristic office staff group; they are collected in the unanswered-questions report the office uses to improve its information later

6.3 Options (outcome = "ambiguous")

200 · ChatReply (ambiguous)
{
  "reply": "เรื่องล้างแอร์ มีหลายแบบนะคะ ไม่ทราบว่าสนใจเรื่องไหนคะ\n\n• จองคิวล้างแอร์\n• เวลาช่างล้างแอร์เข้าห้อง\n\nกดเลือกด้านล่างได้เลยค่ะ หรือจะพิมพ์บอกเพิ่มอีกนิดก็ได้นะคะ 🙏\n\nThis could mean a few different things — tap one below, or just tell me a bit more.",
  "outcome": "ambiguous",
  "options": [
    { "label": "จองคิวล้างแอร์",           "question": "ต้องการจองคิวล้างแอร์" },
    { "label": "เวลาช่างล้างแอร์เข้าห้อง", "question": "ช่างล้างแอร์เข้าห้องได้กี่โมง" }
  ],
  "images": [],
  "latency_ms": 1880
}

Example rendering:

  • Show options[].label as buttons (at most 3)
  • When the resident taps one, send options[].question as a new message via POST .../messages exactly as if they had typed it · the server keeps no button state · show that text as the resident's message in the chat
  • The options are also written into reply, so systems that cannot show buttons still work
  • Buttons only apply to the latest message; hide the old ones when a new message arrives

6.4 Images

  • Show them after reply, in array order · show preview_url in the chat and open url on tap
  • Within one conversation the bot never sends the same image twice

7Errors and retries

Standard HTTP status codes. The body comes in two shapes: Error (detail is an object) and ValidationError (detail is an array) · check the type of detail before reading it

StatuserrorCauseWhat to do
401unauthorizedNo X-API-Key, or the key is invalid/revokedCheck the key · do not retry
403place_forbiddenThis key has no rights to this buildingCheck place_id / contact Naya People
404place_not_foundUnknown place_idCheck place_id
404({"detail": "Not Found"})Wrong path, e.g. user_id contains /Check the URL
405(none)Method not supported on that pathCheck the method
422empty_messagemessage is whitespace onlyDon't send it
422(ValidationError)Missing field, too long, malformed path/query, broken JSONFix the request · do not retry with the same values
429rate_limitedQuota exceeded (section 8) · includes a Retry-After header (seconds)Wait for Retry-After, then resend
503upstream_unavailableAnswer generation temporarily failed (only POST .../messages)Show message to the resident right away (a bilingual apology) and let them resend themselves
503history_unavailableHistory temporarily unreadable or undeletableRetry with backoff
503topics_unavailableTopic list temporarily unreadableRetry with backoff, or use cached data
503not_configuredThe API is not enabled on the serverContact Naya People

Retry policy

Request429503Timeout / network drop
All GETWait for Retry-After, then retryBackoff 2 → 4 → 8 seconds, at most 3 timesSame backoff
DELETE .../messagesWait for Retry-After, then retryRetry until it succeeds · repeated deletes are harmlessSafe to retry
POST .../messagesWait for Retry-After, then retry (the message was not processed)Never retry automatically — the message was already savedNever retry automatically — the message may have been processed; let the resident resend

The API has no idempotency key · resending a POST always adds a new message to the conversation

8Rate limits

RateWindow.nameScopeCurrent valueCounts which requests
client_per_minutePer API key (all residents)120 / minutePOST/GET/DELETE messages, /places, /topics
user_per_minutePer resident (user_id + building)10 messages / minutePOST .../messages only
user_per_dayPer resident200 messages / 24 hPOST .../messages only
(separate)Per API key30 / minute/usage and /users/{user_id}/usage
  • Every limit is a sliding window (the last 60 seconds / 24 hours from now), not a midnight reset
  • Over the limit → 429 with a Retry-After header · that message is not processed, not saved, and does not count against other limits
  • These values may change — read the real value from RateWindow.limit instead of hard-coding it · limit: null = that limit is disabled
  • Quota counters may reset when the server restarts (the stats in daily are kept)
  • Need a higher quota? Contact Naya People

9Response time and message order

TopicRule
Typical response time2–8 seconds per message · short greetings are much faster · follow-up questions may take about 1 second longer than the first
Integrator timeoutAt least 30 seconds (both the HTTP client and any proxy/load balancer in between)
Message orderSend one resident's messages one at a time and wait for the answer before sending the next; concurrent sends may be reordered in the conversation · messages from different residents can be sent concurrently
StreamingNot supported yet; the answer arrives in one piece
Recommended UIShow a "typing..." indicator while waiting

10Conversation behaviour

  • Remembers context for the same user_id for about the last 3 days, e.g. after "who do I contact for air-con cleaning?" a follow-up "what about Saturday?" is understood as being about air-con cleaning, and the bot won't ask for the unit number again if the resident already gave it · you don't need to send history yourself
  • Language: answers in the language the resident wrote in (Thai or English)
  • Answers from documents only: building facts (hours, fees, rules) come from the juristic office's documents; when there is no information it says so (no_context) rather than guessing
  • Wording varies: asking the same question again may get different phrasing, but the facts come from the same documents
  • Updates are immediate: when the juristic office edits the knowledge base, answers change within minutes, with no API release
  • Resident messages cannot change the bot's rules: messages claiming to be from the office or telling the bot to behave differently are treated as resident messages, and the bot never repeats links or phone numbers that appear only in a resident's message
  • Q&A only: for things that must be done in an app, the answer points the resident to the building's app or channel, with a link when available
  • Answers around the clock, regardless of the office's working hours (unlike LINE)
  • No staff handoff: the bot never stops answering API residents and never alerts staff from API messages
  • Not connected to LINE: a resident who asks on both channels has two separate conversations, but both use the same building information
  • Start over with DELETE .../messages or a new user_id

11Security and personal data

DataStored?Notes
message and the bot's answerYesTied to the conversation so follow-ups work · deletable with DELETE · very old data is removed under the juristic office's policy
user_idAs a hashThe raw value is never written to the database or logs
display_nameNoUsed only while writing the answer
Usage statsYesDaily totals, no personal data
  • When a resident asks for their data or account to be deleted, the integrator must call DELETE .../messages and retry until it gets 200
  • Don't send unnecessary sensitive data in message or user_id, such as national ID or bank account numbers
  • Juristic office staff may read unanswered questions to improve the knowledge base; integrators should tell residents in their privacy policy that messages are sent to the juristic office's assistant
  • Keep the API key in a secret manager / environment variable · never log the X-API-Key header
  • The integrator's backend must authenticate residents itself and only use a user_id from the server-side session — never accept a user_id straight from the app, or one user could read another's history

12Go-live checklist

  • The API key lives only on the server — not in the app, client-side code or logs
  • user_id is stable per resident, is not directly personal data, and comes from the server-side session
  • GET /places with the production key returns the agreed place_id
  • reply is shown with line breaks preserved, escaped as text, with tappable links/phone numbers
  • outcome = "ambiguous" is supported: buttons are shown and question is sent back on tap
  • images are shown when present
  • Unknown outcome values are shown like answer, and unknown fields are ignored
  • 429 is handled with Retry-After, and 503 upstream_unavailable by showing message · POST is never retried automatically
  • Timeout ≥ 30 seconds, and one resident's messages are sent one at a time
  • Empty messages and messages over 1000 characters are blocked in the UI
  • DELETE is called when a resident asks for their data or account to be deleted

13Changelog

DateChange
4 Nov 2026Resident messages can no longer inject fake information or instructions for the bot to repeat (no API format change)
3 Nov 2026Added GET /usage, GET /places/{place_id}/users/{user_id}/usage, GET /places/{place_id}/topics
29 Sep 2026Answers that suggest contacting the juristic office get the phone number appended in reply
26 Sep 2026v1 launched: send messages, read/delete history, GET /places

14Contact

Contact Naya People to: request an API key, report a leaked key, add a building, raise a quota, or report a problem (include the time, endpoint, HTTP status and the test user_id — never include the API key)

Answer content (office hours, fees, building rules) belongs to each condominium's juristic office