OpenForm
MCPTools

fill

Last updated on

Fill an OpenForm form or checklist with data, apply defaults, and validate

Validates data against an OpenForm artifact before rendering. Pass the full artifact JSON and a data object. Call get_artifact first to inspect field and party definitions. Use this to catch errors before calling render.

Only forms and checklists support filling. Passing a document or bundle will return an error.

Parameters

ParameterTypeRequiredDescription
artifactobjectYesThe OpenForm artifact (form or checklist) definition
dataobjectYesData to fill. Fields go under "fields" key: { fields: { fieldId: value } }. Parties go under their party ID: { partyId: { id, name, ... } }.

Response

FieldTypeDescription
validbooleanWhether the data passed validation
artifactKindstringDetected kind: form or checklist
dataobjectThe validated data with defaults applied (on success)
errorsarrayList of validation errors, each with field and message
errorstringError message if filling could not be performed

Examples

Successful fill

// Request
{
  "artifact": { "kind": "form", "..." : "..." },
  "data": { "fields": { "firstName": "Jane", "age": 30 } }
}

// Response
{
  "valid": true,
  "artifactKind": "form",
  "data": { "firstName": "Jane", "age": 30 }
}

The data field in the response contains the validated data with any default values applied by the artifact definition.

Failed validation

// Request
{
  "artifact": { "kind": "form", "..." : "..." },
  "data": { "fields": { "firstName": "Jane", "age": "thirty" } }
}

// Response
{
  "valid": false,
  "artifactKind": "form",
  "errors": [
    { "field": "age", "message": "Expected number, received string" }
  ]
}

Each error includes the field name and a message describing the validation failure.

On this page