# Create a Project in this org, or import a template

`POST /o/{org}/p`

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `org` | path | string | yes | The org's slug or id. A caller with no role in the org gets `404`. |

## Request body

- `template` (string, optional): A Project template's id (`GET /community/projects`). The new Project takes the template's goal, instructions and default agent, adds each Community agent it runs (as `POST /o/{org}/agents {template}` does) and creates its automations switched off; send only `name`, `visibility` and a repository with it. `404 NOT_FOUND` for no listed template; `422 TEMPLATE_AGENT_UNLISTED` when one of its agents is no longer listed; `422 TEMPLATE_NEEDS_CONNECTION` with `needs` (`github`: send a repository, `linear`, `gmail`: connect it; an API key takes neither). Answers 201 `{project, agents: [{id, listing_id}], automations}` with each webhook trigger's secret once; anything refused after the Project exists deletes it and its automations (the agents it added stay, and a retry reuses them).
- `name` (string, required)
- `goal` (string, optional)
- `instructions` (string, optional): Standing instructions every run in the Project reads first.
- `file_ids` (array of string, optional): Finished uploads of the caller's (`POST /o/{org}/files`) that become the Project's files, copied into every run started in it. Refused before the Project is made, with the code a run would get (`404 ATTACHMENT_NOT_FOUND`, `409 ATTACHMENT_IN_USE`, `410 ATTACHMENT_EXPIRED`, `400 INVALID_BODY`).
- `visibility` (string, optional, one of `private`, `org`): Defaults to private.
- `repo_host` (string, optional, one of `gitlab`): gitlab.com; absent for GitHub.
- `connection` (string, optional): With `repo_host: gitlab`: which of your GitLab sign-ins (`GET /me/connections`) checks the repository. Not stored.
- `installation_id` (integer, optional)
- `repo_owner` (string, optional)
- `repo_name` (string, optional)
- `repo_id` (integer, optional)
- `default_branch` (string, optional)
- `default_harness` (string, optional, one of `claude`, `codex`, `opencode`): Defaults to claude.
- `default_harness_version` (string, optional)

## Example request

```bash
curl -X POST "https://api.phoenix.so/o/$RUSH_ORG/p" \
  -H "Authorization: Bearer $RUSH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string"
  }'
```

```typescript
const org = process.env.RUSH_ORG;

const res = await fetch(`https://api.phoenix.so/o/${org}/p`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RUSH_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "string",
  }),
});

console.log(res.status, await res.json());
```

```python
import os

import requests

org = os.environ["RUSH_ORG"]

res = requests.post(
    f"https://api.phoenix.so/o/{org}/p",
    headers={"Authorization": f"Bearer {os.environ['RUSH_TOKEN']}"},
    json={
        "name": "string",
    },
)

print(res.status_code, res.json())
```

## Responses

### 201

Project created. An import also answers `agents` (yours, each with the `listing_id` it came from) and `automations` (each switched off; a webhook trigger's secret once).

- `project` (Project, required): The repository is optional Context. A GitHub one has installation_id, repo_owner and repo_name all set; a gitlab.com one has `repo_host: gitlab`, repo_owner (its group path) and repo_name, with installation_id and repo_id null; with none, all are null.
  - `id` (string, required)
  - `org_id` (string, optional): The org the Project belongs to.
  - `user_id` (string, optional): The Project's creator: the one person who sees it while it is private, and the only one who changes its visibility.
  - `visibility` (string, optional, one of `private`, `org`): Who sees the Project, its runs, automations, secrets and files: `private` is its creator alone, `org` is every member of its org. A run is always readable by whoever started it; a run with no Project is readable by them alone.
  - `name` (string, required)
  - `repo_host` (string, optional, one of `gitlab`): Present when the repository is on gitlab.com; absent for a GitHub repository or none.
  - `installation_id` (integer | null, required)
  - `repo_owner` (string | null, required)
  - `repo_name` (string | null, required)
  - `repo_id` (integer | null, optional)
  - `default_branch` (string | null, optional)
  - `default_harness` (string, required, one of `claude`, `codex`, `opencode`): Launch-boundary managed harnesses.
  - `default_harness_version` (string | null, optional)
  - `readiness` (string, required, one of `pending`, `ready`, `error`)
  - `sync_status` (string, optional, one of `idle`, `syncing`, `synced`, `error`)
  - `sync_error` (string | null, optional)
  - `last_synced_at` (string | null, optional)
  - `created_at` (string, optional)
  - `updated_at` (string, optional)
  - `is_default` (boolean, optional): The project a prompt-only surface (Slack) resolves to. Per user, not per org.
  - `people_count` (integer, optional): How many people it is shared with by name (GET …/people lists them).
  - `goal` (string, optional): What the Project is for; empty when unset.
  - `instructions` (string, optional): Standing instructions every run in the Project receives ahead of its prompt; empty when unset.
  - `paused_at` (string | null, optional): When it was paused: no run or follow-up starts (`409 PROJECT_PAUSED`) and no automation fires. Null when running.
  - `archived_at` (string | null, optional): When it was archived. A client leaves it out of its lists; nothing else changes, its runs and automations carry on. Null when not archived.
  - `last_run_at` (string | null, optional): When a run last started in the Project. Null before its first run.
- `agents` (array of object, optional)
  - `id` (string, required)
  - `listing_id` (string, required)
- `automations` (array of Automation, optional)
  - `id` (string, required)
  - `project_id` (string, required): The Project it runs in.
  - `name` (string, required)
  - `prompt` (string, required): The instructions each run receives; a trigger's event follows as untrusted data.
  - `profile_id` (string | null, optional): The saved agent it runs with; null when it runs a default harness or is a wake.
  - `harness` (string, optional, one of `claude`, `codex`, `opencode`): The default harness it runs; absent with a saved agent or a wake.
  - `model` (string, optional): The model it runs `harness` with; absent for the harness default.
  - `effort` (string, optional): The effort it runs `model` at; absent for the model default.
  - `profile` (object | null, optional): The saved agent it runs with; null when none, or when the caller cannot see that agent (`profile_id` still names it).
    - `id` (string, optional)
    - `name` (string, optional)
    - `harness` (string, optional, one of `claude`, `codex`, `opencode`): Launch-boundary managed harnesses.
  - `session_id` (string | null, optional): Makes it a wake: each fire sends the prompt to this session as a follow-up instead of starting a run. The session must be in this Project, changeable by `created_by`, resumable and open. A fire that lands mid-turn is skipped; a session that has closed turns the automation off and notifies its runner.
  - `read_only` (boolean, required): Its runs can read the repository and comment, but not push.
  - `enabled` (boolean, required)
  - `max_runs_per_hour` (integer, required): Runs and wake turns all its triggers together may start per hour. A trigger's run past it is created queued and starts when the hour has room, up to one more hour's worth waiting; an event past that is refused, and so are Run now and a wake at the cap.
  - `notify_each_run` (boolean, required): How its finished runs reach `created_by`: each on its own (true), or as one Slack message a day that each run updates (false, the default). Failures always come on their own. Only `created_by` may change it (`403 FORBIDDEN` for anyone else, an org admin included).
  - `created_by` (string, required): The member its runs start as: the last one to change what it does.
  - `api_key_id` (string | null, optional): The API key it was set up or last changed with. Its fires are then that key's runs: prepaid credits, the key's connection rules and `max_concurrent`; once the key is revoked or expires they start nothing (`skipped`, `api_key_revoked`). A key changes only automations set up with a key (`403 FORBIDDEN` otherwise). Null: set up in the console, it runs as `created_by`.
  - `created_at` (string, required)
  - `updated_at` (string, required)
  - `triggers` (array of AutomationTrigger, required)
    - `id` (string, required)
    - `kind` (string, required, one of `github`, `schedule`, `webhook`, `linear`, `email`, `session`)
    - `events` (array of string | string, optional): GitHub event keys (kind `github`) or Linear event keys (kind `linear`).
    - `branch_patterns` (array of string, optional): Globs on a pull request's base branch (kind `github` only).
    - `config` (TriggerConfig, optional)
      - `labels` (array of string, optional): Kind `github`: any-of label filter. Kind `linear`: the labels whose addition fires `linear.issue.labeled` (required with it).
      - `teams` (array of string, optional): Kind `linear`: Linear team keys; empty means every public team.
      - `states` (object, optional): Kind `linear`: Linear state name -> mode (required with `linear.issue.state_changed`). `plan` starts a read-only run that posts its plan as a comment on the issue through the runner's Linear connection; `exec` starts an ordinary run.
      - `authors` (array of string, optional): Kind `github`: GitHub logins.
      - `cron` (string, optional): Kind `schedule`: a 5-field cron expression, at most hourly (every 10 minutes for a wake). Exactly one of `cron` and `every` is sent; `every` is stored as its cron.
      - `every` (string, optional, one of `10m`, `30m`, `1h`, `1d`): Kind `schedule`: the plain-language schedule, read in `timezone` (`1d` is midnight); stored and returned as `cron`. `10m` and `30m` need a wake (the automation's `session_id`).
      - `timezone` (string, optional): Kind `schedule`: an IANA timezone; UTC when omitted.
      - `from` (array of string, optional): Kind `email`: senders that may start a run, each an address (`dana@acme.com`) or a domain (`acme.com`, `@acme.com`); empty means anyone. Mail from anyone else, or whose domain did not pass DMARC at Gmail, is skipped.
      - `label` (string, optional): Kind `email`: a Gmail label name; only new mail carrying it fires (a Gmail filter that adds the label picks the mail). Without it, any new inbox message fires.
      - `history_id` (string, optional): Kind `email`: the Gmail history the trigger has read up to. An email trigger reads its runner's connected Gmail (primary account) about once a minute; each new message (sender, subject, date, the plain-text body up to 64 KB, at most 20 attachments as the run's files) starts one run, deduped on its Gmail id. Mail sent by the runner never fires. Adding one needs a Gmail connection (422 `GMAIL_NOT_CONNECTED`) and makes the caller its runner.
      - `history_account` (string, optional): Kind `email`: the Gmail account `history_id` belongs to. When the runner's account changes, the trigger reads from now.
      - `agents` (array of string, optional): Kind `session` (required): the runs it follows, by saved agent id, or a harness name for runs with no saved agent. When such a run in the Project ends, the automation starts with the ended run's status, outcome, pull request, structured result and final message as its event. Its runner must be able to read that run.
      - `ended` (array of string, optional): Kind `session`: the ways the run ended that fire it; `[completed]` when omitted.
      - `outcome` (array of string, optional): Kind `session`: fire only when the run's structured result (its `output_schema` answer, when valid) has one of these as `outcome`, such as `approved` or `changes_requested`. Absent means any.
      - `max_depth` (integer, optional): Kind `session`: how many session triggers in a row may follow one run something else started; 3 when omitted. Runs on one pull request count together, so a review and fix loop through GitHub events ends too.
    - `next_fire_at` (string | null, optional): The next schedule slot, or when an email trigger next reads Gmail; null for other kinds.
    - `last_fired_at` (string | null, optional)
    - `created_at` (string, required)
    - `webhook_url` (string, optional): Kind `webhook` only: POST here with `Authorization: Bearer <secret>`; the body (at most 64 KB) becomes the event text and an `Idempotency-Key` header dedups retries. Answers 202 with a TriggerFireOutcome, and 401 for an unknown trigger or a wrong secret alike.
    - `webhook_secret` (string, optional): Kind `webhook`, only in the response that created or rotated it.
  - `recent_runs` (array of object, optional): Its five latest runs, newest first.
    - `id` (string, required)
    - `status` (string, required)
    - `trigger_id` (string | null, required): The trigger that started it; null for Run now.
    - `title` (string | null, required): The run's title: the first line of its prompt unless someone named it.
    - `summary` (string | null, required): What the agent said when the run finished; null until then.
    - `created_at` (string, required)

### 400

Malformed request.

### 401

No bearer, an unknown, revoked or expired one, or an API key on a route keys cannot call.

### 409

A Project with this (case-insensitive) name already exists in the org.

### 422

A template that cannot be imported now: `TEMPLATE_AGENT_UNLISTED` (names `agent`), or `TEMPLATE_NEEDS_CONNECTION` (lists `needs`).

### 429

The account is over its request budget, 1,800 a minute shared by the person's API keys and console on every API host (`RATE_LIMITED`). The error names the limit. Wait `Retry-After` seconds.

## Example response (201)

```json
{
  "project": {
    "id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
    "org_id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
    "user_id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
    "visibility": "private",
    "name": "string",
    "repo_host": "gitlab",
    "installation_id": 0,
    "repo_owner": "string",
    "repo_name": "string",
    "repo_id": 0,
    "default_branch": "string",
    "default_harness": "claude",
    "default_harness_version": "string",
    "readiness": "pending",
    "sync_status": "idle",
    "sync_error": "string",
    "last_synced_at": "2026-10-06T12:00:00Z",
    "created_at": "2026-10-06T12:00:00Z",
    "updated_at": "2026-10-06T12:00:00Z",
    "is_default": true,
    "people_count": 0,
    "goal": "string",
    "instructions": "string",
    "paused_at": "2026-10-06T12:00:00Z",
    "archived_at": "2026-10-06T12:00:00Z",
    "last_run_at": "2026-10-06T12:00:00Z"
  },
  "agents": [
    {
      "id": "string",
      "listing_id": "string"
    }
  ],
  "automations": [
    {
      "id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
      "project_id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
      "name": "string",
      "prompt": "string",
      "profile_id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
      "harness": "claude",
      "model": "string",
      "effort": "string",
      "profile": {
        "id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
        "name": "string",
        "harness": "claude"
      },
      "session_id": "string",
      "read_only": true,
      "enabled": true,
      "max_runs_per_hour": 1,
      "notify_each_run": true,
      "created_by": "string",
      "api_key_id": "string",
      "created_at": "2026-10-06T12:00:00Z",
      "updated_at": "2026-10-06T12:00:00Z",
      "triggers": [
        {
          "id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6e8c0a14",
          "kind": "github",
          "events": ["issue_comment.mention"],
          "branch_patterns": ["string"],
          "config": {
            "labels": [
              {}
            ],
            "teams": [
              {}
            ],
            "states": {},
            "authors": [
              {}
            ],
            "cron": "string",
            "every": "10m",
            "timezone": "string",
            "from": [
              {}
            ],
            "label": "string",
            "history_id": "string",
            "history_account": "string",
            "agents": [
              {}
            ],
            "ended": ["completed"],
            "outcome": [
              {}
            ],
            "max_depth": 1
          },
          "next_fire_at": "2026-10-06T12:00:00Z",
          "last_fired_at": "2026-10-06T12:00:00Z",
          "created_at": "2026-10-06T12:00:00Z",
          "webhook_url": "https://example.com",
          "webhook_secret": "string"
        }
      ],
      "recent_runs": [
        {
          "id": "string",
          "status": "string",
          "trigger_id": "string",
          "title": "string",
          "summary": "string",
          "created_at": "2026-10-06T12:00:00Z"
        }
      ]
    }
  ]
}
```
