Project Data Import
The project data import API creates a new project's data graph from a knora-api (v2 external schema) JSON-LD payload. The server transforms the payload into the internal knora-base representation, validates it, and streams it into the triplestore.
The data import handles instance data only — the resources and their values. The project and at least one of its ontologies must already exist on the instance. The project's data graph must contain no data other than list nodes (create-only): a graph holding only list nodes is permitted, because list-using projects carry their list nodes there.
Endpoints
For request/response schemas, error codes, and interactive testing, see the OpenAPI documentation.
| Route | Method | Description |
|---|---|---|
/v3/projects/{projectIri}/data-imports |
POST |
Upload JSON-LD and trigger async import |
/v3/projects/{projectIri}/data-imports/{importId} |
GET |
Poll import status |
/v3/projects/{projectIri}/data-imports/{importId} |
DELETE |
Delete a completed/failed import |
Authentication and Authorization
Triggering an import requires a valid Bearer JWT token and SystemAdmin permissions. Requests from
non-SystemAdmin callers (e.g. project admins) are rejected with 403 Forbidden.
Imported data is attributed to the onBehalfOfUser, not the triggering admin. That user is validated synchronously,
before any 202/write:
- An unknown email or username is rejected
404 Not Found(on_behalf_of_user_not_found). - A user that is a system admin, not a member or admin of the project, inactive, or without project-wide create
rights is rejected
400 Bad Request(on_behalf_of_user_ineligible), with areasonin the error details (is_system_admin,not_project_member,inactive,cannot_create). - A value that parses as neither an email nor a username is rejected
400(reason: malformed_identifier).
Feature Flag
The endpoints are gated behind the
allow-project-data-import feature flag,
which is disabled by default. When disabled, the endpoints return 404 Not Found.
Request Format
The request requires an onBehalfOfUser query parameter — the project user (a user email or username) every
imported resource and value is attributed to. It must be an active member or admin of the target project and not
a system admin (see Authentication and Authorization).
The request body is the project's data graph as JSON-LD in the knora-api v2 external (complex) schema, with content
type application/ld+json. The payload contains resources and their values, optionally with an explicit
hasPermissions per resource or value. It contains no admin data or ontologies.
Server-managed resource and value metadata is synthesised during the import and need not be supplied in the payload
(hasPermissions is the exception — see below):
attachedToProjectis derived from the{projectIri}path parameter.attachedToUseris theonBehalfOfUser, not the authenticated (triggering) admin.hasPermissionsis honored when a resource or value carries it in the payload, validated and reformatted to match the single-resource create path. Otherwise it is resolved per entity from the project's default object access permissions (DOAPs) as they apply to theonBehalfOfUser— including resource-class and property DOAPs, with group precedence (a project member resolves the ProjectMember-group DOAP).- Creation dates are set to the time of the import.
The onBehalfOfUser is resolved once at trigger time. Its eligibility, and the group memberships that determine the
resolved DOAPs, are a snapshot: mid-flight changes to that user (deactivation, role change, removal) are not
reconsidered. The parameter is
per-request, so a retry after a delete may supply a different user. The import status response reports the
on-behalf-of user (the onBehalfOf field) alongside createdBy (the triggering admin), so attribution is auditable
without reading a resource.
@graph declarations in the payload are ignored: all data is written exclusively into the project's data named
graph, which is derived from the project.
Size limit
The raw request body is limited to 250 MiB. The client should send the Content-Length header. A declared length
above the limit is rejected with 413 Payload Too Large and error code payload_too_large before the body is read:
{
"message": "The payload of 262144001 bytes exceeds the limit of 262144000 bytes.",
"errors": [
{
"code": "payload_too_large",
"message": "The payload of 262144001 bytes exceeds the limit of 262144000 bytes.",
"details": {
"size": "262144001",
"max": "262144000"
}
}
]
}
The server closes the connection after a non-2xx response to a request that declares more than 1 MiB
(Connection: close), including this 413, because the unread body is still on the wire. A client must open a new
connection for its next request, and may see the connection reset while it is still sending the body.
Without a Content-Length header, only the server's 1 MiB cap applies: a chunked body above 1 MiB is rejected by the
server with a bare 413 that carries no v3 error body.
A body that is longer than its declared length and exceeds the limit is accepted with 202. The task then fails with
the message "The payload exceeds the limit of 250 MiB."
Key Behaviors
The import is asynchronous. Triggering an import returns 202 Accepted with a task ID.
Poll the status endpoint until status is completed or failed.
The status field is one of: in_progress, completed, failed.
The import is create-only: if the project's data graph already holds data other than list nodes, the request is
rejected with 409 Conflict and error code data_graph_exists. A graph containing only list nodes is permitted —
list-using projects carry their list nodes in the data graph. The precondition is checked synchronously when the
import is triggered and re-verified immediately before the upload. Updating or extending an existing data graph is not
possible with this API.
The project must have at least one ontology. A project with no ontologies is rejected synchronously with
409 Conflict and error code project_ontologies_missing. This check runs before the create-only check: a
project with no ontologies is rejected whatever its data graph holds, so the list-node exception is not reached.
Only one data-graph import can exist at a time. Attempting to create a second returns 409 Conflict with the
existing task's id in the error details. Delete the previous task before triggering a new one.
Only one import runs at a time on this server, whether it is a bulk import or a migration import. While one runs,
a new import of either kind is rejected with 409 Conflict and error code import_running:
{
"message": "Another import runs on this server. Try again later.",
"errors": [
{
"code": "import_running",
"message": "Another import runs on this server. Try again later.",
"details": {}
}
]
}
The slot check runs before the import_exists check: a second import of the same kind while the first one runs gets
import_running, not import_exists. The request validation checks of the endpoint (400, 404,
project_ontologies_missing and data_graph_exists) still run before the slot check. The slot covers the running
import, not the task's lifetime. A failed task that waits for its DELETE does not block the other kind of import, but
still blocks its own kind with import_exists.
The upload to Fuseki is atomic — if the upload fails, no partial data is written to the triplestore.
Import Validation
Before anything is written to the triplestore, the transformed data is SHACL-validated against the knora-base data shapes. The project's ontologies are fetched from the triplestore to support the validation. Validation failure fails the task with a descriptive error message and leaves the triplestore untouched.
The data import applies an extra bulk-import shape: every imported resource and value must be attachedToUser the
onBehalfOfUser. This shape is specific to the data import and does not run for the project-migration import.
The data import also validates against shapes generated from the project ontologies. It rejects:
- a resource class that is not a class of the project ontologies or one of
Region,LinkObj,VideoSegmentandAudioSegment - a resource with fewer values of a property than its minimum cardinality, or with more than its maximum cardinality
- a resource with a property that has no cardinality on its class
- a value of the wrong type for its property
- a link to a resource of the wrong class
- a list value whose node does not exist, is a root node, or is not in the list of the property
Shared ontologies are not supported. Resources of shared classes, and of project classes that subclass shared classes, fail validation.
The presence of at least one project ontology is checked synchronously at trigger time
(409 project_ontologies_missing, see Key Behaviors). The task also re-checks it as a backstop
before validation.
Typical Workflow
# Upload and trigger import (onBehalfOfUser is a project user email or username)
curl -s --request POST \
--url 'https://server/v3/projects/http%3A%2F%2Frdfh.ch%2Fprojects%2F0001/data-imports?onBehalfOfUser=project.member' \
--header 'Authorization: Bearer <jwt>' \
--header 'Content-Type: application/ld+json' \
--data-binary @project-data.jsonld
# Response: {"id": "<importId>", "status": "in_progress", ...}
# Poll status until completed
curl -s --request GET \
--url 'https://server/v3/projects/http%3A%2F%2Frdfh.ch%2Fprojects%2F0001/data-imports/<importId>' \
--header 'Authorization: Bearer <jwt>'
# Response: {"status": "completed", ...}
# Cleanup
curl --request DELETE \
--url 'https://server/v3/projects/http%3A%2F%2Frdfh.ch%2Fprojects%2F0001/data-imports/<importId>' \
--header 'Authorization: Bearer <jwt>'
Limitations
- Project and ontologies must already exist: The import assumes class and property IRIs in the payload resolve against ontologies already in the triplestore.
- Create-only: The data graph must contain no data other than list nodes. Re-importing requires deleting the project's data graph first, which is out of scope for this API.
- Assets must be pre-ingested: The import does not ingest binary assets. File values must reference assets already
present in ingest. The import fetches their metadata by internal filename and rejects an asset that is not yet
ingested. 3D file values (
DDDFileValue) are not yet supported. - JSON-LD only: Other RDF serializations are not accepted.
- Single instance: Task state is held in memory per instance.