> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ana.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Activity

> How to read the activity feed of an account, what each status, wait reason and failure reason means, and what to show to the user.

After you read this page, you can build an activity view: read the rows of an account, show the right text for each status and reason, and keep the view current.

## The feed

`GET /api/wallets/:aa/activity` returns the payment rows of one account on the network of the API host. In the SDK, call `getActivity(aa)`. The SDK aborts the request after `ACTIVITY_REQUEST_TIMEOUT_MS`, 10000 milliseconds.

The route needs no authentication. Anyone who knows an account address can read its feed. A row tells only what the chain will show anyway: no rule text, no payee of a payment that did not land, and nothing about other accounts.

This route is on the Anafi API, so the CORS limit in the [Introduction](https://docs.ana.fi/introduction.md) applies to a browser page.

A row appears when a rule fires and the engine signs a payment. An action that the engine refuses before it signs, for example an amount at or below the fee floor, makes no row.

## The row

| Field | Type | Meaning |
| - | - | - |
| `kind` | `"payment"` or `"off_ramp_fee"` | `payment`: a payment or an exchange of a rule. `off_ramp_fee`: the Anafi fee of one bank payout. |
| `redemptionId` | 32-byte hex | The identity of the row. See [Identity and order](#identity-and-order). |
| `status` | string | Where the payment is. See [Statuses](#statuses). |
| `txHash` | hex or `null` | The transaction hash. `null` before the first send. |
| `createdAt` | integer | The Unix second when the engine signed the payment. |
| `waitReason` | string or `null` | Why an open row waits. `null` when it has no reason to report, and on a final row. |
| `failureReason` | string or `null` | Why a row failed. Set only when `status` is `failed`, else `null`. |
| `fee` | array or `null` | The fee legs of a `landed` row, each with `token`, `tokenAddress` and `amountRaw`. An empty list means no fee. `null` for other statuses. |
| `gasCharge` | object or `null` | The gas charge of the adapter: `tokenAddress`, the zero address for the native coin, and `amountRaw` in base units. The Anafi API leaves the field out when no charge is recorded, and the SDK then returns `null`. |

The SDK returns `gasCharge.amountRaw` as a `bigint`. It sets a malformed `fee` or `gasCharge` to `null` and keeps the row. It throws on an unknown `kind`.

For the meaning of `fee` and `gasCharge`, see [Fees](https://docs.ana.fi/concepts/fees.md).

## Statuses

| `status` | Final | Meaning | What to show |
| - | - | - | - |
| `queued` | No | The engine signed the payment. Anafi has not sent it yet. | "Scheduled." |
| `in_progress` | No | Anafi has the payment. It sent a transaction, or it holds the payment for a reason in `waitReason`. | "In progress", and the text of `waitReason`. |
| `delivered` | No | A transaction of the payment is mined without a revert and has enough confirmations. The final status follows: `landed`, or `failed` if the transfers of the payment failed. | "On chain. The final status follows." Link `txHash`. |
| `landed` | Yes | The adapter executed the payment. | "Paid." Link `txHash`. Show `fee` and `gasCharge`. |
| `failed` | Yes | The payment did not land. `failureReason` says why. | The text of `failureReason`. |
| `withdrawn` | Yes | The engine withdrew the payment: a new document removed the rule, or the account was parked. | "Withdrawn: the rule was removed or the automation stopped." |

The SDK type `OutboxTaskStatus` also has `superseded`. The Anafi API never lists a row with this status, because a newer row carries the same payment.

A row moves only forward: `queued`, then `in_progress`, then `delivered`, then a final status. A row can skip a step. A final status does not change.

## Wait reasons

An open row can carry a `waitReason`. Anafi tries again while the reason holds. If the payment cannot land before its deadline, the row closes as `failed` with `window_expired`.

| `waitReason` | Meaning | What to show |
| - | - | - |
| `insufficient_funds` | The account holds less than the payment sends. | "The payment waits for funds. Top up the account to let the payment go out." |
| `grant_inactive_pending` | The Safe module reads disabled. | "The payment waits: the Anafi module of this Safe is off. Enable it to let the payment go out." |
| `adapter_delisted_pending` | The registry does not list the adapter now. | "The payment waits: the Anafi adapter is not listed on this network now." |
| `simulation_reverted` | The payment cannot execute at the current block. A later block can change this. | "The payment waits: it cannot execute now. Anafi tries again." |
| `swap_below_market` | The swap would pay too far below the market price now. | "The swap waits: its price is too far below the market." |
| `guard_undecided` | Anafi cannot judge the swap price at the current block. | "The swap waits: Anafi cannot check its price now." |
| `fee_above_cap` | The network fee is too high to send the payment now. The payment waits for lower fees. | "The payment waits: network fees are too high now." |
| `in_flight` | A transaction is sent and waits for the chain. | "Sent. The chain has not included it yet." |
| `nonce_already_used` | Another copy of this payment landed. The feed waits for its confirmation. | "Sent. The chain confirms it soon." |
| `deadline_margin` | The payment is too close to its deadline to send. It closes soon. | "Too close to its deadline to send." |
| `account_blocked` | Anafi holds all payments of this account. | "Anafi has paused payments from this account." Tell the user to contact Anafi. |
| `account_redeem_in_flight` | Another payment of this account waits for its first receipt. Payments of an account with no sponsor go out one at a time. | "The payment waits for another payment of this account." |

Treat an unknown `waitReason` as a generic wait: "The payment waits. Anafi tries again."

## Failure reasons

| `failureReason` | Meaning | What to show |
| - | - | - |
| `insufficient_funds` | The account held less of the token, or of the native coin, than the payment sends. | "The account did not hold enough. Nothing was paid. Top it up for the next payment." |
| `grant_inactive` | The Safe does not have the Anafi module enabled. | "The Anafi permission of this account is off. Nothing was paid." |
| `adapter_delisted` | The registry no longer lists the adapter. | "The Anafi adapter of this network is retired. Nothing was paid." |
| `window_expired` | The deadline of the payment passed before it landed. | "It could not go out before its deadline. Nothing was paid." |
| `swap_below_market` | Anafi refused a swap whose output was too far below the market price. | "The swap was held back: the price was too far below the market." |
| `reverted_on_chain` | The transaction reverted on chain, and Anafi stopped. | "The transaction failed on chain. Nothing was paid." |
| `wrong_network` | The payment was signed for another network. | "It was signed for another network. Nothing was paid." |
| `legs_failed_on_chain` | The transaction landed, but the transfers of the payment failed. The adapter undid them. | "The payment failed on chain." If `gasCharge.amountRaw` is above 0, add: "The network fee was charged." |
| `other` | Any other failure. | "It could not go through. Nothing was paid." |

Treat an unknown `failureReason` as `other`.

A failed payment is not sent again. The rule fires again at its next trigger.

## Identity and order

* `redemptionId` is the identity of a row. It is unique for each payment of the account, and it stays the same while the feed keeps the row. Use it as the key of the row in your view.
* `redemptionId` tells nothing about the payment and nothing about other accounts. It is not the redeem digest and not a transaction hash.
* `txHash` can change while a row is open, when Anafi sends a new transaction for the same payment. Do not use it as the key.
* The feed returns rows newest first. The SDK does not sort them again.
* Anafi keeps a final row for a limited time only. Store the rows that you need for a record.

## Keep the view current

* Poll `getActivity` every few seconds while a row is open. Poll less often when all rows are final.
* Send one request at a time. Start the next poll only after the last one settles.
* Treat a failed request as a stale view, and show an error. Do not clear the rows that you already show.
* Merge rows by `redemptionId`, and replace the old row with the new one.
* On `landed`, read the balances of the account again.

```ts theme={null}
import type { ActivityItem, AnafiClient, Hex } from "@anafi-cc/anafi-sdk";

declare const anafi: AnafiClient;
declare const account: Hex;

let inFlight = false;
let rows = new Map<Hex, ActivityItem>();

async function poll(): Promise<void> {
  if (inFlight) return;
  inFlight = true;
  try {
    const items = await anafi.getActivity(account);
    rows = new Map(items.map((item) => [item.redemptionId, item]));
  } catch (error) {
    console.error("activity is stale", error);
  } finally {
    inFlight = false;
  }
}

setInterval(poll, 3000);
```

## Related pages

* [Fees](https://docs.ana.fi/concepts/fees.md)
* [Execution](https://docs.ana.fi/flows/execution.md)
* [Activity and fees in the SDK](https://docs.ana.fi/sdk/activity-and-fees.md)
* [API reference](https://docs.ana.fi/api-reference/introduction.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.