Monica
Log in
API v1
v1
View as Markdown

List value lists

GET QUERY /api/v1/value-lists

List the value lists of your account, each with its choices, so a field offering choices can name the one it takes them from.

A value list is a named set of choices defined once for the account and reused by any number of fields: genders, phone labels, contact categories. The lists are in the order the settings show them, and the choices of each in their own order.

Only the shared lists are here. The choices somebody typed into a single field belong to that field and are not listed.

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.

Query parameters

Path parameters go in the address. GET sends the others in the address too, QUERY sends them as JSON in the request body. Anything not listed here is ignored.

page integer Optional default: 1

Which page to answer with.

per_page integer Optional default: 25

How many one page holds, between 1 and 100. A number outside the range is brought back into it rather than refused.

Returns

A page of value lists, and how many there are in all. The lists of another account are never included.

data array

The value lists on this page. An empty list rather than an error when there are none.

data[] object

One value list.

data[].type string

Always value_list.

data[].id integer

The id of the list, which is what value_list_id takes when a field is added or configured.

data[].attributes object

What the list holds.

data[].attributes.name string

What the list is called.

data[].attributes.items array

The choices the list offers, in their order. An empty list when it offers none yet.

data[].attributes.items[] object

One choice.

data[].attributes.items[].id integer

The id of the choice, which is what a field offering this list stores as its value.

data[].attributes.items[].label string

What the choice says.

data[].attributes.items[].country_code string

For a choice of the Countries list, its two letter ISO 3166 code, which picks the layout an address in that country is shown in. Null on every other list, and on a country nobody gave a code yet.

data[].attributes.items[].is_active boolean

Whether the choice is still offered. A choice no longer offered stays on every record that already has it.

data[].attributes.items[].position integer

Its place in the list, counting from 1.

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 value lists there are in all, not how many are on this page.

Status codes

Every code the API answers with, and what the body holds when it does.

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.

GET
curl https://friends.ban.is/api/v1/value-lists?page=2&per_page=10 \
-H "Authorization: Bearer $MONICA_TOKEN"
const response = await fetch('https://friends.ban.is/api/v1/value-lists?page=2&per_page=10', {
headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
$response = Http::withToken($token)->get('https://friends.ban.is/api/v1/value-lists?page=2&per_page=10');
QUERY
curl https://friends.ban.is/api/v1/value-lists \
-X QUERY \
-H "Authorization: Bearer $MONICA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"page": 2,
"per_page": 10
}'
const response = await fetch('https://friends.ban.is/api/v1/value-lists', {
method: 'QUERY',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
page: 2,
per_page: 10,
}),
})
const data = await response.json()
$response = Http::withToken($token)->query('https://friends.ban.is/api/v1/value-lists', [
'page' => 2,
'per_page' => 10,
]);
Response 200
{
"data": [
{
"type": "value_list",
"id": 3,
"attributes": {
"name": "Genders",
"items": [
{
"id": 11,
"label": "Woman",
"country_code": null,
"is_active": true,
"position": 1
},
{
"id": 12,
"label": "Man",
"country_code": null,
"is_active": true,
"position": 2
},
{
"id": 13,
"label": "Non-binary",
"country_code": null,
"is_active": true,
"position": 3
}
]
}
}
],
"meta": {
"page": 1,
"per_page": 25,
"total": 1
}
}

Keys act as you, with exactly the access you have. Make one per integration so you can revoke it alone.