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

# Test ramp in the sandbox

> Test pBRL onramp, offramp, refunds, and failure outcomes on Base Sepolia with the Pods sandbox

Build and test your ramp integration before going live. The Pods ramp sandbox uses the same quote and status endpoints as production—`GET /v2/swap/quote` and `GET /v2/swap/status/{id}`—against a real testnet ERC-20 on Base Sepolia (`pBRL`), so you can verify how your application handles quotes, on-chain settlements, refunds, and payout failures without a live Pix transfer.

## Supported sandbox corridors

| | Onramp (`BRL` → `pBRL`) | Offramp (`pBRL` → `BRL`) |
| - | - | - |
| **Choose this when** | Testing fiat Pix deposits that mint crypto to a user wallet. | Testing crypto redemptions that pay out BRL via Pix. |
| **Your backend sends** | `originChain=fiat`, `destinationChain=base-sepolia`, `tokenIn=BRL`, `tokenOut=<pBRL>`, `amountIn` (BRL cents), and `destinationAddress`. | `originChain=base-sepolia`, `destinationChain=fiat`, `tokenIn=<pBRL>`, `tokenOut=BRL`, `amountIn` (pBRL wei), `originAddress`, and `pixKey`. |
| **In production** | The user pays the returned Pix BR Code (`paymentInstructions.pix.copyPaste`), and Pods settles crypto to `destinationAddress`. | Your application signs and submits `transactionData` from `originAddress`, and Pods sends the Pix payout to `pixKey`. |
| **In the sandbox** | Pods returns a mock BR Code. Calling `/v2/swap/status/sandbox/confirmed` mints real `pBRL` on Base Sepolia when `kycUserId` matches, or records an on-chain refund when it differs. | Calling `/v2/swap/status/sandbox/confirmed` burns the wallet’s `pBRL` on Base Sepolia, or `/v2/swap/status/sandbox/confirmed-to-failed` simulates a failed Pix payout without burning tokens. |

Both corridors use `GET /v2/swap/status/{id}` to track the quote’s progress.

> **What you can test**
>
> Test your backend quote requests, BR Code rendering, status polling, on-chain balance updates on Base Sepolia (`84532`), payer-mismatch refunds, and offramp payout failures. Pix rails and recipient lookups are simulated in staging; `pBRL` (`0x9762f60740142cF11C0F32C6e24cd3e86016C0f2`) is a testnet token with no claim on real BRL. Sandbox transition routes are not registered in production.

## Before you start

You’ll need:

* **Your staging Pods API URL and customer API key**, provided by Pods.
* **An approved [sandbox KYC](https://docs.pods.finance/guides/kyc/sandbox.md) profile** (`status: "approved"`, `brlaEnabled: true`) whose `walletAddress` matches the ramp wallet. Save its `kycUserId`.
* **Node.js 20 or later** to run the examples using built-in `fetch`.

| Item | Sandbox value |
| - | - |
| **Staging API base URL** | Provided by Pods (`PODS_API_BASE_URL`). Sandbox routes return `404` in production. |
| **Authentication** | Header `x-api-key: <your-staging-api-key>` sent from your backend. |
| **Network** | Base Sepolia (`base-sepolia`, chain ID `84532`). |
| **`pBRL` token address** | `0x9762f60740142cF11C0F32C6e24cd3e86016C0f2` (`18` decimals). |
| **Exchange rate** | Fixed `1:1` (`1 BRL = 1 pBRL`) with zero fees. |
| **Amount limits** | `1` to `100000` BRL cents (`R$0.01` to `R$1,000.00`), or `10000000000000000` to `1000000000000000000000` `pBRL` base units (`0.01` to `1000 pBRL` in whole cents). |

### Set up the Node.js client

Run these examples on your backend. Configure `PODS_API_BASE_URL` and `PODS_API_KEY` in your environment with the staging values provided by Pods.

Save this helper as `pods-client.mjs`:

```js theme={null}
const baseUrl = process.env.PODS_API_BASE_URL?.replace(/\/+$/, "");
const apiKey = process.env.PODS_API_KEY;

if (!baseUrl || !apiKey) {
  throw new Error(
    "Set PODS_API_BASE_URL and PODS_API_KEY to your staging credentials."
  );
}

export const PBRL_TOKEN_ADDRESS =
  "0x9762f60740142cF11C0F32C6e24cd3e86016C0f2";

export async function podsRequest(path, { method = "GET", body } = {}) {
  const response = await fetch(`${baseUrl}${path}`, {
    method,
    headers: {
      "x-api-key": apiKey,
      ...(body !== undefined
        ? { "content-type": "application/json" }
        : {}),
    },
    ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
  });

  const data = await response.json();

  if (!response.ok) {
    const error = new Error(
      data.error?.message ?? `Pods request failed (${response.status})`
    );

    error.status = response.status;
    error.code = data.error?.code;
    error.details = data.error?.details;

    throw error;
  }

  return data;
}

export function getSwapQuote(params) {
  const query = new URLSearchParams(params);
  return podsRequest(`/v2/swap/quote?${query}`);
}

export function getSwapStatus(quoteId) {
  return podsRequest(`/v2/swap/status/${encodeURIComponent(quoteId)}`);
}

export function confirmSandboxQuote(quoteId, { kycUserId } = {}) {
  return podsRequest("/v2/swap/status/sandbox/confirmed", {
    method: "POST",
    body: {
      quoteId,
      ...(kycUserId !== undefined ? { kycUserId } : {}),
    },
  });
}

export function failSandboxOffRamp(quoteId, failureCode) {
  return podsRequest("/v2/swap/status/sandbox/confirmed-to-failed", {
    method: "POST",
    body: {
      quoteId,
      ...(failureCode !== undefined ? { failureCode } : {}),
    },
  });
}
```

The examples below use ES modules and top-level `await`. Save them as `.mjs` files alongside the helper.

## Ramp status reference

These are the quote statuses used by the sandbox ramp flows:

| Status | Meaning | What your application should do |
| - | - | - |
| `pending` | The quote was created and is awaiting payment confirmation. | On onramp, display `paymentInstructions.pix.copyPaste`. In the sandbox, trigger a confirmation or failure transition when ready. |
| `processing` | An on-chain Base Sepolia settlement (`onramp` or `offramp`) is in flight. | Show a processing state and continue polling `GET /v2/swap/status/{id}`. |
| `fulfilled` | The on-chain `pBRL` mint (onramp) or burn (offramp) succeeded. | Show completion and link or record `destinationTxHash`. |
| `refunded` | The onramp `kycUserId` was missing, `null`, or did not match the quote’s KYC profile. | Show that the payment was refunded using `failure` (`code: "THIRD_PARTY_PAYER"` and `message`). No `pBRL` was minted. |
| `failed` | The offramp payout was rejected (simulated via `confirmed-to-failed`), or an on-chain settlement reverted. | Show the failure using `failure` (`code` and `message`) or `failureReason`. |
| `expired` | The 15-minute quote deadline elapsed before confirmation. | Request a fresh quote before retrying. |

## Onramp: BRL Pix to pBRL

Use the standard `GET /v2/swap/quote` endpoint with `originChain=fiat`, `destinationChain=base-sepolia`, `tokenIn=BRL`, and `tokenOut=0x9762f60740142cF11C0F32C6e24cd3e86016C0f2`. Pass `amountIn` in BRL cents (`1000` = `R$10.00`) and `destinationAddress` set to the wallet on your approved sandbox KYC profile.

### 1. Request an onramp quote

```js theme={null}
import {
  PBRL_TOKEN_ADDRESS,
  getSwapQuote,
  getSwapStatus,
  confirmSandboxQuote,
} from "./pods-client.mjs";

const walletAddress = "<approved-sandbox-wallet-address>";
const kycUserId = "<approved-sandbox-kyc-user-id>";

const onramp = await getSwapQuote({
  originChain: "fiat",
  destinationChain: "base-sepolia",
  tokenIn: "BRL",
  tokenOut: PBRL_TOKEN_ADDRESS,
  amountIn: "1000",
  destinationAddress: walletAddress,
});

const quoteId = onramp.quote.id;
console.log(onramp);
```

Expected response:

```json theme={null}
{
  "quote": {
    "id": "f3cff570-7d81-4932-9898-7e04569345b1",
    "quoteId": "f3cff570-7d81-4932-9898-7e04569345b1",
    "status": "pending",
    "originChain": "fiat",
    "destinationChain": "base-sepolia",
    "chainIdOut": 84532,
    "tokenIn": {
      "contract": "BRL",
      "symbol": "BRL",
      "decimals": 2,
      "amount": "1000",
      "chainId": 0,
      "priceInUSD": 0.179,
      "amountInUSD": 1.79
    },
    "tokenOut": {
      "contract": "0x9762f60740142cf11c0f32c6e24cd3e86016c0f2",
      "symbol": "pBRL",
      "decimals": 18,
      "amount": "10000000000000000000",
      "expectedAmountOut": "10000000000000000000",
      "minAmountOut": "10000000000000000000",
      "chainId": 84532,
      "priceInUSD": 0.179,
      "amountInUSD": 1.79
    },
    "destinationAddress": "0x0000000000000000000000000000000000000001",
    "feeBreakdown": {
      "charges": [],
      "summary": {}
    },
    "paymentInstructions": {
      "method": "PIX SANDBOX",
      "expiresAt": "2026-11-17T18:10:00.000Z",
      "pix": {
        "copyPaste": "sandbox-only-dont-pay-it:f3cff570-7d81-4932-9898-7e04569345b1"
      }
    }
  },
  "chainId": null,
  "transactionData": [],
  "paymentInstructions": {
    "method": "PIX SANDBOX",
    "expiresAt": "2026-11-17T18:10:00.000Z",
    "pix": {
      "copyPaste": "sandbox-only-dont-pay-it:f3cff570-7d81-4932-9898-7e04569345b1"
    }
  },
  "id": "673a2b1c4d5e6f7890123456"
}
```

Save `onramp.quote.id`. The response matches the production Pix onramp envelope, with a visually non-payable placeholder in `paymentInstructions.pix.copyPaste` (`sandbox-only-dont-pay-it:<quoteId>`) so your frontend can render the QR or copy-paste code without risk of a real Pix transfer.

### 2. Simulate payment confirmation (mint pBRL)

Continue in the same script and pass both `quoteId` and the matching `kycUserId`:

```js theme={null}
// Matching kycUserId mints the quoted pBRL on Base Sepolia.
const confirmed = await confirmSandboxQuote(quoteId, { kycUserId });

console.log(confirmed.status);
console.log(confirmed.destinationTxHash);
```

Relevant response fields:

```json theme={null}
{
  "id": "f3cff570-7d81-4932-9898-7e04569345b1",
  "quoteId": "f3cff570-7d81-4932-9898-7e04569345b1",
  "status": "fulfilled",
  "originChain": "fiat",
  "destinationChain": "base-sepolia",
  "destinationTxHash": "0xdbb6…f10d",
  "destinationBlockNumber": "18452310"
}
```

When `kycUserId` matches the profile bound to the quote, Pods broadcasts a real `onramp` transaction on Base Sepolia that mints `10 pBRL` (`10000000000000000000`) to `destinationAddress` and reconciles the `QuoteMinted` event.

### 3. Confirm the result in your application

```js theme={null}
const status = await getSwapStatus(quoteId);

if (status.status === "fulfilled") {
  console.log("Minted pBRL on Base Sepolia:", status.destinationTxHash);
}
```

You can inspect `destinationTxHash` on [Base Sepolia BaseScan](https://sepolia.basescan.org).

## Offramp: pBRL to BRL Pix

To test an offramp, the `originAddress` wallet must already hold `pBRL` on Base Sepolia (minted through the onramp flow above). Pass `amountIn` in 18-decimal `pBRL` base units (`10000000000000000000` = `10 pBRL`, a whole number of BRL cents) along with `originAddress` and any non-empty `pixKey`.

### 1. Request an offramp quote

Start a separate script:

```js theme={null}
import {
  PBRL_TOKEN_ADDRESS,
  getSwapQuote,
  getSwapStatus,
  confirmSandboxQuote,
} from "./pods-client.mjs";

const walletAddress = "<approved-sandbox-wallet-address>";

const offramp = await getSwapQuote({
  originChain: "base-sepolia",
  destinationChain: "fiat",
  tokenIn: PBRL_TOKEN_ADDRESS,
  tokenOut: "BRL",
  amountIn: "10000000000000000000",
  originAddress: walletAddress,
  pixKey: "recipient-pix-key@example.com",
});

const quoteId = offramp.quote.id;
console.log(offramp);
```

Expected response:

```json theme={null}
{
  "quote": {
    "id": "81c4a912-3e10-4b5a-9c11-2a3b4c5d6e7f",
    "quoteId": "81c4a912-3e10-4b5a-9c11-2a3b4c5d6e7f",
    "status": "pending",
    "originChain": "base-sepolia",
    "destinationChain": "fiat",
    "chainIdIn": 84532,
    "tokenIn": {
      "contract": "0x9762f60740142cf11c0f32c6e24cd3e86016c0f2",
      "symbol": "pBRL",
      "decimals": 18,
      "amount": "10000000000000000000",
      "chainId": 84532,
      "priceInUSD": 0.179,
      "amountInUSD": 1.79
    },
    "tokenOut": {
      "contract": "BRL",
      "symbol": "BRL",
      "decimals": 2,
      "amount": "1000",
      "expectedAmountOut": "1000",
      "minAmountOut": "1000",
      "chainId": 0,
      "priceInUSD": 0.179,
      "amountInUSD": 1.79
    },
    "provider": "avenia",
    "originAddress": "0x0000000000000000000000000000000000000001",
    "feeBreakdown": {
      "charges": [],
      "summary": {}
    }
  },
  "chainId": 84532,
  "transactionData": [],
  "id": "673a2b1c4d5e6f7890123457"
}
```

Just like production offramp quotes, the response carries `chainId` and `transactionData` without a `paymentInstructions` block. If the wallet’s `pBRL` balance is below `amountIn`, the quote step returns `409 SANDBOX_INSUFFICIENT_PBRL`.

### 2. Simulate settlement (burn pBRL)

Confirm the offramp quote with `quoteId` alone (`kycUserId` is not required for offramp confirmation):

```js theme={null}
// Burns the quoted pBRL from originAddress on Base Sepolia.
const confirmed = await confirmSandboxQuote(quoteId);

console.log(confirmed.status);
console.log(confirmed.destinationTxHash);
```

Relevant response fields:

```json theme={null}
{
  "id": "81c4a912-3e10-4b5a-9c11-2a3b4c5d6e7f",
  "quoteId": "81c4a912-3e10-4b5a-9c11-2a3b4c5d6e7f",
  "status": "fulfilled",
  "originChain": "base-sepolia",
  "destinationChain": "fiat",
  "destinationTxHash": "0x94a1…c302",
  "destinationBlockNumber": "18452325"
}
```

Pods broadcasts a real transaction on Base Sepolia that burns the quoted `pBRL` from `originAddress` and reconciles the `QuoteRedeemed` event.

### 3. Confirm the result in your application

```js theme={null}
const status = await getSwapStatus(quoteId);

if (status.status === "fulfilled") {
  console.log("Burned pBRL on Base Sepolia:", status.destinationTxHash);
}
```

## Test refunds and failures

Use separate pending quotes to verify how your application handles a payer-mismatch refund on an onramp or a rejected Pix payout on an offramp.

### Simulate an onramp refund (payer mismatch)

Create a new onramp quote, then call `confirmSandboxQuote` with a missing, `null`, or different `kycUserId`:

```js theme={null}
// Omitting kycUserId (or passing a different UUID) simulates a third-party payer mismatch.
const refunded = await confirmSandboxQuote(onrampQuoteId, {
  kycUserId: null,
});

console.log(refunded.status);
console.log(refunded.failure); // { code: 'THIRD_PARTY_PAYER', message: '…' }
console.log(refunded.destinationTxHash);
```

Relevant response fields:

```json theme={null}
{
  "id": "a1b2c3d4-e5f6-4789-8012-3456789abcde",
  "quoteId": "a1b2c3d4-e5f6-4789-8012-3456789abcde",
  "status": "refunded",
  "failure": {
    "code": "THIRD_PARTY_PAYER",
    "message": "The Pix payer is not the account holder. The payment was refunded."
  },
  "failureReason": "The Pix payer is not the account holder. The payment was refunded.",
  "refundReason": "The Pix payer is not the account holder. The payment was refunded.",
  "destinationTxHash": "0x7f12…e891"
}
```

Pods records a `QuoteRefunded` event on the Base Sepolia `pBRL` contract without minting tokens and transitions the quote to `refunded`.

### Simulate a failed offramp payout

Create a new offramp quote (against a wallet holding enough `pBRL`), then call `failSandboxOffRamp`:

```js theme={null}
// Simulate a rejected Pix payout without burning the wallet's pBRL.
const failed = await failSandboxOffRamp(
  offrampQuoteId,
  "THIRD_PARTY_PAYOUT"
);

console.log(failed.status);
console.log(failed.failure);
```

Relevant response fields:

```json theme={null}
{
  "id": "c9d8e7f6-5a4b-4321-9876-543210fedcba",
  "quoteId": "c9d8e7f6-5a4b-4321-9876-543210fedcba",
  "status": "failed",
  "failureReason": "The Pix key belongs to a third party and third-party payouts are not enabled for this quote.",
  "failure": {
    "code": "THIRD_PARTY_PAYOUT",
    "message": "The Pix key belongs to a third party and third-party payouts are not enabled for this quote."
  }
}
```

`failureCode` is optional and defaults to `PROVIDER_REJECTED`. Supported values:

| `failureCode` | Simulated scenario |
| - | - |
| `PROVIDER_REJECTED` | Default. The payment provider rejected the Pix payout. |
| `THIRD_PARTY_PAYOUT` | The destination Pix key belongs to a third party when not permitted. |
| `KYC_REJECTED` | The sender’s KYC status did not pass payout compliance checks. |
| `AMOUNT_MISMATCH` | The settlement amount did not match the payout ticket. |

This transition applies only to a `pending` (or `confirmed`) sandbox offramp quote and makes no on-chain transaction, so the wallet keeps its `pBRL` balance.

## State transitions

### Onramp (`BRL` → `pBRL`)

```mermaid theme={null}
stateDiagram-v2
    state "pending: awaiting Pix confirmation" as pending
    state "processing: Base Sepolia tx in flight" as processing
    state "fulfilled: pBRL minted on-chain" as fulfilled
    state "refunded: QuoteRefunded on-chain (no mint)" as refunded
    state "failed: on-chain settlement revert" as failed

    [*] --> pending: GET /v2/swap/quote
    pending --> processing: POST /v2/swap/status/sandbox/confirmed
    processing --> fulfilled: kycUserId matches quote
    processing --> refunded: kycUserId omitted, null, or different
    processing --> failed: on-chain revert
```

### Offramp (`pBRL` → `BRL`)

```mermaid theme={null}
stateDiagram-v2
    state "pending: awaiting settlement" as pending
    state "processing: Base Sepolia burn in flight" as processing
    state "fulfilled: pBRL burned on-chain" as fulfilled
    state "failed: payout rejected or burn reverted" as failed

    [*] --> pending: GET /v2/swap/quote
    pending --> processing: POST /v2/swap/status/sandbox/confirmed
    processing --> fulfilled: QuoteRedeemed confirmed
    processing --> failed: on-chain revert
    pending --> failed: POST /v2/swap/status/sandbox/confirmed-to-failed
```

## Troubleshooting and reference

| Response | Meaning / next step |
| - | - |
| `404` on a sandbox route in production | Sandbox transition routes are available only in staging. Check your API base URL. |
| `400 INVALID_SANDBOX_AMOUNT` | Onramp `amountIn` must be `1..100000` BRL cents; offramp `amountIn` must be a positive multiple of `1e16` up to `1000 pBRL`. |
| `400 INVALID_PIX_KEY` | The offramp `pixKey` was blank or invalid. Pass a non-empty Pix key string. |
| `403 SANDBOX_KYC_REQUIRED` | No approved sandbox KYC profile (`brlaEnabled: true`) is linked to the ramp wallet for your customer. Complete [Sandbox KYC](https://docs.pods.finance/guides/kyc/sandbox.md) first. |
| `403 SANDBOX_CUSTOMER_RESTRICTED` | Your customer access policy blocks sandbox ramp quotes. Contact Pods to check your staging customer configuration. |
| `404 QUOTE_NOT_FOUND` | The `quoteId` does not exist, belongs to another customer, or is not a sandbox `pBRL` quote (for example, calling `confirmed-to-failed` on an onramp quote). |
| `409 SANDBOX_INSUFFICIENT_PBRL` | The `originAddress` wallet holds less `pBRL` on Base Sepolia than the offramp `amountIn`. Mint `pBRL` with an onramp quote first. |
| `409 PAYMENT_STATE_CONFLICT` | The quote has already reached a terminal state (`fulfilled`, `failed`, `refunded`, or `expired`) and cannot be transitioned again. |
| `409 QUOTE_EXPIRED` | The 15-minute quote deadline passed before confirmation. Request a new quote. |
| `503 SANDBOX_PBRL_UNAVAILABLE` | The Base Sepolia RPC or `pBRL` contract could not be reached. Retry the request; infrastructure errors leave a pending quote retryable. |

Additional behavior:

* `GET /v2/swap/status/{id}` is read-only for sandbox quotes until you call a sandbox transition endpoint (or the quote expires).
* Terminal quotes (`fulfilled`, `refunded`, `failed`, `expired`) reject further transition calls with `409 PAYMENT_STATE_CONFLICT`.
* Validation or RPC errors (`HttpError`) during `POST /v2/swap/status/sandbox/confirmed` leave the quote retryable; only a genuine on-chain revert marks the quote `failed`.
* In-flight settlements acquire a 60-second lease so concurrent confirmation calls reconcile the same transaction rather than broadcasting duplicate mints or burns.

## Prepare for production

Before moving beyond the sandbox, verify that your application:

* Requests quotes through `GET /v2/swap/quote` using production chain names (`base`, `polygon`, `monad`, `solana`, `stable`) and token addresses.
* Renders `paymentInstructions.pix.copyPaste` on onramps and signs/submits `transactionData` on offramps.
* Polls `GET /v2/swap/status/{id}` until a terminal status (`fulfilled`, `refunded`, `failed`, `expired`) and handles `failure` details.
* Uses a production Pods API key and keeps it on the backend.

Continue with the production guides:

* [Pods Ramp Overview](https://docs.pods.finance/guides/ramp/overview.md): end-to-end architecture for KYC, quotes, and limits.
* [Move Money with Pods Ramp](https://docs.pods.finance/guides/ramp/quotes.md): production parameters, token addresses, and execution instructions across all supported networks.
* [Track Pods Ramp Status](https://docs.pods.finance/guides/ramp/status.md): production status polling and Pix `fiatSettlement` receipts (`endToEndId` and `refundEndToEndId`).


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