# Events

> Documentation index: https://ridewithgps.com/api/v1/doc/llms.txt

An event is an organized ride, with its routes and the riders who RSVP to it.

The participant endpoints read and set the authenticated user's own RSVP. An app RSVPs for a rider with that rider's own token: organization accounts can't RSVP for their members. Get notified of RSVPs with [webhooks](https://ridewithgps.com/api/v1/doc/webhooks.md).

OpenAPI specification for these endpoints: https://ridewithgps.com/api/v1/openapi/openapi_events.yaml

## Events

### Returns a list of events

`GET /api/v1/events.json`

Returns a paginated list of events accessible to the authenticated user.

Supports filtering by `name`, `visibility` and `archived` status.

Archived events are left out unless `archived=true` is passed, which returns them
on their own.

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `page` | integer | query | no | Page number for pagination |
| `page_size` | integer | query | no | Number of items per page (20-200) |
| `name` | string | query | no | Filter by name (partial match) |
| `visibility` | string | query | no | Filter by visibility. One of: `public`, `followers_only`, `mutual_followers_only`, `private`. |
| `archived` | string | query | no | Filter by archived status. One of: `true`, `false`. |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `events` | array of objects |  |
| `events[].id` | integer |  |
| `events[].user_id` | integer |  |
| `events[].url` | string |  |
| `events[].html_url` | string |  |
| `events[].visibility` | string |  |
| `events[].name` | string |  |
| `events[].description` | string or null |  |
| `events[].logo_url` | string or null |  |
| `events[].banner_url` | string or null |  |
| `events[].location` | string or null |  |
| `events[].lat` | number or null | Latitude |
| `events[].lng` | number or null | Longitude |
| `events[].time_zone` | string |  |
| `events[].start_date` | string |  |
| `events[].start_time` | string |  |
| `events[].end_date` | string |  |
| `events[].end_time` | string |  |
| `events[].all_day` | boolean |  |
| `events[].archived` | boolean |  |
| `events[].created_at` | date-time |  |
| `events[].updated_at` | date-time |  |
| `meta` | object |  |
| `meta.pagination` | object |  |
| `meta.pagination.record_count` | integer | Total number of records |
| `meta.pagination.page_count` | integer | Total number of pages |
| `meta.pagination.page_size` | integer | Number of records per page |
| `meta.pagination.next_page_url` | string or null | URL for the next page (null if last page) |

#### Errors

- `401` Unauthorized

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/events.json
```

#### Example response

```json
{
  "events": [
    {
      "id": 123,
      "user_id": 123,
      "url": "https://ridewithgps.com/api/v1/events/123.json",
      "html_url": "https://ridewithgps.com/events/123",
      "visibility": "public",
      "name": "Portland Century",
      "description": "A 100 mile ride around Portland",
      "logo_url": "https://ridewithgps.com/files/logo.jpg",
      "banner_url": "https://ridewithgps.com/files/banner.jpg",
      "location": "Portland, OR",
      "lat": 45.521529,
      "lng": -122.691804,
      "time_zone": "America/Los_Angeles",
      "start_date": "2000-01-01",
      "start_time": "09:00",
      "end_date": "2000-01-01",
      "end_time": "15:00",
      "all_day": false,
      "archived": false,
      "created_at": "2000-01-01T12:00:00Z",
      "updated_at": "2000-01-01T12:00:00Z"
    }
  ],
  "meta": {
    "pagination": {
      "record_count": 45,
      "page_count": 3,
      "page_size": 20,
      "next_page_url": "https://ridewithgps.com/api/v1/events.json?page=2"
    }
  }
}
```

### Returns the specified event

`GET /api/v1/events/{id}.json`

Returns detailed information about a specific event.

The `participants` array is included only when the authenticated user is the event owner.

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | integer | path | yes |  |
| `privacy_code` | string | query | no | Privacy code for the non public asset |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `event` | object |  |
| `event.id` | integer |  |
| `event.user_id` | integer |  |
| `event.url` | string |  |
| `event.html_url` | string |  |
| `event.visibility` | string |  |
| `event.name` | string |  |
| `event.description` | string or null |  |
| `event.logo_url` | string or null |  |
| `event.banner_url` | string or null |  |
| `event.location` | string or null |  |
| `event.lat` | number or null | Latitude |
| `event.lng` | number or null | Longitude |
| `event.time_zone` | string |  |
| `event.start_date` | string |  |
| `event.start_time` | string |  |
| `event.end_date` | string |  |
| `event.end_time` | string |  |
| `event.all_day` | boolean |  |
| `event.archived` | boolean |  |
| `event.created_at` | date-time |  |
| `event.updated_at` | date-time |  |
| `event.tags` | array of strings | Tags. Only present on club-owned events. |
| `event.organizers` | array of objects | Event organizers. Only present on organization-owned events, and limited to organizers who are still active members of the organization. |
| `event.organizers[].id` | integer |  |
| `event.organizers[].name` | string |  |
| `event.organizers[].created_at` | date-time |  |
| `event.organizers[].updated_at` | date-time |  |
| `event.routes` | array of objects |  |
| `event.routes[].id` | integer |  |
| `event.routes[].user_id` | integer |  |
| `event.routes[].url` | string |  |
| `event.routes[].html_url` | string |  |
| `event.routes[].visibility` | string |  |
| `event.routes[].name` | string |  |
| `event.routes[].description` | string or null |  |
| `event.routes[].locality` | string or null |  |
| `event.routes[].administrative_area` | string or null |  |
| `event.routes[].country_code` | string or null |  |
| `event.routes[].distance` | number | Distance in meters |
| `event.routes[].elevation_gain` | number | Elevation gain in meters |
| `event.routes[].elevation_loss` | number | Elevation loss in meters |
| `event.routes[].first_lat` | number |  |
| `event.routes[].first_lng` | number |  |
| `event.routes[].last_lat` | number |  |
| `event.routes[].last_lng` | number |  |
| `event.routes[].sw_lat` | number | Southwest bounding box latitude |
| `event.routes[].sw_lng` | number | Southwest bounding box longitude |
| `event.routes[].ne_lat` | number | Northeast bounding box latitude |
| `event.routes[].ne_lng` | number | Northeast bounding box longitude |
| `event.routes[].track_type` | string or null |  |
| `event.routes[].terrain` | string or null |  |
| `event.routes[].difficulty` | string or null |  |
| `event.routes[].unpaved_pct` | number or null |  |
| `event.routes[].surface` | string or null |  |
| `event.routes[].archived` | boolean or null | null for non owned routes |
| `event.routes[].created_at` | date-time |  |
| `event.routes[].updated_at` | date-time |  |
| `event.photos` | array of objects |  |
| `event.photos[].id` | integer |  |
| `event.photos[].url` | string |  |
| `event.photos[].highlighted` | boolean |  |
| `event.photos[].caption` | string or null |  |
| `event.photos[].lat` | number or null |  |
| `event.photos[].lng` | number or null |  |
| `event.photos[].elevation` | integer or null |  |
| `event.photos[].location` | string or null |  |
| `event.photos[].locality` | string or null |  |
| `event.photos[].administrative_area` | string or null |  |
| `event.photos[].country_code` | string or null |  |
| `event.photos[].created_at` | date-time |  |
| `event.participants` | array of objects | Event participants. Only included for the event owner. |
| `event.participants[].user` | object |  |
| `event.participants[].user.id` | integer |  |
| `event.participants[].user.name` | string |  |
| `event.participants[].user.email` | string or null | Null for accounts without a real email address. |
| `event.participants[].user.created_at` | date-time |  |
| `event.participants[].user.updated_at` | date-time |  |
| `event.participants[].status` | string | `participant` (going), `interested`, `declined` (not going), or `disallowed` (removed by an organizer, or expired). A `disallowed` rider can neither RSVP again nor withdraw. One of: `participant`, `interested`, `declined`, `disallowed`. |
| `event.participants[].created_at` | date-time |  |
| `event.participants[].updated_at` | date-time |  |

#### Errors

- `401` Unauthorized
- `403` Forbidden - Event not visible to user
- `404`  Not Found - Event not found

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/events/123.json
```

#### Example response

```json
{
  "event": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/events/123.json",
    "html_url": "https://ridewithgps.com/events/123",
    "visibility": "public",
    "name": "Portland Century",
    "description": "A 100 mile ride around Portland",
    "logo_url": "https://ridewithgps.com/files/logo.jpg",
    "banner_url": "https://ridewithgps.com/files/banner.jpg",
    "location": "Portland, OR",
    "lat": 45.521529,
    "lng": -122.691804,
    "time_zone": "America/Los_Angeles",
    "start_date": "2000-01-01",
    "start_time": "09:00",
    "end_date": "2000-01-01",
    "end_time": "15:00",
    "all_day": false,
    "archived": false,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "tags": [
      "Tags"
    ],
    "organizers": [
      {
        "id": 123,
        "name": "Alex Rider",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "routes": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/routes/123.json",
        "html_url": "https://ridewithgps.com/routes/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "distance": 40237,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "unpaved_pct": 12,
        "surface": "mostly_paved",
        "archived": false,
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "photos": [
      {
        "id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "highlighted": false,
        "caption": "View from Pittock Mansion",
        "lat": 45.521529,
        "lng": -122.691804,
        "elevation": 290,
        "location": "Pittock Mansion",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "created_at": "2000-01-01T12:00:00Z"
      }
    ],
    "participants": [
      {
        "user": {
          "id": 123,
          "name": "Alex Rider",
          "email": "alex@example.com",
          "created_at": "2000-01-01T12:00:00Z",
          "updated_at": "2000-01-01T12:00:00Z"
        },
        "status": "participant",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ]
  }
}
```

### Creates an event

`POST /api/v1/events.json`

Creates a new event for the authenticated user.

**Note**: The `organizer_ids`, `logo`, and `banner` fields are supported only for organization-owned events. They are not supported for user-owned events.

**Multipart uploads**: To upload logo and banner images, send a request with `Content-Type: multipart/form-data` using the following fields:
- `event[name]` - Event name
- `event[description]` - Event description
- `event[logo]` - Logo image (binary)
- `event[banner]` - Banner image (binary)
- etc.

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Request body (`application/json`)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `event` | object | yes |  |
| `event.name` | string | no |  |
| `event.description` | string or null | no |  |
| `event.visibility` | string | no |  |
| `event.location` | string | no |  |
| `event.lat` | number | no | Latitude |
| `event.lng` | number | no | Longitude |
| `event.time_zone` | string or null | no |  |
| `event.start_date` | string | no |  |
| `event.start_time` | string | no |  |
| `event.end_date` | string | no |  |
| `event.end_time` | string | no |  |
| `event.logo` | file or null | no |  |
| `event.banner` | file or null | no |  |
| `event.archived` | boolean | no | Archives or unarchives the event. Archived events are left out of `GET /api/v1/events.json` unless it is called with `archived=true`, but they stay reachable by id. Archiving does not remove the event from public event search on ridewithgps.com. Archiving an already archived event leaves its original archive date untouched. |
| `event.route_ids` | array of integers | no | Routes attached to the event, in display order. This replaces the current set: routes already on the event but missing from the array are detached, and an empty array detaches all of them. Omit the field to leave the event's routes untouched. Only routes owned by the event owner can be attached. For organization-owned events the owner is the organization account, not the manager making the request. Ids that fail this check are ignored without an error. On a personal (not organization-owned) ride planned in the Ride with GPS mobile app, whose routes can belong to other riders, a new id that fails it, or the id of a deleted route, instead leaves all of the event's routes unchanged, still without an error. |
| `event.organizer_ids` | array of integers | no | User ids of the event organizers. Organization-owned events only: the field is accepted and stored for user-owned events, but those events never return an `organizers` array, so it has no visible effect. This replaces the current set: ids already on the event but missing from the array are dropped, and an empty array clears all of them. Omit the field to leave the event's organizers untouched. The `organizers` array in the response is filtered to users who are active members of the organization, so an id that does not match one is stored but never returned. Unlike `route_ids`, this array carries no display order. |

#### Response `201`

| Name | Type | Description |
| --- | --- | --- |
| `event` | object |  |
| `event.id` | integer |  |
| `event.user_id` | integer |  |
| `event.url` | string |  |
| `event.html_url` | string |  |
| `event.visibility` | string |  |
| `event.name` | string |  |
| `event.description` | string or null |  |
| `event.logo_url` | string or null |  |
| `event.banner_url` | string or null |  |
| `event.location` | string or null |  |
| `event.lat` | number or null | Latitude |
| `event.lng` | number or null | Longitude |
| `event.time_zone` | string |  |
| `event.start_date` | string |  |
| `event.start_time` | string |  |
| `event.end_date` | string |  |
| `event.end_time` | string |  |
| `event.all_day` | boolean |  |
| `event.archived` | boolean |  |
| `event.created_at` | date-time |  |
| `event.updated_at` | date-time |  |
| `event.tags` | array of strings | Tags. Only present on club-owned events. |
| `event.organizers` | array of objects | Event organizers. Only present on organization-owned events, and limited to organizers who are still active members of the organization. |
| `event.organizers[].id` | integer |  |
| `event.organizers[].name` | string |  |
| `event.organizers[].created_at` | date-time |  |
| `event.organizers[].updated_at` | date-time |  |
| `event.routes` | array of objects |  |
| `event.routes[].id` | integer |  |
| `event.routes[].user_id` | integer |  |
| `event.routes[].url` | string |  |
| `event.routes[].html_url` | string |  |
| `event.routes[].visibility` | string |  |
| `event.routes[].name` | string |  |
| `event.routes[].description` | string or null |  |
| `event.routes[].locality` | string or null |  |
| `event.routes[].administrative_area` | string or null |  |
| `event.routes[].country_code` | string or null |  |
| `event.routes[].distance` | number | Distance in meters |
| `event.routes[].elevation_gain` | number | Elevation gain in meters |
| `event.routes[].elevation_loss` | number | Elevation loss in meters |
| `event.routes[].first_lat` | number |  |
| `event.routes[].first_lng` | number |  |
| `event.routes[].last_lat` | number |  |
| `event.routes[].last_lng` | number |  |
| `event.routes[].sw_lat` | number | Southwest bounding box latitude |
| `event.routes[].sw_lng` | number | Southwest bounding box longitude |
| `event.routes[].ne_lat` | number | Northeast bounding box latitude |
| `event.routes[].ne_lng` | number | Northeast bounding box longitude |
| `event.routes[].track_type` | string or null |  |
| `event.routes[].terrain` | string or null |  |
| `event.routes[].difficulty` | string or null |  |
| `event.routes[].unpaved_pct` | number or null |  |
| `event.routes[].surface` | string or null |  |
| `event.routes[].archived` | boolean or null | null for non owned routes |
| `event.routes[].created_at` | date-time |  |
| `event.routes[].updated_at` | date-time |  |
| `event.photos` | array of objects |  |
| `event.photos[].id` | integer |  |
| `event.photos[].url` | string |  |
| `event.photos[].highlighted` | boolean |  |
| `event.photos[].caption` | string or null |  |
| `event.photos[].lat` | number or null |  |
| `event.photos[].lng` | number or null |  |
| `event.photos[].elevation` | integer or null |  |
| `event.photos[].location` | string or null |  |
| `event.photos[].locality` | string or null |  |
| `event.photos[].administrative_area` | string or null |  |
| `event.photos[].country_code` | string or null |  |
| `event.photos[].created_at` | date-time |  |
| `event.participants` | array of objects | Event participants. Only included for the event owner. |
| `event.participants[].user` | object |  |
| `event.participants[].user.id` | integer |  |
| `event.participants[].user.name` | string |  |
| `event.participants[].user.email` | string or null | Null for accounts without a real email address. |
| `event.participants[].user.created_at` | date-time |  |
| `event.participants[].user.updated_at` | date-time |  |
| `event.participants[].status` | string | `participant` (going), `interested`, `declined` (not going), or `disallowed` (removed by an organizer, or expired). A `disallowed` rider can neither RSVP again nor withdraw. One of: `participant`, `interested`, `declined`, `disallowed`. |
| `event.participants[].created_at` | date-time |  |
| `event.participants[].updated_at` | date-time |  |

#### Errors

- `401` Unauthorized
- `422` Validation error

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
  "event": {
    "name": "Portland Century",
    "description": "A 100 mile ride around Portland",
    "visibility": "public",
    "location": "Portland, OR",
    "lat": 45.521529,
    "lng": -122.691804,
    "time_zone": "America/Los_Angeles",
    "start_date": "2000-01-01",
    "start_time": "09:00",
    "end_date": "2000-01-01",
    "end_time": "15:00",
    "archived": false,
    "route_ids": [
      1
    ],
    "organizer_ids": [
      1
    ]
  }
}' \
  https://ridewithgps.com/api/v1/events.json
```

#### Example response

```json
{
  "event": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/events/123.json",
    "html_url": "https://ridewithgps.com/events/123",
    "visibility": "public",
    "name": "Portland Century",
    "description": "A 100 mile ride around Portland",
    "logo_url": "https://ridewithgps.com/files/logo.jpg",
    "banner_url": "https://ridewithgps.com/files/banner.jpg",
    "location": "Portland, OR",
    "lat": 45.521529,
    "lng": -122.691804,
    "time_zone": "America/Los_Angeles",
    "start_date": "2000-01-01",
    "start_time": "09:00",
    "end_date": "2000-01-01",
    "end_time": "15:00",
    "all_day": false,
    "archived": false,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "tags": [
      "Tags"
    ],
    "organizers": [
      {
        "id": 123,
        "name": "Alex Rider",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "routes": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/routes/123.json",
        "html_url": "https://ridewithgps.com/routes/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "distance": 40237,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "unpaved_pct": 12,
        "surface": "mostly_paved",
        "archived": false,
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "photos": [
      {
        "id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "highlighted": false,
        "caption": "View from Pittock Mansion",
        "lat": 45.521529,
        "lng": -122.691804,
        "elevation": 290,
        "location": "Pittock Mansion",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "created_at": "2000-01-01T12:00:00Z"
      }
    ],
    "participants": [
      {
        "user": {
          "id": 123,
          "name": "Alex Rider",
          "email": "alex@example.com",
          "created_at": "2000-01-01T12:00:00Z",
          "updated_at": "2000-01-01T12:00:00Z"
        },
        "status": "participant",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ]
  }
}
```

### Updates the specified event

`PUT /api/v1/events/{id}.json`

Updates an existing event owned by the authenticated user.

**Note**: The `organizer_ids`, `logo`, and `banner` fields are supported only for organization-owned events. They are not supported for user-owned events.

**Multipart uploads**: To upload logo and banner images, send a request with `Content-Type: multipart/form-data` using the following fields:
- `event[name]` - Event name
- `event[description]` - Event description
- `event[logo]` - Logo image (binary)
- `event[banner]` - Banner image (binary)
- etc.

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | integer | path | yes |  |

#### Request body (`application/json`)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `event` | object | yes |  |
| `event.name` | string | no |  |
| `event.description` | string or null | no |  |
| `event.visibility` | string | no |  |
| `event.location` | string | no |  |
| `event.lat` | number | no | Latitude |
| `event.lng` | number | no | Longitude |
| `event.time_zone` | string or null | no |  |
| `event.start_date` | string | no |  |
| `event.start_time` | string | no |  |
| `event.end_date` | string | no |  |
| `event.end_time` | string | no |  |
| `event.logo` | file or null | no |  |
| `event.banner` | file or null | no |  |
| `event.archived` | boolean | no | Archives or unarchives the event. Archived events are left out of `GET /api/v1/events.json` unless it is called with `archived=true`, but they stay reachable by id. Archiving does not remove the event from public event search on ridewithgps.com. Archiving an already archived event leaves its original archive date untouched. |
| `event.route_ids` | array of integers | no | Routes attached to the event, in display order. This replaces the current set: routes already on the event but missing from the array are detached, and an empty array detaches all of them. Omit the field to leave the event's routes untouched. Only routes owned by the event owner can be attached. For organization-owned events the owner is the organization account, not the manager making the request. Ids that fail this check are ignored without an error. On a personal (not organization-owned) ride planned in the Ride with GPS mobile app, whose routes can belong to other riders, a new id that fails it, or the id of a deleted route, instead leaves all of the event's routes unchanged, still without an error. |
| `event.organizer_ids` | array of integers | no | User ids of the event organizers. Organization-owned events only: the field is accepted and stored for user-owned events, but those events never return an `organizers` array, so it has no visible effect. This replaces the current set: ids already on the event but missing from the array are dropped, and an empty array clears all of them. Omit the field to leave the event's organizers untouched. The `organizers` array in the response is filtered to users who are active members of the organization, so an id that does not match one is stored but never returned. Unlike `route_ids`, this array carries no display order. |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `event` | object |  |
| `event.id` | integer |  |
| `event.user_id` | integer |  |
| `event.url` | string |  |
| `event.html_url` | string |  |
| `event.visibility` | string |  |
| `event.name` | string |  |
| `event.description` | string or null |  |
| `event.logo_url` | string or null |  |
| `event.banner_url` | string or null |  |
| `event.location` | string or null |  |
| `event.lat` | number or null | Latitude |
| `event.lng` | number or null | Longitude |
| `event.time_zone` | string |  |
| `event.start_date` | string |  |
| `event.start_time` | string |  |
| `event.end_date` | string |  |
| `event.end_time` | string |  |
| `event.all_day` | boolean |  |
| `event.archived` | boolean |  |
| `event.created_at` | date-time |  |
| `event.updated_at` | date-time |  |
| `event.tags` | array of strings | Tags. Only present on club-owned events. |
| `event.organizers` | array of objects | Event organizers. Only present on organization-owned events, and limited to organizers who are still active members of the organization. |
| `event.organizers[].id` | integer |  |
| `event.organizers[].name` | string |  |
| `event.organizers[].created_at` | date-time |  |
| `event.organizers[].updated_at` | date-time |  |
| `event.routes` | array of objects |  |
| `event.routes[].id` | integer |  |
| `event.routes[].user_id` | integer |  |
| `event.routes[].url` | string |  |
| `event.routes[].html_url` | string |  |
| `event.routes[].visibility` | string |  |
| `event.routes[].name` | string |  |
| `event.routes[].description` | string or null |  |
| `event.routes[].locality` | string or null |  |
| `event.routes[].administrative_area` | string or null |  |
| `event.routes[].country_code` | string or null |  |
| `event.routes[].distance` | number | Distance in meters |
| `event.routes[].elevation_gain` | number | Elevation gain in meters |
| `event.routes[].elevation_loss` | number | Elevation loss in meters |
| `event.routes[].first_lat` | number |  |
| `event.routes[].first_lng` | number |  |
| `event.routes[].last_lat` | number |  |
| `event.routes[].last_lng` | number |  |
| `event.routes[].sw_lat` | number | Southwest bounding box latitude |
| `event.routes[].sw_lng` | number | Southwest bounding box longitude |
| `event.routes[].ne_lat` | number | Northeast bounding box latitude |
| `event.routes[].ne_lng` | number | Northeast bounding box longitude |
| `event.routes[].track_type` | string or null |  |
| `event.routes[].terrain` | string or null |  |
| `event.routes[].difficulty` | string or null |  |
| `event.routes[].unpaved_pct` | number or null |  |
| `event.routes[].surface` | string or null |  |
| `event.routes[].archived` | boolean or null | null for non owned routes |
| `event.routes[].created_at` | date-time |  |
| `event.routes[].updated_at` | date-time |  |
| `event.photos` | array of objects |  |
| `event.photos[].id` | integer |  |
| `event.photos[].url` | string |  |
| `event.photos[].highlighted` | boolean |  |
| `event.photos[].caption` | string or null |  |
| `event.photos[].lat` | number or null |  |
| `event.photos[].lng` | number or null |  |
| `event.photos[].elevation` | integer or null |  |
| `event.photos[].location` | string or null |  |
| `event.photos[].locality` | string or null |  |
| `event.photos[].administrative_area` | string or null |  |
| `event.photos[].country_code` | string or null |  |
| `event.photos[].created_at` | date-time |  |
| `event.participants` | array of objects | Event participants. Only included for the event owner. |
| `event.participants[].user` | object |  |
| `event.participants[].user.id` | integer |  |
| `event.participants[].user.name` | string |  |
| `event.participants[].user.email` | string or null | Null for accounts without a real email address. |
| `event.participants[].user.created_at` | date-time |  |
| `event.participants[].user.updated_at` | date-time |  |
| `event.participants[].status` | string | `participant` (going), `interested`, `declined` (not going), or `disallowed` (removed by an organizer, or expired). A `disallowed` rider can neither RSVP again nor withdraw. One of: `participant`, `interested`, `declined`, `disallowed`. |
| `event.participants[].created_at` | date-time |  |
| `event.participants[].updated_at` | date-time |  |

#### Errors

- `401` Unauthorized
- `404` Event not found

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X PUT \
  -H "Content-Type: application/json" \
  -d '{
  "event": {
    "name": "Portland Century",
    "description": "A 100 mile ride around Portland",
    "visibility": "public",
    "location": "Portland, OR",
    "lat": 45.521529,
    "lng": -122.691804,
    "time_zone": "America/Los_Angeles",
    "start_date": "2000-01-01",
    "start_time": "09:00",
    "end_date": "2000-01-01",
    "end_time": "15:00",
    "archived": false,
    "route_ids": [
      1
    ],
    "organizer_ids": [
      1
    ]
  }
}' \
  https://ridewithgps.com/api/v1/events/123.json
```

#### Example response

```json
{
  "event": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/events/123.json",
    "html_url": "https://ridewithgps.com/events/123",
    "visibility": "public",
    "name": "Portland Century",
    "description": "A 100 mile ride around Portland",
    "logo_url": "https://ridewithgps.com/files/logo.jpg",
    "banner_url": "https://ridewithgps.com/files/banner.jpg",
    "location": "Portland, OR",
    "lat": 45.521529,
    "lng": -122.691804,
    "time_zone": "America/Los_Angeles",
    "start_date": "2000-01-01",
    "start_time": "09:00",
    "end_date": "2000-01-01",
    "end_time": "15:00",
    "all_day": false,
    "archived": false,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "tags": [
      "Tags"
    ],
    "organizers": [
      {
        "id": 123,
        "name": "Alex Rider",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "routes": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/routes/123.json",
        "html_url": "https://ridewithgps.com/routes/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "distance": 40237,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "unpaved_pct": 12,
        "surface": "mostly_paved",
        "archived": false,
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "photos": [
      {
        "id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "highlighted": false,
        "caption": "View from Pittock Mansion",
        "lat": 45.521529,
        "lng": -122.691804,
        "elevation": 290,
        "location": "Pittock Mansion",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "created_at": "2000-01-01T12:00:00Z"
      }
    ],
    "participants": [
      {
        "user": {
          "id": 123,
          "name": "Alex Rider",
          "email": "alex@example.com",
          "created_at": "2000-01-01T12:00:00Z",
          "updated_at": "2000-01-01T12:00:00Z"
        },
        "status": "participant",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ]
  }
}
```

### Deletes the specified event

`DELETE /api/v1/events/{id}.json`

Deletes an event owned by the authenticated user

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | integer | path | yes |  |

#### Response `204`

Event deleted successfully

#### Errors

- `401` Unauthorized
- `404` Event not found

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X DELETE \
  https://ridewithgps.com/api/v1/events/123.json
```

## Event Participants

### Returns the authenticated user's RSVP to the event

`GET /api/v1/events/{event_id}/participant.json`

Returns the authenticated user's RSVP, or `null` for `participant` when they have none.

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `event_id` | integer | path | yes | Event ID |
| `privacy_code` | string | query | no | Privacy code for the non public asset |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `participant` | object |  |
| `participant.user` | object |  |
| `participant.user.id` | integer |  |
| `participant.user.name` | string |  |
| `participant.user.email` | string or null | Null for accounts without a real email address. |
| `participant.user.created_at` | date-time |  |
| `participant.user.updated_at` | date-time |  |
| `participant.status` | string | `participant` (going), `interested`, `declined` (not going), or `disallowed` (removed by an organizer, or expired). A `disallowed` rider can neither RSVP again nor withdraw. One of: `participant`, `interested`, `declined`, `disallowed`. |
| `participant.created_at` | date-time |  |
| `participant.updated_at` | date-time |  |

#### Errors

- `401` Unauthorized
- `403` Forbidden - Event not visible to user, or an organization account
- `404` Not Found - Event not found

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/events/123/participant.json
```

#### Example response

```json
{
  "participant": {
    "user": {
      "id": 123,
      "name": "Alex Rider",
      "email": "alex@example.com",
      "created_at": "2000-01-01T12:00:00Z",
      "updated_at": "2000-01-01T12:00:00Z"
    },
    "status": "participant",
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Sets the authenticated user's RSVP to the event

`POST /api/v1/events/{event_id}/participant.json`

RSVPs to the event as the authenticated user, with `participant.status`: `participant` (going,
the default), `interested`, or `declined` (not going). Sending the same status again changes nothing.

Organization accounts can't RSVP, so an integration acting for a rider uses that
rider's own token.

An event whose organization requires its own waiver answers `participant` with a 422
and a `waiver_url` until the rider has signed it.

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `event_id` | integer | path | yes | Event ID |
| `privacy_code` | string | query | no | Privacy code for the non public asset |

#### Request body (`application/json`)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `participant` | object | no |  |
| `participant.status` | string | no | One of: `participant`, `interested`, `declined`. |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `participant` | object |  |
| `participant.user` | object |  |
| `participant.user.id` | integer |  |
| `participant.user.name` | string |  |
| `participant.user.email` | string or null | Null for accounts without a real email address. |
| `participant.user.created_at` | date-time |  |
| `participant.user.updated_at` | date-time |  |
| `participant.status` | string | `participant` (going), `interested`, `declined` (not going), or `disallowed` (removed by an organizer, or expired). A `disallowed` rider can neither RSVP again nor withdraw. One of: `participant`, `interested`, `declined`, `disallowed`. |
| `participant.created_at` | date-time |  |
| `participant.updated_at` | date-time |  |

#### Errors

- `400` Malformed body: participant is not an object, or status is not a string
- `401` Unauthorized
- `403` Forbidden - Event not visible to user, an organization account, an RSVP removed by the organizer or expired, or a planned ride that refuses the rider
- `404` Not Found - Event not found
- `422` Invalid status, or a waiver to sign first

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
  "participant": {
    "status": "participant"
  }
}' \
  https://ridewithgps.com/api/v1/events/123/participant.json
```

#### Example response

```json
{
  "participant": {
    "user": {
      "id": 123,
      "name": "Alex Rider",
      "email": "alex@example.com",
      "created_at": "2000-01-01T12:00:00Z",
      "updated_at": "2000-01-01T12:00:00Z"
    },
    "status": "participant",
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Withdraws the authenticated user's RSVP to the event

`DELETE /api/v1/events/{event_id}/participant.json`

Removes the authenticated user from the event's participants, so they can RSVP again
later. It works even if the user can no longer see the event, but not for an RSVP the
organizer removed or that expired (`disallowed`, 403).

#### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

#### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `event_id` | integer | path | yes | Event ID |

#### Response `204`

RSVP withdrawn

#### Errors

- `401` Unauthorized
- `403` Forbidden - An RSVP removed by the organizer or expired, or an organization account
- `404` Not Found - Event not found

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X DELETE \
  https://ridewithgps.com/api/v1/events/123/participant.json
```
