create

user.document.create

Creates a new document in the caller’s private vault. The data payload is validated against the referenced schema (schemaRef OR embedded documentSchema) before encryption.

Auth

Bearer JWT + unsealed vault.

Input

input DocumentInput {
    name: String!
    schemaRef: String            # either this OR documentSchema — not both
    documentSchema: JSON         # inline JSON Schema (Draft 2020-12)
    description: String
    uniquePerVault: Boolean      # default false; immutable after creation
    data: JSON!
}
Info

schemaRef and documentSchema are mutually exclusive. Provide exactly one. If uniquePerVault: true, the database enforces a single document per vault per schema — creating a second one will fail.

Use schemaRef to target one of the 24 built-in schemas. Use documentSchema to pass an inline JSON Schema (Draft 2020-12) — see Embedded schemas for the supported features, $ref composition, and gotchas (schema is immutable after create).

GraphQL

mutation($input: DocumentInput!) {
  user {
    document {
      create(input: $input) {
        id
        version
        name
        schemaRef
        audit { createdAt }
      }
    }
  }
}

Response

Returns DocumentMetadata (no content echo). The fresh ID is id, version starts at 1.

curl

curl -X POST https://api.test.geena.eu/graphql \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation($i: DocumentInput!) { user { document { create(input: $i) { id version } } } }",
    "variables": {
      "i": {
        "name": "My name",
        "schemaRef": "https://schema.identa.io/core/PersonFullName.json",
        "data": { "firstName": "Alice", "lastName": "Liddell" }
      }
    }
  }'

Errors

Validation errors against the JSON Schema come back as GraphQL errors under the errors array. Consider calling validate first if you want structured field-level feedback without mutating state.