Write record batch legacy
POST /v1/organisations/{organisation_id}/workspaces/{workspace_id}/collections/{name}/records/batch Deprecated
Upserts, creates or deletes up to 500 records, each its own write, paced by the collection's write rate (collections-design §5.2).
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 -
workspace_idpathstringrequired -
namepathstringrequired
Request body
application/json RecordBatch required
-
createCreateRecord[]|null -
deleteBatchDelete[]|null -
on_item_errorItemErrors -
syncBatchSync|null -
upsertBatchUpsert[]|nullCreates each record whose key is new and changes the given fields of the others; needs the collection's
key.
Responses
-
Each item's outcome in order; an item that failed doesn't undo the others, and
sync.delete_missingdeletes nothing then -
unauthenticated -
forbidden:sync.delete_missingneeds the collection'saccess.delete;workspace_content_restricted,invalid_origin,insufficient_scope -
No such space,
collection_missing, or collections are off -
collection_has_no_keyforupsert,collection_detached -
validation_failed: one ofupsert,createanddelete, with at most 500 items -
rate_limited: the API key's requests per minute are used up; retry afterRetry-Afterseconds -
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_keycollection_detached - 422
validation_failedcreate - 429
rate_limited - 500
internal - 503
unavailable
Examples
curl -X POST "$IVY_API_URL/v1/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/collections/$NAME/records/batch" \
-H "Authorization: Bearer $IVY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}' import { client, writeRecordBatchLegacy } 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 writeRecordBatchLegacy({
path: { organisation_id: organisationId, workspace_id: workspaceId, name },
body: {},
}); {
"create": [
{
"fields": {},
"place": {
"column": "string",
"view": "string"
}
}
],
"delete": [
{
"id": "id_123",
"key": {}
}
],
"on_item_error": "continue",
"sync": {
"delete_missing": false
},
"upsert": [
{
"fields": {},
"key": {}
}
]
} {
"created": 0,
"deleted": 0,
"deleted_missing": 0,
"failed": 0,
"items": [
{
"error": {
"code": "not_found",
"field": "string",
"message": "A short explanation for people",
"reason": "string"
},
"index": 0,
"key": "string",
"outcome": "created",
"record_id": "record_123"
}
],
"unchanged": 0,
"updated": 0
}