openapi: 3.0.3
info:
  title: Authentication API
  description: Monitr's Authentication API
  version: 1.16.10
  termsOfService: https://monitr.be/terms/
  contact:
    name: Engineering Team
    email: engineering@monitr.be
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas: {}
paths:
  /.well-known/jwks.json:
    get:
      summary: Get a list of JWKs
      tags:
        - JWK
      description: A list of public JSON Web Keys (JWK) used for JWT verification.
      responses:
        "200":
          description: Default Response
  /login:
    post:
      summary: Login with username/password an optional OTP token
      tags:
        - User
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                email:
                  format: email
                  type: string
                  example: email@example.com
                password:
                  type: string
                otp:
                  minLength: 6
                  maxLength: 6
                  type: string
              required:
                - email
                - password
        required: true
      responses:
        "200":
          description: Access token and refresh token
          content:
            application/json:
              schema:
                description: Access token and refresh token
                additionalProperties: false
                type: object
                properties:
                  token:
                    type: string
                  refreshToken:
                    type: string
                required:
                  - token
                  - refreshToken
  /register:
    post:
      summary: Request a registration
      tags:
        - User
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - firstName
                - lastName
              properties:
                invite:
                  type: string
                email:
                  type: string
                  format: email
                  example: email@example.com
                firstName:
                  type: string
                lastName:
                  type: string
                companyName:
                  type: string
                consentMarketing:
                  type: boolean
              oneOf:
                - required:
                    - email
                - required:
                    - invite
              dependencies:
                email:
                  - companyName
                companyName:
                  - email
        required: true
      responses:
        "202":
          description: The registration email has been sent
  /register/password:
    post:
      summary: Finish the registration
      tags:
        - User
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                password:
                  type: string
                emailToken:
                  type: string
                invite:
                  additionalProperties: false
                  type: object
                  properties:
                    team:
                      additionalProperties: false
                      type: object
                      properties:
                        id:
                          format: uuid
                          type: string
                        name:
                          type: string
                      required:
                        - id
                        - name
                    organisation:
                      additionalProperties: false
                      type: object
                      properties:
                        id:
                          format: uuid
                          type: string
                        name:
                          type: string
                      required:
                        - id
                        - name
                  required:
                    - team
                    - organisation
              required:
                - password
                - emailToken
        required: true
      responses:
        "201":
          description: Access token and refresh token
          content:
            application/json:
              schema:
                description: Access token and refresh token
                additionalProperties: false
                type: object
                properties:
                  token:
                    type: string
                  refreshToken:
                    type: string
                required:
                  - token
                  - refreshToken
  /password/forgot:
    post:
      summary: Request a forgot password email
      tags:
        - User
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                email:
                  format: email
                  type: string
                  example: email@example.com
              required:
                - email
        required: true
      responses:
        "202":
          description: Forgot password email sent
  /password/reset:
    post:
      summary: Reset a password using a password reset token
      tags:
        - User
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                password:
                  type: string
                resetToken:
                  type: string
                otp:
                  minLength: 6
                  maxLength: 6
                  type: string
              required:
                - password
                - resetToken
        required: true
      responses:
        "200":
          description: Access token and refresh token
          content:
            application/json:
              schema:
                description: Access token and refresh token
                additionalProperties: false
                type: object
                properties:
                  token:
                    type: string
                  refreshToken:
                    type: string
                required:
                  - token
                  - refreshToken
  /mfa/request:
    post:
      summary: Request MFA enrollment
      tags:
        - MFA
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - token:software:totp
              required:
                - type
        required: true
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                token:
                  type: string
  /mfa/enroll:
    post:
      summary: Submit MFA enrollment
      tags:
        - MFA
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                token:
                  type: string
                code:
                  minLength: 6
                  maxLength: 6
                  type: string
              required:
                - token
                - code
        required: true
      security:
        - bearerAuth: []
      responses:
        "201":
          description: Sucessfully enrolled MFA
servers:
  - url: https://auth.monitr.be
    description: Production
