Upsert record
PUT /v1/organisations/{organisation_id}/spaces/{space_id}/collections/{name}/records/by-key/{value}
Creates the record with this key value, or changes the given fields of the record that has it, so data imported again updates rather than duplicates (collections-design §5.1).
Authentication
Send an API key, or an access token from your organisation’s identity provider, in the Authorization header. How API keys work
Scope the API key needs: records:write
Security schemes in the OpenAPI document: session_cookie (cookie __Host-ivy_session)bearer (bearer)api_key (bearer)
Parameters
-
organisation_idpathstringrequired -
space_idpathstringrequired -
namepathstringrequired -
valuepathstringrequiredThe value of the collection's
keyfield
Request body
application/json UpsertRecord required
-
fieldsobjectrequiredValues by field key. A new record gets the
defaultof fields left out; an existing one keeps them, andnullclears one.
Responses
-
The record and whether it was
created,updatedorunchanged: an upsert that changes nothing writes nothing and starts no flow;ETag: "r{revision}" -
unauthenticated -
forbidden: the collection'saccess.createdecides who creates andaccess.updatewho changes;workspace_content_restricted,invalid_origin,insufficient_scope -
No such space,
collection_missing, or collections are off -
collection_has_no_key,key_busy,record_changed,collection_full,collection_detached,workspace_archived -
validation_failed, per field infield:key_mismatchwhenfieldsgives another key value,key_immutable, and those of a create or change -
rate_limited: the collection takes 50 writes a second, 200 at once -
internal -
unavailable: the database is briefly unavailable; retry afterRetry-Afterseconds
Error codes
Errors come back as an ErrorBody whose code is one of these.
- 401
unauthenticated - 403
forbiddenworkspace_content_restrictedinvalid_origininsufficient_scope - 404
collection_missing - 409
collection_has_no_keykey_busyrecord_changedcollection_fullcollection_detachedworkspace_archived - 422
validation_failedkey_immutable - 429
rate_limited - 500
internal - 503
unavailable
Examples
curl -X PUT "$IVY_API_URL/v1/organisations/$ORGANISATION_ID/spaces/$SPACE_ID/collections/$NAME/records/by-key/$VALUE" \
-H "Authorization: Bearer $IVY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"fields":{}}' import { client, upsertRecord } from "@spacivapp/ivy-sdk";
client.setConfig({
baseUrl: process.env.IVY_API_URL,
headers: { Authorization: `Bearer ${process.env.IVY_API_KEY}` },
});
const { data, error, response } = await upsertRecord({
path: { organisation_id: organisationId, space_id: spaceId, name, value },
body: {
fields: {}
},
}); {
"fields": {}
} {
"outcome": "created",
"record": {
"collection": "string",
"collection_id": "collection_123",
"created_at": "2026-01-15T09:30:00Z",
"created_by": {
"id": "id_123",
"type": "user"
},
"fields": {},
"id": "id_123",
"origin": {
"ask_id": "ask_123",
"index": 0,
"kind": "ask",
"run_id": "run_123"
},
"problems": [
{
"code": "not_found",
"field": "string"
}
],
"ranks": {},
"revision": 0,
"schema": "string",
"source": {
"provider": "ivy"
},
"sync": {
"conflict": {},
"error": {},
"pending": {},
"remote_updated_at": "2026-01-15T09:30:00Z"
},
"updated_at": "2026-01-15T09:30:00Z",
"updated_by": {
"id": "id_123",
"type": "user"
}
}
}