> ## Documentation Index
> Fetch the complete documentation index at: https://vastai-80aa3a82-auto-openapi-update-8483c1e9.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Authorize New 2FA Method

> Initiates authorization to add a new 2FA method by verifying identity with an existing method or backup code, returning a value used in the verification step.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/v0/tfa/authorize-new-method/
openapi: 3.1.0
info:
  title: Vast.ai API
  description: >-
    Vast.ai REST API for managing GPU cloud instances, machine operations, and
    AI/ML workflows.


    ## AI Agent Quick-Start


    Install the CLI skill for your agent (Claude Code, Cursor, Windsurf, etc.):
      npx skills add vast-ai/vast-cli

    CLI reference:
    https://raw.githubusercontent.com/vast-ai/vast-cli/master/vastai/SKILL.md

    SDK reference:
    https://raw.githubusercontent.com/vast-ai/vast-cli/master/vastai_sdk/SKILL.md


    ## Auth

    All endpoints require `Authorization: Bearer $VAST_API_KEY`.

    Get your key at: https://cloud.vast.ai/manage-keys/


    ## Key Quirks

    - `gpu_ram` in CLI = GB; in REST API = MB (CLI auto-converts)

    - SSH keys must be registered BEFORE creating an instance (VM: no recovery;
    Docker: can add post-create)

    - `onstart` field is limited to 4048 characters -- gzip+base64 for longer
    scripts

    - `POST /api/v0/asks/{id}/` (create instance) returns `new_contract` as the
    instance ID, not `id`

    - Poll trap: if `actual_status` becomes `exited`, `unknown`, or `offline` it
    will never reach `running` -- destroy and retry
  version: 1.0.0
  contact:
    name: Vast.ai Support
    url: https://discord.gg/vast
servers:
  - url: https://console.vast.ai
    description: Production server
security:
  - BearerAuth: []
paths:
  /api/v0/tfa/authorize-new-method/:
    post:
      tags:
        - Accounts
      summary: Authorize New 2FA Method
      description: >-
        Initiates authorization to add a new 2FA method by verifying identity
        with an existing method or backup code, returning a value used in the
        verification step.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                tfa_method:
                  type: string
                  description: >-
                    Existing method type to use for authorization; automatically
                    'email' when the account has no active methods
                  example: email
                  enum:
                    - sms
                    - totp
                    - email
                tfa_method_id:
                  type: integer
                  description: >-
                    ID of an existing method to verify with; required for
                    sms/totp when the user has multiple methods of the same type
                  example: 3
                backup_code:
                  type: string
                  description: >-
                    Backup code that skips the send/verify round-trip and grants
                    authorization directly
                  example: ABCD-EFGH-1234
      responses:
        '200':
          description: >-
            Returns {success: true, secret} (secret needed for PUT verify step),
            or {success: true, msg: "Authorization successful."} when a backup
            code is used.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Always true
                  secret:
                    type: string
                    description: >-
                      TFA secret required for the PUT verification step (present
                      when using a send/verify flow)
                  msg:
                    type: string
                    description: >-
                      "Authorization successful." (present when backup_code is
                      used and authorization is granted immediately)
              example:
                success: true
                secret: abc123randomtoken
        '400':
          description: >-
            Email not verified ("email_not_verified"), invalid tfa_method
            ("invalid_tfa_method"), or Twilio error ("twilio_error").
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Not authenticated or invalid backup code ("invalid_backup_code").
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Team user in team context ("team_user_forbidden").
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            Authorization service temporarily unavailable
            ("service_unavailable").
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - BearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        msg:
          type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key must be provided in the Authorization header

````