# Presentations API

> Manage presentations and the artworks shown in them

A presentation is a record of an event where artworks were shown: an exhibition, an art fair booth, an online viewing room, or a grant or residency application. Each one has a venue, dates, and a checklist of artworks in order. Artists keep [presentations in Valise](https://valise.works/help/presentations) to build their exhibition history and CV.

> The API doesn't include a presentation's photos or documents yet. We plan to
> add them.

## How presentations work

A presentation points to its artworks by ID. To show one with its artworks, combine it with other records:

- A presentation's `artworkIds` are the IDs of [artworks](https://valise.works/help/api/artworks), in checklist order.
- An artwork has the title, year, medium, and dimensions, and its `images` in gallery order. The first image is the one Valise shows for the artwork.
- An artwork's `artistIds` are the IDs of [contacts](https://valise.works/help/api/contacts), and a contact has the artist's `name`. You need these to credit each artwork in a group show, or when a vault holds artworks by more than one artist.

To find the presentations an artwork has been in, list presentations and keep the ones with the artwork's ID in `artworkIds`.

Use the list endpoints when you're showing more than a few records. A list request returns up to 100 records, so a vault of 1,000 artworks takes 10 requests. Getting those artworks one at a time takes 1,000 requests, and the API allows [300 a minute](https://valise.works/help/api#rate-limits).

## The presentation object

| Field        | Type     | Description                                                                                                                                      |
| ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id`         | string   | The presentation's ID.                                                                                                                           |
| `title`      | string   | The title of the exhibition or event, up to 200 characters.                                                                                      |
| `venue`      | string   | The gallery, museum, fair, or other place that held the presentation, up to 200 characters.                                                      |
| `location`   | string   | The city and country as text, like `Montréal, Canada`, up to 200 characters. It isn't linked to the [locations](https://valise.works/help/api/locations) in the API. |
| `type`       | string   | `solo` or `group`.                                                                                                                               |
| `startDate`  | string   | The opening date, as a [partial date](https://valise.works/help/api/dates#partial-dates): `2024`, `2024-03`, or `2024-03-10`.                                        |
| `endDate`    | string   | The closing date, in the same format.                                                                                                            |
| `notes`      | string   | Plain text, up to 8,000 characters.                                                                                                              |
| `artworkIds` | string[] | The IDs of the [artworks](https://valise.works/help/api/artworks) shown, in checklist order. Up to 100.                                                              |
| `createdAt`  | string   | When the presentation was created, as a [timestamp](https://valise.works/help/api/dates#timestamps).                                                                 |
| `updatedAt`  | string   | When the presentation last changed.                                                                                                              |

```json
{
  "id": "pq3x8vneh2kd0tz7wbm4ycs1",
  "title": "Quiet Rooms",
  "venue": "Gallery One",
  "location": "Montréal, Canada",
  "type": "solo",
  "startDate": "2024-03-10",
  "endDate": "2024-05",
  "notes": "Two rooms upstairs",
  "artworkIds": ["ahvxb9zbcew4a0fhroz9ijs0", "iogf1yv44dtudcam42a9rx8o"],
  "createdAt": "2024-09-06T11:17:15Z",
  "updatedAt": "2024-09-06T11:17:15Z"
}
```

The `title`, `location`, `notes`, `startDate`, and `endDate` fields are always in the response. They're empty strings when they haven't been filled in.

## List presentations

The list is ordered by when each presentation was created, newest first. To order it by date, [sort by the start date](https://valise.works/help/api/dates#sorting).

```http
GET /v0/presentations
```

```shell
curl https://api.valise.works/v0/presentations \
  --header "Authorization: Bearer <API_KEY>"
```

Returns a [page](https://valise.works/help/api#pagination) of presentations.

## Get a presentation

```http
GET /v0/presentations/{id}
```

```shell
curl https://api.valise.works/v0/presentations/pq3x8vneh2kd0tz7wbm4ycs1 \
  --header "Authorization: Bearer <API_KEY>"
```

Returns the presentation.

## Create a presentation

```http
POST /v0/presentations
```

The body takes `venue`, `type`, `title`, `location`, `startDate`, `endDate`, `notes`, and `artworkIds`. Only `venue` and `type` are required. The artworks in `artworkIds` go into the presentation in the order given.

Send each date as a [partial date](https://valise.works/help/api/dates#sending-dates). The end date can't be before the start date.

```shell
curl https://api.valise.works/v0/presentations \
  --request POST \
  --header "Authorization: Bearer <API_KEY>" \
  --header "Content-Type: application/json" \
  --data '{"venue": "Gallery One", "type": "solo", "startDate": "2024-03-10", "artworkIds": ["ahvxb9zbcew4a0fhroz9ijs0"]}'
```

Returns the new presentation. If one of the `artworkIds` isn't in your vault or is listed twice, the API returns a `400` naming it and creates nothing. If your vault is at its plan's limit of presentations, the API returns a `409`.

## Update a presentation

```http
PATCH /v0/presentations/{id}
```

The body takes the same fields as [creating a presentation](https://valise.works/help/api/presentations#create-a-presentation), except `artworkIds`, all optional. Fields you leave out keep their value. To clear the title, location, notes, or a date, pass an empty string.

To change the artworks in the presentation, [add](https://valise.works/help/api/presentations#add-an-artwork-to-a-presentation), [remove](https://valise.works/help/api/presentations#remove-an-artwork-from-a-presentation), or [reorder](https://valise.works/help/api/presentations#reorder-a-presentation) them.

```shell
curl https://api.valise.works/v0/presentations/pq3x8vneh2kd0tz7wbm4ycs1 \
  --request PATCH \
  --header "Authorization: Bearer <API_KEY>" \
  --header "Content-Type: application/json" \
  --data '{"endDate": "2024-05"}'
```

Returns the updated presentation. The API checks the dates you send against [the saved ones](https://valise.works/help/api/dates#sending-dates), and returns a `400` if the end date would come before the start date.

## Delete a presentation

The artworks in the presentation aren't deleted. This can't be undone.

```http
DELETE /v0/presentations/{id}
```

```shell
curl https://api.valise.works/v0/presentations/pq3x8vneh2kd0tz7wbm4ycs1 \
  --request DELETE \
  --header "Authorization: Bearer <API_KEY>"
```

Returns no content.

## Add an artwork to a presentation

```http
POST /v0/presentations/{id}/artworks
```

The body takes the `artworkId` of the artwork to add. The artwork goes at the end of the checklist.

```shell
curl https://api.valise.works/v0/presentations/pq3x8vneh2kd0tz7wbm4ycs1/artworks \
  --request POST \
  --header "Authorization: Bearer <API_KEY>" \
  --header "Content-Type: application/json" \
  --data '{"artworkId": "ahvxb9zbcew4a0fhroz9ijs0"}'
```

Returns the updated presentation. Adding an artwork that's already in the presentation changes nothing. If the artwork isn't in your vault, the API returns a `404`. If the presentation already has 100 artworks, it returns a `409`.

## Remove an artwork from a presentation

The artwork itself isn't deleted.

```http
DELETE /v0/presentations/{id}/artworks/{artworkId}
```

```shell
curl https://api.valise.works/v0/presentations/pq3x8vneh2kd0tz7wbm4ycs1/artworks/ahvxb9zbcew4a0fhroz9ijs0 \
  --request DELETE \
  --header "Authorization: Bearer <API_KEY>"
```

Returns no content, even when the artwork isn't in the presentation.

## Reorder a presentation

```http
POST /v0/presentations/{id}/reorder
```

The body takes `artworkIds`: every artwork in the presentation, exactly once, in the new order. This endpoint only changes the order. It can't add or remove artworks.

```shell
curl https://api.valise.works/v0/presentations/pq3x8vneh2kd0tz7wbm4ycs1/reorder \
  --request POST \
  --header "Authorization: Bearer <API_KEY>" \
  --header "Content-Type: application/json" \
  --data '{"artworkIds": ["iogf1yv44dtudcam42a9rx8o", "ahvxb9zbcew4a0fhroz9ijs0"]}'
```

Returns the updated presentation. If the list doesn't match the presentation's artworks, the API returns a `400` naming each artwork that's missing, duplicated, or not in the presentation.

## Examples

### Exhibition history

An exhibition history lists every presentation from newest to oldest, with its venue, title, location, dates, and artworks. To build one:

1. List the presentations and the artworks, following `page.next` on each until it's `null`.
2. Map the artworks by ID, so each ID in a checklist finds its artwork without another request.
3. Sort the presentations by `startDate`. [Partial dates sort in date order as text](https://valise.works/help/api/dates#sorting).
4. Build an entry for each presentation, formatting each date at the precision it has and looking up each artwork in the map.

Here's the whole flow in JavaScript:

```js
const headers = { Authorization: "Bearer <API_KEY>" }

// Follows page.next until it has every record.
const listAll = async (path) => {
  const records = []
  let next = `https://api.valise.works${path}`
  while (next) {
    const response = await fetch(next, { headers })
    if (!response.ok) throw new Error(`${response.status} from ${next}`)
    const body = await response.json()
    records.push(...body.data)
    next = body.page.next
  }
  return records
}

// Formats "2024", "2024-05", or "2024-05-10" with only the parts it has.
const formatPartialDate = (value, locale = "en-US") => {
  if (!value) return ""
  const [year, month, day] = value.split("-").map(Number)
  const date = new Date(Date.UTC(year, (month ?? 1) - 1, day ?? 1))
  return date.toLocaleDateString(locale, {
    timeZone: "UTC",
    year: "numeric",
    month: month ? "long" : undefined,
    day: day ? "numeric" : undefined,
  })
}

// 1. List the presentations and the artworks
const [presentations, artworks] = await Promise.all([
  listAll("/v0/presentations"),
  listAll("/v0/artworks"),
])

// 2. Map the artworks by ID
const artworksById = new Map(artworks.map((artwork) => [artwork.id, artwork]))

// 3. Sort by start date, newest first
presentations.sort((a, b) => b.startDate.localeCompare(a.startDate))

// 4. Build an entry for each presentation
const history = presentations.map((presentation) => ({
  venue: presentation.venue,
  title: presentation.title,
  location: presentation.location,
  // A Set drops the end date when it's the same as the start.
  dates: [...new Set([presentation.startDate, presentation.endDate])]
    .filter(Boolean)
    .map((date) => formatPartialDate(date))
    .join(" – "),
  works: presentation.artworkIds
    // Skips a work deleted between the two requests.
    .flatMap((id) => artworksById.get(id) ?? [])
    .map((artwork) => ({
      title: artwork.title,
      year: artwork.year,
      medium: artwork.medium,
      image: artwork.images[0]?.url,
    })),
}))
```

For the [example presentation](https://valise.works/help/api/presentations#the-presentation-object), the entry is:

```json
{
  "venue": "Gallery One",
  "title": "Quiet Rooms",
  "location": "Montréal, Canada",
  "dates": "March 10, 2024 – May 2024",
  "works": [
    {
      "title": "Morning Grid",
      "year": "1962",
      "medium": "Acrylic on paper",
      "image": "https://uploads.valise.works/..."
    }
    // ...
  ]
}
```

A presentation with no dates sorts last and has an empty `dates`. An artwork with no images has no `image`. An artwork's `year` is [text as the artist entered it](https://valise.works/help/api/dates#artwork-years), like `c. 2023`. Show it as written.

## Related articles

- [Artworks API](https://valise.works/help/api/artworks): List, create, update, and delete artworks
- [Dates](https://valise.works/help/api/dates): How the API formats timestamps, dates, and years
- [Presentations](https://valise.works/help/presentations): Record exhibitions, art fairs, online viewing rooms, and more
