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

# Create Stack

> Creates a stack from applications and databases you already have, and optionally connects them to each other.

Groups applications and databases that already exist into one stack. All members must belong to the same account or workspace and none can be in another stack. To create a stack from a folder in one step, see [Transform Folder into Stack](https://docs.vertracloud.app/api-reference/endpoint/stacks/transform.md). Needs the `stacks:write` scope when called with an API key. Only the owner of a workspace can create stacks in it.

**name** `string` *required*

The stack name.

**description** `string | null`

Optional description.

**network\_mode** `string` (default: public)

Only `public` is accepted. Any other value fails with `STACK_NETWORK_MODE_UNAVAILABLE`.

**members** `object[]`

The resources to put in the stack. Each item has `resource_type` (`application` or `database`) and `resource_id`. A Blob folder is added afterwards with [Add Blob Folder](https://docs.vertracloud.app/api-reference/endpoint/stacks/blob/create.md).

**bindings** `object[]`

Connections to create between the members. Each item has `app_id` (the application that receives the variables), exactly one of `database_id` or `target_app_id`, and an optional `env_map` (variable name to what it receives; see [Create Connection](https://docs.vertracloud.app/api-reference/endpoint/stacks/bindings/create.md)). Without `env_map`, the standard names of the engine are used.

**workspace\_id** `string`

The workspace that will own the stack.

### Response

**response** `object`

The stack created (`201`), with the same fields as [Get Stack](https://docs.vertracloud.app/api-reference/endpoint/stacks/get.md), plus:

**Toggle object**

**restart\_required** `boolean`

`true` when at least one application must restart to read the variables or certificates the new connections created. An application reads them only when it starts, so the platform does not restart it for you.

**apps\_to\_restart** `string[]`

The applications that need a restart. Empty when `restart_required` is `false`. Restart them with [Restart Application](https://docs.vertracloud.app/api-reference/endpoint/apps/restart.md).

The same two fields come back on every change that can alter variables or certificates of an application: transform, add or remove a member, create or change a connection, add a database or a Blob folder.

```json Response theme={null}
{
  "response": {
    "id": "stk-abc123def456",
    "name": "shop",
    "network_mode": "public",
    "members": [],
    "bindings": [],
    "restart_required": true,
    "apps_to_restart": ["app-abc123def456"]
  }
}
```

```bash cURL theme={null}
curl -X POST https://api.vertracloud.app/v1/stacks \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "shop",
    "members": [
      { "resource_type": "application", "resource_id": "app-abc123def456" },
      { "resource_type": "database", "resource_id": "db-abc123def456" }
    ],
    "bindings": [{ "app_id": "app-abc123def456", "database_id": "db-abc123def456" }]
  }'
```

### Errors

| Status | Code | When |
| - | - | - |
| 400 | `STACK_NETWORK_MODE_UNAVAILABLE` | `network_mode` is not `public`. |
| 409 | `STACK_MEMBER_CONFLICT` | A resource is already in another stack, or is not in the same account or workspace as the stack. |
| 403 | `WORKSPACE_OWNER_ONLY` | You are a workspace member, not the owner. |
| 404 | `APP_NOT_FOUND` | An application does not exist or is not yours. |
| 404 | `DATABASE_NOT_FOUND` | A database does not exist or is not yours. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.