# List vaults

`GET /api/v1/vaults` and `QUERY /api/v1/vaults`

List your vaults, in the order you arranged them or, when asked, the one opened most recently first.

Unless you ask for sort=recent, the order is the one you gave your vaults, which is the order they appear in when you switch between them. It is not the order they were made in, so a vault you moved to the top comes back at the top.

A deleted vault is never listed. An account holding no vault answers with an empty list rather than an error, since that is the state every account starts in.

This endpoint answers GET and QUERY alike, and both return the same answer. GET sends the parameters in the address, QUERY in the request body. [How QUERY works](https://people.hansyeoh.com/docs/api/query-method).

## Query parameters

- `page` (integer, optional, defaults to 1): Which page to answer with.
- `per_page` (integer, optional, defaults to 25): How many vaults one page holds, between 1 and 100. A number outside the range is brought back into it rather than refused.
- `sort` (string, optional): Left out, the vaults come in the order you arranged them. recent puts the vault opened most recently first, the ones never opened last, and breaks a tie with the order you arranged. It is the order of the vaults page of the application. Any other value answers 422.

## Returns

A page of vault objects, and how many there are in all.

- `data` (array): The vaults on this page. An empty list rather than an error when there are none.
- `data[]` (object): One vault.
- `data[].type` (string): Always vault. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data[].id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data[].attributes` (object): Everything the record holds.
- `data[].attributes.slug` (string): The readable name the vault is addressed by, built from its name and unique within your account. It is not stable: renaming the vault rebuilds it and the previous one stops answering, which is why a stored reference should be the id. Nothing lets you choose or edit it.
- `data[].attributes.name` (string): What the vault is called. Up to 255 characters. Reduced to plain text when it was written down, so no markup survives here.
- `data[].attributes.description` (string): What the vault is for, up to 65535 characters, or null when nobody said. Null is the ordinary state of a vault nobody described, not a sign of anything missing.
- `data[].attributes.colour` (string): Exactly one of #3f5fd0, #4f8a49, #9a6a24, #9a3f2b, #6b4fa8, #2f7f86, #a8447a or #4a4a52, written in lower case. It is how vaults are told apart at a glance, and it is decoration: nothing depends on it.
- `data[].attributes.position` (integer): Where the vault sits in your list, counting from 1. It is the order you arranged, and it is the order the list endpoint answers in.
- `data[].attributes.is_default` (boolean): Whether records land here when nothing says which vault. Exactly one of your vaults is true while you hold a vault at all, and none is while you hold none.
- `data[].attributes.contact_count` (integer): How many contacts the vault holds, counting the archived and the partial ones. It is a running count kept as contacts are written down and deleted, rather than something counted when you ask.
- `data[].attributes.last_visited_at` (timestamp): When somebody last opened the vault in the application, as a count of seconds since 1970, or null when nobody ever has. Reading the vault through this API does not count as opening it.
- `data[].attributes.faces` (array): Up to four contacts of the vault to draw as faces on a card, the most recently written down first. Archived and partial contacts are left out. An empty list when there is nobody to draw. How many more there are is contact_count minus the length of this list, which is how the application words it too.
- `data[].attributes.faces[]` (object): One contact, as a card draws it.
- `data[].attributes.faces[].id` (uuid): The id of the contact, which the contacts endpoints take.
- `data[].attributes.faces[].name` (string): The name the contact is shown under, in the order the contact is set to read in.
- `data[].attributes.faces[].avatar_url` (string): Where the small picture of the contact is served to your key, or null when the contact has no picture and is drawn as initials. See Get the picture of a contact.
- `data[].attributes.upcoming_reminder_count` (integer): How many reminders of the vault still wait on an answer up to the last day of the current month, the overdue ones included. The month is the one your own timezone is in. A reminder switched off, or a date already answered, is not counted.
- `data[].attributes.shows_people` (boolean): Whether the screens of the vault show People: its contacts, entities and groups, in the sidebar and in search. True for every new vault. It changes only what the application draws: every endpoint here answers the same either way.
- `data[].attributes.shows_things` (boolean): Whether the sidebar of the vault shows Things, its possessions. True for every new vault. It changes only what the application draws.
- `data[].attributes.shows_knowledge` (boolean): Whether the sidebar of the vault shows Knowledge, its notes and lists. True for every new vault. It changes only what the application draws.
- `data[].attributes.created_at` (timestamp): When the vault was opened, as a count of seconds since 1970 rather than a written date.
- `data[].attributes.updated_at` (timestamp): When its wording last changed, as a count of seconds. Equal to created_at until it first changes.
- `data[].links` (object): Where to find this record.
- `data[].links.self` (string): The absolute address this record is read from.
- `data[].links.web` (string): The page of the vault in the application, which opens for somebody signed in rather than for a key. It is the link to give a person.
- `meta` (object): Where you are in the collection.
- `meta.page` (integer): The page this is, counting from 1.
- `meta.per_page` (integer): How many one page holds, which is the size that was asked for once it has been brought into the allowed range.
- `meta.total` (integer): How many vaults there are in all, not how many are on this page.

## Status codes

| Code | When | Body |
| --- | --- | --- |
| `422` Unprocessable Content | With QUERY, a parameter was sent both in the address and in the body. | A message, and an errors object naming each parameter sent twice. |

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://people.hansyeoh.com/api/v1/vaults?page=2&per_page=10&sort=recent \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://people.hansyeoh.com/api/v1/vaults?page=2&per_page=10&sort=recent', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://people.hansyeoh.com/api/v1/vaults?page=2&per_page=10&sort=recent');
```

## Request with QUERY

```sh
curl https://people.hansyeoh.com/api/v1/vaults \
  -X QUERY \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "page": 2,
      "per_page": 10,
      "sort": "recent"
  }'
```

```javascript
const response = await fetch('https://people.hansyeoh.com/api/v1/vaults', {
  method: 'QUERY',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    page: 2,
    per_page: 10,
    sort: 'recent',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->query('https://people.hansyeoh.com/api/v1/vaults', [
    'page' => 2,
    'per_page' => 10,
    'sort' => 'recent',
]);
```

## Response

`200`

```json
{
    "data": [
        {
            "type": "vault",
            "id": "9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31",
            "attributes": {
                "slug": "dunder-mifflin",
                "name": "Dunder Mifflin",
                "description": "Everybody at the Scranton branch.",
                "colour": "#4f8a49",
                "position": 1,
                "is_default": true,
                "contact_count": 12,
                "last_visited_at": 1764151200,
                "faces": [
                    {
                        "id": "5c2a9e17-3d4b-4f61-8a0c-7e9b2d146f53",
                        "name": "Pam Beesly",
                        "avatar_url": "https://people.hansyeoh.com/api/v1/vaults/dunder-mifflin/contacts/5c2a9e17-3d4b-4f61-8a0c-7e9b2d146f53/avatar"
                    },
                    {
                        "id": "e81f4b02-96c7-4d3a-b5e8-1a7c3f9d2064",
                        "name": "Jim Halpert",
                        "avatar_url": null
                    },
                    {
                        "id": "0b6d3c58-f219-4e8a-9c47-28e5a1d7b930",
                        "name": "Dwight Schrute",
                        "avatar_url": null
                    },
                    {
                        "id": "a4e97f21-5b08-4c6d-8e13-9f2c6b0d4a75",
                        "name": "Michael Scott",
                        "avatar_url": null
                    }
                ],
                "upcoming_reminder_count": 2,
                "shows_people": true,
                "shows_things": true,
                "shows_knowledge": false,
                "created_at": 1756252800,
                "updated_at": 1756339200
            },
            "links": {
                "self": "https://people.hansyeoh.com/api/v1/vaults/dunder-mifflin",
                "web": "https://people.hansyeoh.com/vaults/dunder-mifflin"
            }
        },
        {
            "type": "vault",
            "id": "b17c6d40-2e59-4a1b-8f03-5d84e2a9c6f7",
            "attributes": {
                "slug": "schrute-farms",
                "name": "Schrute Farms",
                "description": null,
                "colour": "#9a6a24",
                "position": 2,
                "is_default": false,
                "contact_count": 3,
                "last_visited_at": null,
                "faces": [
                    {
                        "id": "0b6d3c58-f219-4e8a-9c47-28e5a1d7b930",
                        "name": "Dwight Schrute",
                        "avatar_url": null
                    }
                ],
                "upcoming_reminder_count": 0,
                "shows_people": true,
                "shows_things": true,
                "shows_knowledge": true,
                "created_at": 1756166400,
                "updated_at": 1756166400
            },
            "links": {
                "self": "https://people.hansyeoh.com/api/v1/vaults/schrute-farms",
                "web": "https://people.hansyeoh.com/vaults/schrute-farms"
            }
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 25,
        "total": 2
    }
}
```
