# Experiences

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

**Organizations only.** You need an organization account with access to Experiences; other accounts get a `403`. If your account does not have Experiences enabled, please contact [organizations@ridewithgps.com](mailto:organizations@ridewithgps.com).

To publish a tour step by step, follow [Publish a multi-day tour](https://ridewithgps.com/api/v1/doc/organizations/publish_tours.md).

See also: [Guide page blocks](https://ridewithgps.com/api/v1/doc/reference/guide_page_blocks.md), [Photos](https://ridewithgps.com/api/v1/doc/endpoints/photos.md), [Tasks](https://ridewithgps.com/api/v1/doc/endpoints/tasks.md).

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

## Experiences

### Returns a list of experiences

`GET /api/v1/experiences.json`

Returns a paginated list of the organization's experiences.

Experiences endpoints are only available to organization accounts with access to Experiences.

Supports filtering by `name` and `archived`.

#### 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) |
| `archived` | string | query | no | Filter by archived status. One of: `true`, `false`. |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `experiences` | array of objects |  |
| `experiences[].id` | integer |  |
| `experiences[].url` | string |  |
| `experiences[].name` | string |  |
| `experiences[].description` | string or null |  |
| `experiences[].location` | string |  |
| `experiences[].starts_on` | string or null |  |
| `experiences[].ends_on` | string or null |  |
| `experiences[].active` | boolean | False hides the experience from the app. |
| `experiences[].archived` | boolean |  |
| `experiences[].publish_status` | string | `updates` means the experience changed since the last published package. `failed` means the last build failed; publish again to retry. One of: `unpublished`, `queued`, `processing`, `updates`, `published`, `failed`. |
| `experiences[].logo_url` | string or null |  |
| `experiences[].cover_url` | string or null |  |
| `experiences[].expire_after_days` | integer or null | Days a guest keeps access after joining. Null or 0 means access does not expire. Organizations without unlimited experiences can only use 15 or 30. |
| `experiences[].unlimited` | boolean | True when guests join with one shared guest code; false when each guest needs a limited code. |
| `experiences[].show_routes` | boolean |  |
| `experiences[].reference_id` | string |  |
| `experiences[].require_name` | boolean | Ask guests for their name when they join. |
| `experiences[].require_email` | boolean |  |
| `experiences[].require_phone` | boolean |  |
| `experiences[].require_zip_code` | boolean |  |
| `experiences[].require_reference_id` | boolean |  |
| `experiences[].created_at` | date-time |  |
| `experiences[].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

- `403` Forbidden - Not an organization account

#### Example request

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

#### Example response

```json
{
  "experiences": [
    {
      "id": 123,
      "url": "https://ridewithgps.com/api/v1/experiences/123.json",
      "name": "Oregon Coast tour",
      "description": "Five days along the Oregon coast",
      "location": "Portland, OR",
      "starts_on": "2000-01-01",
      "ends_on": "2000-01-01",
      "active": false,
      "archived": false,
      "publish_status": "unpublished",
      "logo_url": "https://ridewithgps.com/files/logo.jpg",
      "cover_url": "https://ridewithgps.com/files/cover.jpg",
      "expire_after_days": 30,
      "unlimited": false,
      "show_routes": false,
      "reference_id": "TOUR-2000-01",
      "require_name": false,
      "require_email": false,
      "require_phone": false,
      "require_zip_code": false,
      "require_reference_id": 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/experiences.json?page=2"
    }
  }
}
```

### Returns an experience

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

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

| Name | Type | Description |
| --- | --- | --- |
| `experience` | object |  |
| `experience.id` | integer |  |
| `experience.url` | string |  |
| `experience.name` | string |  |
| `experience.description` | string or null |  |
| `experience.location` | string |  |
| `experience.starts_on` | string or null |  |
| `experience.ends_on` | string or null |  |
| `experience.active` | boolean | False hides the experience from the app. |
| `experience.archived` | boolean |  |
| `experience.publish_status` | string | `updates` means the experience changed since the last published package. `failed` means the last build failed; publish again to retry. One of: `unpublished`, `queued`, `processing`, `updates`, `published`, `failed`. |
| `experience.logo_url` | string or null |  |
| `experience.cover_url` | string or null |  |
| `experience.expire_after_days` | integer or null | Days a guest keeps access after joining. Null or 0 means access does not expire. Organizations without unlimited experiences can only use 15 or 30. |
| `experience.unlimited` | boolean | True when guests join with one shared guest code; false when each guest needs a limited code. |
| `experience.show_routes` | boolean |  |
| `experience.reference_id` | string |  |
| `experience.require_name` | boolean | Ask guests for their name when they join. |
| `experience.require_email` | boolean |  |
| `experience.require_phone` | boolean |  |
| `experience.require_zip_code` | boolean |  |
| `experience.require_reference_id` | boolean |  |
| `experience.created_at` | date-time |  |
| `experience.updated_at` | date-time |  |
| `experience.tags` | array of strings |  |
| `experience.route_ids` | array of integers | Routes in the order guests see them. |
| `experience.guest_code` | string or null | Active code guests enter in the app to join. |
| `experience.guide_code` | string or null | Active code for guides; guides never expire. |

#### Errors

- `404` Another organization's experience

#### Example request

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

#### Example response

```json
{
  "experience": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123.json",
    "name": "Oregon Coast tour",
    "description": "Five days along the Oregon coast",
    "location": "Portland, OR",
    "starts_on": "2000-01-01",
    "ends_on": "2000-01-01",
    "active": false,
    "archived": false,
    "publish_status": "unpublished",
    "logo_url": "https://ridewithgps.com/files/logo.jpg",
    "cover_url": "https://ridewithgps.com/files/cover.jpg",
    "expire_after_days": 30,
    "unlimited": false,
    "show_routes": false,
    "reference_id": "TOUR-2000-01",
    "require_name": false,
    "require_email": false,
    "require_phone": false,
    "require_zip_code": false,
    "require_reference_id": false,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "tags": [
      "Tags"
    ],
    "route_ids": [
      1
    ],
    "guest_code": "COAST2000",
    "guide_code": "GUIDE2000"
  }
}
```

### Creates an experience

`POST /api/v1/experiences.json`

Creates an experience for the organization.

Send `source_experience_id` to create a copy of one of the organization's experiences, with its routes and guide pages. Other fields sent with it override the copied values.

`route_ids` sets the experience's routes, in order. Only routes owned by the organization are accepted.

**Multipart uploads**: To upload a logo or cover image, send `multipart/form-data` with `experience[logo]` and `experience[cover]`.

#### 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 |
| --- | --- | --- | --- |
| `experience` | object | yes |  |
| `experience.source_experience_id` | integer | no | Create only. Copies this experience and its guide pages. The copy shares the original's routes; no new routes are created. |
| `experience.name` | string | no |  |
| `experience.description` | string | no |  |
| `experience.location` | string | no |  |
| `experience.starts_on` | string | no |  |
| `experience.ends_on` | string | no |  |
| `experience.active` | boolean | no |  |
| `experience.archived` | boolean | no |  |
| `experience.expire_after_days` | integer or null | no |  |
| `experience.unlimited` | boolean | no |  |
| `experience.show_routes` | boolean | no |  |
| `experience.reference_id` | string | no |  |
| `experience.require_name` | boolean | no |  |
| `experience.require_email` | boolean | no |  |
| `experience.require_phone` | boolean | no |  |
| `experience.require_zip_code` | boolean | no |  |
| `experience.require_reference_id` | boolean | no |  |
| `experience.route_ids` | array of integers | no | Replaces the route list, in this order. |
| `experience.tags` | array of strings | no | Replaces the tags. |
| `experience.logo` | file | no | Multipart only. |
| `experience.cover` | file | no | Multipart only. |

#### Response `201`

| Name | Type | Description |
| --- | --- | --- |
| `experience` | object |  |
| `experience.id` | integer |  |
| `experience.url` | string |  |
| `experience.name` | string |  |
| `experience.description` | string or null |  |
| `experience.location` | string |  |
| `experience.starts_on` | string or null |  |
| `experience.ends_on` | string or null |  |
| `experience.active` | boolean | False hides the experience from the app. |
| `experience.archived` | boolean |  |
| `experience.publish_status` | string | `updates` means the experience changed since the last published package. `failed` means the last build failed; publish again to retry. One of: `unpublished`, `queued`, `processing`, `updates`, `published`, `failed`. |
| `experience.logo_url` | string or null |  |
| `experience.cover_url` | string or null |  |
| `experience.expire_after_days` | integer or null | Days a guest keeps access after joining. Null or 0 means access does not expire. Organizations without unlimited experiences can only use 15 or 30. |
| `experience.unlimited` | boolean | True when guests join with one shared guest code; false when each guest needs a limited code. |
| `experience.show_routes` | boolean |  |
| `experience.reference_id` | string |  |
| `experience.require_name` | boolean | Ask guests for their name when they join. |
| `experience.require_email` | boolean |  |
| `experience.require_phone` | boolean |  |
| `experience.require_zip_code` | boolean |  |
| `experience.require_reference_id` | boolean |  |
| `experience.created_at` | date-time |  |
| `experience.updated_at` | date-time |  |
| `experience.tags` | array of strings |  |
| `experience.route_ids` | array of integers | Routes in the order guests see them. |
| `experience.guest_code` | string or null | Active code guests enter in the app to join. |
| `experience.guide_code` | string or null | Active code for guides; guides never expire. |

#### Errors

- `404` Source experience not found
- `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 '{
  "experience": {
    "source_experience_id": 123,
    "name": "Oregon Coast tour",
    "description": "Five days along the Oregon coast",
    "location": "Portland, OR",
    "starts_on": "2000-01-01",
    "ends_on": "2000-01-01",
    "active": false,
    "archived": false,
    "expire_after_days": 30,
    "unlimited": false,
    "show_routes": false,
    "reference_id": "TOUR-2000-01",
    "require_name": false,
    "require_email": false,
    "require_phone": false,
    "require_zip_code": false,
    "require_reference_id": false,
    "route_ids": [
      1
    ],
    "tags": [
      "Tags"
    ]
  }
}' \
  https://ridewithgps.com/api/v1/experiences.json
```

#### Example response

```json
{
  "experience": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123.json",
    "name": "Oregon Coast tour",
    "description": "Five days along the Oregon coast",
    "location": "Portland, OR",
    "starts_on": "2000-01-01",
    "ends_on": "2000-01-01",
    "active": false,
    "archived": false,
    "publish_status": "unpublished",
    "logo_url": "https://ridewithgps.com/files/logo.jpg",
    "cover_url": "https://ridewithgps.com/files/cover.jpg",
    "expire_after_days": 30,
    "unlimited": false,
    "show_routes": false,
    "reference_id": "TOUR-2000-01",
    "require_name": false,
    "require_email": false,
    "require_phone": false,
    "require_zip_code": false,
    "require_reference_id": false,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "tags": [
      "Tags"
    ],
    "route_ids": [
      1
    ],
    "guest_code": "COAST2000",
    "guide_code": "GUIDE2000"
  }
}
```

### Updates an experience

`PATCH /api/v1/experiences/{id}.json`

Updates an experience. Only the fields sent are changed.

`route_ids` replaces the whole route list, in the order given. Send an empty array to remove every route.
`active: false` hides the experience from the app; publish a package to make it available again.

#### 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 |
| --- | --- | --- | --- |
| `experience` | object | yes |  |
| `experience.source_experience_id` | integer | no | Create only. Copies this experience and its guide pages. The copy shares the original's routes; no new routes are created. |
| `experience.name` | string | no |  |
| `experience.description` | string | no |  |
| `experience.location` | string | no |  |
| `experience.starts_on` | string | no |  |
| `experience.ends_on` | string | no |  |
| `experience.active` | boolean | no |  |
| `experience.archived` | boolean | no |  |
| `experience.expire_after_days` | integer or null | no |  |
| `experience.unlimited` | boolean | no |  |
| `experience.show_routes` | boolean | no |  |
| `experience.reference_id` | string | no |  |
| `experience.require_name` | boolean | no |  |
| `experience.require_email` | boolean | no |  |
| `experience.require_phone` | boolean | no |  |
| `experience.require_zip_code` | boolean | no |  |
| `experience.require_reference_id` | boolean | no |  |
| `experience.route_ids` | array of integers | no | Replaces the route list, in this order. |
| `experience.tags` | array of strings | no | Replaces the tags. |
| `experience.logo` | file | no | Multipart only. |
| `experience.cover` | file | no | Multipart only. |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `experience` | object |  |
| `experience.id` | integer |  |
| `experience.url` | string |  |
| `experience.name` | string |  |
| `experience.description` | string or null |  |
| `experience.location` | string |  |
| `experience.starts_on` | string or null |  |
| `experience.ends_on` | string or null |  |
| `experience.active` | boolean | False hides the experience from the app. |
| `experience.archived` | boolean |  |
| `experience.publish_status` | string | `updates` means the experience changed since the last published package. `failed` means the last build failed; publish again to retry. One of: `unpublished`, `queued`, `processing`, `updates`, `published`, `failed`. |
| `experience.logo_url` | string or null |  |
| `experience.cover_url` | string or null |  |
| `experience.expire_after_days` | integer or null | Days a guest keeps access after joining. Null or 0 means access does not expire. Organizations without unlimited experiences can only use 15 or 30. |
| `experience.unlimited` | boolean | True when guests join with one shared guest code; false when each guest needs a limited code. |
| `experience.show_routes` | boolean |  |
| `experience.reference_id` | string |  |
| `experience.require_name` | boolean | Ask guests for their name when they join. |
| `experience.require_email` | boolean |  |
| `experience.require_phone` | boolean |  |
| `experience.require_zip_code` | boolean |  |
| `experience.require_reference_id` | boolean |  |
| `experience.created_at` | date-time |  |
| `experience.updated_at` | date-time |  |
| `experience.tags` | array of strings |  |
| `experience.route_ids` | array of integers | Routes in the order guests see them. |
| `experience.guest_code` | string or null | Active code guests enter in the app to join. |
| `experience.guide_code` | string or null | Active code for guides; guides never expire. |

#### Errors

- `422` Validation error

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{
  "experience": {
    "source_experience_id": 123,
    "name": "Oregon Coast tour",
    "description": "Five days along the Oregon coast",
    "location": "Portland, OR",
    "starts_on": "2000-01-01",
    "ends_on": "2000-01-01",
    "active": false,
    "archived": false,
    "expire_after_days": 30,
    "unlimited": false,
    "show_routes": false,
    "reference_id": "TOUR-2000-01",
    "require_name": false,
    "require_email": false,
    "require_phone": false,
    "require_zip_code": false,
    "require_reference_id": false,
    "route_ids": [
      1
    ],
    "tags": [
      "Tags"
    ]
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123.json
```

#### Example response

```json
{
  "experience": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123.json",
    "name": "Oregon Coast tour",
    "description": "Five days along the Oregon coast",
    "location": "Portland, OR",
    "starts_on": "2000-01-01",
    "ends_on": "2000-01-01",
    "active": false,
    "archived": false,
    "publish_status": "unpublished",
    "logo_url": "https://ridewithgps.com/files/logo.jpg",
    "cover_url": "https://ridewithgps.com/files/cover.jpg",
    "expire_after_days": 30,
    "unlimited": false,
    "show_routes": false,
    "reference_id": "TOUR-2000-01",
    "require_name": false,
    "require_email": false,
    "require_phone": false,
    "require_zip_code": false,
    "require_reference_id": false,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "tags": [
      "Tags"
    ],
    "route_ids": [
      1
    ],
    "guest_code": "COAST2000",
    "guide_code": "GUIDE2000"
  }
}
```

### Deletes an experience

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

Deletes an experience. An experience that guests have already joined is hidden instead, so their access history is kept.

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

Experience deleted

#### 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/experiences/123.json
```

## Experience Guide Pages

### Returns an experience's guide pages

`GET /api/v1/experiences/{experience_id}/guide_pages.json`

Returns every guide page of the experience, each top-level page followed by the pages under 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `guide_pages` | array of objects |  |
| `guide_pages[].id` | integer |  |
| `guide_pages[].url` | string |  |
| `guide_pages[].experience_id` | integer |  |
| `guide_pages[].parent_id` | integer or null | The top-level page this page sits under, or null. |
| `guide_pages[].position` | integer | Place among the pages that share the parent, starting at 1. |
| `guide_pages[].title` | string |  |
| `guide_pages[].header` | boolean | A header page only lists the pages under it and has no blocks. |
| `guide_pages[].live` | boolean | Live pages update in the app without publishing a new package. |
| `guide_pages[].blocks` | array of objects |  |
| `guide_pages[].blocks[].type` | string | One of: `text`, `photo`, `route`, `elevation_profile`. |
| `guide_pages[].blocks[].markdown` | string | `text` blocks. |
| `guide_pages[].blocks[].photo_id` | integer | `photo` blocks. A photo owned by the organization; upload one with `POST /api/v1/photos`. |
| `guide_pages[].blocks[].on_tap` | string | `photo` blocks. What tapping the photo does. Defaults to `none`. One of: `none`, `enlarge`, `open_link`. |
| `guide_pages[].blocks[].link_url` | string or null | `photo` blocks with `on_tap: open_link`. |
| `guide_pages[].blocks[].route_id` | integer | `route` and `elevation_profile` blocks. A route owned by the organization. |
| `guide_pages[].blocks[].url` | string or null | Read only. The photo image, for `photo` blocks. |
| `guide_pages[].blocks[].name` | string | Read only. The route name shown on a `route` card. |
| `guide_pages[].blocks[].distance` | number | Read only. Meters, as shown on a `route` card. |
| `guide_pages[].blocks[].elevation_gain` | number | Read only. Meters, as shown on a `route` card. |
| `guide_pages[].file` | object or null | Present on PDF pages. |
| `guide_pages[].file.name` | string |  |
| `guide_pages[].file.filename` | string |  |
| `guide_pages[].file.content_type` | string |  |
| `guide_pages[].file.size` | integer |  |
| `guide_pages[].created_at` | date-time |  |
| `guide_pages[].updated_at` | date-time |  |

#### Errors

- `404` Another organization's experience

#### Example request

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

#### Example response

```json
{
  "guide_pages": [
    {
      "id": 123,
      "url": "https://ridewithgps.com/api/v1/experiences/123/guide_pages/123.json",
      "experience_id": 123,
      "parent_id": 123,
      "position": 1,
      "title": "Day 1: Portland to Tillamook",
      "header": false,
      "live": false,
      "blocks": [
        {
          "type": "text",
          "markdown": "Welcome to the tour! Today we ride from Portland to the coast.",
          "photo_id": 123,
          "on_tap": "none",
          "link_url": "https://example.com",
          "route_id": 123,
          "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
          "name": "Forest Park loop",
          "distance": 40237,
          "elevation_gain": 457
        }
      ],
      "file": {
        "name": "day1.pdf",
        "filename": "day1.pdf",
        "content_type": "application/pdf",
        "size": 1093417
      },
      "created_at": "2000-01-01T12:00:00Z",
      "updated_at": "2000-01-01T12:00:00Z"
    }
  ]
}
```

### Returns a guide page

`GET /api/v1/experiences/{experience_id}/guide_pages/{id}.json`

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `guide_page` | object |  |
| `guide_page.id` | integer |  |
| `guide_page.url` | string |  |
| `guide_page.experience_id` | integer |  |
| `guide_page.parent_id` | integer or null | The top-level page this page sits under, or null. |
| `guide_page.position` | integer | Place among the pages that share the parent, starting at 1. |
| `guide_page.title` | string |  |
| `guide_page.header` | boolean | A header page only lists the pages under it and has no blocks. |
| `guide_page.live` | boolean | Live pages update in the app without publishing a new package. |
| `guide_page.blocks` | array of objects |  |
| `guide_page.blocks[].type` | string | One of: `text`, `photo`, `route`, `elevation_profile`. |
| `guide_page.blocks[].markdown` | string | `text` blocks. |
| `guide_page.blocks[].photo_id` | integer | `photo` blocks. A photo owned by the organization; upload one with `POST /api/v1/photos`. |
| `guide_page.blocks[].on_tap` | string | `photo` blocks. What tapping the photo does. Defaults to `none`. One of: `none`, `enlarge`, `open_link`. |
| `guide_page.blocks[].link_url` | string or null | `photo` blocks with `on_tap: open_link`. |
| `guide_page.blocks[].route_id` | integer | `route` and `elevation_profile` blocks. A route owned by the organization. |
| `guide_page.blocks[].url` | string or null | Read only. The photo image, for `photo` blocks. |
| `guide_page.blocks[].name` | string | Read only. The route name shown on a `route` card. |
| `guide_page.blocks[].distance` | number | Read only. Meters, as shown on a `route` card. |
| `guide_page.blocks[].elevation_gain` | number | Read only. Meters, as shown on a `route` card. |
| `guide_page.file` | object or null | Present on PDF pages. |
| `guide_page.file.name` | string |  |
| `guide_page.file.filename` | string |  |
| `guide_page.file.content_type` | string |  |
| `guide_page.file.size` | integer |  |
| `guide_page.created_at` | date-time |  |
| `guide_page.updated_at` | date-time |  |

#### Example request

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

#### Example response

```json
{
  "guide_page": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/guide_pages/123.json",
    "experience_id": 123,
    "parent_id": 123,
    "position": 1,
    "title": "Day 1: Portland to Tillamook",
    "header": false,
    "live": false,
    "blocks": [
      {
        "type": "text",
        "markdown": "Welcome to the tour! Today we ride from Portland to the coast.",
        "photo_id": 123,
        "on_tap": "none",
        "link_url": "https://example.com",
        "route_id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "name": "Forest Park loop",
        "distance": 40237,
        "elevation_gain": 457
      }
    ],
    "file": {
      "name": "day1.pdf",
      "filename": "day1.pdf",
      "content_type": "application/pdf",
      "size": 1093417
    },
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Creates a guide page

`POST /api/v1/experiences/{experience_id}/guide_pages.json`

Adds a guide page to the experience. Without `parent_id` and `position`, the page goes last at the top level.

Content is a list of blocks: Markdown text, photos, route cards and elevation profiles. Photos and routes must belong to the organization. See [Guide page blocks](/api/v1/doc/reference/guide_page_blocks) for every block type and the Markdown text blocks accept.

**PDF pages**: send `multipart/form-data` with `guide_page[title]` and `guide_page[file]` instead of blocks.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |

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

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `guide_page` | object | yes |  |
| `guide_page.title` | string | no |  |
| `guide_page.header` | boolean | no | Create only. |
| `guide_page.live` | boolean | no |  |
| `guide_page.parent_id` | integer or null | no | A top-level page of the experience, or null for top level. A page with pages under it stays top level. |
| `guide_page.position` | integer | no | Place among the pages that share the parent, starting at 1. Defaults to last. |
| `guide_page.blocks` | array of objects | no | Replaces the page content. |
| `guide_page.blocks[].type` | string | yes | One of: `text`, `photo`, `route`, `elevation_profile`. |
| `guide_page.blocks[].markdown` | string | no | `text` blocks. |
| `guide_page.blocks[].photo_id` | integer | no | `photo` blocks. A photo owned by the organization; upload one with `POST /api/v1/photos`. |
| `guide_page.blocks[].on_tap` | string | no | `photo` blocks. What tapping the photo does. Defaults to `none`. One of: `none`, `enlarge`, `open_link`. |
| `guide_page.blocks[].link_url` | string or null | no | `photo` blocks with `on_tap: open_link`. |
| `guide_page.blocks[].route_id` | integer | no | `route` and `elevation_profile` blocks. A route owned by the organization. |
| `guide_page.blocks[].url` | string or null | no | Read only. The photo image, for `photo` blocks. |
| `guide_page.blocks[].name` | string | no | Read only. The route name shown on a `route` card. |
| `guide_page.blocks[].distance` | number | no | Read only. Meters, as shown on a `route` card. |
| `guide_page.blocks[].elevation_gain` | number | no | Read only. Meters, as shown on a `route` card. |
| `guide_page.file` | file | no | Create only, multipart. A PDF, sent instead of blocks. |

#### Response `201`

| Name | Type | Description |
| --- | --- | --- |
| `guide_page` | object |  |
| `guide_page.id` | integer |  |
| `guide_page.url` | string |  |
| `guide_page.experience_id` | integer |  |
| `guide_page.parent_id` | integer or null | The top-level page this page sits under, or null. |
| `guide_page.position` | integer | Place among the pages that share the parent, starting at 1. |
| `guide_page.title` | string |  |
| `guide_page.header` | boolean | A header page only lists the pages under it and has no blocks. |
| `guide_page.live` | boolean | Live pages update in the app without publishing a new package. |
| `guide_page.blocks` | array of objects |  |
| `guide_page.blocks[].type` | string | One of: `text`, `photo`, `route`, `elevation_profile`. |
| `guide_page.blocks[].markdown` | string | `text` blocks. |
| `guide_page.blocks[].photo_id` | integer | `photo` blocks. A photo owned by the organization; upload one with `POST /api/v1/photos`. |
| `guide_page.blocks[].on_tap` | string | `photo` blocks. What tapping the photo does. Defaults to `none`. One of: `none`, `enlarge`, `open_link`. |
| `guide_page.blocks[].link_url` | string or null | `photo` blocks with `on_tap: open_link`. |
| `guide_page.blocks[].route_id` | integer | `route` and `elevation_profile` blocks. A route owned by the organization. |
| `guide_page.blocks[].url` | string or null | Read only. The photo image, for `photo` blocks. |
| `guide_page.blocks[].name` | string | Read only. The route name shown on a `route` card. |
| `guide_page.blocks[].distance` | number | Read only. Meters, as shown on a `route` card. |
| `guide_page.blocks[].elevation_gain` | number | Read only. Meters, as shown on a `route` card. |
| `guide_page.file` | object or null | Present on PDF pages. |
| `guide_page.file.name` | string |  |
| `guide_page.file.filename` | string |  |
| `guide_page.file.content_type` | string |  |
| `guide_page.file.size` | integer |  |
| `guide_page.created_at` | date-time |  |
| `guide_page.updated_at` | date-time |  |

#### Errors

- `422` Invalid blocks

#### 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 '{
  "guide_page": {
    "title": "Day 1: Portland to Tillamook",
    "header": false,
    "live": false,
    "parent_id": 123,
    "position": 1,
    "blocks": [
      {
        "type": "text",
        "markdown": "Welcome to the tour! Today we ride from Portland to the coast.",
        "photo_id": 123,
        "on_tap": "none",
        "link_url": "https://example.com",
        "route_id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "name": "Forest Park loop",
        "distance": 40237,
        "elevation_gain": 457
      }
    ]
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123/guide_pages.json
```

#### Example response

```json
{
  "guide_page": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/guide_pages/123.json",
    "experience_id": 123,
    "parent_id": 123,
    "position": 1,
    "title": "Day 1: Portland to Tillamook",
    "header": false,
    "live": false,
    "blocks": [
      {
        "type": "text",
        "markdown": "Welcome to the tour! Today we ride from Portland to the coast.",
        "photo_id": 123,
        "on_tap": "none",
        "link_url": "https://example.com",
        "route_id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "name": "Forest Park loop",
        "distance": 40237,
        "elevation_gain": 457
      }
    ],
    "file": {
      "name": "day1.pdf",
      "filename": "day1.pdf",
      "content_type": "application/pdf",
      "size": 1093417
    },
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Updates a guide page

`PATCH /api/v1/experiences/{experience_id}/guide_pages/{id}.json`

Updates a guide page. Only the fields sent are changed. `blocks` replaces the whole content. See [Guide page blocks](/api/v1/doc/reference/guide_page_blocks).

Send `parent_id` and/or `position` to move the page; the other pages are renumbered.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

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

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `guide_page` | object | yes |  |
| `guide_page.title` | string | no |  |
| `guide_page.header` | boolean | no | Create only. |
| `guide_page.live` | boolean | no |  |
| `guide_page.parent_id` | integer or null | no | A top-level page of the experience, or null for top level. A page with pages under it stays top level. |
| `guide_page.position` | integer | no | Place among the pages that share the parent, starting at 1. Defaults to last. |
| `guide_page.blocks` | array of objects | no | Replaces the page content. |
| `guide_page.blocks[].type` | string | yes | One of: `text`, `photo`, `route`, `elevation_profile`. |
| `guide_page.blocks[].markdown` | string | no | `text` blocks. |
| `guide_page.blocks[].photo_id` | integer | no | `photo` blocks. A photo owned by the organization; upload one with `POST /api/v1/photos`. |
| `guide_page.blocks[].on_tap` | string | no | `photo` blocks. What tapping the photo does. Defaults to `none`. One of: `none`, `enlarge`, `open_link`. |
| `guide_page.blocks[].link_url` | string or null | no | `photo` blocks with `on_tap: open_link`. |
| `guide_page.blocks[].route_id` | integer | no | `route` and `elevation_profile` blocks. A route owned by the organization. |
| `guide_page.blocks[].url` | string or null | no | Read only. The photo image, for `photo` blocks. |
| `guide_page.blocks[].name` | string | no | Read only. The route name shown on a `route` card. |
| `guide_page.blocks[].distance` | number | no | Read only. Meters, as shown on a `route` card. |
| `guide_page.blocks[].elevation_gain` | number | no | Read only. Meters, as shown on a `route` card. |
| `guide_page.file` | file | no | Create only, multipart. A PDF, sent instead of blocks. |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `guide_page` | object |  |
| `guide_page.id` | integer |  |
| `guide_page.url` | string |  |
| `guide_page.experience_id` | integer |  |
| `guide_page.parent_id` | integer or null | The top-level page this page sits under, or null. |
| `guide_page.position` | integer | Place among the pages that share the parent, starting at 1. |
| `guide_page.title` | string |  |
| `guide_page.header` | boolean | A header page only lists the pages under it and has no blocks. |
| `guide_page.live` | boolean | Live pages update in the app without publishing a new package. |
| `guide_page.blocks` | array of objects |  |
| `guide_page.blocks[].type` | string | One of: `text`, `photo`, `route`, `elevation_profile`. |
| `guide_page.blocks[].markdown` | string | `text` blocks. |
| `guide_page.blocks[].photo_id` | integer | `photo` blocks. A photo owned by the organization; upload one with `POST /api/v1/photos`. |
| `guide_page.blocks[].on_tap` | string | `photo` blocks. What tapping the photo does. Defaults to `none`. One of: `none`, `enlarge`, `open_link`. |
| `guide_page.blocks[].link_url` | string or null | `photo` blocks with `on_tap: open_link`. |
| `guide_page.blocks[].route_id` | integer | `route` and `elevation_profile` blocks. A route owned by the organization. |
| `guide_page.blocks[].url` | string or null | Read only. The photo image, for `photo` blocks. |
| `guide_page.blocks[].name` | string | Read only. The route name shown on a `route` card. |
| `guide_page.blocks[].distance` | number | Read only. Meters, as shown on a `route` card. |
| `guide_page.blocks[].elevation_gain` | number | Read only. Meters, as shown on a `route` card. |
| `guide_page.file` | object or null | Present on PDF pages. |
| `guide_page.file.name` | string |  |
| `guide_page.file.filename` | string |  |
| `guide_page.file.content_type` | string |  |
| `guide_page.file.size` | integer |  |
| `guide_page.created_at` | date-time |  |
| `guide_page.updated_at` | date-time |  |

#### Errors

- `422` Invalid move

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{
  "guide_page": {
    "title": "Day 1: Portland to Tillamook",
    "header": false,
    "live": false,
    "parent_id": 123,
    "position": 1,
    "blocks": [
      {
        "type": "text",
        "markdown": "Welcome to the tour! Today we ride from Portland to the coast.",
        "photo_id": 123,
        "on_tap": "none",
        "link_url": "https://example.com",
        "route_id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "name": "Forest Park loop",
        "distance": 40237,
        "elevation_gain": 457
      }
    ]
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123/guide_pages/123.json
```

#### Example response

```json
{
  "guide_page": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/guide_pages/123.json",
    "experience_id": 123,
    "parent_id": 123,
    "position": 1,
    "title": "Day 1: Portland to Tillamook",
    "header": false,
    "live": false,
    "blocks": [
      {
        "type": "text",
        "markdown": "Welcome to the tour! Today we ride from Portland to the coast.",
        "photo_id": 123,
        "on_tap": "none",
        "link_url": "https://example.com",
        "route_id": 123,
        "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
        "name": "Forest Park loop",
        "distance": 40237,
        "elevation_gain": 457
      }
    ],
    "file": {
      "name": "day1.pdf",
      "filename": "day1.pdf",
      "content_type": "application/pdf",
      "size": 1093417
    },
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Deletes a guide page

`DELETE /api/v1/experiences/{experience_id}/guide_pages/{id}.json`

Deletes a guide page. Deleting a header also deletes the pages under 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

#### Response `204`

Guide page deleted

#### 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/experiences/123/guide_pages/123.json
```

## Experience Packages

### Returns an experience's packages

`GET /api/v1/experiences/{experience_id}/packages.json`

Returns the packages built for the experience, newest first. Guests download the newest package.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `page` | integer | query | no | Page number for pagination |
| `page_size` | integer | query | no | Number of items per page (20-200) |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `packages` | array of objects |  |
| `packages[].id` | integer |  |
| `packages[].url` | string |  |
| `packages[].experience_id` | integer |  |
| `packages[].status` | string | `failed` means the last build of the experience failed; the task of the publish request reports it too. One of: `queued`, `processing`, `ready`, `failed`. |
| `packages[].file_size` | integer or null | Bytes, once the package is ready. |
| `packages[].created_at` | date-time |  |
| `packages[].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) |

#### Example request

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

#### Example response

```json
{
  "packages": [
    {
      "id": 123,
      "url": "https://ridewithgps.com/api/v1/experiences/123/packages/123.json",
      "experience_id": 123,
      "status": "queued",
      "file_size": 26381512,
      "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/experiences/123/packages.json?page=2"
    }
  }
}
```

### Returns a package

`GET /api/v1/experiences/{experience_id}/packages/{id}.json`

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `package` | object |  |
| `package.id` | integer |  |
| `package.url` | string |  |
| `package.experience_id` | integer |  |
| `package.status` | string | `failed` means the last build of the experience failed; the task of the publish request reports it too. One of: `queued`, `processing`, `ready`, `failed`. |
| `package.file_size` | integer or null | Bytes, once the package is ready. |
| `package.created_at` | date-time |  |
| `package.updated_at` | date-time |  |

#### Errors

- `404` Another experience's package

#### Example request

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

#### Example response

```json
{
  "package": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/packages/123.json",
    "experience_id": 123,
    "status": "queued",
    "file_size": 26381512,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Publishes an experience

`POST /api/v1/experiences/{experience_id}/packages.json`

Makes the experience available to guests and builds a new package with its current routes and guide pages. The build runs in the background.

Returns a task. Poll the task URL, also given in the `Location` header, until its status is `completed`. A finished build lists the package in `items`; a failed one reports a `build_failed` error. Refused with a 409 while a build is queued or running, or when nothing changed since the last build.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |

#### Response `202`

| Name | Type | Description |
| --- | --- | --- |
| `task` | object |  |
| `task.id` | integer |  |
| `task.user_id` | integer |  |
| `task.url` | string | API url of the task, to poll until it completes |
| `task.type` | string | What kind of work the task performs. `gps_file_upload` for uploads, `experience_package` for experience packages |
| `task.status` | string | `pending` until the task has run, then `completed` |
| `task.created_at` | date-time |  |
| `task.updated_at` | date-time |  |
| `task.items` | array of objects | Assets created by the task. Empty while pending, and empty if nothing was created. A file holding several tracks creates one asset per track |
| `task.items[].item_type` | string | Type of the created asset: `route` or `trip` for uploads, `experience_package` for experience packages |
| `task.items[].item_id` | integer |  |
| `task.items[].item_url` | string or null | API url of the created asset |
| `task.errors` | array of objects | Anything that went wrong, one entry per track that could not be imported. Empty when the task succeeded entirely |
| `task.errors[].code` | string | Machine readable reason. One of `duplicate`, `time_data_missing`, `no_tracks`, `empty_file`, `parse_failed`, `failed_to_process`, `weigh_in_failed`, `build_failed`, `error` |
| `task.errors[].message` | string | Human readable description, always in English |
| `task.errors[].item_type` | string or null | Set when the error refers to an existing asset, as for a duplicate |
| `task.errors[].item_id` | integer or null |  |
| `task.errors[].item_url` | string or null |  |

#### Errors

- `409` A build is already running

#### Example request

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

#### Example response

```json
{
  "task": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/tasks/123.json",
    "type": "gps_file_upload",
    "status": "completed",
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "items": [
      {
        "item_type": "route",
        "item_id": 123,
        "item_url": "https://ridewithgps.com/api/v1/routes/123.json"
      }
    ],
    "errors": [
      {
        "code": "duplicate",
        "message": "This route already exists",
        "item_type": "route",
        "item_id": 123,
        "item_url": "https://ridewithgps.com/api/v1/routes/123.json"
      }
    ]
  }
}
```

## Experience Codes

### Returns an experience's codes

`GET /api/v1/experiences/{experience_id}/codes.json`

Returns every code of the experience, active or not, newest first.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `codes` | array of objects |  |
| `codes[].id` | integer |  |
| `codes[].url` | string |  |
| `codes[].code` | string | What guests enter in the app. Letters and digits, upper case. |
| `codes[].kind` | string | `guest`: the shared code of an unlimited experience. `guide`: for guides, whose access never expires. `limited`: a code with an `access_limit`, for experiences whose `unlimited` is false. One of: `guest`, `guide`, `limited`. |
| `codes[].active` | boolean |  |
| `codes[].access_limit` | integer or null | How many guests can join with a `limited` code. |
| `codes[].times_used` | integer |  |
| `codes[].created_at` | date-time |  |
| `codes[].updated_at` | date-time |  |

#### Example request

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

#### Example response

```json
{
  "codes": [
    {
      "id": 123,
      "url": "https://ridewithgps.com/api/v1/experiences/123/codes/123.json",
      "code": "COAST2000",
      "kind": "guest",
      "active": false,
      "access_limit": 20,
      "times_used": 3,
      "created_at": "2000-01-01T12:00:00Z",
      "updated_at": "2000-01-01T12:00:00Z"
    }
  ]
}
```

### Returns a code

`GET /api/v1/experiences/{experience_id}/codes/{id}.json`

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `code` | object |  |
| `code.id` | integer |  |
| `code.url` | string |  |
| `code.code` | string | What guests enter in the app. Letters and digits, upper case. |
| `code.kind` | string | `guest`: the shared code of an unlimited experience. `guide`: for guides, whose access never expires. `limited`: a code with an `access_limit`, for experiences whose `unlimited` is false. One of: `guest`, `guide`, `limited`. |
| `code.active` | boolean |  |
| `code.access_limit` | integer or null | How many guests can join with a `limited` code. |
| `code.times_used` | integer |  |
| `code.created_at` | date-time |  |
| `code.updated_at` | date-time |  |

#### Errors

- `404` Another experience's code

#### Example request

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

#### Example response

```json
{
  "code": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/codes/123.json",
    "code": "COAST2000",
    "kind": "guest",
    "active": false,
    "access_limit": 20,
    "times_used": 3,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Creates a code

`POST /api/v1/experiences/{experience_id}/codes.json`

Creates a code guests enter in the app to join the experience. Omit `code` to get a random one.

A new `guest` or `guide` code replaces the active code of the same kind: guests who already joined keep their access, and the old code stops working. A replaced code nobody used is deleted.

`guest` codes are for experiences whose `unlimited` is true. `limited` codes are for experiences whose `unlimited` is false; they add to the existing ones and need an `access_limit`. `guide` codes need the guide shortcut in the organization's plan.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |

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

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | object | yes |  |
| `code.kind` | string | yes | One of: `guest`, `guide`, `limited`. |
| `code.code` | string | no | 4 to 20 letters or digits. Stored upper case. |
| `code.access_limit` | integer | no | `limited` codes only. |

#### Response `201`

| Name | Type | Description |
| --- | --- | --- |
| `code` | object |  |
| `code.id` | integer |  |
| `code.url` | string |  |
| `code.code` | string | What guests enter in the app. Letters and digits, upper case. |
| `code.kind` | string | `guest`: the shared code of an unlimited experience. `guide`: for guides, whose access never expires. `limited`: a code with an `access_limit`, for experiences whose `unlimited` is false. One of: `guest`, `guide`, `limited`. |
| `code.active` | boolean |  |
| `code.access_limit` | integer or null | How many guests can join with a `limited` code. |
| `code.times_used` | integer |  |
| `code.created_at` | date-time |  |
| `code.updated_at` | date-time |  |

#### Errors

- `422` Invalid code

#### 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 '{
  "code": {
    "kind": "guest",
    "code": "SMITH2000",
    "access_limit": 20
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123/codes.json
```

#### Example response

```json
{
  "code": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/codes/123.json",
    "code": "COAST2000",
    "kind": "guest",
    "active": false,
    "access_limit": 20,
    "times_used": 3,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Updates a code

`PATCH /api/v1/experiences/{experience_id}/codes/{id}.json`

Turns a code on or off, or changes the `access_limit` of a `limited` code. The limit cannot go below the times the code was used.

Turning a `guest` or `guide` code back on makes it the experience's code of that kind again. The active `guest` code cannot be turned off, and neither can the active `guide` code when the plan includes the guide shortcut: create a new code to replace 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

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

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | object | yes |  |
| `code.active` | boolean | no |  |
| `code.access_limit` | integer | no |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `code` | object |  |
| `code.id` | integer |  |
| `code.url` | string |  |
| `code.code` | string | What guests enter in the app. Letters and digits, upper case. |
| `code.kind` | string | `guest`: the shared code of an unlimited experience. `guide`: for guides, whose access never expires. `limited`: a code with an `access_limit`, for experiences whose `unlimited` is false. One of: `guest`, `guide`, `limited`. |
| `code.active` | boolean |  |
| `code.access_limit` | integer or null | How many guests can join with a `limited` code. |
| `code.times_used` | integer |  |
| `code.created_at` | date-time |  |
| `code.updated_at` | date-time |  |

#### Errors

- `422` Invalid change

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{
  "code": {
    "active": false,
    "access_limit": 20
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123/codes/123.json
```

#### Example response

```json
{
  "code": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/codes/123.json",
    "code": "COAST2000",
    "kind": "guest",
    "active": false,
    "access_limit": 20,
    "times_used": 3,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

## Experience Guests

### Returns an experience's guests

`GET /api/v1/experiences/{experience_id}/guests.json`

Returns the guests who joined the experience with a code and downloaded it, newest first.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `page` | integer | query | no | Page number for pagination |
| `page_size` | integer | query | no | Number of items per page (20-200) |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `guests` | array of objects |  |
| `guests[].id` | integer |  |
| `guests[].url` | string |  |
| `guests[].code` | string | The code the guest joined with. |
| `guests[].code_kind` | string | One of: `guest`, `guide`, `limited`. |
| `guests[].details` | object | What the guest entered when the experience asks for it (`require_name`, `require_email`, ...). |
| `guests[].details.name` | string |  |
| `guests[].details.email` | string |  |
| `guests[].details.phone` | string |  |
| `guests[].details.zip_code` | string |  |
| `guests[].details.reference_id` | string |  |
| `guests[].can_email` | boolean | The guest agreed to be emailed. |
| `guests[].download_count` | integer |  |
| `guests[].expires_at` | date-time or null | When access ends. Null means it does not expire. |
| `guests[].removed_by_guest` | boolean | The guest removed the experience from the app. Entering the code again brings it back. |
| `guests[].joined_at` | date-time |  |
| `guests[].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) |

#### Example request

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

#### Example response

```json
{
  "guests": [
    {
      "id": 123,
      "url": "https://ridewithgps.com/api/v1/experiences/123/guests/123.json",
      "code": "COAST2000",
      "code_kind": "guest",
      "details": {
        "name": "Alex Rider",
        "email": "alex@example.com",
        "phone": "+1 503 555 0100",
        "zip_code": "97209",
        "reference_id": "BOOKING-1234"
      },
      "can_email": false,
      "download_count": 1,
      "expires_at": "2000-01-01T12:00:00Z",
      "removed_by_guest": false,
      "joined_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/experiences/123/guests.json?page=2"
    }
  }
}
```

### Returns a guest

`GET /api/v1/experiences/{experience_id}/guests/{id}.json`

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `guest` | object |  |
| `guest.id` | integer |  |
| `guest.url` | string |  |
| `guest.code` | string | The code the guest joined with. |
| `guest.code_kind` | string | One of: `guest`, `guide`, `limited`. |
| `guest.details` | object | What the guest entered when the experience asks for it (`require_name`, `require_email`, ...). |
| `guest.details.name` | string |  |
| `guest.details.email` | string |  |
| `guest.details.phone` | string |  |
| `guest.details.zip_code` | string |  |
| `guest.details.reference_id` | string |  |
| `guest.can_email` | boolean | The guest agreed to be emailed. |
| `guest.download_count` | integer |  |
| `guest.expires_at` | date-time or null | When access ends. Null means it does not expire. |
| `guest.removed_by_guest` | boolean | The guest removed the experience from the app. Entering the code again brings it back. |
| `guest.joined_at` | date-time |  |
| `guest.updated_at` | date-time |  |

#### Errors

- `404` Another experience's guest

#### Example request

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

#### Example response

```json
{
  "guest": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/guests/123.json",
    "code": "COAST2000",
    "code_kind": "guest",
    "details": {
      "name": "Alex Rider",
      "email": "alex@example.com",
      "phone": "+1 503 555 0100",
      "zip_code": "97209",
      "reference_id": "BOOKING-1234"
    },
    "can_email": false,
    "download_count": 1,
    "expires_at": "2000-01-01T12:00:00Z",
    "removed_by_guest": false,
    "joined_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

### Updates a guest's access

`PATCH /api/v1/experiences/{experience_id}/guests/{id}.json`

Sets when the guest loses access. Send a past time to end access now, or null so it never expires. Unless the organization has unlimited expiry, the time can be at most `expire_after_days` days from now, and null is refused when the experience sets `expire_after_days`.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `id` | integer | path | yes |  |

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

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `guest` | object | yes |  |
| `guest.expires_at` | date-time or null | no |  |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `guest` | object |  |
| `guest.id` | integer |  |
| `guest.url` | string |  |
| `guest.code` | string | The code the guest joined with. |
| `guest.code_kind` | string | One of: `guest`, `guide`, `limited`. |
| `guest.details` | object | What the guest entered when the experience asks for it (`require_name`, `require_email`, ...). |
| `guest.details.name` | string |  |
| `guest.details.email` | string |  |
| `guest.details.phone` | string |  |
| `guest.details.zip_code` | string |  |
| `guest.details.reference_id` | string |  |
| `guest.can_email` | boolean | The guest agreed to be emailed. |
| `guest.download_count` | integer |  |
| `guest.expires_at` | date-time or null | When access ends. Null means it does not expire. |
| `guest.removed_by_guest` | boolean | The guest removed the experience from the app. Entering the code again brings it back. |
| `guest.joined_at` | date-time |  |
| `guest.updated_at` | date-time |  |

#### Errors

- `422` Unreadable time

#### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{
  "guest": {
    "expires_at": "2000-01-01T12:00:00Z"
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123/guests/123.json
```

#### Example response

```json
{
  "guest": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/experiences/123/guests/123.json",
    "code": "COAST2000",
    "code_kind": "guest",
    "details": {
      "name": "Alex Rider",
      "email": "alex@example.com",
      "phone": "+1 503 555 0100",
      "zip_code": "97209",
      "reference_id": "BOOKING-1234"
    },
    "can_email": false,
    "download_count": 1,
    "expires_at": "2000-01-01T12:00:00Z",
    "removed_by_guest": false,
    "joined_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```

## Experience Messages

### Returns an experience's messages

`GET /api/v1/experiences/{experience_id}/messages.json`

Returns the messages sent to the guests of the experience, newest first. Requires messaging for the organization.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |
| `page` | integer | query | no | Page number for pagination |
| `page_size` | integer | query | no | Number of items per page (20-200) |

#### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `messages` | array of objects |  |
| `messages[].id` | integer |  |
| `messages[].content` | string |  |
| `messages[].created_at` | date-time |  |
| `messages[].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

- `403` Messaging is not enabled for the organization

#### Example request

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

#### Example response

```json
{
  "messages": [
    {
      "id": 123,
      "content": "Meet in the hotel lobby at 8:00 for the day 2 briefing.",
      "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/experiences/123/messages.json?page=2"
    }
  }
}
```

### Sends a message

`POST /api/v1/experiences/{experience_id}/messages.json`

Sends a message to the experience's guests. Guests get a push notification and find the message in the app.

#### 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 |
| --- | --- | --- | --- | --- |
| `experience_id` | integer | path | yes |  |

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

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | object | yes |  |
| `message.content` | string | yes |  |

#### Response `201`

| Name | Type | Description |
| --- | --- | --- |
| `message` | object |  |
| `message.id` | integer |  |
| `message.content` | string |  |
| `message.created_at` | date-time |  |
| `message.updated_at` | date-time |  |

#### Errors

- `422` Empty message

#### 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 '{
  "message": {
    "content": "Rain tomorrow: we start at 10:00 instead of 8:30."
  }
}' \
  https://ridewithgps.com/api/v1/experiences/123/messages.json
```

#### Example response

```json
{
  "message": {
    "id": 123,
    "content": "Meet in the hotel lobby at 8:00 for the day 2 briefing.",
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z"
  }
}
```
