Skip to content

Create and change instances

What a valid payload looks like

Instances are sent as JSON-LD:

{
  "@type": "https://example.org/types/Person",
  "https://example.org/properties/name": "Ada Lovelace",
  "https://example.org/properties/affiliation": { "@id": "https://example.org/org/analytical-society" }
}
Rule Example of what is rejected with 400
Creating or fully replacing needs an @type a payload with no @type
@type is an IRI "@type": "helloWorld", "@type": {"@id": "http://Test"}
Property names are full IRIs, or resolvable with an @context "foo:bar": "test" without a context
An @id is an http(s) IRI or a UUID "@id": "not-an-id"
A link holds nothing but its @id {"@id": "http://x", "http://other": "y"}
An embedded object has an @type a nested object with neither @id nor @type
Internal properties can't be set by you a key in the internal namespace

@context is supported and expanded on the way in:

{
  "@context": { "@vocab": "http://schema.org/" },
  "@type": "http://Test",
  "name": "test"
}

To see how Core would normalize a document without storing it, post it to POST /v4/jsonld/normalizedPayload.

Create

POST /v4/instances?space=neuroscience
POST /v4/instances/{uuid}?space=neuroscience

An @id in the payload isn't used as the instance's ID. It is added to the instance's identifiers instead.

If the UUID or one of the identifiers already belongs to an instance, you get a 409 that names it. These options make imports repeatable:

Parameter Effect
updateIfExists=true Replaces your contribution on the existing instance instead of failing - this only requires write permission on the existing instance
skipIfUnchanged=true Does nothing if your contribution would stay the same
validate=false Skips validation for this write

Writing to a space that doesn't exist yet creates it, if you have the permission to manage that space.

Update

Request Effect on your contribution @type needed
PUT /v4/instances/{id} It is replaced by the payload Yes
PATCH /v4/instances/{id} The properties in the payload are overwritten; others stay No

A PUT doesn't erase what others wrote

Updates apply to your own contribution. If a colleague has set a property and you PUT a payload without it, the colleague's value stays on the instance. See Contribution.

Both accept skipIfUnchanged and validate, and return the updated instance. They also accept the response options.

Remove an identifier

An update never removes an identifier the instance already has, even if your payload has another @id or http://schema.org/identifier. To get rid of one, remove it explicitly:

DELETE /v4/instances/{id}/identifiers?identifier=https://example.org/old-id

The identifier is removed from all contributions, so it doesn't come back, and the updated instance is returned. The released version keeps the identifier until you release the instance again; a released instance becomes HAS_CHANGED.

Response Reason
400 The identifier is the instance's UUID, plain or with the instance namespace
404 The instance doesn't have the identifier
409 A relation of any instance points to the identifier, in progress or released. Remove the link first

Retract your contribution

DELETE /v4/instances/{id}/contribution

Empties your contribution to the instance: it is put together again from the contributions of the others ("deleted": false in the response). Only the @type of your contribution is kept, so the instance keeps its type. The instance no longer counts as one you have contributed to (e.g. for withContribution=true) until you contribute again. If nobody else contributes to it, the instance is deleted ("deleted": true) - the same as a DELETE, so a released instance needs ?forceUnrelease=true. A released instance which is kept becomes HAS_CHANGED. The identifiers you contributed stay with the instance - remove them explicitly.

Response Reason
404 You haven't contributed to the instance (or have already retracted)
409 The instance would be deleted, but it is released and forceUnrelease isn't set

Move to another space

PUT /v4/instances/{id}/spaces/{targetSpace}

You need WRITE in both spaces. A released instance can't be moved (409): unrelease it first.

Delete

DELETE /v4/instances/{id}

A released instance is protected and the request is rejected with 409. To unrelease and delete in one step, add ?forceUnrelease=true, which needs the RELEASE permission as well as DELETE.

Deleting also removes the instance's comments, favorites, validation results and pending invitations.

Batches

To create, update, delete, release or unrelease many instances, send them in one batch (/v4 only). The server processes the items in chunks, each of them within one transaction and set-based - which is much faster than one request per instance.

POST /v4/batch/instances?space=myspace
[
  { "payload": { "@id": "https://example.org/people/ada", "@type": "https://example.org/types/Person", "https://example.org/properties/name": "Ada Lovelace" } },
  { "id": "1b9c7a8e-6f1e-4d6c-9a43-6a1f0a3e7f11", "space": "otherspace", "payload": { "@type": "https://example.org/types/Person", "https://example.org/properties/name": "Charles Babbage" } }
]

Every item is treated like POST /instances/{id}?updateIfExists=true: if its id or one of the identifiers of its payload points to an existing instance, that instance is updated (like a PUT, or a PATCH with partial=true). Otherwise, a new instance is created in the space of the item - or the space of the batch - with the given id or a new UUID. With updateIfExists=false, items pointing to existing instances fail with 409. skipIfUnchanged and validate work as for single instances.

POST /v4/batch/instances/delete (with forceUnrelease), POST /v4/batch/instances/retract (with forceUnrelease), POST /v4/batch/instances/release and POST /v4/batch/instances/unrelease take a list of UUIDs.

The response is the batch job with the outcome per item, in the order of the request:

{
  "data": {
    "id": "8d0e...", "operation": "UPSERT", "status": "COMPLETED", "atomic": false,
    "total": 2, "processed": 2, "succeeded": 1, "failed": 1,
    "items": [
      { "index": 0, "id": "4f7a...", "status": "CREATED" },
      { "index": 1, "id": "1b9c...", "status": "FAILED", "error": { "code": 409, "message": "..." } }
    ]
  }
}
Item status Meaning
CREATED, UPDATED, UNCHANGED The instance was created, changed or found unchanged
DELETED, RELEASED, UNRELEASED The operation succeeded
RETRACTED Your contribution was removed, the instance is kept for the contributions of others
FAILED The item failed - error holds the code and message the single endpoint would have answered with
ROLLED_BACK The item would have succeeded, but the atomic batch was rolled back
NOT_PROCESSED The job was interrupted (e.g. by a restart of the server) before the item was processed - submit it again
  • Failures are per item. A failing item doesn't affect the others. With atomic=true, the whole batch is processed in a single transaction and rolled back if a single item fails.
  • Permissions are checked up front. If you aren't allowed to apply a single item, the whole batch is rejected with 401 and nothing is written.
  • One item per instance. Items of the same batch must not point to the same instance, nor share an identifier - all but the first fail with 409.
  • Large batches run in the background. With async=true, the response is 202 with the queued job. Poll GET /v4/batch/jobs/{id} until its status is COMPLETED (all items processed - check their outcome) or FAILED (the job couldn't be processed to its end, e.g. because of a restart of the server). Add returnItems=false while polling.
  • Interrupted jobs can be resumed. The outcome is stored together with every processed chunk, so a job interrupted by a restart states exactly which items have been processed. Submit the NOT_PROCESSED items again - the SDKs do that for you. GET /v4/batch/jobs lists your jobs. Only you can see your jobs; they are removed after 7 days.
  • A batch has at most 10000 items.

The Python and Java SDKs submit batches in the background and wait for them by default - and resubmit what an interrupted job hasn't processed. They also offer a sync: upsert a list of instances and retract your contributions to all other instances of the type.

Required permissions

Action Functionality
Create CREATE in the space
Update WRITE in the space
Remove an identifier WRITE in the space
Retract your contribution WRITE in the space, plus DELETE if the instance is deleted
Move WRITE in the current and target space
Delete DELETE in the space, plus RELEASE with forceUnrelease

What each role grants