> ## 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.

# Create Coinbase onramp URL

Creates a Coinbase Onramp buy URL and optionally returns a session token for reuse.

` POST /onramp/coinbase/onramp-url `

Create Coinbase onramp URL

Creates a Coinbase Onramp buy URL and optionally returns a session token for reuse.

## Servers

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

## Request body (required)

Content type: ` application/json `

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

  - Required fields: ` presetFiatAmount `, ` fiatCurrency `, ` defaultAsset `, ` defaultPaymentMethod `, ` destinationAddress `, ` blockchains `, ` country `, ` orderId `, ` redirectUrl `

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

    - 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" `

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

    - example: ` "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1" `

  - ` blockchains `: type ` array ` — Supported blockchains for the session

    - example: ` ["base"] `

    - ` array item `: type ` string `

  - ` country `: type ` string ` — ISO country code of the end user

    - example: ` "US" `

  - ` orderId `: type ` string ` — Associated AnySpend order ID

    - example: ` "5392f7a7-d472-4d6b-9848-bd07117fb82d" `

  - ` redirectUrl `: type ` string ` — Redirect URL after completing the purchase

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

  - ` useSessionToken `: type ` boolean ` — Whether to create and embed a session token automatically

    - default: ` false `

## Responses

### ` 200 ` — Onramp URL created successfully

Content type: ` application/json `

- ` value `: type ` object `

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

  - ` success `: type ` boolean `

    - example: ` true `

  - ` message `: type ` string `

    - example: ` "Onramp URL created successfully" `

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

    - Required fields: ` url `

    - ` url `: type ` string ` — Coinbase-hosted onramp URL

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

    - ` sessionToken `: type ` string ` — Optional session token created alongside the 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/onramp-url' \
  -H 'Content-Type: application/json' \
  -d '{
  "presetFiatAmount": "100",
  "fiatCurrency": "USD",
  "defaultAsset": "USDC",
  "defaultPaymentMethod": "CARD",
  "destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
  "blockchains": [
    "base"
  ],
  "country": "US",
  "orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
  "redirectUrl": "https://www.anyspend.com/orders",
  "useSessionToken": false
}'
```

### JavaScript

```javascript
const response = await fetch('https://mainnet.anyspend.com/onramp/coinbase/onramp-url', {
  method: 'POST',
  headers: {
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "presetFiatAmount": "100",
    "fiatCurrency": "USD",
    "defaultAsset": "USDC",
    "defaultPaymentMethod": "CARD",
    "destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
    "blockchains": [
      "base"
    ],
    "country": "US",
    "orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
    "redirectUrl": "https://www.anyspend.com/orders",
    "useSessionToken": false
  })
});

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

### Python

```python
import requests

response = requests.post('https://mainnet.anyspend.com/onramp/coinbase/onramp-url', json={
  "presetFiatAmount": "100",
  "fiatCurrency": "USD",
  "defaultAsset": "USDC",
  "defaultPaymentMethod": "CARD",
  "destinationAddress": "0x58241893EF1f86C9fBd8109Cd44Ea961fDb474e1",
  "blockchains": [
    "base"
  ],
  "country": "US",
  "orderId": "5392f7a7-d472-4d6b-9848-bd07117fb82d",
  "redirectUrl": "https://www.anyspend.com/orders",
  "useSessionToken": false
})
print(response.json())
```