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

# Register a user

> Create the identity for a patient-facing app user with a service token, the first call in the registration flow.

First step of user registration. See the [User Registration](https://openloop.mintlify.site/api-reference/user-registration-guide.md) guide for the full call order, from a service token through the user's own tokens.


## OpenAPI

````yaml post /auth/register
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /auth/register:
    post:
      tags:
        - Auth
      summary: Register a user
      description: >-
        Creates a user identity. Does not return tokens — the new identity
        starts `pending_verification` until the OTP flow in `POST
        /auth/send-otp` and `POST /auth/verify-otp` confirms the email.
        Currently assigns the `PATIENT` role; other roles will come in the
        future.


        Requires a **service token** — the caller's token `sub` must be a
        client_credentials (M2M) subject; a user token is rejected with 401.


        **Permissions:** `users:create`
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthRegisterRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthRegisterResponse'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Bearer token is missing the users:create permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - serviceToken:
            - users:create
components:
  schemas:
    AuthRegisterRequest:
      type: object
      required:
        - email
        - phone_number
        - first_name
        - last_name
      properties:
        email:
          type: string
          format: email
          maxLength: 254
        phone_number:
          type: string
          pattern: ^\+[1-9]\d{1,14}$
        first_name:
          type: string
          maxLength: 200
        last_name:
          type: string
          maxLength: 200
    AuthRegisterResponse:
      type: object
      required:
        - data
        - request_id
      properties:
        data:
          type: object
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: Identifier of the newly created user identity.
            status:
              type: string
              enum:
                - pending_verification
                - active
              description: >-
                New identities start `pending_verification` until the OTP flow
                verifies the email.
        request_id:
          type: string
          format: uuid
          description: Correlation id echoed on every response.
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            error_code:
              type: string
          required:
            - message
            - error_code
        request_id:
          type: string
      required:
        - error
        - request_id
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}

````

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