Docs
ENFR
Dashboard
Get started

Quickstart

Make your first API call, collect a test payment and receive its webhook.

You need a Monerail account. Everything below happens in test mode: no real money moves.

  1. Create a test key. In the dashboard, open Developers › API keys, give the key a name (2 to 60 characters) and create it in test mode. It starts with mr_test_. Copy it now: it is shown only once. Keep it on your server, never in a web page or a mobile app.
  2. Check your balance. This proves the key works.
curl https://api.monerail.com/v1/balance \
  -H "Authorization: Bearer $MONERAIL_KEY"

Every endpoint of the API reference has the same call in curl, Node.js, Python, PHP, Go, Java, Ruby and C#.

JSON
{
  "object": "balance",
  "livemode": false,
  "available": [{ "currency": "XAF", "amount": 0 }],
  "cards": { "currency": "USD", "amount": 0 }
}
  1. Collect a payment. Ask a customer in Cameroon to pay 5,000 XAF with MTN Mobile Money. Send an Idempotency-Key so a retry can never charge twice.
curl https://api.monerail.com/v1/collections \
  -H "Authorization: Bearer $MONERAIL_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-42" \
  -d '{
    "amount": 5000,
    "currency": "XAF",
    "phone": "237670000999",
    "operator": "MTN",
    "customer": { "name": "Awa Ndiaye" },
    "client_reference": "order_42"
  }'

The collection comes back with a status and, while the customer has something to do, a next_action. Show its message to your customer.

JSON
{
  "id": "3b8f6c1e-2a47-4d1b-9e35-7c0a9d2f4e61",
  "object": "collection",
  "status": "pending",
  "amount": 5000,
  "currency": "XAF",
  "next_action": {
    "type": "customer_approval",
    "message": "A payment request was sent. The customer enters their PIN.",
    "ussd_code": "*126#"
  }
}

In test mode, the payment partner’s sandbox decides how the collection proceeds and how it ends. See Testing.

  1. Receive the result. Create a webhook endpoint (dashboard › Developers › Webhooks, or the API) that receives collection events. When the collection reaches a final status, Monerail sends collection.succeeded, collection.failed or collection.expired. A succeeded collection carries its fee and net. Verify the signature, then mark the order paid.
  2. Go further. Read Collections, Errors for what can go wrong, Security, and Going live when you are ready.