# Create a project

Create an Error Tracking project and get the DSN that the Sentry SDK of your app sends to.

Create one project per app or service. Replace _web_ with your project's name.

## Prerequisites

- Permission for `errors:CreateProject`. Without it, the console shows **Create project** as
  unavailable, with the note "Creating a project needs errors:CreateProject. Ask an administrator."
- In the console, also `errors:ListProjects` to open **Projects** (without it the page shows an
  access-denied notice) and on the new project to open it (without it the project is not found).
- Room in the **Error Tracking projects** quota (see [Quotas](quotas.md)).

## Create the project

A project costs nothing by itself; you pay for the events it accepts and what it stores (see
[What is Error Tracking?](what-is.md)).

**Console**
1. In Error Tracking, open **Projects**, then choose **Create project**.
2. For **Name**, enter web.
3. For **Platform**, choose what the app runs. The console proposes **Next.js**. The platform only
   chooses the setup instructions the console shows; events of any SDK are accepted.
4. Choose **Create**.

The console opens the project's **Setup** tab, with the DSN in the page header and the setup
snippet for the platform you chose.

**CLI**
```sh
dcloud errors projects create --name web --platform javascript-nextjs
```

Without `--platform`, the platform is `other`. `--slug` sets the slug yourself.

**API**
```http
POST /errors/api/projects
{ "name": "web", "platform": "javascript-nextjs" }
```

The answer is `201` with the project, its one key and its `dsn`. Without `platform`, the platform
is `other`.

**Terraform**
```hcl
resource "dcloud_errors_project" "web" {
  name     = "web"
  platform = "javascript-nextjs"
}

output "dsn" {
  value = dcloud_errors_project.web.dsn
}
```

Changing `slug` replaces the project, with a new DSN and none of its issues.

## Result

The project exists with one active DSN key and these settings: retention 30 days, no project rate
limit, client IP addresses not kept, and default alert mails to the organization's owners and
admins on. Put the DSN into `Sentry.init({ dsn })`, or into `SENTRY_DSN`, which most SDKs read when
`init()` gets no DSN.

The slug is what `sentry-cli --project` and `SENTRY_PROJECT` name, and the start of every short id
(`WEB-1A`). Without one, it is derived from the name: lowercase letters, digits and dashes, with
`-2`, `-3`, … added when another project of the organization has it.

## When creation is refused

- `409` "A project with the slug … exists already" when the slug you gave is taken.
- `409` "No free slug for this name; choose one" when no free slug can be derived from the name.
- `409` "Quota exceeded: Error Tracking projects (errors.projects) — …" when the quota is used up.

## Related

- [Change project settings](change-project-settings.md)
- [Connect an app](connect-an-app.md)
- `errors.projects.create` · `dcloud errors projects create` · `dcloud_errors_project`
