# Connect a tenant to a project

Source: https://www.jawsdeploy.net/rest-api/tenants-project-connect | Section: Tenants

Connect a tenant to a project and choose the environments it can be deployed to.

`POST /api/tenant/project`

Connects a tenant to a project. The tenant, the project and the environments must all be in the same workspace.

A tenant can be connected to a project only once. To change the environments of an existing connection use `PUT /api/tenant/project`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `tenantId` | body | string | yes | ID of the tenant. |
| `projectId` | body | string | yes | ID of a project in the tenant's workspace. |
| `environmentIds` | body | array<string> | no | IDs of environments in the tenant's workspace the tenant can be deployed to. Leave out or send `[]` for none. |

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `tenantId` or `projectId`, an environment that is not in this workspace, or the tenant is already connected to the project. |
| 401 | Missing or invalid Basic auth credentials, or the service account lacks permission to manage tenants in this workspace. |

Example request:

```
POST /api/tenant/project HTTP/1.1
Authorization: Basic <base64(serviceAccountId:apiKey)>
Content-Type: application/json

{
  "tenantId": "tnt_acme",
  "projectId": "prj_abc123",
  "environmentIds": ["env_test", "env_prod"]
}
```

Example response:

```
{
  "projectId": "prj_abc123",
  "name": "Acme web",
  "tenantedDeployments": "Allowed",
  "environments": [
    { "environmentId": "env_test", "name": "Test" },
    { "environmentId": "env_prod", "name": "Production" }
  ]
}
```

