# Create a project.

> `repo` is a GitHub `owner/name`, or null for a project that only exists in Koidog's own mirror (no pull requests are opened).
> https://koi.dog/docs/api/projects/create-project/

`POST /api/v1/projects` · Scope: `config`

No path or query parameters.

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

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | yes | The project's name, shown in the dashboard. At least 1 character. |
| `repo` | `string \| null` | yes | GitHub `owner/name`, or null for a project that only exists locally. Matches `^[\w.-]+\/[\w.-]+$`. |
| `defaultBranch` | `string` | no | The branch crews start from. Default `main`. |
| `instructions` | `string` | no | Text every agent of this project's crews is given with its task. Default empty. |
| `validation` | `object` | no | The checks a node runs after an agent finishes, in the order install, build, lint, test. A `koidog.json` in the repository, when there is one, is used instead. Default `{}`. |
| `validation.install` | `string` | no | Command that installs dependencies. Left out, the step is skipped. |
| `validation.build` | `string` | no | Command that builds the project. Left out, the step is skipped. |
| `validation.test` | `string` | no | Command that runs the tests. Left out, the step is skipped. |
| `validation.lint` | `string` | no | Command that lints the project. Left out, the step is skipped. |
| `validation.preview` | `object` | no | How to run a live preview of the project. The command runs (after the project's `install` step, if any) as an isolated slot user, with `PORT` set to the first port of the slot's range; `port` picks another port inside that range for apps that cannot read `PORT`. The preview is up only after an HTTP request to `ready.path` answers (any status below 500) within `ready.timeoutSeconds`. |
| `validation.preview.command` | `string` | yes | The command that starts the preview server. At least 1 character. |
| `validation.preview.port` | `integer` | no | The port the preview listens on, inside the slot's range. Left out, `PORT`. |
| `validation.preview.ready` | `object` | no | Readiness check. Absent: GET / within 300 seconds. |
| `validation.preview.ready.path` | `string` | no | The path requested to see whether the preview is up. Matches `^\/.*`. |
| `validation.preview.ready.timeoutSeconds` | `5–1800` | no | How long to wait for that path to answer. |
| `validation.commands` | `object` | no | Extra named commands a project declares besides its validation steps, name to command line (for example `screenshot`). A node runs one only when an agent asks for it by name through the project-commands tool (node feature "project\_commands"); they are never part of the checks after a run. |

## Response.

201 Created: a `Project`. The example has placeholder values.

- **422 validation_failed**: The body does not match its schema; each problem is in `details`.

## Request.

```sh
curl -X POST https://app.koi.dog/api/v1/projects \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Landing page",
      "repo": "<owner/repo>"
    }'
```

```js
const res = await fetch("https://app.koi.dog/api/v1/projects", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Landing page",
    repo: "<owner/repo>",
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://app.koi.dog/api/v1/projects",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "name": "Landing page",
        "repo": "<owner/repo>",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "name": "string",
  "repo": "string",
  "defaultBranch": "string",
  "instructions": "string",
  "validation": {
    …
  },
  "createdAt": "string",
  "archivedAt": "string"
}
```
