Skip to main content

Create Records

Create a Record

POST /api/v1/records

curl -X POST https://api.rushdb.com/api/v1/records \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"label": "MOVIE",
"data": {"title": "Inception", "rating": 8.8, "genre": "sci-fi"},
"options": {"suggestTypes": true}
}'

Request body

FieldTypeDescription
labelstringLabel for the new record
dataobjectProperty key-value pairs
optionsobjectSee options table below

Options

OptionDefaultDescription
suggestTypestrueInfer property types automatically
convertNumericValuesToNumbersfalseConvert string numbers to number type
capitalizeLabelsfalseUppercase all inferred label names
relationshipType__RUSHDB__RELATION__DEFAULT__Relationship type for nested links
returnResultfalseReturn the created record in the response
mergeByFields to match on for upsert
mergeStrategyappendappend or rewrite

Upsert (create or update)

Supply mergeBy and/or mergeStrategy in options to trigger upsert behavior.

# Match on 'title'; append/update rating if found
curl -X POST https://api.rushdb.com/api/v1/records \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"label": "MOVIE",
"data": {"title": "Inception", "rating": 9.0},
"options": {"mergeBy": ["title"], "mergeStrategy": "append"}
}'
mergeBy valueMatch behaviour
["field"]Match only on listed fields
[] or omittedMatch on ALL incoming property keys
StrategyBehaviour
append (default)Add/update incoming fields; preserve all other existing fields
rewriteReplace all fields; unmentioned fields are removed

Precise type control (properties array)

curl -X POST https://api.rushdb.com/api/v1/records \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"label": "MOVIE",
"properties": [
{"name": "title", "type": "string", "value": "Inception"},
{"name": "rating", "type": "number", "value": 8.8},
{"name": "genres", "type": "string", "value": "sci-fi,thriller", "valueSeparator": ","},
{"name": "releasedAt", "type": "datetime", "value": "2010-07-16T00:00:00Z"}
]
}'

With a transaction

# 1. Begin a transaction
TX_ID=$(curl -s -X POST https://api.rushdb.com/api/v1/tx \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ttl": 10000}' | jq -r '.data.id')

# 2. Create records using the transaction header
curl -X POST https://api.rushdb.com/api/v1/records \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Transaction-Id: $TX_ID" \
-d '{"label": "MOVIE", "data": {"title": "Inception"}}'

# 3. Commit
curl -X POST https://api.rushdb.com/api/v1/tx/$TX_ID/commit \
-H "Authorization: Bearer $RUSHDB_API_KEY"

See also