# Build a new base template.

> Not automated yet: the server answers `409 not_automated` with the steps to build one by hand (cloud/base/provision.sh on a build VM, save the snapshot, then activate it).
> https://koi.dog/docs/api/cloud/build-template/

`POST /api/v1/cloud/templates/build` · Scope: `config`

When built it will start a VM, need budget headroom, and answer at once with progress on the timeline. Experimental: this route may change inside v1. When an API key calls it, the timeline records who did what and the outcome. No path or query parameters, and no body.

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Makes a retry safe: the same key with the same request returns the first answer and does nothing else. |

## Response.

202 Accepted: a JSON object. The work continues and is reported on the timeline. The example has placeholder values.

## Request.

```sh
curl -X POST https://app.koi.dog/api/v1/cloud/templates/build \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)"
```

```js
const res = await fetch("https://app.koi.dog/api/v1/cloud/templates/build", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
  },
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://app.koi.dog/api/v1/cloud/templates/build",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "started": true
}
```
