# Query company two-factor settings

Source: https://developer.avalara.com/products/returns/integration-guides/managed-returns/mse4585278200914/

Guide: Avalara Managed Returns API (U.S. and Canada)

# Query company two-factor settings

Retrieve a company's 2-factor authentication (2FA) forwarding alias and notification email settings with the companies GraphQL query.

The `companies` query returns 2FA or MFA settings for a specified company through the `twoFactorSettings` field. When a tax authority requires 2FA, it sends verification codes to the company alias address. That address then forwards the email to the customer notification address.

This is a company-level setting. Each company has exactly 1 alias that is shared across every tax authority it onboards with, and exactly 1 forwarding email.

Key considerations:

-   **Required company ID**: Pass the company ID as an integer argument. If `id` is omitted, `twoFactorSettings` returns `null`, and an error is added to the `errors` array.

-   **Field distinction**: Selecting `codeDetails` does not read or create the alias. To read the alias, select `twoFactorSettings`.

## View request

```
query Companies($id: Int) {
  companies(id: $id) {
    value {
      id
      twoFactorSettings {
        companyId
        alias {
          aliasId
          alias
          email
          externalId
          sources {
            id
            name
          }
        }
      }
    }
    errors {
      message
    }
  }
}
```

**Input variables**:

```
{
  "id": 1234567
}
```

Table 1. Input variable details

Argument

Type

Description

`id`

`Int`

The company whose 2FA settings to return. This is a number, not a string. Required for `twoFactorSettings`.

## View response

```
{
  "data": {
    "companies": {
      "value": [
        {
          "id": 1234567,
          "twoFactorSettings": {
            "companyId": "1234567",
            "alias": {
              "aliasId": "5501",
              "alias": "k3m9x2@2fa.example.com",
              "email": "customer@example.com",
              "externalId": "1234567",
              "sources": [
                {
                  "id": "3",
                  "name": "Returns"
                }
              ]
            }
          }
        }
      ],
      "errors": []
    }
  }
}
```

**Response field descriptions**:

Response field

Description

`twoFactorSettings.companyId`

The company that the settings belong to.

`alias.aliasId`

The alias identifier.

`alias.alias`

The alias address where the tax authority sends 2FA emails.

`alias.email`

The customer email address that the alias forwards to. Returns null when no email has been associated.

`alias.externalId`

The alias external identifier.

`alias.sources`

The sources associated with the alias, for example, Returns.

Note

If the alias can't be returned, `twoFactorSettings.alias` is null and the reason is reported in the top-level GraphQL errors array. (Only `codeDetails` failures are reported in the `companies.errors` array.)

## Next step

To change the forwarding email, see [Update company two-factor alias](/managed-returns/asq2206617581230/ "Update the email address that a company two-factor authentication (2FA) alias forwards to by using the updateCompanyTwoFactorAlias GraphQL mutation."). To view the codes that have arrived, see [Query received two-factor security codes](/managed-returns/eqz5010147963677/ "Retrieve 2-factor authentication, 2FA, emails, and security verification codes for a company by using the companies GraphQL query."). If no 2FA updates are needed, proceed to [Grant authority access and trigger extraction](/managed-returns/skf6239163889825/ "Submit portal credentials for a tax authority, validate credentials and 2-factor authentication, and start background return extraction by using the grantAuthorityAccess GraphQL mutation.").

​​