# Create a Tenant

`POST https://api.agilitycredit.net/v3/tenants`

Docs page: https://apidocs.agilitycredit.com/api/create-tenant · Tag: Administration

Creates a customer tenant under your account. Only integrator accounts can create tenants. Your account becomes the parent and integrator of the new tenant, so your API key can act on it by sending the returned `tenant_id` as `Agc-Tenant-Id`. Only the account details below are accepted; every other configuration setting starts at its default and is managed from the Agility Portal. Optionally, send `api_user` to also create a user with the `api` role, to be sent as `Agc-User-Id` when acting on the new tenant.

Authentication: `Authorization: Bearer <api key>`.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Agc-Tenant-Id` | header | yes | The tenant ID provided by Agility Credit. |
| `Agc-User-Id` | header | yes | The requestor user ID. |
| `Idempotency-Key` | header | yes | A unique, idempotent key. We recommend to use a guid |

## Request body (`application/json`), required

Schema: `CreateTenant`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account_name` | string | yes |  |
| `legal_name` | string | yes |  |
| `address_billing` | object | yes |  |
| `address_billing.street` | string | yes |  |
| `address_billing.city` | string | yes |  |
| `address_billing.state_code` | string | yes | Two-letter uppercase state code. |
| `address_billing.postal_code` | string | yes |  |
| `address_billing.country_code` | string | yes | Two-letter uppercase ISO country code. |
| `address_physical` | object | yes |  |
| `address_physical.street` | string | yes |  |
| `address_physical.city` | string | yes |  |
| `address_physical.state_code` | string | yes | Two-letter uppercase state code. |
| `address_physical.postal_code` | string | yes |  |
| `address_physical.country_code` | string | yes | Two-letter uppercase ISO country code. |
| `phone_number` | string | yes |  |
| `website` | string | yes |  |
| `tax_id` | string | yes |  |
| `company_established_date` | string |  | Date in `YYYY-MM-DD` format. |
| `timezone` | string |  | IANA timezone name. Defaults to `America/Los_Angeles`. |
| `subdomain` | string |  | Lowercase letters, digits and hyphens (1 to 63 characters, not starting or ending with a hyphen). Must be unique across Agility Credit. Defaults to the generated tenant ID. |
| `market` | string: `automotive`, `non-automotive`, `mortgage` | yes |  |
| `enduser_type` | string |  |  |
| `nature_of_business` | string: `auto_dealer`, `vehicle_financing`, `auto_refinance`, `equipment_financing`, `medical_financing`, `home_improvement_financing`, `buy_now_pay_later`, `unsecured`, `personal_loans`, `tax_relief`, … (6 more) | yes |  |
| `primary_title` | string |  |  |
| `inspection_email` | string |  |  |
| `inspection_full_name` | string |  |  |
| `inspection_phone` | string |  |  |
| `inspection_title` | string |  |  |
| `product_addons` | object |  | Driver license verification is the only product addon that can be changed through the API. `driver_license_verify` must be enabled (in the same request or already on the tenant) to enable `driver_license_verify_doc_liveness` or `driver_lic… |
| `product_addons.driver_license_verify` | boolean |  |  |
| `product_addons.driver_license_verify_doc_liveness` | boolean |  |  |
| `product_addons.driver_license_verify_selfie` | boolean |  |  |
| `ip_whitelist` | array of object |  |  |
| `ip_whitelist[].value` | string | yes |  |
| `ip_whitelist[].description` | string | yes |  |

Example:

```json
{
  "account_name": "Acme Motors",
  "legal_name": "Acme Motors LLC",
  "address_billing": {
    "street": "123 Main St",
    "city": "Austin",
    "state_code": "TX",
    "postal_code": "78701",
    "country_code": "US"
  },
  "address_physical": {
    "street": "123 Main St",
    "city": "Austin",
    "state_code": "TX",
    "postal_code": "78701",
    "country_code": "US"
  },
  "phone_number": "5125550100",
  "website": "https://www.acmemotors.com",
  "tax_id": "12-3456789",
  "nature_of_business": "auto_dealer",
  "market": "automotive",
  "subdomain": "acmemotors",
  "product_addons": {
    "driver_license_verify": true
  },
  "api_user": {
    "first_name": "Jane",
    "last_name": "Doe",
    "email": "api@acmemotors.com"
  }
}
```

## Responses

| Status | Description | Body |
| --- | --- | --- |
| 201 | Tenant created | CreateTenantResponse |
| 400 | Bad Request. Returned when the body fails schema validation, or when `driver_license_verify_doc_liveness` or `driver_license_verify_selfie` is enabled without `driver_license_verify`. | BadRequestResponse |
| 401 | Unauthorized | UnauthorizedResponse |
| 403 | Your account is not an integrator. | TenantErrorResponse |
| 409 | The subdomain is already taken, or a request with the same `Idempotency-Key` is still in progress. | TenantErrorResponse |
| 429 | Too Many Requests | TooManyRequestsResponse |
| 500 | Internal Server Error | AgilityServerErrorResponse |
Top-level 201 fields: `tenant_id`, `parent_id`, `subdomain`, `status`, `created_at`.

### Error bodies

400:

```json
{
  "status": "Bad Request - Validation Failed",
  "error": "data.market must be one of ['automotive', 'non-automotive', 'mortgage']"
}
```

401:

```json
{
  "message": "Unauthorized"
}
```

403:

```json
{
  "error": "Only integrator tenants can create tenants"
}
```

409:

```json
{
  "error": "Subdomain already exists"
}
```

429:

```json
{
  "error": "Too Many Requests"
}
```

500:

```json
{
  "message": "Agility Server Error"
}
```
