Deliver Data Step

Use this to write workflow data back to your organization's data source. Should be used to insert new records, update existing ones, upsert data conditionally, or skip operations based on your workflow logic. The step supports mapping workflow fields to dataset entity properties with type-aware transformations.

Top-level properties

nametyperequiredconstraintsdescription
datasetsarrayyesitems: datasetOne or more dataset operations to perform

Dataset

nametyperequiredconstraintsdescription
datasetIdstringyesIdentifier of the target dataset
selectedSearchDataStepstringnonullable: trueReference to a data search step that provides context
stepDatasetInstanceIdstringnonullable: trueSpecific dataset instance identifier for this workflow step
entitiesarrayyesitems: datasetEntityEntity operations to perform on this dataset

Dataset Entity

nametyperequiredconstraintsdescription
linkIdstringnonullable: trueOptional link to related entity or record
entityIdstringyesIdentifier of the entity type being written
operationstringyesenum: INSERT, UPDATE, UPSERT, SKIPOperation to perform on this entity
mappingsarrayyesitems: mappingField mappings from workflow data to entity properties

Operations

  • INSERT: Create a new record in the dataset
  • UPDATE: Modify an existing record (requires key field match)
  • UPSERT: Insert if new, update if exists (based on key fields)
  • SKIP: No operation; useful for conditional logic branches

Mapping

nametyperequiredconstraintsdescription
fieldIdstringyesnullable: trueDataset field identifier being mapped to
valuestringyesnullable: trueWorkflow field or literal value to write
isKeyFieldbooleanyesWhether this field is part of the entity's primary key
primitiveTypestringyesnullable: truePrimitive data type hint (e.g., string, number, boolean)
complexTypestringyesnullable: trueComplex or custom type hint for advanced transformations

Minimal Example (JSON)

{
  "datasets": [
    {
      "datasetId": "contacts_db",
      "selectedSearchDataStep": null,
      "stepDatasetInstanceId": null,
      "entities": [
        {
          "linkId": null,
          "entityId": "contact",
          "operation": "INSERT",
          "mappings": [
            {
              "fieldId": "email",
              "value": "[email protected]",
              "isKeyField": true,
              "primitiveType": "string",
              "complexType": null
            }
          ]
        }
      ]
    }
  ]
}

Full Example (JSON)

{
  "datasets": [
    {
      "datasetId": "customer_records",
      "selectedSearchDataStep": "search_step_123",
      "stepDatasetInstanceId": "instance_456",
      "entities": [
        {
          "linkId": "link_789",
          "entityId": "customer",
          "operation": "UPSERT",
          "mappings": [
            {
              "fieldId": "customer_id",
              "value": "{{`form`.`customer_id`}}",
              "isKeyField": true,
              "primitiveType": "string",
              "complexType": null
            },
            {
              "fieldId": "full_name",
              "value": "{{`form`.`first_name`}} {{`form`.`last_name`}}",
              "isKeyField": false,
              "primitiveType": "string",
              "complexType": null
            },
            {
              "fieldId": "email",
              "value": "{{`form`.`email`}}",
              "isKeyField": false,
              "primitiveType": "string",
              "complexType": "email"
            },
            {
              "fieldId": "subscription_count",
              "value": "{{`form`.`subscriptions.length`}}",
              "isKeyField": false,
              "primitiveType": "number",
              "complexType": "integer"
            },
            {
              "fieldId": "is_active",
              "value": "true",
              "isKeyField": false,
              "primitiveType": "boolean",
              "complexType": null
            }
          ]
        },
        {
          "linkId": null,
          "entityId": "audit_log",
          "operation": "INSERT",
          "mappings": [
            {
              "fieldId": "timestamp",
              "value": "{{`workflow`.`timestamp`}}",
              "isKeyField": false,
              "primitiveType": "string",
              "complexType": "datetime"
            },
            {
              "fieldId": "action",
              "value": "customer_updated",
              "isKeyField": false,
              "primitiveType": "string",
              "complexType": null
            }
          ]
        }
      ]
    }
  ]
}

TypeScript Example

import { writeOutConfig, type WriteOutConfig } from '@odin/workflows-schema';

const deliverDataStep: WriteOutConfig = {
  datasets: [
    {
      datasetId: 'sales_leads',
      selectedSearchDataStep: null,
      stepDatasetInstanceId: null,
      entities: [
        {
          linkId: null,
          entityId: 'lead',
          operation: 'INSERT',
          mappings: [
            {
              fieldId: 'lead_id',
              value: '`{{`form`.`lead_id`}}',
              isKeyField: true,
              primitiveType: 'string',
              complexType: null,
            },
            {
              fieldId: 'company_name',
              value: '{{`form`.`company`}}',
              isKeyField: false,
              primitiveType: 'string',
              complexType: null,
            },
            {
              fieldId: 'lead_score',
              value: '{{`form`.`score`}}',
              isKeyField: false,
              primitiveType: 'number',
              complexType: 'integer',
            },
          ],
        },
      ],
    },
  ],
};