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

# Add 2FA Config

> Add a 2FA configuration to the user's organization settings for automated two-factor authentication.

Programmatically creating 2FA configs is currently only supported for TOTP seeds. Contact us on Slack if you need programmatic support for email/SMS as well.

## Use Cases

* **Automated Login**: Configure 2FA seeds for services your workflows need to access automatically
* **Site-Specific Authentication**: Match configurations to specific URLs for targeted authentication
* **Multi-Service Support**: Store multiple 2FA configurations for different services

## Configuration Details

Each 2FA configuration can include:

* **Seed**: The TOTP secret/seed for generating 2FA codes (required)
* **Name**: A friendly name to identify the configuration (optional)
* **Partial URL**: URL pattern to automatically match and apply the configuration (optional)

> [!NOTE]
>
> Either `name` or `partial_url` must be provided along with the required `seed`.

## Response

The API returns:

* The added configuration details
* Total number of configurations for your organization
* Array of all existing configurations

## Security Notes

* 2FA seeds are stored securely and associated with your organization
* Configurations are only accessible via authenticated API requests
* Seeds are used to generate TOTP codes during automated browser sessions


## OpenAPI

````yaml POST /add_2fa_config
openapi: 3.0.1
info:
  title: Simplex API
  description: API for browser automation, web scraping, and workflow automation
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.simplex.sh
security:
  - bearerAuth: []
paths:
  /add_2fa_config:
    post:
      description: >-
        Add a 2FA configuration to the user's organization settings for
        automated two-factor authentication.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                seed:
                  type: string
                  description: The 2FA seed/secret for generating TOTP codes.
                name:
                  type: string
                  description: Optional name for the 2FA configuration.
                partial_url:
                  type: string
                  description: Optional partial URL to match for automatic 2FA code entry.
              required:
                - seed
      responses:
        '200':
          description: 2FA configuration added successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  succeeded:
                    type: boolean
                    description: Whether the operation succeeded.
                  added_config:
                    type: object
                    description: The 2FA configuration that was added.
                    properties:
                      type:
                        type: string
                        description: The type of 2FA configuration (always 'seed').
                      two_fa_seed:
                        type: string
                        description: The 2FA seed that was stored.
                      name:
                        type: string
                        description: The name of the configuration.
                      partial_url:
                        type: string
                        description: The partial URL pattern.
                  total_configs:
                    type: integer
                    description: Total number of 2FA configs for this organization.
                  all_configs:
                    type: array
                    description: Array of all 2FA configurations.
                    items:
                      type: object
                  error:
                    type: string
                    description: Error message if the operation failed.
                required:
                  - succeeded
        '400':
          description: Bad Request - Invalid input or missing required fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
        - lang: python
          label: Add 2FA config
          source: |-
            from simplex import SimplexClient

            client = SimplexClient(api_key='your_api_key')

            result = client.add_2fa_config(
                seed='JBSWY3DPEHPK3PXP',
                name='GitHub',
                partial_url='github.com'
            )

            print(f"Total configs: {result['total_configs']}")
        - lang: typescript
          label: Add 2FA config
          source: |-
            import { SimplexClient } from 'simplex';

            const client = new SimplexClient({ apiKey: 'your_api_key' });

            const result = await client.add2faConfig('JBSWY3DPEHPK3PXP', {
              name: 'GitHub',
              partialUrl: 'github.com'
            });

            console.log(`Total configs: ${result.total_configs}`);
        - lang: curl
          label: Add 2FA config
          source: |-
            curl -X POST "https://api.simplex.sh/add_2fa_config" \
              -H "X-API-Key: your_api_key_here" \
              -H "Content-Type: application/json" \
              -d '{
                "seed": "JBSWY3DPEHPK3PXP",
                "name": "GitHub",
                "partial_url": "github.com"
              }'
components:
  schemas:
    Error:
      required:
        - error
        - message
      type: object
      properties:
        succeeded:
          type: boolean
          example: false
        error:
          type: string
          example: Invalid API key.
  securitySchemes:
    bearerAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Simplex API Key

````

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