> ## 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.

# Save a Stack as a Template

> Saves one of your stacks as a private template with one service per member, choosing variables and files for each application.

This call saves a stack as a private template with a first version and answers `201` with the template, one service per member you choose. The connection variables of the stack become placeholders that point at the other services (`{{services.db.url}}`, for example), and each Blob folder of the stack becomes a Blob service. A member left out of the template also leaves out the variables that pointed at it. Databases are recreated empty: their data is never copied.

Needs the `templates:write` scope when called with an API key. The plan, limit and workspace rules of [Create a Private Template](https://docs.vertracloud.app/api-reference/endpoint/templates/create.md) apply, the template is not verified by Vertra Cloud, and the refusals of [Create Template from App](https://docs.vertracloud.app/api-reference/endpoint/templates/create-from-app.md) apply to each application member. Read the proposal first with [Review Template Draft](https://docs.vertracloud.app/api-reference/endpoint/templates/draft.md).

**stack\_id** `string` *required*

The stack ID.

**workspace\_id** `string`

If the stack belongs to a workspace, the workspace's ID.

**id** `string` *required*

The slug of the template, lowercase letters, digits and hyphens.

**name** `object` *required*

The name by language: `pt-br` (required), `en` and `es`, up to 50 characters each.

**description** `object` *required*

The description by language, same shape as `name`, up to 128 characters each.

**category** `string` *required*

`automation`, `ai-agents`, `bots`, `apis`, `cms`, `monitoring`, `starters`, `databases` or `other`.

**tags** `string[]`

Up to 10 tags.

**version** `string`

The first version, as a semantic version. Default `1.0.0`.

**permissions** `object`

What users of the template may do, as in the [permissions](https://docs.vertracloud.app/templates/create/permissions.md) of the manifest.

**members** `object[]` *required*

What to save of each member of the stack, an application or a database.

**member object**

**resource\_id** `string` *required*

The ID of the application or database to save.

**service\_id** `string` *required*

The id the service gets in the manifest.

**env** `object[]`

One review per variable of an application. A variable without a review is left out of the template. Each review has:

* `key`: the variable name.
* `mode`: `question` (becomes a question the user answers; the value is not copied), `keep` (the value is copied; refused when it looks like a credential), `generate` (becomes a secret the platform generates for each user, with `generate` set to `random:<n>` or `uuid`), `hidden` (copied but hidden from whoever uses the template; the value stays out of sight of whoever uses the template) or `omit` (left out).
* `label` and `help`: texts by language (`pt-br`, `en`, `es`), used by `question` and `generate`.
* `generate`: how the secret is generated, `random:<n>` or `uuid`.

Read the suggestions first with [Review Template Draft](https://docs.vertracloud.app/api-reference/endpoint/templates/draft.md).

**paths** `string[]`

The paths of the application's `/app` that go into the template, for applications with code. Without it, everything goes in except what the draft leaves unselected. `.env*` files, the platform folder and dependency folders can never be included.

**ram** `object`

The memory of the service in MB: `min`, `recommended` and optional `max`.

**workspace\_id** `string`

The workspace that will own the template. Without it, the template belongs to you.

```bash cURL theme={null}
curl -X POST https://api.vertracloud.app/v1/templates/from-stack/stk-abc123def456 \
  -H "Authorization: Bearer $VERTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "api-with-postgres",
    "name": { "pt-br": "API com Postgres", "en": "API with Postgres" },
    "description": { "pt-br": "API e banco prontos." },
    "category": "apis",
    "members": [
      { "resource_id": "app-abc123def456", "service_id": "api" },
      { "resource_id": "db-abc123def456", "service_id": "db" }
    ]
  }'
```

### Response

The same template object returned by [Create a Private Template](https://docs.vertracloud.app/api-reference/endpoint/templates/create.md), with `201 Created`. `creates_stack` is `true` and `services` has one entry per member.

```json Response theme={null}
{
  "response": {
    "id": "tpl-abc123def456",
    "slug": "api-with-postgres",
    "origin": "private",
    "name": { "pt-br": "API com Postgres", "en": "API with Postgres" },
    "category": "apis",
    "creates_stack": true,
    "services": [
      { "id": "api", "kind": "app", "source_type": "code", "database": null, "blob_visibility": null, "ram": { "min": 256, "recommended": 512 }, "web": "required", "conditional": false },
      { "id": "db", "kind": "database", "source_type": null, "database": "postgres", "blob_visibility": null, "ram": { "min": 256, "recommended": 256 }, "web": null, "conditional": false }
    ],
    "ram_min_total": 512,
    "created_at": "2026-10-27T14:02:00Z",
    "updated_at": "2026-10-27T14:02:00Z"
  }
}
```

### Error Responses

**code** `string`

The error code indicating the reason for the failure. Possible values:

* `API_KEY_SCOPE_DENIED`: The API key does not have the `templates:write` scope (`403`).
* `STACK_NOT_FOUND`: The stack does not exist or is not yours.
* `APP_NOT_FOUND`: A member application does not exist.
* `TEMPLATE_SAVE_NOT_ALLOWED`: A member application came from a share link, or runs a platform image (`403`).
* `TEMPLATE_CLOSED`: A member comes from a closed template (`403`).
* `TEMPLATE_MANIFEST_INVALID`: The result is not a valid manifest; `details.issues` lists the findings.
* `TEMPLATE_SECRET_IN_SOURCE`: A selected file holds a secret; `details.files` lists the paths (`400`).
* `TEMPLATE_SLUG_TAKEN`: The slug is already in use among your templates or is reserved.
* `TEMPLATE_PRIVATE_LIMIT_REACHED`: The account already has 5 private templates.
* `PLAN_DOES_NOT_SUPPORT_CUSTOM_IMAGES`: The plan cannot create templates.
* `WORKSPACE_OWNER_ONLY`: Only the workspace owner saves templates in it.

```json Error Response theme={null}
{
  "code": "TEMPLATE_CLOSED"
}
```


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