
# Write many event types at once

Upserts event types keyed by slug, the key that pages and events reference, and deletes the named slugs, all in one request. Everything lands or nothing does. Re-sending the same entry is a no-op update, so retries are safe.

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

Requires the `content` scope.

To create a single type and be told when its slug is already in use, use [POST /sites/{siteId}/event-types](/api/events/post-event-types).

## Usage

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

## 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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| eventTypes | array | One of eventTypes/deleteSlugs | Up to 500 entries. Each creates the type or updates it in place, keyed by slug. |
| deleteSlugs | array | One of eventTypes/deleteSlugs | Slugs to delete. Each type's events stay published and stop being categorized under it, and the slug is removed from newsletter subscribers' interests. |

The request body may be up to 16 MB, and a larger one is refused with 413.

The site is named in the path, not the body. See [addressing](/api/overview#addressing). Publish your changes with [POST /sites/{siteId}/deployments](/api/deployments/post-deployments) once the batch has landed.

## Entry fields

An entry takes the same fields [the single create](/api/events/post-event-types#body) takes.

| 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. |

On an update, every optional field you omit keeps its stored value. Sending `{"name": "New name", "slug": "breathwork"}` renames the type and leaves its description, image, page link, and position untouched.

## Response

```json
{
  "eventTypes": [
    { "id": "t8qj2xv7mz4r", "name": "Breathwork", "slug": "breathwork", "status": "created" }
  ],
  "deleted": ["retired-type"]
}
```

Validation failures return 422 with problems keyed by entry index. See [errors](/api/overview#errors).