# Create client account and company

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

Guide: Avalara Managed Returns API (EMEA)

# Create client account and company

Create a new client account and default company for a VAT merchant using the Avalara Managed Returns API.

Create a new Client Account to onboard a VAT client using the Avalara Managed Returns API. The first step in onboarding a VAT client is to provision a new Avalara Client Account from within your Firm (Partner) account.

When you provision a new Client Account, the following actions occur automatically:

-   A new Client Account is created, representing the merchant.
-   The Client Account is linked to your Firm (Partner) Account through a firm–client relationship.
-   A default company profile is created using the same name as the Client Account.
-   A license key is generated, which can be used for future authentication into the Client Account (for example, by integrations or APIs).

This process enables downstream setup tasks such as importing transactions and configuring registrations.

To provision a new Client Account:

-   The account name and address must be valid and unique. Invalid addresses trigger an error at the time of provisioning
-   Use a Firm (Partner) token for this operation. Client credentials aren’t accepted for account creation or provisioning

**View request**:

```
mutation {
  vatCreateMerchant(
    input: {
      additionalFields: {
        isTestAccount: true
      }
      customer: {
        name: "ELR TEST - eConnect Cust 22326"
        website: ""
        contacts: [
          {
            contactTypes: ["primary"]
            email: "talita.paes+eConnectDemo003@avalara.com"
            jobTitle: "Compliance Person"
            telephone: ""
            mailingAddress: {
              line1: "21 Street"
              line2: ""
              line3: ""
              city: "Brighton"
              region: ""
              country: "GB"
              postalCode: "BN435NN"
            }
            name: {
              familyName: "Talita"
              givenName: "Paes"
              prefix: "Ms."
              suffix: ""
            }
          }
        ]
        legalAddress: {
          line1: "21 Street"
          line2: ""
          line3: ""
          city: "Brighton"
          region: ""
          country: "GB"
          postalCode: "BN435NN"
        }
      }
    }
  ) {
    account {
      envs {
        environment
        organizationId
        tenantId
        userId
      }
    }
    errors {
      extensions {
        requestId
        status
        timestamp
        type
      }
      message
    }
    clientId
    clientSecret
  }
}
```

**View response**:

```
{
  "data": {
    "vatCreateMerchant": {
      "clientId": "07ae28f8220547d4b9d7924f6a22b988",
      "clientSecret": "EAZaqZ4EaqCo3XX0rVxfauCYi4",
      "id": "d23af9a7-13b2-4685-a27c-371e2232e858",
      "account": {
        "envs": [
          {
            "environment": "prd",
            "organizationId": "69c26e240241703a52370db0",
            "tenantId": "69c26e242862db047f440146",
            "userId": "59cddb71-1f18-4b02-9513-9624d2c4d9c5"
          }
        ]
      },
      "errors": null
    }
  }
}
```

After creating the merchant, wait for the credentials to be ready before continuing.

Use the following query:

```
query VatMerchantCredentialsReady {
  vatMerchantCredentialsReady
}
```

Poll this query before moving to the next step.