# 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.

- Endpoint: `POST https://api.returning.ai/v1/data-workflows/reward-events/lookup`
- Section: Users and data / Data workflows
- Authentication: `Authorization: Bearer <API_KEY>` (Community API key)
- Permission: `dataWorkflows` (Shown in the dashboard as "Data Workflows".)
- Retries: Read-only. Retry missing or still-processing receipts with backoff until your reconciliation window ends.
- Guide: hand-written
- Verified: live, 2026-11-21
- Last updated: 21 Nov 2026
- Web page: https://docs.returning.ai/api-reference/data-workflows/look-up-reward-events

## 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.

**Instead:** Use [Read event-ingest lifecycle status](https://docs.returning.ai/api-reference/data-workflows/read-event-ingest-lifecycle-status-by-trigger-and-batch-id.md) to check whether the workflow ran a batch.

## Authentication

- Header: `Authorization: Bearer <API_KEY>`
- Permission: `dataWorkflows`

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

## Request

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Authorization` | `string` | Yes | Community API key with `dataWorkflows`. (`Bearer <API_KEY>`) |
| `Content-Type` | `string` | Yes | Request body format. (`application/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.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workflow_id` | `string` | Yes | 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. (24 hex characters) |
| `event_keys` | `string[]` | Yes | The original reward event keys supplied to that workflow. The limit applies before duplicates are removed. (1 to 100 strings, each 1 to 512 characters after trimming) |

### Example request

```bash
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.

### Response fields

| Field | Type | Presence | Description |
| --- | --- | --- | --- |
| `status` | `string` | always | `success` for a completed lookup. |
| `message` | `string` | always | Human-readable summary. |
| `data` | `object` | always | The workflow and its lookup results. |
| `data.workflow_id` | `string` | always | The requested workflow ID, in lowercase. (`^[a-fA-F0-9]{24}$`) |
| `data.results` | `object[]` | always | One result per unique trimmed event key, in first-seen request order. |
| `data.results.event_key` | `string` | always | The original reward event key. |
| `data.results.found` | `boolean` | always | Whether a receipt exists for this key in the requested workflow and community. (`true`) |
| `data.results.status` | `string` | always | `processing`, `completed`, or `null` if unavailable. (`processing`, `completed`, `null`; nullable) |
| `data.results.has_error` | `boolean` | always | Whether the receipt records an error for the original reward. |
| `data.results.account_id` | `string` | always | Account identifier saved with the event, or `null`. (Nullable) |
| `data.results.trade_id` | `string` | always | Trade identifier saved with the event, or `null`. (Nullable) |
| `data.results.occurred_at` | `string` | always | Event timestamp supplied for the original reward, or `null`. (Nullable) |
| `data.results.completed_at` | `string` | always | When the original award completed, or `null`. (Nullable) |
| `data.results.requested_rewards` | `object` | always | Requested amounts. An unavailable amount is `null`. |
| `data.results.requested_rewards.xp` | `number` | always | Requested XP. (Nullable) |
| `data.results.requested_rewards.coins` | `number` | always | Requested coins. (Nullable) |
| `data.results.actual_rewards` | `object` | always | Saved amounts actually awarded, or `null` when unavailable. (Nullable) |
| `data.results.actual_rewards.xp` | `number` | always | XP awarded, or `null`. (Nullable) |
| `data.results.actual_rewards.coins` | `number` | always | Regular coins awarded, or `null`. (Nullable) |
| `data.results.actual_rewards.premium_coins` | `number` | always | Premium coins awarded, or `null`. (Nullable) |
| `data.results.actual_rewards.premium_currency_id` | `string` | always | ID of the premium currency awarded, or `null`. (Nullable) |
| `data.results.metadata` | `object` | always | Saved event metadata as string values. An empty object means no metadata was saved. |
| `data.results.reversal` | `object` | always | Cancellation recorded against the original event, or `null` if none is recorded. (Nullable) |
| `data.results.reversal.event_key` | `string` | always | The cancellation event's key, or `null`. (Nullable) |
| `data.results.reversal.status` | `string` | always | `processing`, `completed`, or `null` if unavailable. (`processing`, `completed`, `null`; nullable) |
| `data.results.reversal.occurred_at` | `string` | always | Event timestamp supplied for the cancellation, or `null`. (Nullable) |
| `data.results.reversal.claimed_at` | `string` | always | When cancellation processing started, or `null`. (Nullable) |
| `data.results.reversal.completed_at` | `string` | always | When cancellation completed, or `null`. (Nullable) |
| `data.results.reversal.has_error` | `boolean` | always | Whether a cancellation error is recorded. |

### Example response (200)

```json
{
  "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 request

| Status | Code | What to do |
| --- | --- | --- |
| 400 | `VALIDATION_ERROR` | Check `meta.errors` and fix the request body before retrying. |
| 401 | `AUTHENTICATION_REQUIRED` | Send a valid community API key in the `Authorization` header. |
| 403 | `API_KEY_PERMISSION_DENIED` | Grant the community key Data Workflows permission. |
| 403 | `COMMUNITY_ACCESS_DENIED` | Use a community API key for the workflow's community. |

### Fix the data

| Status | Code | What to do |
| --- | --- | --- |
| 404 | `COMMUNITY_NOT_FOUND` | Check that the API key belongs to an existing community. |

### Retry with backoff

| Status | Code | What to do |
| --- | --- | --- |
| 429 | `RATE_LIMITED` | Wait for the time in the `Retry-After` header before calling again. |
| 500 | `AUTHENTICATION_FAILED` | Retry the read with backoff. |
| 500 | `INTERNAL_ERROR` | 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.

## Next step

- [Event ingest and batch status](https://docs.returning.ai/workflow-builder/event-ingest-setup-and-batch-status.md): Follow the batch from ingest through the workflow run and bulk update.
