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

# API Reference

> Core Sweepr partner API routes for V2 builds, V2 confirmation, status checks, and V1 fallback.

# API Reference

Base URL:

```txt theme={"dark"}
https://dev-api.sweepr.co/sweepr
```

Authentication:

```txt theme={"dark"}
x-api-key: <partner_api_key>
```

## GET /v2/status

Returns V2 availability, supported chains, configured build mode, indexer settings, router allowlists, and V5 contract addresses.

This endpoint is public and does not require an API key.

Responses use the standard Sweepr envelope. Read the status payload from `data`:

```json theme={"dark"}
{
  "ok": true,
  "data": {
    "version": "v2",
    "evmBuildMode": "v5_partner_fees",
    "chains": []
  }
}
```

## POST /v2/sweep/build

Builds an EVM V2 sweep transaction. The partner is resolved from `x-api-key`; partner identity, payout wallet, and fee share are never accepted from the request body.

Request:

```json theme={"dark"}
{
  "chain": "base",
  "wallet": "0xUserWallet",
  "tokens": [
    {
      "mint": "0xTokenAddress",
      "amount": "1000000000000000000",
      "symbol": "TOKEN",
      "decimals": 18
    }
  ],
  "outputMint": "0xOutputToken",
  "slippageBps": 100
}
```

Response includes:

* `sweepId`
* `chain`
* `mode`
* `contractVersion`
* `contractAddress`
* `permit2` typed data
* `transaction` placeholder
* `transactionTemplate`
* `feeAuthorization`
* `feeMode`
* estimated output and fee summary

The user must sign the returned Permit2 typed data, then send the finalized V5 transaction.

## POST /v2/sweep/status/:id/confirm

Confirms a submitted V2 sweep by reading the transaction receipt and decoding `SweepExecutedV5`.

Request:

```json theme={"dark"}
{
  "txHash": "0x..."
}
```

The endpoint updates the sweep transactions and partner fee ledger using the actual on-chain event values.

Confirm behavior:

* If the transaction receipt is not indexed yet, Sweepr returns `pending`.
* If the same transaction was already confirmed, Sweepr returns the completed result again.
* If the sweep was already confirmed with a different transaction hash, Sweepr rejects the request.
* If the sweep is expired or void, Sweepr rejects the request.
* Sweepr only accepts a V5 event that matches the stored fee authorization for that sweep.

Sweepr validates the event against:

* user address
* partner id
* partner recipient
* output token
* token count

Status and confirm requests are partner-scoped. A partner API key can only access sweeps owned by that partner.

## GET /v2/sweep/status/:id

Returns sweep status, transaction status, and fee ledger details.

Common statuses:

| Status      | Meaning                                                                    |
| ----------- | -------------------------------------------------------------------------- |
| `pending`   | Sweep is built or submitted, but not completed yet.                        |
| `completed` | V5 event matched the original fee authorization and the ledger is updated. |
| `expired`   | Fee authorization expired before transaction submission.                   |
| `failed`    | Submitted transaction reverted or could not be accepted.                   |

The fee authorization block may include:

* `checkAttempts`
* `lastCheckedAt`
* `nextCheckAt`
* `lastError`
* expected fee amounts
* actual fee amounts after confirmation

## V1 Routes

V1 remains available for Solana and off-chain partner accounting:

```txt theme={"dark"}
GET  /v1/status
POST /v1/sweep/discover
POST /v1/sweep/build
GET  /v1/sweep/status/:id
GET  /v1/sweep/history
GET  /v1/sweep/output-tokens
```
