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

# Login or Create User by SMS

> Create an SMS OTP (one-time passcode) to the provided phone number for login verification. If no user account exists for the provided phone number, a new user will be created and OTP sent by SMS.
## Returns

A successful response returns an object with `user_id`, `user_created` indicating if the user has been newly created, and `phone_number_id` properties.



## OpenAPI

````yaml post /v1/auth/otps/sms/login_or_create
openapi: 3.1.0
info:
  title: MoonKey Auth API
  description: >-
    Explore all the details of MoonKey Auth API. All of our APIs are RESTful and
    accept and return JSON.
  version: v1
servers:
  - url: https://api.moonkey.fun
    description: Production
    variables: {}
security:
  - Authorization: []
tags:
  - name: Users
    description: User management API
  - name: Magic Links
    description: ''
  - name: OTPs
    description: >-
      Send OTP (One-time passcodes) by all the supported delivery methods such
      as SMS, email.
  - name: OAuth
    description: ''
  - name: Wallets Login
    description: ''
  - name: Managed Wallets
    description: ''
  - name: Wallet Import
    description: >-
      Import existing wallets into the platform using secure HPKE encryption.
      This flow ensures raw entropy (seed phrases or private keys) never touches
      the server in plaintext.
externalDocs:
  url: ''
  description: ''
paths:
  /v1/auth/otps/sms/login_or_create:
    post:
      tags:
        - OTPs
      summary: Login or Create User by SMS
      description: >-
        Create an SMS OTP (one-time passcode) to the provided phone number for
        login verification. If no user account exists for the provided phone
        number, a new user will be created and OTP sent by SMS.

        ## Returns


        A successful response returns an object with `user_id`, `user_created`
        indicating if the user has been newly created, and `phone_number_id`
        properties.
      operationId: LoginOrCreateUserBySMS
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginOrCreateUserBySMSRequest'
            examples:
              LoginOrCreateUserBySMSReq:
                value:
                  phone_number: '+14152222222'
                  expires_in: 3
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  phone_number_id:
                    type: string
                    minLength: 1
                    readOnly: true
                  user_created:
                    type: boolean
                    readOnly: true
                  user_id:
                    type: string
                    minLength: 1
                    readOnly: true
                  status:
                    type: string
                required:
                  - phone_number_id
                  - user_created
                  - user_id
                  - status
              examples:
                LoginOrCreateUserBySMSResp:
                  value:
                    phone_number_id: pn_24oXBLRv6BoHXbNZoTAZkAFlRsy
                    user_created: false
                    status: pending
                    user_id: user_24wFP9pDa9YiMJLun94iKykoZs2
components:
  schemas:
    LoginOrCreateUserBySMSRequest:
      description: ''
      type: object
      properties:
        phone_number:
          type: string
          minLength: 1
          description: >-
            E.164 formatted mobile phone number that uniquely identifies the
            user.
        expires_in:
          type: number
          description: >-
            Expiration time of the OTP in minutes. Must be between 1 to 10
            minutes, defaults to 1 minute.
        requires_verification:
          type: boolean
          description: >-
            Determines if verification for the authentication method (email,
            phone_number) is required before marking the user as active.
        device_fingerprint:
          type: object
          description: >-
            Device fingerprinting metadata for fraud detection during
            verification step. This is useful to ensure that the user who
            originated the request matches the user that verifies the token.
            Verification requirements can be enabled in the `Verify OTP` step by
            matching fields in the `device_fingerprint` such as IP, User Agent
            or the combination of them (more fraud detection features **coming
            soon**!)
          properties:
            ip:
              type: string
              description: IP of the user originating the request.
            user_agent:
              type: string
              description: User Agent of the browser originating the request.
      required:
        - phone_number
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: >-
        Auth Platform API includes all the Auth related features. All Users,
        Phone Numbers, Emails, and OTPs are associated with an `App` as the
        container.


        Endpoints only accept App's `Secret API keys` other than certain
        endpoints that are used client side or via SDK that accept the
        `public_token`.


        ## Authentication using App Api Key


        ## Header:


        ```

        Authorization: Bearer {api_key}

        ```


        ## Authenticated Request


        ```curl

        curl \
          -X GET https://api.moonkey.fun/v1/auth/users/user_24wFP9pDa9YiMJLun94iKykoZs2 \
          -H "Authorization: Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1r"
        ```

````