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

# Time-Based One-Time Password (TOTP) Integration

> Handle TOTP codes in automations

Generate TOTP codes from authenticator apps (Google Authenticator, Microsoft Authenticator, Authy) for 2FA.

<Info>
  If you are looking for 2FA codes from Email or Slack, please refer to the [Two-Factor Authentication Integration](/docs/advanced/two-fa-integration) documentation.
</Info>

## Get Your TOTP Secret

Follow this guide to extract your TOTP secret: [TOTP Secret Extraction Guide](https://cavalloj.medium.com/totp-secret-extraction-from-qr-codes-ee097b4c687f)

***

## Direct TOTP Secret

Provide the TOTP secret directly in `secure_parameters`:

```json theme={null}
{
  "secure_parameters": {
    "auth_code": [{
      "totp": {
        "totp_secret": "YOUR_BASE32_SECRET",
        "digits": 6
      }
    }]
  }
}
```

| Property      | Type  | Default  | Description                |
| ------------- | ----- | -------- | -------------------------- |
| `totp_secret` | `str` | Required | Base32-encoded TOTP secret |
| `digits`      | `int` | `6`      | Number of digits in code   |

***

## TOTP via 1Password (Recommended)

Store the TOTP secret in 1Password for better security:

```json theme={null}
{
  "secure_parameters": {
    "auth_code": [{
      "onepassword": {
        "type": "totp_secret",
        "vault_name": "my_vault",
        "item_name": "my_login",
        "field_name": "totp_secret",
        "digits": 6
      }
    }]
  }
}
```

<Tip>
  See [1Password Integration](/docs/advanced/onepassword) for setup instructions.
</Tip>

***

## Using in Automations

Reference the TOTP code like any parameter:

```json theme={null}
{
  "type": "action_node",
  "interaction_action": {
    "input_text": {
      "command": "get_by_label(\"Verification Code\")",
      "input_text": "{auth_code[0]}",
      "prompt_instructions": "Enter the 2FA code"
    }
  }
}
```

***

## Complete Example

Here's a complete automation that authenticates with a TOTP-protected service:

```json theme={null}
{
  "url": "https://sample.com/",
  "parameters": {
    "input_parameters": {
      "username": [
        "provider_username"
      ]
    },
    "secure_parameters": {
      "auth_code": [
        {
          "totp": {
            "totp_secret": "YUNFZZZH"
          }
        }
      ]
    },
    "generated_parameters": {}
  },
  "nodes": [
    {
      "type": "action_node",
      "interaction_action": {
        "input_text": {
          "command": "get_by_test_id(\"totp\")",
          "prompt_instructions": "Enter the 2FA code",
          "input_text": "{auth_code[0]}"
        }
      }
    }
  ]
}
```

This example:

* Uses a direct TOTP secret (`YUNFZZZH`) from `secure_parameters`
* Accepts a `username` as an `input_parameter`
* Enters the generated TOTP code into the input field identified by `test_id="totp"`
