Skip to content

Quick start

This guide takes you from a developer account to your first charge, in the sandbox: no real money is used. The examples are provided in cURL, JavaScript (Node.js 18 or later), Python (requests library) and PHP (cURL extension). Your language choice is remembered on every page.

  1. Create your developer account on the developer dashboard (the “Developer space”): full name, company (optional), phone, email and password, then accept the terms of use. Once your email address is confirmed, your test key is available.

    Store it in an environment variable, never in your code:

    Terminal window
    export SAMA_API_KEY="YOUR_TEST_KEY"
  2. Check the connection to the API:

    Terminal window
    curl -sS https://api.sama.money/v1/health/auth \
    -H "Authorization: Bearer $SAMA_API_KEY"

    Expected response:

    {"status":"ok","mode":"test"}

    An error response means the Authorization header is missing, or the key is badly copied.

  3. Create a first charge: you ask for 5,000 F from a test customer. In the sandbox, the charge stays pending (pending) until the customer confirms it on their phone.

    Terminal window
    curl -sS -X POST https://api.sama.money/v1/charges \
    -H "Authorization: Bearer $SAMA_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
    "client_phone": "22370000000",
    "amount_xof": 5000,
    "description": "Order 42"
    }'

    The API answers 200 with the pending charge:

    {
    "reference": "chg_8f3a1c9e2b7d4e60a1c3",
    "object": "charge",
    "mode": "test",
    "amount_xof": 5000,
    "currency": "XOF",
    "client_phone": "22370000000",
    "status": "pending",
    "description": "Order 42",
    "partner_reference": null,
    "account": null,
    "error_message": null,
    "created": 1790848800
    }

    Keep the reference: it identifies the charge in GET /v1/charges/{reference}. Other fields may be added to the response: ignore the ones you do not know.

For what comes next (registering the address that receives your notifications, simulating the customer’s confirmation in the sandbox, reading back the state of a charge), see the Reference, reserved for registered developers. To go live: Accounts and verification.

  • Idempotency: send an Idempotency-Key header (one UUID per operation) on every money-moving operation. Replaying the same request with the same key returns the same result.
  • Amounts: integers in CFA francs (amount_xof), with no decimals.
  • Asynchronous: the customer confirms, not you. Never ship an order for a request that is still pending: wait for the notification or read GET /v1/charges/{reference} again.