openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: profile description: User profile operations - name: conversations description: Conversation and message operations - name: memories description: Remembered facts about the user - name: stats description: Summary stats - name: voice-profiles description: Persistent voice recognition profiles - name: history description: History PIN — gates access to past conversations - name: phone-access description: Phone access code — lets the phone-hosted voice agent identify an account - name: voice-auth description: Voice ID — an MFCC-based voice-biometric alternative to the History PIN, enrolled and verified in-browser paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /profile: get: operationId: getProfile tags: [profile] summary: Get the current user's profile (auto-created on first access) responses: "200": description: Profile content: application/json: schema: $ref: "#/components/schemas/Profile" patch: operationId: updateProfile tags: [profile] summary: Update the current user's profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProfileUpdate" responses: "200": description: Updated profile content: application/json: schema: $ref: "#/components/schemas/Profile" /stats: get: operationId: getStats tags: [stats] summary: Get summary stats for the current user responses: "200": description: Stats content: application/json: schema: $ref: "#/components/schemas/Stats" /conversations: get: operationId: listConversations tags: [conversations] summary: List the current user's conversations, most recent first responses: "200": description: List of conversations content: application/json: schema: type: array items: $ref: "#/components/schemas/Conversation" post: operationId: createConversation tags: [conversations] summary: Start a new conversation requestBody: content: application/json: schema: $ref: "#/components/schemas/ConversationInput" responses: "201": description: Created conversation content: application/json: schema: $ref: "#/components/schemas/Conversation" /conversations/{id}: get: operationId: getConversation tags: [conversations] summary: Get a conversation parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Conversation content: application/json: schema: $ref: "#/components/schemas/Conversation" "404": description: Not found delete: operationId: deleteConversation tags: [conversations] summary: Delete a conversation parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /conversations/{id}/messages: get: operationId: listMessages tags: [conversations] summary: List messages in a conversation, oldest first parameters: - name: id in: path required: true schema: type: integer responses: "200": description: List of messages content: application/json: schema: type: array items: $ref: "#/components/schemas/Message" "404": description: Not found post: operationId: sendMessage tags: [conversations] summary: Send a text message and get the companion's reply parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MessageInput" responses: "201": description: The user message and the companion's reply content: application/json: schema: $ref: "#/components/schemas/MessageExchange" "404": description: Not found /conversations/{id}/voice-messages: post: operationId: sendVoiceMessage tags: [conversations] summary: Send a voice recording and get a spoken reply back description: > Accepts a base64-encoded audio recording, transcribes it, identifies the speaker against enrolled voice profiles if any, gets the companion's reply, and synthesizes that reply as speech. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/VoiceMessageInput" responses: "201": description: The transcribed user message, companion's reply, and synthesized audio content: application/json: schema: $ref: "#/components/schemas/VoiceMessageExchange" "404": description: Not found /memories: get: operationId: listMemories tags: [memories] summary: List things the companion remembers about the user responses: "200": description: List of memories content: application/json: schema: type: array items: $ref: "#/components/schemas/Memory" /memories/{id}: delete: operationId: deleteMemory tags: [memories] summary: Forget a remembered fact parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /voice-profiles: get: operationId: listVoiceProfiles tags: [voice-profiles] summary: List enrolled voice profiles for the current account responses: "200": description: List of voice profiles content: application/json: schema: type: array items: $ref: "#/components/schemas/VoiceProfile" post: operationId: enrollVoiceProfile tags: [voice-profiles] summary: Manually enroll a new voice profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/VoiceProfileInput" responses: "201": description: Enrolled voice profile content: application/json: schema: $ref: "#/components/schemas/VoiceProfile" /history/pin: post: operationId: setHistoryPin tags: [history] summary: Set or change the History PIN that gates access to past conversations description: > If a PIN is already set, currentPin must be supplied and correct. On success, immediately unlocks history for the caller (same as unlockHistory) so the PIN doesn't have to be re-entered right after setting it. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/HistoryPinInput" responses: "200": description: PIN set; history unlocked content: application/json: schema: $ref: "#/components/schemas/HistoryTokenResponse" "403": description: currentPin missing or incorrect delete: operationId: removeHistoryPin tags: [history] summary: Remove the History PIN, returning history to unprotected requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/HistoryPinRemovalInput" responses: "204": description: PIN removed (or was never set) "403": description: currentPin incorrect /history/unlock: post: operationId: unlockHistory tags: [history] summary: Verify the History PIN and obtain a short-lived unlock token requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/HistoryUnlockInput" responses: "200": description: Correct PIN — unlock token issued content: application/json: schema: $ref: "#/components/schemas/HistoryTokenResponse" "400": description: No History PIN is configured "401": description: Incorrect PIN "429": description: Too many failed attempts — temporarily locked out /phone-access/code: post: operationId: setPhoneAccessCode tags: [phone-access] summary: Set or change the 6-digit code that identifies this account on the phone line description: > If a code is already set, currentCode must be supplied and correct. This code is not used for anything inside the app — it exists purely so the phone-hosted xAI Voice Agent can tell which account a call belongs to, since a call has no Clerk session. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PhoneAccessCodeInput" responses: "200": description: Code set content: application/json: schema: $ref: "#/components/schemas/Profile" "403": description: currentCode missing or incorrect "429": description: Too many failed attempts — temporarily locked out delete: operationId: removePhoneAccessCode tags: [phone-access] summary: Remove the phone access code, disabling phone-line identification for this account requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PhoneAccessCodeRemovalInput" responses: "200": description: Code removed (or was never set) content: application/json: schema: $ref: "#/components/schemas/Profile" "403": description: currentCode incorrect "429": description: Too many failed attempts — temporarily locked out /voice-profiles/{id}: patch: operationId: updateVoiceProfile tags: [voice-profiles] summary: Rename a voice profile parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/VoiceProfileUpdate" responses: "200": description: Updated voice profile content: application/json: schema: $ref: "#/components/schemas/VoiceProfile" "404": description: Not found delete: operationId: deleteVoiceProfile tags: [voice-profiles] summary: Remove an enrolled voice profile parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /voice-auth/status: get: operationId: getVoiceAuthStatus tags: [voice-auth] summary: Check whether Voice ID is enrolled for this account responses: "200": description: Voice ID enrollment status content: application/json: schema: $ref: "#/components/schemas/VoiceAuthStatusResponse" /voice-auth/challenge: post: operationId: createVoiceAuthChallenge tags: [voice-auth] summary: Issue a short-lived spoken challenge phrase (a 4-digit sequence) description: > Call this immediately before recording, whether enrolling or verifying. The returned phrase must be read aloud in the same recording that gets sent to enroll/verify — this is both a liveness check (defeats simple replay of old audio) and a content check (confirms real speech was captured, not silence or noise). responses: "200": description: Challenge issued content: application/json: schema: $ref: "#/components/schemas/VoiceAuthChallengeResponse" /voice-auth/enroll: post: operationId: enrollVoiceAuth tags: [voice-auth] summary: Enroll Voice ID from one or more challenge recordings description: > Provide 1-3 recordings, each reading aloud the phrase from a fresh /voice-auth/challenge call. Multiple samples are averaged into a single voiceprint template for better robustness. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/VoiceAuthEnrollInput" responses: "200": description: Voice ID enrolled content: application/json: schema: $ref: "#/components/schemas/VoiceAuthEnrollResponse" "400": description: Challenge expired/invalid, or the spoken phrase didn't match /voice-auth/verify: post: operationId: verifyVoiceAuth tags: [voice-auth] summary: Verify Voice ID and obtain a short-lived unlock token description: > Uses the exact same token type as History PIN unlock (HistoryTokenResponse) so the frontend can treat a Voice ID match as an equivalent unlock. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/VoiceAuthVerifyInput" responses: "200": description: Voice match — unlock token issued content: application/json: schema: $ref: "#/components/schemas/HistoryTokenResponse" "400": description: Voice ID not enrolled, or challenge expired/invalid "401": description: Spoken phrase didn't match, or voice didn't match closely enough "429": description: Too many failed attempts — temporarily locked out /voice-auth: delete: operationId: removeVoiceAuth tags: [voice-auth] summary: Remove Voice ID enrollment responses: "204": description: Removed (or was never enrolled) components: schemas: HealthStatus: type: object properties: status: type: string required: - status Profile: type: object required: [ userId, companionName, historyPinEnabled, phoneAccessCodeEnabled, wakeWordEnabled, createdAt, updatedAt, ] properties: userId: { type: string } preferredName: { type: ["string", "null"] } companionName: { type: string } historyPinEnabled: type: boolean description: True if a History PIN is configured, gating access to past conversations phoneAccessCodeEnabled: type: boolean description: True if a 6-digit phone access code is configured, letting the phone line identify this account wakeWordEnabled: type: boolean description: True if live voice should wait for the wakeWord sign-off instead of ending a turn on the first silence wakeWord: type: ["string", "null"] description: The sign-off word that ends a turn when wakeWordEnabled is true (e.g. "over") createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } ProfileUpdate: type: object properties: preferredName: { type: string } companionName: { type: string, minLength: 1 } wakeWordEnabled: { type: boolean } wakeWord: { type: string, minLength: 1, maxLength: 32 } Stats: type: object required: [conversationCount, messageCount, memoryCount, voiceProfileCount, lastActiveAt] properties: conversationCount: { type: integer } messageCount: { type: integer } memoryCount: { type: integer } voiceProfileCount: { type: integer } lastActiveAt: { type: ["string", "null"], format: date-time } Conversation: type: object required: [id, title, createdAt, updatedAt] properties: id: { type: integer } title: { type: ["string", "null"] } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } ConversationInput: type: object properties: title: { type: string } Message: type: object required: [id, conversationId, role, content, createdAt] properties: id: { type: integer } conversationId: { type: integer } role: { type: string, enum: [user, assistant] } content: { type: string } speakerName: { type: ["string", "null"] } createdAt: { type: string, format: date-time } MessageInput: type: object required: [content] properties: content: { type: string, minLength: 1 } MessageExchange: type: object required: [userMessage, assistantMessage] properties: userMessage: { $ref: "#/components/schemas/Message" } assistantMessage: { $ref: "#/components/schemas/Message" } VoiceMessageInput: type: object required: [audioBase64, mimeType] properties: audioBase64: { type: string, description: Base64-encoded audio data } mimeType: { type: string, description: "e.g. audio/webm" } VoiceMessageExchange: type: object required: [userMessage, assistantMessage, audioBase64, audioMimeType] properties: userMessage: { $ref: "#/components/schemas/Message" } assistantMessage: { $ref: "#/components/schemas/Message" } audioBase64: type: string description: Base64-encoded synthesized speech audio of the reply audioMimeType: { type: string } speakerName: type: ["string", "null"] description: Name of the recognised speaker, or null if unrecognised autoEnrolled: type: boolean description: True if a new voice profile was automatically created from a self-introduction Memory: type: object required: [id, content, category, createdAt] properties: id: { type: integer } content: { type: string } category: { type: ["string", "null"] } createdAt: { type: string, format: date-time } VoiceProfile: type: object required: [id, name, createdAt] properties: id: { type: integer } name: { type: string } lastHeardAt: { type: ["string", "null"], format: date-time } createdAt: { type: string, format: date-time } VoiceProfileInput: type: object required: [name, audioBase64, mimeType] properties: name: { type: string, minLength: 1 } audioBase64: { type: string } mimeType: { type: string } VoiceProfileUpdate: type: object required: [name] properties: name: { type: string, minLength: 1 } HistoryPinInput: type: object required: [pin] properties: pin: type: string pattern: "^[0-9]{4,8}$" description: New 4-8 digit numeric PIN currentPin: type: string description: Required (and must be correct) when a PIN is already set HistoryPinRemovalInput: type: object required: [currentPin] properties: currentPin: { type: string } HistoryUnlockInput: type: object required: [pin] properties: pin: { type: string } PhoneAccessCodeInput: type: object required: [code] properties: code: type: string pattern: "^[0-9]{6}$" description: New 6-digit numeric phone access code currentCode: type: string description: Required (and must be correct) when a code is already set PhoneAccessCodeRemovalInput: type: object required: [currentCode] properties: currentCode: { type: string } HistoryTokenResponse: type: object required: [token, expiresAt] properties: token: type: string description: Opaque signed token — send as the X-History-Token header expiresAt: { type: string, format: date-time } VoiceAuthStatusResponse: type: object required: [enrolled] properties: enrolled: { type: boolean } enrolledAt: { type: ["string", "null"], format: date-time } modelVersion: { type: ["string", "null"] } VoiceAuthChallengeResponse: type: object required: [challengeId, phrase, expiresAt] properties: challengeId: { type: string } phrase: type: string description: A short digit sequence to read aloud, e.g. "7 2 9 4" expiresAt: { type: string, format: date-time } VoiceAuthSample: type: object required: [audioBase64, mimeType, challengeId] properties: audioBase64: type: string description: Base64-encoded audio/wav bytes (16-bit PCM) mimeType: { type: string } challengeId: { type: string } VoiceAuthEnrollInput: type: object required: [samples] properties: samples: type: array minItems: 1 maxItems: 3 items: $ref: "#/components/schemas/VoiceAuthSample" VoiceAuthEnrollResponse: type: object required: [enrolled, sampleCount] properties: enrolled: { type: boolean } sampleCount: { type: integer } VoiceAuthVerifyInput: type: object required: [audioBase64, mimeType, challengeId] properties: audioBase64: { type: string } mimeType: { type: string } challengeId: { type: string }