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

# Get Payment Providers

> Retrieve available payment providers for the authenticated user

## Endpoint

```
GET /merchants/accounts/providers
```

## Description

Retrieves a list of all payment providers available to the current user and their chosen defaults. Only the listed payment providers can be used to initiate a transaction.

## Headers

<ParamField header="x-api-key" type="string" required>
  Merchant API key for authentication
</ParamField>

<ParamField header="Authorization" type="string" required>
  Bearer token of the authenticated user

  Format: `Bearer {token}`
</ParamField>

## Response

<ResponseField name="default_deposit_provider" type="string">
  User's default provider for deposits
</ResponseField>

<ResponseField name="default_withdraw_provider" type="string">
  User's default provider for withdrawals
</ResponseField>

<ResponseField name="payment_providers" type="object">
  Object containing available payment providers

  <Expandable title="properties">
    <ResponseField name="mobile_payment_providers" type="array">
      List of mobile payment providers

      <Expandable title="array item">
        <ResponseField name="provider_name" type="string">
          Name of the payment provider (e.g., "mpesa", "airtel")
        </ResponseField>

        <ResponseField name="phone_number" type="string">
          Phone number associated with the provider
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://sandbox.dcash.africa/merchants/accounts/providers \
    --header 'Authorization: Bearer YOUR_USER_TOKEN' \
    --header 'x-api-key: YOUR_MERCHANT_API_KEY'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://sandbox.dcash.africa/merchants/accounts/providers', {
    method: 'GET',
    headers: {
      'x-api-key': 'YOUR_MERCHANT_API_KEY',
      'Authorization': 'Bearer YOUR_USER_TOKEN'
    }
  });

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

  ```python Python theme={null}
  import requests

  url = "https://sandbox.dcash.africa/merchants/accounts/providers"
  headers = {
      "x-api-key": "YOUR_MERCHANT_API_KEY",
      "Authorization": "Bearer YOUR_USER_TOKEN"
  }

  response = requests.get(url, headers=headers)
  data = response.json()
  print(data)
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, "https://sandbox.dcash.africa/merchants/accounts/providers");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "x-api-key: YOUR_MERCHANT_API_KEY",
      "Authorization: Bearer YOUR_USER_TOKEN"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $data = json_decode($response, true);
  print_r($data);
  ?>
  ```
</CodeGroup>

## Example Response

<CodeGroup>
  ```json Response theme={null}
  {
    "default_deposit_provider": "mpesa",
    "default_withdraw_provider": "airtel",
    "payment_providers": {
      "mobile_payment_providers": [
        {
          "provider_name": "mpesa",
          "phone_number": "254797954425"
        },
        {
          "provider_name": "airtel",
          "phone_number": "254780764974"
        }
      ]
    }
  }
  ```
</CodeGroup>

<Info>
  The providers returned by this endpoint are the only ones that can be used when initiating deposit or withdrawal transactions for this user.
</Info>

## Error Codes

| Code                            | Message                               |
| ------------------------------- | ------------------------------------- |
| `authorization_token_not_found` | please provide an authorization token |
| `application_not_authorized`    | application is not authorized         |
| `missing_api_key`               | please provide an api key             |
| `invalid_api_key`               | api key does not exist                |
| `internal_server_error`         | internal server error                 |

## Use Cases

This endpoint is useful for:

* Displaying available payment options to users
* Pre-selecting the user's default payment provider
* Validating payment provider selections before initiating transactions
* Building dynamic payment forms based on user preferences
