Serenities AI™
Back to API Overview

Linked Records API

Create links between records in different tables and manage relationships.

6 endpoints

Endpoints

POST
/api/v1/linkedRecords/createLinkField

Create a link field to connect two tables. Params: tableId (source table), name (field name), linkedTableId (target table), linkType ("one_to_one", "one_to_many", "many_to_many"), linkDisplayMode ("COUNT", "LABELS", "CHIPS"), allowMultipleLinks (boolean), createReciprocal (default true, creates reverse link in target table).

Parameters

tableIdstringrequired

Source table ID from listTables

namestringrequired

Name for the link field

descriptionstring

Optional description

linkedTableIdstringrequired

Target table ID to link to

linkTypestringrequired

Relationship type: "one_to_one", "one_to_many", or "many_to_many"

linkDisplayModestring

Display mode: "COUNT", "LABELS", or "CHIPS"

allowMultipleLinksboolean

Allow linking to multiple records

linkOnDeletestring

What happens to linking rows when a linked record is deleted: RESTRICT blocks the delete while links exist; CASCADE deletes the linking rows too (chains, capped at 500 rows per delete); SET_NULL (default) / NO_ACTION just remove the connection

linkOnUpdatestring

Action on update

createReciprocalboolean

Create reciprocal field in target table

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/linkedRecords/createLinkField \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tableId": "example",
  "name": "example",
  "description": "example"
}'
POST
/api/v1/linkedRecords/linkRecords

Link records together. Params: tableId (source), recordId (source row ID), fieldId (link field ID), linkedRecordIds (array of target row IDs, at most 1,000 a call), preserveOrder.

Parameters

tableIdstringrequired

Source table ID

recordIdstringrequired

Source row ID to link from

fieldIdstringrequired

Link field ID

linkedRecordIdsarrayrequired

Array of target row IDs to link to (at most 1,000)

preserveOrderboolean

Preserve order of linked records

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/linkedRecords/linkRecords \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tableId": "example",
  "recordId": "example",
  "fieldId": "example"
}'
POST
/api/v1/linkedRecords/unlinkRecords

Remove links. Params: tableId, recordId, fieldId, linkedRecordIds (array of IDs to unlink, at most 1,000 a call). Act only on what the person named or picked.

Parameters

tableIdstringrequired

Source table ID

recordIdstringrequired

Source row ID

fieldIdstringrequired

Link field ID

linkedRecordIdsarrayrequired

Array of target row IDs to unlink (at most 1,000)

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/linkedRecords/unlinkRecords \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tableId": "example",
  "recordId": "example",
  "fieldId": "example"
}'
POST
/api/v1/linkedRecords/getLinkedRecords

Get linked records for a row. Params: tableId, recordId, fieldId, limit (a whole number from 1 to 200, default 50; at most 200), offset (a whole number from 0 to 100,000, at most 100,000), sortBy (field to sort by), sortDirection ("asc"|"desc"). Always returns the summarized shape { id, primaryFieldValue, metadata } per linked record — the "expand" flag is currently accepted but ignored (no full-record payload), so fetch the target rows directly if you need all fields.

Parameters

tableIdstringrequired

Source table ID

recordIdstringrequired

Source row ID

fieldIdstringrequired

Link field ID

expandboolean

Include full record data

limitinteger

Max records to return: a whole number from 1 to 200 (default 50; at most 200)

offsetinteger

Skip records for pagination: a whole number from 0 to 100,000 (at most 100,000)

sortBystring

Field to sort by

sortDirectionstring

Sort direction

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/linkedRecords/getLinkedRecords \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tableId": "example",
  "recordId": "example",
  "fieldId": "example"
}'
POST
/api/v1/linkedRecords/bulkLinkRecords

Bulk link operations. Params: tableId, fieldId, operations (array of {sourceRecordId, targetRecordIds, operation: "link"|"unlink"|"replace"}): at most 100 operations a call, each with at most 1,000 targetRecordIds, and at most 1,000 targetRecordIds in total across all the operations of one call (link, replace and unlink alike): split a bigger change into several calls.

Parameters

tableIdstringrequired

Source table ID

fieldIdstringrequired

Link field ID

operationsarrayrequired

Array of link operations to perform (at most 100; at most 1,000 target IDs in total across all operations)

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/linkedRecords/bulkLinkRecords \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tableId": "example",
  "fieldId": "example",
  "operations": {}
}'
POST
/api/v1/linkedRecords/reorderLinkedRecords

Change link order. Params: tableId, recordId, fieldId, orderedRecordIds (array in desired order, at most 1,000).

Parameters

tableIdstringrequired

Source table ID

recordIdstringrequired

Source row ID

fieldIdstringrequired

Link field ID

orderedRecordIdsarrayrequired

Target row IDs in desired order (at most 1,000)

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/linkedRecords/reorderLinkedRecords \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tableId": "example",
  "recordId": "example",
  "fieldId": "example"
}'