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

# Get user by phone number

> Retrieves a user by their phone number.



## OpenAPI

````yaml /api-reference/openapi.json get /users
openapi: 3.1.0
info:
  title: Sotto API
  version: 1.0.0
  description: >-
    The Sotto API provides programmatic access to manage users, send messages,
    upload files, configure webhooks, and read your segments and custom data
    fields. All requests are authenticated with an HMAC-SHA256 signature. See
    the **Authentication** guide for signing details.
  contact:
    name: Sotto Support
    email: support@bigco.ai
servers:
  - url: https://api.bigco.ai/api/v1
    description: Production
security:
  - hmacSignature: []
tags:
  - name: Users
    description: Create, retrieve, update, and delete users.
  - name: Messages
    description: Send messages to a user.
  - name: Files
    description: Upload media files for use in messages.
  - name: Brand
    description: Retrieve information about your brand.
  - name: Webhooks
    description: Subscribe to and manage event callbacks.
  - name: Segments
    description: Read the audience segments configured for your brand.
  - name: Custom Data
    description: Read the custom data fields configured for your brand.
paths:
  /users:
    get:
      tags:
        - Users
      summary: Get user by phone number
      description: Retrieves a user by their phone number.
      operationId: getUserByPhoneNumber
      parameters:
        - name: phone_number
          in: query
          required: true
          description: Phone number in E.164 format (e.g. `+15551234567`).
          schema:
            type: string
            example: '+15551234567'
      responses:
        '200':
          description: The matching user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserAPI'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    UserAPI:
      type: object
      properties:
        id:
          type: integer
          description: The user's unique Sotto ID. Use this for update and delete requests.
          example: 1
        phone_number:
          type: string
          description: The user's phone number in E.164 format.
          example: '+15551234567'
        first_name:
          type:
            - string
            - 'null'
          maxLength: 50
          example: Jane
        last_name:
          type:
            - string
            - 'null'
          maxLength: 50
          example: Doe
        email_address:
          type:
            - string
            - 'null'
          format: email
          maxLength: 50
          example: jane.doe@example.com
        date_of_birth:
          type:
            - string
            - 'null'
          description: Date of birth in MM/DD/YYYY format.
          example: 01/01/1990
        messaging_consent:
          type:
            - boolean
            - 'null'
          description: >-
            `true` if subscribed to messages, `false` if unsubscribed, `null` if
            the user has neither opted in nor opted out.
          example: true
        custom_data:
          $ref: '#/components/schemas/CustomDataValues'
        location:
          oneOf:
            - $ref: '#/components/schemas/LocationAPI'
            - type: 'null'
        is_deleted:
          type: boolean
          description: Whether the user has been deleted.
          default: false
          example: false
        date_created:
          type: string
          format: date-time
          description: UTC time when the user was created.
          example: '2024-01-01T12:00:00Z'
        date_last_updated:
          type: string
          format: date-time
          description: UTC time when the user was last updated.
          example: '2024-10-01T12:00:00Z'
      required:
        - id
        - phone_number
        - date_created
        - date_last_updated
    CustomDataValues:
      type:
        - object
        - 'null'
      description: >-
        Key/value pairs of custom data. Each key must match a configured custom
        data field name, lowercased and snake-cased (e.g. "Loyalty Tier" becomes
        `loyalty_tier`). Values may be a string, number, or array.
      additionalProperties:
        anyOf:
          - type: string
          - type: number
          - type: array
            items: {}
          - type: 'null'
      example:
        loyalty_tier: Gold
        loyalty_points: 1000
        hobby:
          - running
          - swimming
    LocationAPI:
      type: object
      description: A user's resolved location, derived from their postal code.
      properties:
        postal_code:
          type:
            - string
            - 'null'
          example: '10001'
        city:
          type:
            - string
            - 'null'
          example: New York
        county:
          type:
            - string
            - 'null'
          example: New York
        state:
          type:
            - string
            - 'null'
          example: New York
        state_code:
          type:
            - string
            - 'null'
          example: NY
    Error:
      type: object
      properties:
        detail:
          type: object
          properties:
            type:
              type: string
              description: Machine-readable error type.
              example: not_authenticated
            msg:
              type: string
              description: Human-readable error message.
              example: HMAC signature verification failed
          required:
            - type
            - msg
      required:
        - detail
  responses:
    Unauthorized:
      description: Unauthorized — HMAC signature verification failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail:
              type: not_authenticated
              msg: HMAC signature verification failed
    NotFound:
      description: Not found — the requested resource does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail:
              type: user_not_found
              msg: User with ID [1] not found.
    ValidationError:
      description: Validation error — one or more fields failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail:
              type: invalid_phone_number
              msg: Invalid phone number [555-123-4567] provided.
    InternalServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail:
              type: UNCAUGHT_ERROR
              msg: Internal server error
  securitySchemes:
    hmacSignature:
      type: apiKey
      in: header
      name: x-bigco-hmac-sha256
      description: >-
        Base64-encoded HMAC-SHA256 signature of the request. Every request must
        also include the `x-bigco-hmac-username` and `x-date` headers, and
        POST/PUT requests must include `x-digest`. See the Authentication guide
        for the full signing procedure.

````