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

Keep a member's tier or role in sync

When a member's tier, plan or membership changes on your side, the community has to reflect it: the field that records the tier, the roles that grant access, and whatever consumes them. A one-time award is not enough, because access has to be removable as well as grantable.
The API builds and checks the workflow that converges the member's state. The authoritative readback happens through the platform's user and role endpoints.

The contract to write first#

PartWhat to record
IdentityThe stable external identifier, and the community field it maps to
Input valuesEvery external value the workflow accepts, and how it is normalised
Canonical fieldThe field that stores the current tier or plan
Role setThe complete set of roles after each value, including roles that must be absent
ConsumerThe channel, category or feature that must change its answer
TimingHow long the change may take, and the point at which it must be exact
Five claims are separate, and each needs its own readback: the request was accepted, the workflow ran, the field changed, the role set is exactly right, and the consumer now answers differently.

1. Create the workflow with the trigger your system uses#

A webhook trigger is the usual shape, because the tier change happens on your side:
Keep the generated key from this response; a later read redacts it.
An event ingest trigger works too when the source already batches: use batchIdPath: "metadata.batch_id" and a record id such as change_id, so a resent change cannot apply twice.

2. Converge, do not accumulate#

The failure to design out is a role that is added on upgrade and never removed on downgrade. Two rules prevent it:
Write the canonical value, do not add to it. A post-user-fields step with logic: overwrite stores exactly the new tier. logic: add on a tier field makes the number meaningless.
Reconcile the whole role set. Grant the new role and remove the incompatible one in the same run, so the member never holds both.
A platform action that writes a field:
tier here is a custom field the community defines, so its key comes from the catalog's post list rather than from a guess. The platform checks the key against the community's real fields and keeps the label you send, here Tier, because that label is the name the step's result uses. Send the catalog's label, or use your own deliberately and reference that label downstream.
Role reconciliation is a bulk update, because roles are a bulk field. Reversible mode is the wrong tool here: a role change is state, not a reward.
The CSV itself, with one row per role to add and one per role to remove, comes from a Code step: type: "code", options.inputs bound to the tier payload, and the source in options.sourceCode.code. Create it with POST /{workflowId}/nodes like any other step. A dry run shows the builder's inputs and source but not its output, so live-test the builder on its own against one transition first, then dry-run the rest around it.

3. Dry-run the transitions you care about#

Run one dry run per transition in the matrix below, and read wouldDo for the field step: the field, the value, and the logic. Nothing is written, so a mistake here costs nothing.

4. The transition matrix#

CaseTransitionWhat it proves
Createno member state, then a tierThe initial field and role state are applied
Upgradelower to higherThe higher access is granted
Downgradehigher to lowerThe higher access is removed, not just hidden
Jumplow to a non-adjacent highThe workflow does not depend on every intermediate step
Revisithigh, low, then high againA previously held state can be applied again
Replaythe same change twiceDelivery retries do not accumulate roles
Edgean unknown tier or a missing identifierThe failure is bounded and does not half-apply
Deploy the workflow with the API and run the matrix against real trigger calls. A Code step does not change that: the workflow deploys like any other, and the transition matrix is what proves the builder is right.

5. Readback that actually proves state#

After each transition, read in this order and stop at the first disagreement:
1.
GET /{workflowId}/runs for the run, then GET /runs/{runId} for each step result.
2.
The member's fields through the platform user endpoints: the canonical tier value.
3.
The member's roles through the platform role endpoints: exact equality with the intended set, not just presence of the expected role.
4.
The consumer that uses the role: a channel, a category, or a feature call.
A workflow run that says success proves step execution. It does not prove the member's roles, and it does not prove the consumer.

6. Failure handling#

What you seeWhat it meansWhat to do
Field updated, role unchangedThe role step was skipped, or wrote the wrong columnRead the run detail for the role step, then the job detail per row.
Upgrade works, downgrade leaves the old roleThe role step only addsReconcile the whole role set, subtract included.
Repeated change adds a second roleNo deduplication on the sender or the triggerConfigure a record id, or make the sender idempotent.
Run success, member unchangedThe step wrote the same value it readCheck the binding and the logic.
User not foundThe identifier did not resolveFix the sender's field, then the selector binding.
A retry re-executes the whole workflow. For a converging workflow that is safe on the field (overwrite) but not on a role addition, so reconcile before retrying.

7. Cleanup#

Undeploy when the sync should stop; the member's last state stays as it is. A test matrix should use synthetic members, and those can be removed through the platform's user endpoints after the run.

What the API does not cover#

Writing the role CSV logic for you. A Code step runs what you wrote; the add/remove set and the row order are your design.
Reading roles and fields. Those are platform endpoints, not workflow ones.
Deciding the tier rules. A rolling window, a retain period or a one-step demotion is a design decision, and a calculation that needs one usually belongs in a Code step.
The consumer's own behaviour: a channel or category answering differently is proven by that surface, not by a workflow run.
Modified at 2026-10-28 04:44:01
Previous
Set up an event-ingest workflow and check batch status
Next
Reversible rewards
Built with