# Create a project

Source: https://openpanel.sh/docs/projects/create

Create a project in the console, with the CLI or the API, then rename it, change who sees it, link a folder to it, or delete it.

A project is made with its **production** environment, and you get admin access to it. You need the role **Owner**, **Admin** or **Can deploy** in the organization. See [Projects](/docs/concepts/projects) for what a project holds.

## Create one [#create-one]

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
On the **Projects** page, click **New project**. Give it a **Name**, choose **Who can see it**, and click **Create project**. The project opens on its [canvas](/docs/projects/canvas), in production.
</Tab>

<Tab value="CLI">
```sh
openpanel projects create shop
```

Add `--private` to make it a [private project](/docs/members/private-projects) from the start.
</Tab>

<Tab value="API">
```sh
curl -X POST https://openpanel.sh/api/v1/projects \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "shop"}'
```

Add `"visibility": "private"` to make it private from the start. The answer is the project, with its id and its production environment:

```json
{
  "id": "01a23329-7dcc-7005-8000-154157fc0298",
  "name": "shop",
  "slug": "shop",
  "visibility": "organization",
  "environments": [{ "id": "01a23329-7dd0-7004-97fa-2b27946a7170", "name": "production", "production": true }],
  "access": "admin"
}
```

To retry safely after a network error, send an `Idempotency-Key` header: the same key returns the first answer instead of making a second project. See [the API overview](/docs/api).
</Tab>
</Tabs>

A name is 1 to 60 characters. Its slug is made from it, such as `my-shop` for `My Shop!`, with `-2` added when the organization already has that slug.

## Work in it from a folder [#work-in-it-from-a-folder]

The CLI takes `--project` (the slug, the name or the id) on every command. To leave it out, link a folder once:

```sh
openpanel link --project shop --service web
```

This writes `.openpanel.json` in the folder, and commands run in it or below use that project and service. `--service` is optional.

## Rename it [#rename-it]

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
Open **Project settings**, change the **Name** under **General**, and click **Save**.
</Tab>

<Tab value="CLI">
```sh
openpanel projects rename shop storefront
```
</Tab>

<Tab value="API">
```sh
curl -X PATCH https://openpanel.sh/api/v1/projects/$PROJECT_ID \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "storefront"}'
```
</Tab>
</Tabs>

The slug follows the new name. Services' opnl.app addresses made before keep their names. Renaming needs admin on the project.

## Change who sees it [#change-who-sees-it]

A project is seen by the whole organization, each member at their role's level, or it is private and seen only by the members given access.

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
Open **Project settings**. **Visibility** chooses between everyone in the organization and **Private: only the people you add**. **Access** lists every member with their role and gives one of them their own level, or **No access**.
</Tab>

<Tab value="CLI">
```sh
openpanel projects visibility shop private
openpanel projects access shop
openpanel projects access shop rasa@example.com deploy
```

The second command lists each member with their role and their own access to the project, if any; the third gives one member deploy access. Use `none` to hide the project from someone, or `role` to let their role decide again.
</Tab>

<Tab value="API">
```sh
curl -X PATCH https://openpanel.sh/api/v1/projects/$PROJECT_ID \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"visibility": "private"}'

curl -X PUT https://openpanel.sh/api/v1/projects/$PROJECT_ID/access/$USER_ID \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"access": "deploy"}'
```

`access` is `none`, `view`, `deploy` or `admin`, or `null` to let the member's role decide again. `GET /projects/$PROJECT_ID/access` lists every member with their own access.
</Tab>
</Tabs>

Both need admin on the project. Whoever makes a project private keeps admin on it. See [Per-project access](/docs/members/per-project-access) and [Private projects](/docs/members/private-projects).

## Environments [#environments]

Every project is made with one environment, **production**, and services are made in it unless you name another. A project admin adds more beside it, such as `staging`: each runs its own services with its own variables.

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
Open the project's **Settings**, then **Environments**, and choose **Add environment**. The environment menu in the project's bar switches between them; a service made there belongs to the environment shown.
</Tab>

<Tab value="CLI">
```sh
openpanel environments create staging --project shop
openpanel services create web --image nginx:1.27 --environment staging --project shop
openpanel environments --project shop
```
</Tab>

<Tab value="API">
```sh
curl -X POST https://openpanel.sh/api/v1/projects/$PROJECT_ID/environments \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "staging"}'
```

Then pass the answer's `id` as `environmentId` when you create a service.
</Tab>
</Tabs>

- **A name** is up to 32 lowercase letters, digits and hyphens, once per project.
- **Service names are used once in a project.** Its environments share one private network on each server for now, so a service in `staging` cannot be called `web` while `production` has a `web`; call it `web-staging`.
- **Deleting an environment** deletes its own variables. Production cannot be deleted, and an environment that still has services cannot either: delete its services first (`openpanel environments delete staging --project shop`, or `DELETE /environments/{environmentId}`).
- New environments start empty: services and variables are not copied from production.

## Delete a project [#delete-a-project]

Deleting a project deletes its services with their volumes, variables, deployments and domains, and its servers stop its containers. It needs admin on the project and cannot be undone.

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
Open **Project settings**, click **Delete project** under **Danger zone**, and confirm.
</Tab>

<Tab value="CLI">
```sh
openpanel projects delete shop
```

The CLI asks you to confirm. Add `--yes` where nobody is at the terminal.
</Tab>

<Tab value="API">
```sh
curl -X DELETE https://openpanel.sh/api/v1/projects/$PROJECT_ID \
  -H "Authorization: Bearer $OPENPANEL_TOKEN"
```

The answer is `204 No Content`.
</Tab>
</Tabs>

The data in the project's volumes is not wiped from the servers. See [Volumes](/docs/volumes#remove-a-volume).

## What can go wrong [#what-can-go-wrong]

| Message | What it means |
|---|---|
| "Give the project a name." | The name is empty. |
| "A project name is at most 60 characters." | Shorten the name. |
| "This needs admin access, and you have deploy." | Renaming, changing access and deleting need admin on the project. |
| "The owner always has admin access to every project." | The organization's owner's access cannot be changed. |
| "This API key is limited to some projects, so it cannot do this." | A key limited to projects cannot create a project. |

<Cards>
<Card href="/docs/projects/add-service" title="Add a service" description="The next step: something to run." />
</Cards>