<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/ramp/sell-checkout -->

# Create Sell Checkout

Create a checkout intent to execute an off-ramp (crypto to fiat) transaction. Pass the `onramp` value from a sell quote response.

<EndpointHeader verb="POST" path="/payment/api/v1/off-ramp/checkout" />

## Request

### Headers

<ParamTable
  label="Header"
  rows={[
    { name: "Content-Type", required: true, desc: "`application/json`" },
    { name: "x-request-id", desc: "Custom request ID for tracing" },
  ]}
/>

:::note Public Endpoint
This endpoint does not require authentication headers.
:::

### Body Parameters

<ParamTable
  rows={[
    { name: "onramp", type: "string", required: true, desc: "Identifier from sell quote response" },
    { name: "source", type: "string", required: true, desc: "Crypto ID (e.g. `btc_bitcoin`)" },
    { name: "destination", type: "string", required: true, desc: "Fiat currency (e.g. `usd`)" },
    { name: "amount", type: "number", required: true, desc: "Crypto amount to sell" },
    { name: "type", type: "string", required: true, desc: "`sell`" },
    { name: "paymentMethod", type: "string", required: true, desc: "Payout method (e.g. `bank_transfer`)" },
    { name: "walletAddress", type: "string", desc: "Source wallet address. See [Wallet Addresses](/docs/rest-api/endpoints/ramp/wallet-addresses)" },
    { name: "walletMemo", type: "string", desc: "Memo/tag for XRP, XLM, etc." },
    { name: "network", type: "string", desc: "Blockchain network" },
    { name: "country", type: "string", desc: "ISO country code" },
    { name: "sessionId", type: "string", desc: "Checkout session ID for tracking" },
    { name: "walletAddresses", type: "object", desc: "Network-to-address mappings" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "transactionId": "txn_def456",
    "redirectUrl": "https://checkout.example.com/...",
    "status": "pending"
  },
  "message": "Sell checkout intent created"
}
```

### Response Fields

<ParamTable
  rows={[
    { name: "transactionId", type: "string", desc: "Unique transaction identifier" },
    { name: "redirectUrl", type: "string", desc: "URL to redirect the user to complete the sell" },
    { name: "status", type: "string", desc: "Initial status (`pending`)" },
  ]}
/>

### Error Responses

<ErrorTable
  rows={[
    { code: "VALIDATION_ERROR", status: "400", message: "Invalid request body" },
    { code: "OFFRAMP_CHECKOUT_FAILED", status: "500", message: "Failed to create sell checkout" },
  ]}
/>

<CodeRail>

## Examples

<Tabs groupId="language">
  <TabItem value="curl" label="cURL" default>

```bash
curl -X POST https://api.zenpayz.com/payment/api/v1/off-ramp/checkout \
  -H "Content-Type: application/json" \
  -d '{
    "onramp": "moonpay",
    "source": "btc_bitcoin",
    "destination": "usd",
    "amount": 0.01,
    "type": "sell",
    "paymentMethod": "bank_transfer",
    "walletAddress": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
  }'
```

  </TabItem>
  <TabItem value="javascript" label="JavaScript">

```javascript
const response = await fetch('https://api.zenpayz.com/payment/api/v1/off-ramp/checkout', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    onramp: 'moonpay',
    source: 'btc_bitcoin',
    destination: 'usd',
    amount: 0.01,
    type: 'sell',
    paymentMethod: 'bank_transfer',
    walletAddress: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
  }),
});

const { data } = await response.json();
window.location.href = data.redirectUrl;
```

  </TabItem>
  <TabItem value="python" label="Python">

```python
import requests

response = requests.post(
    "https://api.zenpayz.com/payment/api/v1/off-ramp/checkout",
    json={
        "onramp": "moonpay",
        "source": "btc_bitcoin",
        "destination": "usd",
        "amount": 0.01,
        "type": "sell",
        "paymentMethod": "bank_transfer",
        "walletAddress": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    },
)

data = response.json()["data"]
print(f"Transaction: {data['transactionId']}")
print(f"Redirect to: {data['redirectUrl']}")
```

  </TabItem>
</Tabs>

</CodeRail>

## Next Steps

- [Transaction Status](/docs/rest-api/endpoints/ramp/transaction-status) -- Poll transaction progress
- [Sell Quotes](/docs/rest-api/endpoints/ramp/sell-quotes) -- Get quotes before checkout
- [Wallet Addresses](/docs/rest-api/endpoints/ramp/wallet-addresses) -- Understand wallet resolution
