A relation field links records. Its metadata gives the target object and the cardinality in config. Relations come in pairs: a person's company is the other side of a company's people. Changing one side changes both.
| Cardinality | Example | Read as |
|---|---|---|
many_to_one | a person's company | one linked record, or null |
one_to_many | a company's people | an array |
many_to_many | a field linking both ways | an array |
A linked record looks like this:
{
"id": "84dc4b91-e114-4f52-97f1-8fa7cee37687",
"displayValue": "Globex",
"objectSlug": "companies",
"imageUrl": null
}Lists hold up to 10 linked records per field, single records up to 50. relationCounts has the full numbers.
Page through links#
/records/{recordId}/relations/{fieldKey}| Parameter | Default | Rules |
|---|---|---|
offset | 0 | 0–1,000,000 |
limit | 100 | 1–100 |
curl --fail-with-body "$JEMERO_URL/records/$COMPANY_ID/relations/people?limit=100&offset=0" \
-H "Authorization: Bearer $JEMERO_API_KEY"{
"records": [
{
"id": "e1b83a4a-1363-4d45-a755-981a448cb410",
"displayValue": "Grace Hopper",
"objectSlug": "people",
"imageUrl": null
}
],
"total": 1
}An unknown or non-relation fieldKey answers 404 Relation field not found.
Change links#
Write relations with Create or Update. Use record IDs.
For a many-to-one field, send an ID, or null to unlink:
curl --fail-with-body -X PATCH "$JEMERO_URL/records/$PERSON_ID" \
-H "Authorization: Bearer $JEMERO_API_KEY" \
-H "Content-Type: application/json" \
-d "{ \"values\": { \"company\": \"$COMPANY_ID\" } }"For a field with many links, you have two choices. An array replaces all links:
{ "values": { "people": ["e1b83a4a-1363-4d45-a755-981a448cb410"] } }An object with add and remove changes only what you name:
curl --fail-with-body -X PATCH "$JEMERO_URL/records/$COMPANY_ID" \
-H "Authorization: Bearer $JEMERO_API_KEY" \
-H "Content-Type: application/json" \
-d "{ \"values\": { \"people\": { \"add\": [\"$PERSON_ID\"] } } }"- Each list takes up to 500 IDs.
- Linked records must be live records of the relation's target object. Otherwise the answer is
400. - Where a record can have only one parent, linking it to a new one moves it from the old one.
Filter by links#
Use is_any_of, is_empty or is_not_empty on the relation's field ID. See Filtering.