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

# Build Redeem

> Build a transaction to redeem outcome tokens on a resolved prediction market. Converts winning shares back to USDC.

<Warning>**Alpha** — This endpoint is part of the Prediction Markets API, currently in early access. May change without notice.</Warning>

### Request Body

<ParamField body="address" type="string" required>
  The wallet address (EOA). The Safe address is derived automatically.
</ParamField>

<ParamField body="conditionId" type="string" required>
  The condition ID of the market (same as `marketId` from market details).
</ParamField>

<ParamField body="indexSets" type="array" required>
  Array of index sets to redeem. For binary markets, use `[1, 2]` (Yes=1, No=2).
</ParamField>

<ParamField body="isNegRisk" type="boolean" default={false}>
  Set to `true` for neg-risk (multi-outcome) markets. This routes the redemption through the NegRiskAdapter contract instead of ConditionalTokens directly.
</ParamField>

### Response

<ResponseField name="data" type="object">
  Transaction calldata for the redemption.

  <Expandable title="Redeem Transaction">
    <ResponseField name="to" type="string">The Safe address (transaction is sent to the Safe which executes the redemption).</ResponseField>
    <ResponseField name="calldata" type="string">Encoded Safe `execTransaction` calldata wrapping the `redeemPositions` call (`0x`-prefixed hex).</ResponseField>
    <ResponseField name="chainId" type="number">Chain ID (137 for Polygon).</ResponseField>
    <ResponseField name="safeAddress" type="string">The Safe trading account.</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="hostname" type="string">Server node identifier.</ResponseField>
<ResponseField name="took" type="number">Request processing time in milliseconds.</ResponseField>

### How Redemption Works

For **standard markets** (`isNegRisk: false`):

* Calls `ConditionalTokens.redeemPositions(USDC, 0x0, conditionId, indexSets)` through the Safe.
* Burns outcome tokens and returns USDC to the Safe for winning positions.

For **neg-risk markets** (`isNegRisk: true`):

* Calls `NegRiskAdapter.redeemPositions(conditionId, indexSets)` through the Safe.

### Usage Example

```bash theme={null}
curl -X POST "https://api.mobula.io/api/2/pm/redeem/build" \
  -H "Content-Type: application/json" \
  -d '{
    "address": "0xYourWalletAddress",
    "conditionId": "0x5a300c31e036a97a7a14aa248f5fb0d39c02a06803a910643f1ab2edc22fa99f",
    "indexSets": [1, 2],
    "isNegRisk": false
  }'
```

### Integration Example

```typescript theme={null}
// Build the redeem transaction
const res = await fetch('https://api.mobula.io/api/2/pm/redeem/build', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    address: walletAddress,
    conditionId: market.marketId,
    indexSets: [1, 2],
    isNegRisk: market.negRisk
  })
});
const { data: redeemTx } = await res.json();

// Send the transaction on-chain (Polygon)
const txHash = await walletClient.sendTransaction({
  to: redeemTx.to,
  data: redeemTx.calldata,
  chain: polygon
});
```

<Note>
  Redemption is only possible after a market has been resolved. The transaction is wrapped in a Safe `execTransaction` call because the outcome tokens are held by the Safe, not the EOA directly. The EOA (as Safe owner) can authorize this call using a pre-approved sender signature.
</Note>


## OpenAPI

````yaml POST /2/pm/redeem/build
openapi: 3.0.0
info:
  version: 1.0.0
  title: Mobula API
  description: >-
    Documentation of the Mobula API


    **Demo API**: The default server (demo-api.mobula.io) is a demo API with
    rate limits.

    For production use, please use api.mobula.io with an API key from
    https://admin.mobula.io
servers:
  - url: https://demo-api.mobula.io/api/
    description: Demo API (rate limited, for testing only)
  - url: https://api.mobula.io/api/
    description: Production API (requires API key)
security: []
tags:
  - name: V2 - Token
    description: Token details, price, security, ATH, and holder data
  - name: V2 - Market Data
    description: Market details, OHLCV history, and lighthouse metrics
  - name: V2 - Trades
    description: Token trades, enriched trades, and trade filters
  - name: V2 - Wallet
    description: Wallet positions, activity, trades, analysis, and labels
  - name: V2 - Assets
    description: Cross-chain asset details and price history
  - name: V2 - Swap
    description: Swap quoting and execution
  - name: V2 - Perps
    description: Perpetual futures quoting, execution, and positions
  - name: V2 - Bridge
    description: Cross-chain bridge quoting and intent status (Alpha Preview)
  - name: V2 - DeFi
    description: Bonding pools and pulse data
  - name: V2 - Search
    description: Universal fast search
  - name: V2 - Blockchains
    description: System metadata and chain listings
  - name: V1 - Market Data
    description: Market prices, history, sparklines, pairs, and multi-data
  - name: V1 - Wallet
    description: Wallet portfolio, transactions, history, and NFTs
  - name: V1 - Token
    description: First buyers
  - name: V1 - Trades
    description: Market trades by pair
  - name: V1 - Metadata
    description: Token metadata, categories, trendings, and news
  - name: V1 - Assets
    description: List all assets
  - name: V1 - Search
    description: Search for assets, tokens, and pairs
  - name: V1 - DeFi
    description: Bonding pool pulse data
  - name: V1 - Blockchains
    description: Blockchain listings, pairs, and stats
  - name: V1 - Webhooks
    description: Webhook management
  - name: V1 - Feed
    description: Custom feed creation
paths:
  /2/pm/redeem/build:
    post:
      tags:
        - V2 - Prediction Markets
      summary: Build a CTF/NegRiskAdapter redeemPositions transaction
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                address:
                  type: string
                  minLength: 1
                conditionId:
                  type: string
                  minLength: 1
                indexSets:
                  type: array
                  items:
                    type: integer
                    minimum: 0
                    exclusiveMinimum: true
                  minItems: 1
                isNegRisk:
                  type: boolean
              required:
                - address
                - conditionId
                - indexSets
      responses:
        '201':
          description: Prediction Markets response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    nullable: true
                    description: >-
                      See the per-endpoint reference for the exact response
                      shape.
                  hostname:
                    type: string
                  took:
                    type: number
                required:
                  - hostname
                  - took

````