# Manage projects and environments

> Create a Falak project, add a staging environment by duplicating production, assign servers and databases per environment, and delete what you don't need.

Source: https://falak.sh/docs/guides/projects-and-environments/

This guide creates a project for a product, adds a **staging** environment copied from production, and wires staging to its own servers and database. Read [Projects, environments and services](/docs/concepts/projects-environments-services/) for the concepts.

## Create a project

1. On the **Projects** dashboard, click **+ New**.
2. Enter a name (and optionally a description). The project is created with a `production` environment.
3. Open it and add services with **+ Create**.

```bash title="API"
curl -X POST https://falak.example.com/api/v1/projects \
  -H "Authorization: Bearer $FALAK_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" \
  -d '{"name": "Shop", "description": "Storefront and admin"}'
```

## Add a staging environment

1. In the canvas top bar, open the environment switcher and choose **New environment**.
2. Name it `staging` and choose **Duplicate from: production**.
3. Falak copies every **site**: configuration, deploy script, Laravel toggles, shared paths and variables, at the same position and with the same service names. Databases are not copied, servers are not assigned, and push-to-deploy is off.
4. Create the staging database with the **same service name** as in production (for example `shop-db`). References like `${{ shop-db.DATABASE_URL }}` now resolve to the staging database.
5. For each site: **Settings → Servers**, pick staging servers; **Settings → Source**, pick the staging branch and turn push-to-deploy on if you want it.
6. Deploy.

```bash title="API: duplicate production into staging"
curl -X POST https://falak.example.com/api/v1/projects/01j…/environments \
  -H "Authorization: Bearer $FALAK_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" \
  -d '{"name": "staging", "from_environment_id": "01j…"}'
```

The response includes `warnings[]` for anything that could not be copied. Duplicating needs `projects.manage` and `sites.create`.

Protect staging with [basic auth](/docs/guides/routing-rules/#basic-auth) and give it a [test domain](/docs/guides/domains/#test-domain).

## Move between environments

Use the environment switcher in the top bar. The canvas remembers positions per environment. Deep links include the environment slug: `/projects/{project}/{environment}`.

## Rename and delete

- Rename a project or environment in **Project settings**. Renaming an environment changes its slug.
- Delete an environment when it is **empty** and not the production environment.
- Delete a project when it is **empty** and not the Default project.

Delete services first (each service panel → **Settings → Danger**). Deleting a site removes it from its servers.

## Next steps
