# Create an event
Add a new event to your organization. Supports idempotent requests via the Idempotency-Key header.

POST /events

## Headers
- Content-Type (string, required): Must be application/json.
- Idempotency-Key (string): Unique key to prevent duplicate creation on retry. UUID recommended.

## Request Body
- name (string, required): Event name
- slug (string, required): URL-friendly slug (must be unique within org)
- type (string, required): Event type
- date (string, required): Event date (YYYY-MM-DD)
- endDate (string): End date for multi-day events (YYYY-MM-DD)
- startTime (string): Start time (HH:MM or HH:MM:SS)
- endTime (string): End time (HH:MM or HH:MM:SS)
- address (object): Event location
- lat (number): Latitude
- lng (number): Longitude
- description (string): Event description
- websiteUrl (string): Event website URL
- registrationUrl (string): Registration page URL

## Authorization
write:events

## Request Examples

### curl
```curl
curl -X POST https://api.intervals.run/events \
  -H "Authorization: Bearer INTERVALS_PARTNER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Summer Solstice 10K",
    "slug": "summer-solstice-10k",
    "type": "race",
    "date": "2025-06-21",
    "startTime": "07:30",
    "description": "Celebrate the longest day with a scenic 10K.",
    "websiteUrl": "https://northshorerace.com/solstice-10k",
    "registrationUrl": "https://runsignup.com/solstice-10k"
  }'
```

### JavaScript
```javascript
const res = await fetch(
  "https://api.intervals.run/events",
  {
  method: "POST",
  headers: { Authorization: "Bearer INTERVALS_PARTNER_API_KEY" },
  body: JSON.stringify({
    "name": "Summer Solstice 10K",
    "slug": "summer-solstice-10k",
    "type": "race",
    "date": "2025-06-21",
    "startTime": "07:30",
    "description": "Celebrate the longest day with a scenic 10K.",
    "websiteUrl": "https://northshorerace.com/solstice-10k",
    "registrationUrl": "https://runsignup.com/solstice-10k"
  }),
  }
);
const { data } = await res.json();
```

## Responses

### 201 (201)
```json
{
  "data": {
    "eventId": "e83ghi012jkl345"
  }
}
```

### 409 (409)
```json
{
  "error": {
    "code": "CONFLICT",
    "message": "Idempotency key has already been used with a different request body"
  }
}
```

### 422 (422)
```json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "errors": {
      "name": [
        "Required"
      ],
      "type": [
        "Required"
      ],
      "date": [
        "Required"
      ]
    }
  }
}
```