Skip to content

Change Data from your own system

Data can be written to from your own system as well as from the app. Use the Data Management API when a server should keep a set of records in step with another system, when a script should load or correct records, or when an agent is asked to work in Data. Replaying a request must not create a second copy of a record, and a person’s edit must not be overwritten without anyone noticing: the API is built for both.

To read Data in an application, use @ebitex/data-sdk or Ebitex.Data.Delivery with a delivery key instead. Delivery is cached, can be made safe for a browser, and is not counted against a management key’s budget. The management API is for doing the work, and for reconciling and checking it.

In the Data app, open Settings and Management keys, and make a key. Pick one access level, each including the one below:

Level Can
Read Read models, records, a record’s history and folders
Write Everything Read can, and create, update, upsert, delete and restore records
Schema Everything Write can, and create, change and delete models

You can only make a key you could use yourself: a Write key needs the permission to edit and delete records, and a Schema key also the permission to manage models. A key is shown once, when you make it. Only the Data app makes this kind of key; the generic key screen in Hub does not.

The key is for servers and pipelines, never a browser: it has no CORS policy, and a key restricted to origins is refused. You can limit it to the IP addresses your servers call from. It may make 300 requests a minute unless you set another number when you make it (10 to 6,000), counted across all its partitions; a request over the limit answers 429 rate_limited with Retry-After; the body also carries retryAfterSeconds and limitPerMinute.

Send the key as a bearer token to /data/management/v1.

Describe the calling key answers with the organization, the key’s scopes and the partitions it is bound to:

Terminal window
curl https://api.ebitex.io/data/management/v1/whoami \
-H "Authorization: Bearer $EBITEX_DATA_MANAGEMENT_KEY"
{
"organizationId": "…",
"organizationName": "Drakeshead Kennels",
"organizationSlug": "drakeshead",
"keyId": "…",
"keyName": "Registry sync",
"scopes": ["data.management.read", "data.management.write"],
"partitions": [
{ "id": "…", "key": "default", "name": "Default" },
{ "id": "…", "key": "archive", "name": "Archive" }
],
"partitionRequired": true
}

A key is bound to between one and twenty partitions and works in nothing else.

  • With one partition, every request runs in it and you send nothing more.
  • With several, every request except whoami names the partition, by its id in X-Data-Partition or by its key in X-Data-Partition-Key. A request that names none is 400 partition_required, a malformed id is 400 invalid_partition, and a partition that is not one of the key’s is 403 partition_not_allowed. The API never chooses one for you.
Terminal window
curl https://api.ebitex.io/data/management/v1/models \
-H "Authorization: Bearer $EBITEX_DATA_MANAGEMENT_KEY" \
-H "X-Data-Partition-Key: archive"

List models and get a model say what a record may hold, and list the field types say what a field may be. A record’s document is checked against its model exactly as the app checks it, and a refusal names the failing field.

Create or update a record by key is the call a synchronisation uses. Put the other system’s own id in the record’s key, and send the whole document:

Terminal window
curl -X PUT https://api.ebitex.io/data/management/v1/models/dog/records/rex-of-drakeshead \
-H "Authorization: Bearer $EBITEX_DATA_MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Rex of Drakeshead", "document": { "colour": "black" } }'
  • A key that is free creates the record and answers 201.
  • A key that exists in that model updates it and answers 200.
  • A key that exists in another model answers 409 model_mismatch; a key never changes a record’s model.
  • Sending the same thing again changes nothing: no new version and no event.

Every record comes back with a rowVersion. To update, send it back:

{ "name": "Rex of Drakeshead", "document": { "colour": "tan" }, "rowVersion": 7 }

A stale rowVersion means someone saved since you read: the answer is 409 concurrency_conflict and nothing is written. Read the record again and decide. An update with no rowVersion is 428 row_version_required. A key that really is the source of truth for a record can send "overwrite": true instead, which skips the check; the change is marked as an overwrite in the organization’s activity log.

To create a record without a key of your own, use Create a record. A document may be up to 256 KiB, and a record’s folder is root or a folder’s id.

List records pages through the partition (pageSize up to 100) and filters by model, search, folderId, keys, updatedSince and updatedBy. Use it to reconcile what is there with your own system, not to serve traffic.

A record’s history is kept. List its versions, get one, compare two and restore one. A restore writes the old content back as a new version, checked against the model as it is now, so a model that has changed since may refuse it and say why.

Delete a record removes it for good, and is refused with 409 record_in_use while another record or a Content page refers to it.

A Schema key creates, changes and deletes models. Before you save, ask what a change would do with Check a model change without saving it: it validates the whole model, says how the change is classified and the version it would make, and counts the existing records it would leave invalid. It writes nothing.

Change a model takes a whole new definition and the rowVersion of your last read. A change that would leave records invalid answers 409 model_impact with the review and saves nothing: a person finishes it in the Data app. Deleting a model that anything uses answers 409 model_in_use.

These are decisions for a person in the app, and the API refuses them whatever the key’s level:

  • Creating or deleting partitions, changing who may see a folder, making or revoking keys, and importing a file are not offered at all.
  • A key cannot make a model or a field more public. A model a key creates is private, and a request that asks for a public model or field is 409 exposure_change_denied. Narrowing, or leaving things as they are, is allowed.
  • A key cannot remove the values of a field from records: a model update that asks to strip is 400 strip_not_available.

A key sees only the folders that are open to everyone. A folder restricted to named roles, and the records in it, answer as if they did not exist.

A write is held to the same rules as a person’s: the same validation, folder rules and plan limits (403 quota_exceeded when the organization has reached its record or model limit), the same version history and the same webhook events (data.record.created, data.record.updated and data.record.deleted). The organization’s activity log records the key as the actor with the partition and level it used, and a record’s history shows the key’s name as who made the change.

Status error Meaning
400 partition_required, invalid_partition The key has several partitions and the request named none, or named something that is not an id
400 validation_failed, model_is_abstract, strip_not_available, invalid_sort The body or query is not valid; the message says how
401 missing_api_key, invalid_api_key No key, or an unknown, revoked, expired or origin-restricted one
402 payment_required The organization’s subscription needs attention
403 scope_denied, app_not_available, ip_denied, partition_not_allowed, quota_exceeded The key’s level, the app, the address it was used from, the partition or the plan does not allow this
404 not_found No such route, model, record or version, or it is in a folder the key cannot see
409 concurrency_conflict, model_mismatch, record_key_taken, model_taken, model_impact, model_in_use, record_in_use, exposure_change_denied The request conflicts with what is stored
413 document_too_large The document is over 256 KiB
428 row_version_required An update did not say which version it read
429 rate_limited, too_many_failed_authentications The key spent its budget for this minute, or too many requests with a wrong key came from your address
503 data_unconfigured Data is not available on this server

The @ebitex/mcp server has a Data module that drives this API with a management key in EBITEX_DATA_MANAGEMENT_KEY. When the key has several partitions, every tool call has to name one, and every result says which partition it ran in. See @ebitex/mcp.