# Templates API

> Deploy a catalog or custom template into a project environment through the REST API — inputs, domains, servers, position — and read the response.

Source: https://falak.sh/docs/api/templates/

## `POST /api/v1/projects/{project}/{environment}/templates/{slug}/deploy`

Creates a Compose site from a template in the given project environment and starts its first deployment. Same body and response as the **Deploy** button of the configure form. Rate limited to 30/minute.

**Permissions:** `templates.view`, `projects.manage` and `sites.create`. Without `deployments.create`, the site is created but not deployed (a warning says so).

| Path part | Rule |
|---|---|
| `{project}` | Project id (26-character ULID) |
| `{environment}` | Environment slug or id |
| `{slug}` | Template slug, `^[a-z0-9][a-z0-9-]{0,49}$` |

| Body field | Rule |
|---|---|
| `server_ids[]` | Required; 1–50 server ids |
| `source` | `catalog` or `custom` (when a custom template shares a catalog slug) |
| `name` | Optional site name, `^[A-Za-z0-9][A-Za-z0-9 ._-]*$`, up to 64 characters |
| `inputs` | Object `{KEY: value}` (up to 200); missing generated inputs are generated |
| `domains` | Object `{service: choice}` (up to 50); a name or a [domain choice](/docs/api/domains-and-dns/#domain-choices); missing = the organization default |
| `position` | `{x, y}` canvas position |

```bash
curl -X POST "https://falak.example.com/api/v1/projects/01j…/production/templates/n8n/deploy" \
  -H "Authorization: Bearer $FALAK_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" \
  -d '{"server_ids": ["01k…"],
       "inputs": {"TIMEZONE": "Europe/Berlin"},
       "domains": {"n8n": "n8n.example.com"}}'
```

```json title="201 Created"
{"data": {
  "site_id": "01k…",
  "name": "n8n",
  "service_id": "01k…",
  "deployment_id": "01k…",
  "domains": {"n8n": "n8n.example.com"},
  "panel_url": "/projects/01j…/production/service/site/01k…/deployments"
},
 "warnings": []}
```

`404` when the project, environment or template is not found. Follow the deployment with the [Deployments API](/docs/api/deployments/).

Browsing templates and managing custom templates are available in the UI only. See [Templates](/docs/templates/deploy-a-template/).
