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

Reward members from your own system with a webhook workflow

A webhook trigger lets your own system award XP, coins or a numerical user field when something happens on your side: a deposit, a course completion, a support action. The API builds the workflow that receives those calls, and the same API proves what the workflow did.
The one step the API cannot take is deciding what "the same event twice" means in your system. That stays with the sender.

What you end up with#

1.
A draft workflow with a webhook trigger and its generated key.
2.
A read step that resolves the member from the event.
3.
A branch and a write step that awards the reward once per event.
4.
A live workflow, one real run, and the member's field read back.

1. Read the catalog#

Check nodeTypes for platform-action and http, and triggerTypes for webhook. Note the URL of each type's schema; every option below comes from it.
Take every field key from the catalog rather than guessing one: GET /catalog returns platformActionFields.get and platformActionFields.post, each entry carrying the key the step stores, the label the platform stores beside it, and whether the field is builtin or custom. A key outside those lists is stored as sent and POST /{workflowId}/validate reports UNKNOWN_USER_FIELD as a warning, but the step reads or writes nothing, so take the key from the catalog.

2. Decide the event contract first#

Write it down before building anything: the event name, the field that identifies the member, the field that identifies the event (for deduplication), and the reward amount.
Keep the reward amount in the workflow, not in the sender's payload. A sender that can choose the amount can choose to send a million.

3. Create the workflow with its trigger#

A webhook trigger key is generated by the platform. Ask for it with apiKey.enabled: true and no value, and keep the key from this response: no later read shows it again.
Readback: 201, status: draft, trigger.type: webhook, a revision, and trigger.options.apiKey.value present. That value is your sender's credential. Store it somewhere secret and do not paste it into a document.
tokenExchangeEnabled is the other supported mode: the sender first exchanges the workflow key for a short session and sends that instead. Choose one mode and tell the sender which. The sender's side, the key exchange, sending the event and reading back the result, is covered in Workflow webhooks.
Cleanup: if you abandon this workflow, delete it (step 9) so an unused key does not stay valid.

4. Add the read step#

Resolve the member from the event payload. The trigger's id is trigger._id from the create response, and the payload field is read from the trigger's root. The read keys total_xp and total_coins below come from the catalog's get list:
Readback: 201 with the step, its _id and the new revision. That _id is what later steps reference.

5. Add a branch and the reward step#

A router with one condition branch and one fallback. Conditions use AND: an OR or WHERE group is stored and deployed, and the runtime then treats it as always true, so validation reports ROUTER_OPERATOR_UNSAFE.
Then the award, inside branch 0 of that router (65f1a2b3c4d5e6f708192a3e):
logic: add is what makes the reward cumulative. overwrite replaces the value with the amount, which is almost never what a reward means. The write key xp comes from the catalog's post list; a custom field would appear there with its own key and label.
Readback: GET /{workflowId} shows three steps and the write step nested under the first branch.

6. Validate, then dry-run#

A dry run proves the reward without paying anyone:
Readback: a trace where the read step is executed, the write step is simulated with wouldDo naming the member, the field xp, the amount 100 and the logic add, and sideEffects: "none".
Stop and fix when the trace shows a literal mapping instead of a resolved member, or when the branch taken is not the one you expected. A simulated step's wouldDo.users list is the member the platform resolved, so an empty list means the identifier did not resolve.

7. Deploy and fire one real event#

Then send one event from your own system, with a fresh event id. Read the run back:
Read GET /runs/{runId} for that run, then read the member's field through the platform API. The run result and the member's value together are what settle it; a 200 from the trigger call alone shows only that the call was accepted.

8. Failure handling#

What you seeWhat it meansWhat to do
401 from the webhook callWrong key, or the trigger was replaced after the sender was configuredRead the trigger: a stored key is never shown again, and a PUT cannot replace it. Set the trigger to another type and back to mint a new key, then update the sender.
Deploy went through with warnings you did not readValidation is advisory, so no validation finding refuses a deploy; the response's warnings list what a run may mishandleFix the named steps, then validate again and compare the two reports.
Run error with User not foundThe identifier the event carried does not resolve to a memberCheck the sender's field, then the read step's binding.
Run success, member value unchangedThe write step was skipped, or the amount was zeroRead the run detail and check the branch that ran.
Two awards for one eventThe sender sent the event twice and the workflow has no duplicate guardFix deduplication at the sender, then reconcile the extra award through your own reversal process.
A retry of a failed run is a real execution: POST /runs/{runId}/retry runs the whole workflow again and can pay twice. It needs no confirmation, so read the member's value before retrying, and send an Idempotency-Key so a lost response replays instead of queueing a second run.

9. Cleanup#

A delete also works on a deployed workflow, in one call, with its trigger, steps and run history, and it cannot be undone. Undeploy first if you want runs to stop before the workflow goes. Deleting removes the trigger and its key, but stop the sender as well: it keeps retrying until it is told not to.

What the API does not cover#

Sender-side deduplication. The workflow cannot see that an event is a repeat unless the sender says so or the event carries a stable id the workflow branches on.
Choosing the reward amount from the event. Keep it in the workflow.
A hard guarantee that two runs never overlap for the same member. Ordering is the sender's cadence.
Modified at 2026-10-28 04:44:47
Previous
Build a trading-rewards workflow from event ingest
Next
List step types and trigger types
Built with