Docs menu

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_id path string required
  • workspace_id path string required
  • name path string required

Request body

application/json RecordBatch required

Responses

  • 200 application/json RecordBatchResult

    Each item's outcome in order; an item that failed doesn't undo the others, and sync.delete_missing deletes nothing then

  • 401 application/json ErrorBody

    unauthenticated

  • 403 application/json ErrorBody

    forbidden: sync.delete_missing needs the collection's access.delete; workspace_content_restricted, invalid_origin, insufficient_scope

  • 404 application/json ErrorBody

    No such space, collection_missing, or collections are off

  • 409 application/json ErrorBody

    collection_has_no_key for upsert, collection_detached

  • 422 application/json ErrorBody

    validation_failed: one of upsert, create and delete, with at most 500 items

  • 429 application/json ErrorBody

    rate_limited: the API key's requests per minute are used up; retry after Retry-After seconds

  • 500 application/json ErrorBody

    internal

  • 503 application/json ErrorBody

    unavailable: the database is briefly unavailable; retry after Retry-After seconds

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
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 '{}'
JavaScript SDK
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: {},
});
Example request body
{
  "create": [
    {
      "fields": {},
      "place": {
        "column": "string",
        "view": "string"
      }
    }
  ],
  "delete": [
    {
      "id": "id_123",
      "key": {}
    }
  ],
  "on_item_error": "continue",
  "sync": {
    "delete_missing": false
  },
  "upsert": [
    {
      "fields": {},
      "key": {}
    }
  ]
}
Example response (200)
{
  "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
}