Skip to main content

Relationships

Attach

POST /api/v1/records/:entityId/relationships

# Single target
curl -X POST https://api.rushdb.com/api/v1/records/$MOVIE_ID/relationships \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"targetIds": "$ACTOR_ID", "type": "STARS_IN", "direction": "out"}'

# Multiple targets
curl -X POST https://api.rushdb.com/api/v1/records/$MOVIE_ID/relationships \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"targetIds": ["$ACTOR1_ID", "$ACTOR2_ID"], "type": "STARS_IN"}'
FieldTypeDescription
targetIdsstring | string[]Target record ID(s)
typestringRelationship type
direction"in" | "out"Direction from source to target (out = default)

Detach

PUT /api/v1/records/:entityId/relationships

curl -X PUT https://api.rushdb.com/api/v1/records/$MOVIE_ID/relationships \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"targetIds": "$ACTOR_ID", "typeOrTypes": ["STARS_IN"]}'

List Relationships

GET /api/v1/records/:entityId/relationships

curl "https://api.rushdb.com/api/v1/records/$MOVIE_ID/relationships?limit=50" \
-H "Authorization: Bearer $RUSHDB_API_KEY"

Bulk Create by Key Match

POST /api/v1/relationships/create-many

curl -X POST https://api.rushdb.com/api/v1/relationships/create-many \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {"label": "MOVIE", "key": "id"},
"target": {"label": "ACTOR", "key": "movieId"},
"type": "STARS_IN",
"direction": "out"
}'
FieldTypeDescription
source{label, key?, where?}Source selector
target{label, key?, where?}Target selector
typestringRelationship type
directionstringin or out
manyToManybooleanCartesian product mode — requires non-empty where on both sides

Bulk Delete

POST /api/v1/relationships/delete-many

Same shape as create-many. Omit type to delete any type.

curl -X POST https://api.rushdb.com/api/v1/relationships/delete-many \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {"label": "MOVIE", "key": "id"},
"target": {"label": "ACTOR", "key": "movieId"},
"type": "STARS_IN"
}'
warning

Setting manyToMany: true without where filters on both sides creates an unbounded cartesian product.

Search Relationships

POST /api/v1/relationships/search

curl -X POST https://api.rushdb.com/api/v1/relationships/search \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"where": {"sourceRecord": {"title": "Inception"}}}'

Direction

ValueMeaning
"out" (default)source → target
"in"target → source