> For the complete documentation index, see [llms.txt](https://coindisco.gitbook.io/coindisco/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coindisco.gitbook.io/coindisco/white-label-api/buy-flow.md).

# Buy flow

## 1. Collect valid IDs

Use the [shared resources](/coindisco/white-label-api/shared-resources.md) endpoints to select region, payment method, fiat currency, cryptocurrency, and network.

## 2. Search all eligible providers

```bash
curl 'https://api.coindisco.com/api/white-label/v1/search-buy-quotes/' \
  --request POST \
  --header 'Partner-Api-Key: pk_test_YOUR_PUBLIC_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "region": 157,
    "payment_method": 39,
    "cryptocurrency": 1,
    "currency": 3,
    "network": 1,
    "currency_amount": "400"
  }'
```

Without `service`, quote aggregation is asynchronous:

```json
{
  "search_id": "7e038ab6-3c65-41cb-a364-2d47471b00de"
}
```

## 3. Poll the search

```bash
curl 'https://api.coindisco.com/api/white-label/v1/search-buy-quotes/7e038ab6-3c65-41cb-a364-2d47471b00de/' \
  --header 'Partner-Api-Key: pk_test_YOUR_PUBLIC_KEY'
```

Continue while `status` is `in_progress`. Render partial results only if the application clearly indicates that the search is still running.

```json
{
  "status": "completed",
  "progress": {
    "objects_done": 1,
    "objects_total": 1
  },
  "data": [
    {
      "currency_amount": "400",
      "cryptocurrency_amount": "0.00784",
      "total_fee": "8.00",
      "profit_rate": "51020.40816326530612244898",
      "true_fee": 2.0408163265306123,
      "is_best_rate": true,
      "service": {
        "id": 5,
        "name": "Example Provider"
      },
      "quote_id": "f6307f07-cfb8-4c17-9f4c-a076f5908db2"
    }
  ]
}
```

## Search a specific provider

Add `"service": 5` to the request. When one request item contains a service, the endpoint attempts the provider synchronously and returns the quote object directly instead of a `search_id`.

## 4. Create the buy transaction

Send the selected provider and the same inputs used for its quote. Include the `quote_id` when it is returned.

```bash
curl 'https://api.coindisco.com/api/white-label/v1/retrieve-buy-link/' \
  --request POST \
  --header 'Partner-Api-Key: pk_test_YOUR_PUBLIC_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "service": 5,
    "region": 157,
    "payment_method": 39,
    "cryptocurrency": 1,
    "currency": 3,
    "network": 1,
    "currency_amount": "400",
    "wallet_address": "YOUR_WALLET_ADDRESS",
    "quote_id": "f6307f07-cfb8-4c17-9f4c-a076f5908db2",
    "redirect_url": "https://app.example.com/transactions"
  }'
```

```json
{
  "link": "https://provider.example/checkout/session-id",
  "transaction_id": "638a68f8-111d-4d0c-b6ab-da6a805c419f"
}
```

Open the returned `link`; never construct a provider checkout URL from provider fields.
