Link fields
A link field points from one element to others, such as a Character’s location or friends. Which fields link to which element types is in Fields and on each element type’s page.
Try it on the practice world
Section titled “Try it on the practice world”Run these three in order: each one fills in the ids the ones above it made.
Create a Location:
Run sends the sample to the practice world: anyone can read what it makes, and it resets every night at 03:00 UTC.
curl -s -X POST "https://www.onlyworlds.com/api/v2/location" \
-H "API-Key: {key}" -H "API-Pin: {pin}" -H "Content-Type: application/json" \
-d '{ "name": "Keats", "description": "The capital city of Hyperion." }'Create a Character whose location is that Location:
curl -s -X POST "https://www.onlyworlds.com/api/v2/character" \
-H "API-Key: {key}" -H "API-Pin: {pin}" -H "Content-Type: application/json" \
-d '{ "name": "Sad King Billy", "location": "<location-id>" }'Add the Character to the Location’s founders with the link operations route; the answer is the whole Location, with the Character’s id in founders:
curl -s -X POST "https://www.onlyworlds.com/api/v2/location/<location-id>/links/founders" \
-H "API-Key: {key}" -H "API-Pin: {pin}" -H "Content-Type: application/json" \
-d '{ "add": ["<character-id>"] }'One shape, both directions
Section titled “One shape, both directions”A link field has one bare name and one value shape, in reads and writes alike:
{
"id": "0695…",
"name": "The Consul",
"location": "0698…",
"friends": ["0695…", "0698…"]
}- A single link (
location) is a UUID string, ornull. - A multi link (
friends) is an array of UUID strings. - Read and write use the same name. There is no
_idsor_idsuffix: sendingfriends_idsis a422invalid_request. (The suffixes belong to the Classic API.) - Every id written must name an existing element of the linked element type in this world, or the write is a
400invalid_linknaming the field inparam. An id of an element of another element type fails the same way.
To read the linked elements’ names alongside the ids, use ?expand=.
Setting and clearing links
Section titled “Setting and clearing links”On POST, PUT and PATCH, a link field takes the same shape it reads in. A multi-link value replaces the whole list. An element the list names twice is stored once, in its first place (the same id in two letter cases is one id): [a, b, a] is stored and served as [a, b], and the answer shows the list as stored. A null entry inside the list is refused with a 422 naming the field, and nothing is written (since 2026-11-13). A null entry stored before that rule is left out of what a read serves (since 2026-11-17). To clear:
| Field | Clear with |
|---|---|
| Single link | null |
| Multi link | [] (null is treated the same) |
curl -s -X PATCH "https://www.onlyworlds.com/api/v2/character/{id}" \
-H "API-Key: {key}" -H "API-Pin: {pin}" -H "Content-Type: application/json" \
-d '{ "location": "{time_tombs_id}", "institutions": ["{hegemony_id}"] }'Link two elements
Section titled “Link two elements”- Find the side that holds the field. A link is stored on one element only. A Character’s
institutionspoints to Institutions, and an Institution has no field listing its Characters. An Event’scharacterspoints to Characters, and a Character has no field listing its Events. Each element type’s page lists its link fields and their targets. - Set it on the new element when you can. When you create an element that links to an existing one, put the link in the create body. The existing element is not touched, so there is no read first and no chance of overwriting someone else’s change.
- Add to an existing element with the right write.
- A multi link: use the link operations route, which adds ids without replacing the list.
- A single link:
PATCHit. The new id replaces the old value.
# The Consul joins the Hegemony: add to the Character's multi link
curl -s -X POST "https://www.onlyworlds.com/api/v2/character/{consul_id}/links/institutions" \
-H "API-Key: {key}" -H "API-Pin: {pin}" -H "Content-Type: application/json" \
-d '{ "add": ["{hegemony_id}"] }'A contributor or guest changes only the elements it created. Linking from someone else’s element, by PATCH or by the link operations route, is 403 not_author: set the link on an element you created instead.
Link operations
Section titled “Link operations”POST /api/v2/{type}/{id}/links/{field} adds and removes ids on one multi-link field, with no read beforehand:
curl -s -X POST "https://www.onlyworlds.com/api/v2/character/{id}/links/friends" \
-H "API-Key: {key}" -H "API-Pin: {pin}" -H "Content-Type: application/json" \
-d '{ "add": ["{uuid_a}", "{uuid_b}"], "remove": ["{uuid_c}"] }'- The server merges atomically and returns
200with the full element. - Adds dedupe, so repeating one is harmless. Removes tolerate ids that are not present.
- Added ids must exist in this world (
400invalid_link). {field}must be a multi-link field of that element type; anything else, including a single link, is a422. Pin has no multi-link fields, so the route always answers422on Pin.
Deletes never leave dangling links
Section titled “Deletes never leave dangling links”Deleting an element removes its id from every other element’s links in the same transaction. A write can never create a dangling link either: a reference to a missing element fails as invalid_link instead of being dropped.
In /bulk, links are checked against the world plus the batch’s surviving items, in any order, so a batch may link to its own items without sorting them first.
Guests
Section titled “Guests”A guest key sees only part of a world. Link ids it cannot see are left out of every body it reads (such a single link reads null), a link it writes to an element out of its view is invalid_link, and its writes keep the links it cannot see. See Guests. The same holds for every key an element is hidden from, and the elements that link to it do not change.