> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lala.ist/llms.txt
> Use this file to discover all available pages before exploring further.

# Register a device for push

> Registers the FCM token this device holds, so Lala can reach the student when the
application is closed. Call it after every sign-in, and again whenever the FCM SDK
reports a refreshed token.

The call is idempotent. Registering a token that is already known updates the row
instead of adding a second one, and a token that belonged to another account moves
to the caller — so a reinstall or an account switch cannot leave the previous
student reachable on this device.



## OpenAPI

````yaml /api-reference/openapi.json post /api/devices
openapi: 3.1.0
info:
  title: Lala Client API
  description: >-
    The HTTP API behind Lala, the AI study companion for Turkish YKS and LGS
    students. This document is generated from the Zod schemas that validate each
    request at runtime. Do not hand-edit openapi.json. Student-visible text is
    Turkish. All identifiers are English.
  version: 1.0.0
servers:
  - url: https://client-api.lala.ist
    description: production
  - url: http://localhost:3000
    description: local dev
security:
  - supabaseJwt: []
tags:
  - name: chat
    description: The chat stream, the message history, and reactions
  - name: media
    description: Upload and read message attachments
  - name: plan
    description: The study planner — blocks of work on a day
  - name: journey
    description: Deneme results, topic performance, study-hours stats, and the streak
  - name: profile
    description: The student profile and onboarding
  - name: devices
    description: Push notification devices
  - name: system
    description: Health check
paths:
  /api/devices:
    post:
      tags:
        - devices
      summary: Register a device for push
      description: >-
        Registers the FCM token this device holds, so Lala can reach the student
        when the

        application is closed. Call it after every sign-in, and again whenever
        the FCM SDK

        reports a refreshed token.


        The call is idempotent. Registering a token that is already known
        updates the row

        instead of adding a second one, and a token that belonged to another
        account moves

        to the caller — so a reinstall or an account switch cannot leave the
        previous

        student reachable on this device.
      operationId: postApiDevices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeviceRegisterBody'
      responses:
        '200':
          description: The registered device
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceResponse'
        '400':
          description: The token is empty or too long
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The token is missing, expired, or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: The registration could not be written
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    DeviceRegisterBody:
      type: object
      properties:
        token:
          type: string
          minLength: 1
          maxLength: 4096
          description: The FCM registration token from the client SDK.
        platform:
          $ref: '#/components/schemas/DevicePlatform'
        appVersion:
          type: string
          maxLength: 64
        locale:
          type: string
          maxLength: 32
      required:
        - token
        - platform
    DeviceResponse:
      type: object
      properties:
        device:
          $ref: '#/components/schemas/Device'
      required:
        - device
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        issues:
          description: >-
            Present only on a 400 raised by request validation, capped at 10
            entries. Every other error carries `error` alone.
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssue'
      required:
        - error
      description: Error body. `error` is a short English string.
    DevicePlatform:
      type: string
      enum:
        - ios
        - android
    Device:
      type: object
      properties:
        id:
          type: string
        platform:
          $ref: '#/components/schemas/DevicePlatform'
        token:
          type: string
          description: The registration token, masked to its last 12 characters.
        appVersion:
          anyOf:
            - type: string
            - type: 'null'
        locale:
          anyOf:
            - type: string
            - type: 'null'
        lastSeenAt:
          type: string
        createdAt:
          type: string
      required:
        - id
        - platform
        - token
        - appVersion
        - locale
        - lastSeenAt
        - createdAt
    ValidationIssue:
      type: object
      properties:
        path:
          type: string
          description: Dotted path to the offending field, empty at the root.
        message:
          type: string
      required:
        - path
        - message
  securitySchemes:
    supabaseJwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Supabase access token: `Authorization: Bearer <token>`'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.