UmweltDocs
Reference/Commands/commitBatch
commitBatchcommandsince 0.1

Writes several commits in one transaction.

Request
umwelt call story.umw commitBatch '{
  "commits": [
    {
      "projectId": "ball",
      "attemptId": "unmasking",
      "event": {
        "id": "unmasking",
        "type": "scene",
        "title": "The unmasking",
        "position": { "tick": 8 },
        "participants": ["bob", "duchess"],
        "provenance": { "origin": { "kind": "human" } }
      },
      "records": [
        {
          "kind": "holding",
          "id": "duchess-name",
          "position": { "tick": 8 },
          "provenance": { "origin": { "kind": "human" } },
          "holder": "duchess",
          "attitude": "knows",
          "confidence": 1,
          "accessibility": "available",
          "acquisition": { "kind": "witnessed", "eventId": "unmasking" },
          "claim": {
            "subject": "bob",
            "predicate": "umwelt:name",
            "object": { "kind": "value", "value": "Bob" },
            "polarity": true
          }
        }
      ]
    },
    {
      "projectId": "ball",
      "attemptId": "supper",
      "event": {
        "id": "supper",
        "type": "scene",
        "title": "Supper",
        "position": { "tick": 9 },
        "participants": ["ana", "bob", "duchess"],
        "provenance": { "origin": { "kind": "human" } }
      },
      "records": [
        {
          "kind": "awareness",
          "id": "ana-meets-duchess",
          "position": { "tick": 9 },
          "provenance": { "origin": { "kind": "human" } },
          "holder": "ana",
          "target": "duchess"
        }
      ]
    }
  ]
}'
Request
const result = await client.commitBatch({
  commits: [
    {
      projectId: 'ball',
      attemptId: 'unmasking',
      event: {
        id: 'unmasking',
        type: 'scene',
        title: 'The unmasking',
        position: { tick: 8 },
        participants: ['bob', 'duchess'],
        provenance: provenance,
      },
      records: [
        {
          kind: 'holding',
          id: 'duchess-name',
          position: { tick: 8 },
          provenance: provenance,
          holder: 'duchess',
          attitude: 'knows',
          confidence: 1,
          accessibility: 'available',
          acquisition: { kind: 'witnessed', eventId: 'unmasking' },
          claim: {
            subject: 'bob',
            predicate: 'umwelt:name',
            object: { kind: 'value', value: 'Bob' },
            polarity: true,
          },
        },
      ],
    },
    {
      projectId: 'ball',
      attemptId: 'supper',
      event: {
        id: 'supper',
        type: 'scene',
        title: 'Supper',
        position: { tick: 9 },
        participants: ['ana', 'bob', 'duchess'],
        provenance: provenance,
      },
      records: [
        {
          kind: 'awareness',
          id: 'ana-meets-duchess',
          position: { tick: 9 },
          provenance: provenance,
          holder: 'ana',
          target: 'duchess',
        },
      ],
    },
  ],
});
Request
var result = engine.CommitBatch(new CommitBatchPayload
{
    Commits = new()
    {
        new CommitInput
        {
            ProjectId = "ball",
            AttemptId = "unmasking",
            Event = new EventInput
            {
                Id = "unmasking",
                Type = "scene",
                Title = "The unmasking",
                Position = new Position { Tick = 8 },
                Participants = new() { "bob", "duchess" },
                Provenance = provenance,
            },
            Records = new()
            {
                new RecordInput.Holding
                {
                    Id = "duchess-name",
                    Position = new Position { Tick = 8 },
                    Provenance = provenance,
                    Holder = "duchess",
                    Attitude = Attitude.Knows,
                    Confidence = 1.0,
                    Accessibility = Accessibility.Available,
                    Acquisition = new Acquisition.Witnessed { EventId = "unmasking" },
                    Claim = new Claim
                    {
                        Subject = "bob",
                        Predicate = "umwelt:name",
                        Object = new ClaimObject.ValueClaimObject
                        {
                            Value = JsonSerializer.SerializeToElement("Bob"),
                        },
                        Polarity = true,
                    },
                },
            },
        },
        new CommitInput
        {
            ProjectId = "ball",
            AttemptId = "supper",
            Event = new EventInput
            {
                Id = "supper",
                Type = "scene",
                Title = "Supper",
                Position = new Position { Tick = 9 },
                Participants = new() { "ana", "bob", "duchess" },
                Provenance = provenance,
            },
            Records = new()
            {
                new RecordInput.Awareness
                {
                    Id = "ana-meets-duchess",
                    Position = new Position { Tick = 9 },
                    Provenance = provenance,
                    Holder = "ana",
                    Target = "duchess",
                },
            },
        },
    },
});
Response
[
  {
    "eventId": "unmasking",
    "recordIds": ["duchess-name"],
    "transitionIds": [],
    "version": 12,
    "warnings": []
  },
  {
    "eventId": "supper",
    "recordIds": ["ana-meets-duchess"],
    "transitionIds": [],
    "version": 13,
    "warnings": []
  }
]

Payload

FieldTypeDescription
commitsrequiredCommitInput[]The commits, in order. Each is a full commit payload, all on the same timeline.

Result

A list of CommitOutcome, each with:

FieldTypeDescription
eventIdalwaysstringThe event written, with the id given or generated.
recordIdsalwaysstring[]The records written, in order.
transitionIdsalwaysstring[]The transitions written, in order.
versionalwaysintegerThe version this commit received. Reads at an earlier asOfVersion do not see it.
warningsWarning[]UNKNOWN_PREDICATE (open vocabulary) or SECRET_BREACH. Warnings never block a write.

Rules

One transaction. If one commit fails, none is written.

One timeline. Every commit of a batch must target the same timeline.

Errors

VALIDATION_FAILEDA commit is invalid, or the commits target different timelines.
NOT_FOUNDThe project or timeline does not exist.
VERSION_CONFLICTexpectedVersion is no longer the head of the timeline.
CONFLICTThe attemptId was already used with a different request.
INVALID_STATEThe timeline is a draft that was promoted or discarded, and accepts no more writes.
HANDSHAKE_REQUIREDOver the protocol, hello was not sent first.

Every code is listed in Errors.

See also

Was this page helpful?