Returning.AIDocs
v1

API reference / Data Workflows

.md

Look up reward events

Check the XP and coins actually awarded for original reward events in a data workflow and see whether each award was reversed.

Last updated 21 Nov 2026API v1

Method
POST
Path
https://api.returning.ai/v1/data-workflows/reward-events/lookup
Permission
dataWorkflows
Retries
Read-only. Retry missing or still-processing receipts with backoff until your reconciliation window ends.

When to use this

  • Reconcile your reward ledger after sending a batch to a workflow that uses reversible rewards.
  • Check whether a cancellation completed for an original reward event.

Authentication#

Header
Authorization: Bearer <API_KEY>
Permission
dataWorkflowsShown in the dashboard as “Data Workflows”.

Use a Community API key with dataWorkflows (Data Workflows). Keep the key on your server.

Request#

Headers#

Authorization#stringREQUIRED
Community API key with dataWorkflows.

RuleBearer <API_KEY>

Content-Type#stringREQUIRED
Request body format.

Ruleapplication/json

Body#

Send only workflow_id and event_keys as JSON. The lookup is scoped to the API key's community and the supplied workflow ID. It reads receipts without awarding or reversing anything.

workflow_id#stringREQUIRED
The ID of the workflow that applies the rewards. Use the ID shown in Workflow Builder or returned by [List workflows](op:GET /v1/workflow-builder/data-workflows). The list requires its own workflowBuilder permission.

Rule24 hex characters

Eg"66f000000000000000000001"

event_keys#string[]REQUIRED
The original reward event keys supplied to that workflow. The limit applies before duplicates are removed.

Rule1 to 100 strings, each 1 to 512 characters after trimming

Eg["trade-1001", "trade-1002"]

curl --request POST \
  --url https://api.returning.ai/v1/data-workflows/reward-events/lookup \
  --header 'Authorization: Bearer <API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "workflow_id": "66f000000000000000000001",
    "event_keys": ["trade-1001", "trade-1002"]
  }'

Response#

A missing receipt has only event_key and found: false. A well-formed workflow ID with no matching receipts also returns 200 with found: false for every key. A found receipt includes all the fields shown in the example. Unavailable values are null, and metadata defaults to {}.

Use actual_rewards on a completed original to reconcile what was awarded. A completed reversal records that the saved award was deducted. The original actual_rewards still shows the award and the lookup shows the cancellation under reversal. Look up the original key to see both. A cancellation key has no receipt of its own.

status#stringALWAYS
success for a completed lookup.

Eg"success"

message#stringALWAYS
Human-readable summary.

Eg"Reward events fetched successfully"

data#objectALWAYS
The workflow and its lookup results.

Eg{ ... }

workflow_id#stringALWAYS
The requested workflow ID, in lowercase.

Rule^[a-fA-F0-9]{24}$

Eg"66f000000000000000000001"

results#object[]ALWAYS
One result per unique trimmed event key, in first-seen request order.

Eg[ ... ]

event_key#stringALWAYS
The original reward event key.

Eg"trade-1001"

found#booleanALWAYS
Whether a receipt exists for this key in the requested workflow and community.

Ruletrue

status#stringALWAYS
processing, completed, or null if unavailable.

Ruleprocessing, completed, null; nullable

Eg"completed"

has_error#booleanALWAYS
Whether the receipt records an error for the original reward.

Egfalse

account_id#stringALWAYS
Account identifier saved with the event, or null.

RuleNullable

Eg"account-88"

trade_id#stringALWAYS
Trade identifier saved with the event, or null.

RuleNullable

Eg"1001"

occurred_at#stringALWAYS
Event timestamp supplied for the original reward, or null.

RuleNullable

Eg"2026-11-20T08:00:00.000Z"

completed_at#stringALWAYS
When the original award completed, or null.

RuleNullable

Eg"2026-11-20T08:05:00.000Z"

requested_rewards#objectALWAYS
Requested amounts. An unavailable amount is null.

Eg{"xp": 100, "coins": 100}

xp#numberALWAYS
Requested XP.

RuleNullable

Eg100

coins#numberALWAYS
Requested coins.

RuleNullable

Eg100

actual_rewards#objectALWAYS
Saved amounts actually awarded, or null when unavailable.

RuleNullable

Eg{ ... }

xp#numberALWAYS
XP awarded, or null.

RuleNullable

Eg100

coins#numberALWAYS
Regular coins awarded, or null.

RuleNullable

Eg80

premium_coins#numberALWAYS
Premium coins awarded, or null.

RuleNullable

Eg0

premium_currency_id#stringALWAYS
ID of the premium currency awarded, or null.

RuleNullable

Egnull

metadata#objectALWAYS
Saved event metadata as string values. An empty object means no metadata was saved.

Eg{"instrument": "EURUSD"}

reversal#objectALWAYS
Cancellation recorded against the original event, or null if none is recorded.

RuleNullable

Eg{ ... }

event_key#stringALWAYS
The cancellation event's key, or null.

RuleNullable

Eg"cancel-trade-1001"

status#stringALWAYS
processing, completed, or null if unavailable.

Ruleprocessing, completed, null; nullable

Eg"completed"

occurred_at#stringALWAYS
Event timestamp supplied for the cancellation, or null.

RuleNullable

Eg"2026-11-20T09:00:00.000Z"

claimed_at#stringALWAYS
When cancellation processing started, or null.

RuleNullable

Eg"2026-11-20T09:04:00.000Z"

completed_at#stringALWAYS
When cancellation completed, or null.

RuleNullable

Eg"2026-11-20T09:05:00.000Z"

has_error#booleanALWAYS
Whether a cancellation error is recorded.

Egfalse

{
  "status": "success",
  "message": "Reward events fetched successfully",
  "data": {
    "workflow_id": "66f000000000000000000001",
    "results": [
      {
        "event_key": "trade-1001",
        "found": true,
        "status": "completed",
        "account_id": "account-88",
        "trade_id": "1001",
        "occurred_at": "2026-11-20T08:00:00.000Z",
        "requested_rewards": {
          "xp": 100,
          "coins": 100
        },
        "actual_rewards": {
          "xp": 100,
          "coins": 80,
          "premium_coins": 0,
          "premium_currency_id": null
        },
        "metadata": {
          "instrument": "EURUSD"
        },
        "has_error": false,
        "completed_at": "2026-11-20T08:05:00.000Z",
        "reversal": {
          "event_key": "cancel-trade-1001",
          "status": "completed",
          "occurred_at": "2026-11-20T09:00:00.000Z",
          "claimed_at": "2026-11-20T09:04:00.000Z",
          "completed_at": "2026-11-20T09:05:00.000Z",
          "has_error": false
        }
      },
      {
        "event_key": "trade-1002",
        "found": false
      }
    ]
  }
}

Errors#

Read meta.code for structured errors and meta.errors for invalid fields. Malformed JSON can return 400 before body validation. If your community opts into API rate limiting, a request over the limit returns 429 with meta.code: RATE_LIMITED and a Retry-After header in seconds.

Fix the request04

400VALIDATION_ERRORFix the request
Check meta.errors and fix the request body before retrying.
401AUTHENTICATION_REQUIREDFix the request
Send a valid community API key in the Authorization header.
403API_KEY_PERMISSION_DENIEDFix the request
Grant the community key Data Workflows permission.
403COMMUNITY_ACCESS_DENIEDFix the request
Use a community API key for the workflow's community.

Fix the data01

404COMMUNITY_NOT_FOUNDFix the data
Check that the API key belongs to an existing community.

Retry with backoff03

429RATE_LIMITEDRetry with backoff
Wait for the time in the Retry-After header before calling again.
500AUTHENTICATION_FAILEDRetry with backoff
Retry the read with backoff.
500INTERNAL_ERRORRetry with backoff
Retry the read with backoff.

Retries

A batch can already show processed while its reward updates are still queued. For found: false or status: processing with has_error: false, retry the lookup later. Apply the same rule to a reversal still processing without an error. Record a deduction only after its reversal is completed. Flag a receipt for manual reconciliation when it reports an error or stays unresolved past your reconciliation window.

{
  "meta": {
    "status": "error",
    "statusCode": 400,
    "errors": [
      {
        "path": "workflow_id",
        "code": "invalid_string",
        "message": "workflow_id must be a 24-character hex ObjectId."
      }
    ],
    "code": "VALIDATION_ERROR"
  },
  "message": "API request rejected error.",
  "detail": "The reward event lookup request is invalid.",
  "solution": "Read error detail and try again."
}

Next step#

Event ingest and batch statusFollow the batch from ingest through the workflow run and bulk update.