
# Create an event type

Create one event type. The response is a 201 with the new type's URI in `Location`.

```sh
POST https://sitepaste.com/api/v1/public/sites/{siteId}/event-types
```

Requires the `content` scope.

To write several types at once, or to upsert and delete together, use [POST /sites/{siteId}/event-types/batch](/api/events/post-event-types-batch). To change a type that already exists, use [PATCH /sites/{siteId}/event-types/{slug}](/api/events/patch-event-types-slug).

## Usage

```bash
curl -X POST https://sitepaste.com/api/v1/public/sites/default/event-types \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Breathwork",
    "slug": "breathwork",
    "description": "Guided somatic breathwork"
  }'
```

`Location` names the type by its slug:

```
Location: /api/v1/public/sites/default/event-types/breathwork
```

To create or update in one call, use [the batch](/api/events/post-event-types-batch), which upserts.

## Authorizations

| Header | Type | Required | Description |
|--------|------|----------|-------------|
| Authorization | string | Yes | Bearer token (`Authorization: Bearer sp_...`). Created in the dashboard under Account > Tokens. See [authentication](/api/authentication). |

## Body

The body is one event type object.

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| name | string | Yes | The type's display name. |
| slug | string | Yes | The key pages and events reference it by. |
| description | string | No | Longer text for the type. |
| imageUrl | string | No | Image for the type. |
| pageSlug | string | No | A page on the site to link the type to. |
| sortOrder | integer | No | Position in the type list. A new type appends after the current order when this is omitted. |

The site is named in the path, not the body. See [addressing](/api/overview#addressing). `eventTypes` and `deleteSlugs` belong to the [batch](/api/events/post-event-types-batch). Publish your changes with [POST /sites/{siteId}/deployments](/api/deployments/post-deployments).

## Response

201 Created, with the event type in the representation [GET /sites/{siteId}/event-types/{slug}](/api/events/get-event-types-slug) serves and its URI in `Location`.

## Errors

Field problems return 422 and name the field. A slug already in use on the site returns 409, and nothing is written. See [errors](/api/overview#errors).