Skip to main content

API Testing Guide

Learn how to test your meCash API integration using various tools and methods.

Testing Tools

cURL

Command-line tool for making HTTP requests

Postman

Popular GUI tool for API testing

Code Examples

Language-specific examples in our docs

Basic Authentication Test

Test your API key authentication with the sandbox environment:
curl -X GET "https://sandboxapi.me-cash.com/v1/wallets" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY" \
  -H "Content-Type: application/json"
Expected response:
{
  "status": "success",
  "message": "Wallets retrieved successfully",
  "data": {
    "wallets": []
  }
}

Testing Common Endpoints

1. Get All Wallets

curl -X GET "https://sandboxapi.me-cash.com/v1/wallets" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY"

2. Create a Quote

curl -X POST "https://sandboxapi.me-cash.com/v1/quotes" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from_currency": "USD",
    "to_currency": "EUR",
    "amount": "1000.00"
  }'

3. Create a Payout

curl -X POST "https://sandboxapi.me-cash.com/v2/payouts" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "100.00",
    "currency": "USD",
    "recipient_name": "John Doe",
    "recipient_email": "[email protected]",
    "bank_code": "US001",
    "account_number": "1234567890"
  }'

Simulating Payout States

In the sandbox environment, you can simulate different payout outcomes to test your webhook handling. This is particularly useful for testing error scenarios and ensuring your integration handles failed payouts correctly.

Simulating a Failed Payout

To simulate a payout failure and trigger the payout.failed webhook, simply include “failed” as the remark field in your payout request:
curl -X POST "https://sandboxapi.me-cash.com/v2/payouts" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "100.00",
    "currency": "NGN",
    "recipient_name": "John Doe",
    "bank_code": "058",
    "account_number": "1234567890",
    "remark": "fail"
  }'
When you include "remark": "fail" in your payout request, the system will process the payout as a failure and send a payout.failed webhook to your configured webhook URL. This allows you to test your failure handling logic without real transactions.

Expected Webhook Response

After submitting a payout with "remark": "fail", you will receive a payout.failed webhook event:
{
  "event": "payout.failed",
  "data": {
    "id": "8b99b9d8-998a-48db-9102-xxxxxxxxxxxxx",
    "referenceNumber": "RRT6CBX1NMGUJ",
    "type": "SEND",
    "state": "FAILED",
    "quote": {
      "id": "68d2bae4-7365-42fc-bbc2-xxxxxxxxxxxxx",
      "source": { "currency": "NGN", "amount": 100 },
      "target": { "currency": "NGN", "amount": 100 },
      "rate": 1,
      "fee": { "amount": 5 },
      "summary": { "total": 105 }
    },
    "recipient": {
      "name": "John Doe",
      "account": { "sortCode": "058", "accountNumber": "1234567890" },
      "currency": "NGN",
      "country": "NG",
      "stored": false
    },
    "created": "2025-03-13T15:28:37.258Z",
    "processed": "2025-03-13T15:28:37.258Z"
  }
}
Use this feature alongside webhook.site to inspect and debug your webhook payloads in real-time.

Simulating Virtual Account Funding

Testing your collection flow is critical. In sandbox, you can simulate an incoming bank transfer to any of your virtual accounts.

How to Simulate Funding

To credit a virtual account, use the simulation endpoint:
curl -X POST "https://sandboxapi.me-cash.com/v1/virtual-account/simulate/transfer" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 500000,
    "reference": "VA_REFERENCE_HERE"
  }'
Note: The amount should be in the lowest denomination (e.g., 500000 = 5,000 NGN). This will trigger a virtualaccount.completed webhook.
For full details, see the Simulate Funding API Reference.

Postman Collection

Import this collection into Postman for easy testing:
{
  "info": {
    "name": "meCash API",
    "description": "meCash API testing collection"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.me-cash.com"
    },
    {
      "key": "api_key",
      "value": "YOUR_API_KEY"
    }
  ],
  "request": [
    {
      "name": "Get Wallets",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{api_key}}"
          }
        ],
        "url": {
          "raw": "{{base_url}}/v1/wallets"
        }
      }
    }
  ]
}

Error Testing

Test error scenarios to ensure proper handling:

Invalid API Key

curl -X GET "https://sandboxapi.me-cash.com/v1/wallets" \
  -H "x-api-key: INVALID_KEY"
Expected response:
{
  "status": "error",
  "errorCode": "INVALID_API_KEY",
  "message": "The provided API key is invalid"
}

Missing Required Fields

curl -X POST "https://sandboxapi.me-cash.com/v1/quotes" \
  -H "x-api-key: YOUR_SANDBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from_currency": "USD"
  }'

Rate Limit Testing

Test rate limits by making multiple rapid requests:
for i in {1..15}; do
  curl -X GET "https://sandboxapi.me-cash.com/v1/wallets" \
    -H "x-api-key: YOUR_SANDBOX_API_KEY" &
done
wait

Webhook Testing

Test webhook endpoints using tools like webhook.site:
  1. Go to webhook.site
  2. Copy the provided URL
  3. Add it to your meCash webhook configuration
  4. Trigger events to see webhook payloads

Environment Variables

Set up environment variables for testing:
export MECASH_SANDBOX_API_KEY="your_sandbox_api_key_here"
export MECASH_SANDBOX_URL="https://sandboxapi.me-cash.com"

Then use in your requests:
# Sandbox testing
curl -X GET "$MECASH_SANDBOX_URL/v1/wallets" \
  -H "x-api-key: $MECASH_SANDBOX_API_KEY"

Testing Checklist

  • API key authentication works
  • All required endpoints respond correctly
  • Error handling works as expected
  • Rate limits are respected
  • Webhooks are received and processed
  • Response formats match documentation
  • Required fields validation works
  • Optional fields are handled properly

Need Help?