1. Workflow Builder
Returning.AI
  • Getting Started
  • Users
    • User directory and provisioning
    • Get Users with Filters
    • Create New User
    • Get User Data
    • Manage User Account
    • Get User Milestones
    • Update User Data, Identifier, And Roles
    • Update User XP and Currency
  • Messaging
    • Agent messaging workflow
    • Get Messages
    • Send Message
    • Reply Message
    • React Message
    • Upload message images
  • Gamification
    • Leaderboards
      • Leaderboards
      • List leaderboards with pagination
      • Create a new leaderboard
      • Update an existing leaderboard
      • Get a single leaderboard by ID
      • Delete a leaderboard
    • Streaks & Mini Games
      • Mini-game State and History
      • List user streak logs
      • List mini-game logs by user email
      • Get current mini-game and streak state
      • Update user spin-wheel information
    • Referral
      • Referral Program Integration
      • Get referral programs
      • Get user's referral summary
    • Rolling Data
    • Match Predictions
      • Create match prediction
      • List match predictions
      • Get match prediction
      • Patch match prediction
      • Publish match prediction
      • Settle match prediction
      • Get settlement results
      • Void match prediction
      • Bulk update match predictions
      • Get bulk job status
      • Get bulk job results
    • Loyalty Points
      • Create loyalty points export
      • Get loyalty points export status
      • Get loyalty points export download link
    • Get tier configuration
    • Get daily user XP and coin changes
    • Search user gamification logs
    • Get user activity stats
  • Rewards & Redemptions
    • Store catalog to redemptions
    • List redemption orders by custom-field identifier
    • Update redemption order status or refund
    • Create redemption order status
    • List redemption orders by user email
    • List redemption statuses
    • Get redemption status by ID
    • List redemption orders by community
    • Get redemption order status history
  • Chart Analysis
    • Create Analysis
    • Get Analysis
    • Update Analysis
    • Delete Analysis
    • List Analyses
    • Append Drawings
  • Bulk Operations
    • Bulk user updates
    • List bulk update jobs
    • Get bulk update job status
    • Get bulk update job details
    • Bulk update users from CSV
    • Bulk update premium currency from CSV
  • Channels
    • Iframe
    • List integration channels
  • Events
    • Outgoing webhooks
      • Encryption
      • User Joins Server
      • User Visits server
      • New Message Posted Anywhere
      • New Message Posted To channel
      • Purchased Store Item
    • Incoming webhooks
      • API Keys & Encryption
      • Send message into channels
      • Update Custom User Fields
      • Update In-game currency
  • Widgets
    • Authenticated Widgets
    • Public widgets
    • Channels
    • Leaderboard
    • Milestone
    • Socials
    • Store
  • Store
    • Store catalog
    • Purchase History
      • Archive or restore an order
      • Update redemption instructions or voucher details
    • Categories
      • List Store categories
      • Create Store category
      • Get Store category by ID
      • Update Store category
      • Delete Store category
    • Products
      • List products
      • Update products in bulk
      • Create products in bulk
      • Create product with vouchers
      • Read product
      • Update product and append vouchers
      • Delete product
    • Redemption-transaction
      • Get redemption transaction detail
    • Get Store configuration
    • Update Store configuration
  • Community Analytics
    • Get Loyalty Overview
    • Get Phone Verification Contacts
  • Community
    • Community directory and appearance
    • Appearance
      • Update community theme colors
      • Update community bot profile
      • Update community URL metadata
      • Update community name and URL
    • Community Users
      • Get community users
      • Get user
    • Create community
  • API Keys
    • API key lifecycle
    • Community API Keys
      • Create API key
      • Read API keys
      • Delete API key
      • Update API key
    • User API Keys
      • List user API keys
      • Create user API key
      • Update user API key
      • Delete user API key
      • Get current API key information
  • User Fields
    • User field definitions and history
    • User Field History
      • Get all user field histories in a community
      • Get user field histories for a specific field
      • Get user field histories for a specific user
      • Get user field histories of specific user field and user
      • Update A User Field Value
      • Deprecated Field-First History Write
      • Deprecated Field-First History Read
    • Get A User Field Definition
    • Update A User Field Definition
    • Create A User Field Definition
    • Delete A User Field Definition
    • List User Field Definitions
  • Legacy
    • Servers
      • Create server
      • List servers
      • Update server metadata
    • Bulk Operations
      • Bulk import users from CSV
    • Authentication
      • Secure Auth
      • Register user with password
      • Verify user email
      • Log in user with password
    • Badges
      • List badges
      • Create badge
      • Update badge
      • Delete badge
      • Remove badge from user
      • Award badge to user
    • Messaging
    • Roles & Permissions
      • List server roles
      • Create role
      • Update role
      • Delete role
      • List user roles
      • Add role to user
      • Remove role from user
    • Users
      • Get user
      • Upload user avatar
    • Channels
      • Create channel
      • Update channel
      • Delete channel
    • API Keys
      • List integration API keys
      • Create integration API key
      • Delete integration API key
      • Update integration API key
  • Data Workflows
    • Read event-ingest lifecycle status by trigger and batch ID.
  • Community Logs
    • Retrieve and export community logs
  • Workflow Builder
    • Workflow Builder API overview
    • Connect an AI agent to the Workflow Builder tools
    • Bind step inputs to trigger and earlier-step outputs
    • Code steps through the API
    • Edit safely: revisions, conflicts, export, import and copying a workflow
    • Set up an event-ingest workflow and check batch status
    • Keep a member's tier or role in sync
    • Reversible rewards
    • Test without side effects, then confirm a live run
    • Build a trading-rewards workflow from event ingest
    • Reward members from your own system with a webhook workflow
    • List step types and trigger types
      GET
    • List workflows
      GET
    • Create a workflow
      POST
    • Get a workflow
      GET
    • Rename a workflow or set its failure webhook
      PATCH
    • Delete a workflow
      DELETE
    • Duplicate a workflow
      POST
    • Export a workflow definition
      GET
    • Validate a stored workflow
      POST
    • Create or replace the trigger
      PUT
    • Add a step
      POST
    • Get a step
      GET
    • Update a step
      PATCH
    • Delete a step
      DELETE
    • Reorder a main-line step
      POST
    • Duplicate a step
      POST
    • Add a router branch
      POST
    • Update a router branch
      PATCH
    • Delete a router branch
      DELETE
    • Duplicate a router branch
      POST
    • Test one step
      POST
    • Test a whole workflow
      POST
    • Deploy a workflow
      POST
    • Undeploy a workflow
      POST
    • List the runs of a workflow
      GET
    • Get one run
      GET
    • Retry a failed run
      POST
    • Call the workflow tools over MCP
      POST
  • Schemas
    • Sample Schemas
    • Schemas
    • Outgoing webhooks
    • Analysis
    • Pet
    • Category
    • Tag
    • ValidationError
    • NotFoundError
    • InternalServerError
    • NotImplementedError
    • CreateUserFieldHistoryResponse
    • CreateUserFieldHistorySuccessResponse
    • UserFieldHistoryItem
    • GetUserFieldHistoriesResponse
    • UserFieldHistoriesValidationError
    • UserFieldHistoriesMetaWithValidation
    • UserFieldHistoriesMetaWithPagination
    • GetUserFieldHistoriesSuccessResponse
    • CreateUserFieldResponse
    • CreateUserFieldSuccessResponse
    • DeleteUserFieldResponse
    • DeleteUserFieldSuccessResponse
    • UserFieldCreator
    • GetUserFieldResponse
    • GetUserFieldSuccessResponse
    • ValidationErrorItem
    • GetUserFieldsMetaResponse
    • CreatorInfo
    • UserFieldResponse
    • GetUserFieldsSuccessResponse
    • UpdateUserFieldResponse
    • UpdateUserFieldPayload
    • UpdateUserFieldSuccessResponse
    • MetaResponse
    • GetUserResponse
    • GetUserSuccessResponse
    • Purchased store item
    • ErrorResponse
    • New message posted to channel
    • UpdateAnalysisRequest
    • User visits server
    • AppendDrawingsRequest
    • User join server
    • CreateAnalysisResponse
    • GetAnalysisResponse
    • UpdateAnalysisResponse
    • AppendDrawingsResponse
    • AnalysisMetadata
    • Expiry
    • Levels
    • LevelEntry
    • Drawing
    • HorizontalLineDrawing
    • LineDrawing
    • RectangleDrawing
    • ParallelDrawing
    • FibonacciRetracementDrawing
    • Coordinate
    • DrawingStyle
    • AnalysisDetail
    • AnalysisSummary
    • CreateAnalysisRequest
    • ListAnalysesResponse
    • StandardApiError
    • StandardSuccessEnvelope
    • PurchasedStoreItemEvent
    • ChannelMessagePostedEvent
    • UserVisitedCommunityEvent
    • UserJoinedCommunityEvent
  1. Workflow Builder

Add a step

POST
/v1/workflow-builder/data-workflows/{workflowId}/nodes
POST /{workflowId}/nodes needs workflowBuilder.

What this endpoint does#

Adds one step to a workflow: at a position on the main line, or inside a router branch. The step's options are validated against its type before anything is stored, and the position is resolved by the server.
A branch step is registered with its branch in the same call. The response carries the stored step and the workflow's new revision.

Quick start#

Authentication and permission#

Authorization: Bearer <API_KEY> with workflowBuilder, on a workflow of the key's community. If-Match is optional. Send the revision you read to avoid overwriting a concurrent change (a stale value is refused with 409 VERSION_CONFLICT); omit it and your write wins as the last one. A deployed workflow is edited with the same call: the change applies immediately.
FailureMeaningRecovery
400 VALIDATION_FAILEDThe options do not match the step type, or position names a step that is not on the main lineRead the type's schema from GET /catalog, or read the workflow for current step ids.
404 BRANCH_NOT_FOUNDposition.branchIndex is out of range for that routerRead the router and use an existing branch index.

Complete examples#

Append an HTTP step after an existing step:
A router with one condition branch and one fallback. Conditions use AND groups: OR and WHERE groups are stored and deployed, and the runtime then treats the group as always true, so validation warns ROUTER_OPERATOR_UNSAFE:
A step inside the router's first branch. The branch index is the position in branches, and the step is also added to the workflow's step order automatically:
{
  "data": {
    "node": {
      "_id": "65f1a2b3c4d5e6f708192a3c",
      "name": "Read member XP",
      "type": "platform-action",
      "order": 1,
      "continueOnFailure": false,
      "retryOnFailure": false,
      "options": {
        "action": "get-user-fields",
        "selectUser": { "type": "email", "value": ["{{65f1a2b3c4d5e6f708192a41.email}}"] },
        "fields": [{ "label": "Total XP", "field": "total_xp" }]
      }
    },
    "revision": "68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501",
    "redactedPaths": []
  }
}

Success and readback#

HTTP 201 with { node, revision, redactedPaths }, and the new revision in the ETag header. node._id is the id every later step or reference uses.
Read back with GET /{workflowId}: the step must appear at the intended place, with the branch membership you asked for, and the options must match what you sent after normalisation. For an HTTP step with a JSON or raw body, the stored body is a single template element containing the JSON text, which is the shape the canvas shows.

Errors and recovery#

Status and codeWhenRecovery
400 VALIDATION_FAILEDOptions do not match the type, a required field is missing, or position.after is not on the main lineFix the named field.
400 NODE_NOT_IN_WORKFLOWA router's branch list names a step that is not part of this workflowReference only steps this workflow owns.
400 LEADERBOARD_NOT_IN_COMMUNITYA leaderboard step names another community's leaderboardUse a leaderboard of the key's community.
400 REDACTED_VALUE_WITHOUT_STORED_SECRETA marker arrived on a new step, where nothing can be stored yetSend the real credential.
401 AUTHENTICATION_REQUIREDNo key, or an unknown keySend a valid key.
403 API_KEY_PERMISSION_DENIEDNo workflowBuilderGrant the permission.
404 WORKFLOW_NOT_FOUNDUnknown workflow id, or another community's workflowUse an id from this community.
404 BRANCH_NOT_FOUNDposition.branchIndex does not exist on that routerRead the router and use a valid index.
409 VERSION_CONFLICTYou sent an If-Match that is not the current revision. meta.currentRevision carries the live valueRe-read and resend against the new revision.
415 UNSUPPORTED_MEDIA_TYPEThe body was not declared application/jsonSend the header.
429 RATE_LIMITEDThe community's API rate limit was reachedWait for the window to reset, then retry.
500 INTERNAL_ERRORUnexpected failureRe-read the workflow before retrying.
503 LOCK_UNAVAILABLEThe write lock store did not answer, so nothing was writtenRetry shortly.

Retry safety#

Adding a step is not idempotent: two accepted calls create two steps. A retry after a timeout can leave a duplicate, so read the workflow and check for the step before resending. A retry with the revision from before the first attempt is refused with 409 VERSION_CONFLICT, which is the safe outcome.

Gotchas#

position.after: "trigger" inserts before the current first step. Omitting position appends to the end of the main line.
A branch step is created on the main line first and then registered with its branch, so a step that is in a branch still appears in the workflow's id list.
options must be the complete payload for the type. A partial options object is not merged with anything: there is nothing stored yet.
A platform-action field key must be a real field of the community. A read action accepts total_xp, total_coins, xp and coin; a write action accepts xp and coin; a custom field uses its own key. GET /catalog lists them. A key outside the list is stored as sent, and POST /{workflowId}/validate reports UNKNOWN_USER_FIELD as a warning, so read the list instead of guessing: a step that reads nothing fails at run time, not at write time.
A label you send is stored exactly as sent. Only a missing or empty label is filled from the catalog, for example Total XP for a read of total_xp and XP for a write to xp, so send the catalog's label unless you need a specific one.
A read step's result is keyed by that label, so a later step references {{<readStepId>.Total XP}}, not the field key. Validation reports REFERENCE_UNKNOWN_FIELD when a reference names a label the step does not produce.
An HTTP step's auth must be present. Use {"type":"bearer-token","token":[]} for "no auth"; an empty value is not treated as a secret.
A credential-named header or parameter is redacted on read even when you authored it as a template. See redactedPaths in the response.
A Code step is a normal step type here: type: "code" with options.inputs and options.sourceCode.code. It can be created, changed, duplicated, imported and tested like any other step; sideEffects: true because its source can write.
A leaderboard step reads that leaderboard's own community, so it may only name a leaderboard of the key's community.
continueOnFailure and retryOnFailure default to false. Set them explicitly when the workflow must continue past a failure.
Send logic explicitly on every write step's field (add, subtract, overwrite). The stored default is overwrite, which can zero a balance, and nothing refuses the write: POST /{workflowId}/validate reports POST_LOGIC_REQUIRED as a warning.
A step id should appear once across a router's branch lists: a second listing makes a run execute the step twice. Nothing refuses the write; POST /{workflowId}/validate reports NODE_LISTED_TWICE as a warning.
retryOnFailure is for a step that can fail and be repeated safely: one HTTP call, one email, one bulk update, or a write of one field. POST /{workflowId}/validate warns with RETRY_REPEATS_SIDE_EFFECTS on a router whose branches contain a step that pays or calls outside, and on a write step that sets more than one field, because a retry would repeat several side effects at once. Nothing refuses the write.

Next steps#

PATCH /{workflowId}/nodes/{nodeId} to change the step you just added.
POST /{workflowId}/nodes/{nodeId}/test with mode: "dry-run" to check this one step without side effects.
POST /{workflowId}/validate once the workflow is complete.

Request

Path Params

Header Params

Body Params application/jsonRequired

Examples

Responses

🟢201201 Success
application/json
The stored step with the workflow's new revision.
Bodyapplication/json

🟠400400 VALIDATION_FAILED / NODE_NOT_IN_WORKFLOW / REDACTED_VALUE_WITHOUT_STORED_SECRET / LEADERBOARD_NOT_IN_COMMUNITY
🟠401401 AUTHENTICATION_REQUIRED / API_KEY_REQUIRED
🟠403403 API_KEY_PERMISSION_DENIED
🟠404404 WORKFLOW_NOT_FOUND
🟠409409 VERSION_CONFLICT / WORKFLOW_LOCKED
🟠413413 VALIDATION_FAILED
🟠415415 UNSUPPORTED_MEDIA_TYPE
🟠429429 RATE_LIMITED
🔴500500 INTERNAL_ERROR
🔴503503 LOCK_UNAVAILABLE
Request Request Example
Shell
JavaScript
Java
Swift
cURL
curl --location 'https://api.returning.ai/v1/workflow-builder/data-workflows/65f1a2b3c4d5e6f708192a3b/nodes' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'If-Match: 162af81f5de4ff2b557a4087de9a9a73a0ed4e621f737787e35a93614cb50d1c' \
--header 'Content-Type: application/json' \
--data '{
  "type": "platform-action",
  "name": "Read member XP",
  "position": {
    "after": "trigger"
  },
  "options": {
    "action": "get-user-fields",
    "selectUser": {
      "type": "email",
      "value": [
        "{{65f1a2b3c4d5e6f708192a41.email}}"
      ]
    },
    "fields": [
      {
        "label": "Total XP",
        "field": "total_xp"
      }
    ]
  }
}'
Response Response Example
201 - 201 Success
{
  "data": {
    "node": {
      "_id": "65f1a2b3c4d5e6f708192a3c",
      "name": "Read member XP",
      "type": "platform-action",
      "order": 1,
      "continueOnFailure": false,
      "retryOnFailure": false,
      "options": {
        "action": "get-user-fields",
        "selectUser": {
          "type": "email",
          "value": [
            "{{65f1a2b3c4d5e6f708192a41.email}}"
          ]
        },
        "fields": [
          {
            "label": "Total XP",
            "field": "total_xp"
          }
        ]
      }
    },
    "revision": "68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501",
    "redactedPaths": []
  }
}
Modified at 2026-10-28 04:46:59
Previous
Create or replace the trigger
Next
Get a step
Built with