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

# Definir Método MFA Preferido

> Use este endpoint para definir o método MFA preferido de um usuário. O método selecionado já deve estar habilitado.



## OpenAPI

````yaml pt/openapi/v3-current/AM-identity.yaml patch /v1/users/{id}/mfa/preferred
openapi: 3.1.0
info:
  title: Plugin de Identidade
  description: ''
  version: 2.4.5
servers:
  - url: https://identity.sandbox.lerian.net
security: []
tags:
  - name: API de Grupos
  - name: API de Aplicações
  - name: API de Usuários
  - name: API de MFA
  - name: API de Provedores
  - name: API de Provedores de Aplicação
paths:
  /v1/users/{id}/mfa/preferred:
    patch:
      tags:
        - API de MFA
      summary: Definir Método MFA Preferido
      description: >-
        Use este endpoint para definir o método MFA preferido de um usuário. O
        método selecionado já deve estar habilitado.
      parameters:
        - $ref: '#/components/parameters/UserId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MFAPreferredInput'
            example:
              mfaType: app
      responses:
        '200':
          description: Método MFA preferido atualizado com sucesso.
          content:
            application/json:
              schema:
                type: object
                properties:
                  preferredType:
                    type: string
              example:
                preferredType: app
          headers: {}
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              examples:
                Error0001:
                  $ref: '#/components/examples/Error0001'
                Error0004:
                  $ref: '#/components/examples/Error0004'
                Error0007:
                  $ref: '#/components/examples/Error0007'
                Error0041:
                  $ref: '#/components/examples/Error0041'
                Error0044:
                  $ref: '#/components/examples/Error0044'
                Error0049:
                  $ref: '#/components/examples/Error0049'
          headers: {}
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              examples:
                Error1003:
                  $ref: '#/components/examples/Error1003'
          headers: {}
        '500':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              examples:
                Error0006:
                  $ref: '#/components/examples/Error0006'
          headers: {}
      security:
        - bearer: []
components:
  parameters:
    UserId:
      name: id
      in: path
      description: O identificador único do usuário que você deseja recuperar.
      required: true
      example: 019c96a0-0c21-71f9-a487-66a1258278a1
      schema:
        type: string
  schemas:
    MFAPreferredInput:
      description: Informações necessárias para definir o método MFA preferido.
      type: object
      required:
        - mfaType
      properties:
        mfaType:
          type: string
          description: O tipo de MFA a ser definido como preferido.
          enum:
            - app
            - email
            - sms
        secret:
          type: string
          description: O segredo TOTP (necessário para MFA por aplicativo).
    ErrorMessage:
      description: A mensagem de erro da resposta.
      type: object
      properties:
        code:
          type: string
          description: Um identificador único e estável para o erro.
        title:
          type: string
          description: Um breve resumo do problema.
        message:
          type: string
          description: Orientação detalhada para resolver o erro.
  examples:
    Error0001:
      summary: Missing Fields in Request
      value:
        code: IDE-0001
        title: Missing Fields in Request
        message: Your request is missing one or more required fields.
    Error0004:
      summary: Unexpected Fields in the Request
      value:
        code: IDE-0004
        title: Unexpected Fields in the Request
        message: >-
          The request body contains more fields than expected. Please send only
          the allowed fields.
    Error0007:
      summary: Bad Request
      value:
        code: IDE-0007
        title: Bad Request
        message: The server could not understand the request due to malformed syntax.
    Error0041:
      summary: MFA Not Enabled
      value:
        code: IDE-0041
        title: MFA Not Enabled
        message: MFA is not enabled for this user.
    Error0044:
      summary: MFA Invalid Type
      value:
        code: IDE-0044
        title: MFA Invalid Type
        message: >-
          The provided MFA type is invalid. Accepted values are app, email, and
          sms.
    Error0049:
      summary: MFA Method Not Enabled
      value:
        code: IDE-0049
        title: MFA Method Not Enabled
        message: The specified MFA method is not enabled for this user.
    Error1003:
      summary: User ID Not Found
      value:
        code: IDE-1003
        title: User ID Not Found
        message: The provided user ID does not exist in our records.
    Error0006:
      summary: Internal Server Error
      value:
        code: IDE-0006
        title: Internal Server Error
        message: The server encountered an unexpected error. Please try again later.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: O token de autorização no formato 'Bearer <token>'.

````