> For the complete documentation index, see [llms.txt](https://docs.wellcomecollection.org/catalogue-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wellcomecollection.org/catalogue-api/requesting_flow.md).

# How users request items

Users can use the website to request items to view in the library; we provide a series of APIs to help them do that.

See also [How does item requesting work?](broken://spaces/mNeKBZYcfnVQtLDYvJ5T/pages/tRT0nwe8bOw5zZeP0N6B)

This is what the flow looks like:

````mermaid
```mermaid
sequenceDiagram
     participant user
     participant front end
     participant works API
     participant items API
     participant requests API
     participant Sierra
     participant content api

     user->>front end: views a works page<br/> with items

     front end->>works API: get information about<br/>items on a work
     works API-->>front end: OK

     front end->>items API: get up-to-date status of items<br/>using catalogue ID
     items API->>works API: get matching Sierra IDs<br/>for catalogue IDs
     works API-->>items API: OK
     items API->>Sierra: get latest Sierra item data
     Sierra-->>items API: OK

     items API ->> content api: get nextOpeningDates for venue(s) that matches the item's<br/>Sierra location code

     items API->>front end: returns items with up-to-date status<br/> and available dates for pick up (1)
     front end->>front end: render items with<br/>updated information

     user->>front end: clicks "Request item"
     front end->>requests API: request an item using catalogue ID
     requests API->>works API: get matching Sierra IDs<br/>for catalogue IDs
     works API-->>requests API: OK
     requests API->>Sierra: place request in<br/>Sierra
     Sierra-->>requests API: OK
     requests API->>front end: return result of request to user
```
````

### (1) Available dates for pickup

The items API returns a list of dates (`AvailableDates`) when the item can be viewed.

Once we have the latest Sierra item data:

* If the item has the Sierra item location code "harop"&#x20;

This means the item is held at Deepstore (off-site storage).&#x20;

We request both Deepstore and Wellcome library open days from the content-api (<https://api-stage.wellcomecollection.org/content/v0/venues?title=library%2Cdeepstore>)

We find the 11th Deepstore working day (lead time is 10 days). The list of `AvailableDates` is comprised of all Wellcome library opening days after that.

* If the item has any other Sierra item location code

We request Wellcome library open days from the content-api (<https://api-stage.wellcomecollection.org/content/v0/venues?title=library>)

If the request is made on a closed day or before 10am on an open day, the list of `AvailableDates`starts from the 2nd on the list returned by the content-api.

If the request is made after 10am on an open day, the list of `AvailableDates` starts from the 3rd on the list returned by the content-api.

#### NOTE on the content-api /venues endpoint

The response includes a `nextOpeningDates` list for each venue requested, which is used by the itemsAPI to generate the list of `AvailableDates`.

The `nextOpeningDates` list is created from the venue's regular open days and exceptional closed days stored in the venues index. We start from a list of 50 days starting today, and filter out all regular open days and exceptional closed days.&#x20;

The list starts today, unless today is a closed/non-working day.&#x20;
