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

# Generate direct Coinbase onramp URL

Generates a direct Coinbase Onramp URL along with the session token backing it.

` POST /onramp/coinbase/direct-url `

Generate direct Coinbase onramp URL

Generates a direct Coinbase Onramp URL along with the session token backing it.

## Servers

- ` https://mainnet.anyspend.com ` — Production server

## Request body (required)

Content type: ` application/json `

- ` value `: type ` object ` — Request body to generate a direct Coinbase onramp URL

  - Required fields: ` destinationAddress `, ` blockchains `

  - ` destinationAddress `: type ` string ` — Destination wallet address

    - example: ` "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1" `

  - ` blockchains `: type ` array ` — Supported blockchain identifiers

    - example: ` ["base"] `

    - ` array item `: type ` string `

  - ` assets `: type ` array ` — Optional list of asset symbols to whitelist

    - example: ` ["USDC"] `

    - ` array item `: type ` string `

  - ` presetFiatAmount `: type ` string ` — Preset fiat amount

    - example: ` "100" `

  - ` fiatCurrency `: type ` string ` — Fiat currency code

    - example: ` "USD" `

  - ` defaultAsset `: type ` string ` — Default asset to purchase

    - example: ` "USDC" `

  - ` defaultPaymentMethod `: type ` string ` — Default payment method identifier

    - example: ` "CARD" `

  - ` redirectUrl `: type ` string ` — Redirect URL after payment completion

    - example: ` "https://www.anyspend.com/orders" `

## Responses

### ` 200 ` — Direct onramp URL generated successfully

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` success `, ` message `, ` data `, ` statusCode `

  - ` success `: type ` boolean `

    - example: ` true `

  - ` message `: type ` string `

    - example: ` "Direct onramp URL generated successfully" `

  - ` data `: type ` object ` — Direct Coinbase onramp URL result

    - Required fields: ` url `, ` sessionToken `

    - ` url `: type ` string ` — Coinbase onramp URL that can be used directly

      - example: ` "https://pay.coinbase.com/buy/select-asset?... " `

    - ` sessionToken `: type ` string ` — Session token bound to the generated URL

      - example: ` "token_123" `

  - ` statusCode `: type ` number `

    - example: ` 200 `

### ` 400 ` — Bad request

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` success `, ` message `, ` statusCode `

  - ` success `: type ` boolean `

    - example: ` false `

  - ` message `: type ` string `

    - example: ` "Bad request" `

  - ` statusCode `: type ` number `

    - example: ` 400 `

## Request examples

### cURL

```curl
curl -X POST 'https://mainnet.anyspend.com/onramp/coinbase/direct-url' \
  -H 'Content-Type: application/json' \
  -d '{
  "destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
  "blockchains": [
    "base"
  ],
  "assets": [
    "USDC"
  ],
  "presetFiatAmount": "100",
  "fiatCurrency": "USD",
  "defaultAsset": "USDC",
  "defaultPaymentMethod": "CARD",
  "redirectUrl": "https://www.anyspend.com/orders"
}'
```

### JavaScript

```javascript
const response = await fetch('https://mainnet.anyspend.com/onramp/coinbase/direct-url', {
  method: 'POST',
  headers: {
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
    "blockchains": [
      "base"
    ],
    "assets": [
      "USDC"
    ],
    "presetFiatAmount": "100",
    "fiatCurrency": "USD",
    "defaultAsset": "USDC",
    "defaultPaymentMethod": "CARD",
    "redirectUrl": "https://www.anyspend.com/orders"
  })
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

response = requests.post('https://mainnet.anyspend.com/onramp/coinbase/direct-url', json={
  "destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
  "blockchains": [
    "base"
  ],
  "assets": [
    "USDC"
  ],
  "presetFiatAmount": "100",
  "fiatCurrency": "USD",
  "defaultAsset": "USDC",
  "defaultPaymentMethod": "CARD",
  "redirectUrl": "https://www.anyspend.com/orders"
})
print(response.json())
```