Skip to main content

API Playground

All API endpoints in this documentation include an interactive playground that allows you to test requests directly from your browser.

Setup Your API Key

Before testing, you need to configure your authentication:
1

Get Your Merchant API Key

Contact DCash support or log into your merchant dashboard to obtain your API key
2

Configure the Playground

Click the “Authorization” button in the playground and enter your API key in the x-api-key field
3

Add User Token (if needed)

For endpoints requiring user authentication, add the Bearer token in the Authorization header

Test Credentials

For sandbox testing, use these credentials:
{
  "email": "[email protected]",
  "password": "7223acsd"
}

Testing Different Endpoints

OAuth Login (Browser-based)

The OAuth endpoint returns HTML and cannot be tested in the API playground.
To test the OAuth flow:
  1. Construct the URL manually:
    https://sandbox.dcash.africa/oauth/authorization/login?app_id=YOUR_APP_ID&redirect_url=YOUR_REDIRECT_URL
    
  2. Replace YOUR_APP_ID with your actual app ID
  3. Set a valid redirect_url for your application
  4. Open the URL in your browser
  5. Log in with the test credentials
  6. Complete the authentication flow
  7. Your webhook will receive the authorization token

Get Payment Providers

1

Set Authentication

Add both x-api-key (merchant key) and Authorization (Bearer token)
2

Send Request

Click the “Send” button to get the user’s available payment providers

Deposits (C2B)

1

Configure Headers

  • x-api-key: Your merchant API key
  • Authorization: Bearer token from OAuth flow
2

Fill Request Body

{
  "reference_id": "test_001",
  "description": "Test Deposit",
  "payment_provider": "mpesa",
  "amount": 10,
  "currency": "USD",
  "webhook_url": "https://your-webhook-url.com/webhook"
}
3

Send Request

Click “Send” to initiate the deposit
4

Complete Payment

Check your phone for the M-Pesa prompt and complete the payment

Check Transaction Status

1

Get Transaction ID

Use the transaction_id from a previous deposit or withdrawal
2

Add API Key

Only x-api-key is required (no user token needed)
3

Send Request

Click “Send” to check the status

Withdrawals (B2C)

1

Configure Authentication

Add your x-api-key in the authorization section
2

Fill Request Body

{
  "reference_id": "withdrawal_001",
  "description": "Test Withdrawal",
  "payment_provider": "mpesa",
  "email": "[email protected]",
  "amount": 10,
  "currency": "USD"
}
3

Send Request

The withdrawal will be processed immediately

Troubleshooting

Make sure the base URL is configured correctly in the API settings. The base URL should be https://sandbox.dcash.africa
  • Check that your API key is correct
  • Verify the x-api-key header is set
  • For user-specific endpoints, ensure you have a valid Bearer token
  • Verify all required fields are included in the request body
  • Check that the payment_provider is from the list of available providers
  • Ensure amounts are valid numbers
  • Verify your webhook URL is publicly accessible
  • Use the “Check Transaction Status” endpoint to verify the transaction completed
  • Check your webhook server logs for incoming requests

Best Practices

Use Valid Webhooks

Always use a real, publicly accessible webhook URL for testing deposits

Test Small Amounts

Start with small amounts (e.g., 10 USD) when testing

Save Tokens

Store your test Bearer tokens for reuse during testing

Check Providers First

Always call “Get Payment Providers” before initiating transactions

Next Steps

Ready to integrate? Check out the Authentication guide to get started with your application.