Connect

Act on Behalf

Call the ePay API for a connected business with the ePay-Account header.

Act on Behalf of a Connected Business

Call the normal ePay API with your own secret key and add the ePay-Account header with the connected business's account_id. The request runs as that business: a payment you create is its payment, paid into its wallet.

POST /v1/transactions/initialize HTTP/1.1
Host: api.e-pay.et
Authorization: Bearer sk_live_your_key_here
ePay-Account: acct_9Kd2mQ7xL4pR8sT1
Content-Type: application/json

Request

raw HTTP

Nothing NestJS-specific here — this is the same Node.js client call.

Nothing Django-specific here — this is the same Python client call.

Nothing Flask-specific here — this is the same Python client call.

Nothing FastAPI-specific here — this is the same Python client call.

Nothing Laravel-specific here — this is the same PHP client call.

Nothing Spring Boot-specific here — this is the same Java client call.

curl https://api.e-pay.et/v1/transactions/initialize \
  -X POST \
  -H "Authorization: Bearer sk_live_your_key_here" \
  -H "ePay-Account: acct_9Kd2mQ7xL4pR8sT1" \
  -H "Content-Type: application/json" \
  -H "x-idempotency-key: order_123" \
  -d '{
    "amount": "250.00",
    "currencyCode": "ETB",
    "customerPhone": "+251911234567",
    "merchantReference": "order_123",
    "returnUrl": "https://app.example.com/orders/123/complete"
  }'
const res = await fetch('https://api.e-pay.et/v1/transactions/initialize', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.EPAY_SECRET_KEY}`,
    'ePay-Account': restaurant.epayAccountId, // acct_…
    'Content-Type': 'application/json',
    'x-idempotency-key': `order_${order.id}`,
  },
  body: JSON.stringify({
    amount: '250.00',
    currencyCode: 'ETB',
    customerPhone: '+251911234567',
    merchantReference: `order_${order.id}`,
    returnUrl: `https://app.example.com/orders/${order.id}/complete`,
  }),
});

if (!res.ok) throw new Error(`ePay ${res.status}: ${await res.text()}`);
const { data } = await res.json();
import os

import requests

res = requests.post(
    "https://api.e-pay.et/v1/transactions/initialize",
    headers={
        "Authorization": f"Bearer {os.environ['EPAY_SECRET_KEY']}",
        "ePay-Account": restaurant.epay_account_id,  # acct_…
        "x-idempotency-key": f"order_{order.id}",
    },
    json={
        "amount": "250.00",
        "currencyCode": "ETB",
        "customerPhone": "+251911234567",
        "merchantReference": f"order_{order.id}",
        "returnUrl": f"https://app.example.com/orders/{order.id}/complete",
    },
    timeout=30,
)
res.raise_for_status()
payment = res.json()["data"]
$ch = curl_init('https://api.e-pay.et/v1/transactions/initialize');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('EPAY_SECRET_KEY'),
        'ePay-Account: ' . $restaurant['epay_account_id'], // acct_…
        'Content-Type: application/json',
        'x-idempotency-key: order_' . $order['id'],
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'amount'            => '250.00',
        'currencyCode'      => 'ETB',
        'customerPhone'     => '+251911234567',
        'merchantReference' => 'order_' . $order['id'],
        'returnUrl'         => 'https://app.example.com/orders/' . $order['id'] . '/complete',
    ]),
]);

$body   = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if ($status >= 300) throw new RuntimeException("ePay {$status}: {$body}");
$payment = json_decode($body, true)['data'];
body, _ := json.Marshal(map[string]string{
	"amount":            "250.00",
	"currencyCode":      "ETB",
	"customerPhone":     "+251911234567",
	"merchantReference": "order_" + orderID,
	"returnUrl":         "https://app.example.com/orders/" + orderID + "/complete",
})

req, _ := http.NewRequestWithContext(ctx, http.MethodPost,
	"https://api.e-pay.et/v1/transactions/initialize", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("EPAY_SECRET_KEY"))
req.Header.Set("ePay-Account", restaurant.EpayAccountID) // acct_…
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-idempotency-key", "order_"+orderID)

res, err := http.DefaultClient.Do(req)
if err != nil {
	return err
}
defer res.Body.Close()
if res.StatusCode >= 300 {
	return fmt.Errorf("ePay %d", res.StatusCode)
}
String json = """
    {
      "amount": "250.00",
      "currencyCode": "ETB",
      "customerPhone": "+251911234567",
      "merchantReference": "order_%s",
      "returnUrl": "https://app.example.com/orders/%s/complete"
    }""".formatted(orderId, orderId);

HttpRequest request = HttpRequest.newBuilder(
        URI.create("https://api.e-pay.et/v1/transactions/initialize"))
    .header("Authorization", "Bearer " + System.getenv("EPAY_SECRET_KEY"))
    .header("ePay-Account", restaurant.getEpayAccountId()) // acct_…
    .header("Content-Type", "application/json")
    .header("x-idempotency-key", "order_" + orderId)
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response =
    HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());

Node.js SDK support is coming soon. Switch to for a working example in Node.js today.

Python SDK support is coming soon. Switch to for a working example in Python today.

PHP SDK support is coming soon. Switch to for a working example in PHP today.

Java SDK support is coming soon. Switch to for a working example in Java today.

Go SDK support is coming soon. Switch to for a working example in Go today.

The request and response are exactly those of the endpoint you call — see Initialize a Payment.


Taking an app fee

To earn a fee on the payment, add productFeeAmount (e.g. "25.00") to the body of initialize or direct, or set a default app fee for your app in the dashboard. It's only accepted with the ePay-Account header. See App fees for pricing models, refunds and reporting.


Endpoints available on behalf

A read_write connection can call every endpoint above. Every other endpoint rejects the ePay-Account header — including POST /v1/transactions/sms-link and GET /v1/transactions/:reference/webhook-deliveries.


What you can see

On behalf of a connected business you only see — and can only cancel or refund — payments your app created through that connection. Lists, lookups, receipts and refunds behave as if the business's other payments didn't exist. Payments the business takes itself, or through other apps, are never visible to you.


When calls work

ModeWorks when
Sandbox (sk_test_)Your app is submitted or approved and not disabled or suspended, and the connection isn't suspended. pending_kyb connections and live connections both work in sandbox.
Live (sk_live_)Your app is approved, the connection was made with cp_live_ and is active (the business's KYB is verified), and neither the app nor the connection is suspended.

livemode_enabled on the account tells you whether live calls work right now. A sandbox connection can't be used with sk_live_.


Errors

Problems with the connection return 403 with a code:

{
  "status": "error",
  "data": {
    "code": "insufficient_scope",
    "message": "This connection only allows read access"
  }
}
codeMeaning
account_not_connectedUnknown or empty account ID, not connected to your app, disconnected, or the business can't be used right now.
insufficient_scopeThe endpoint can't be called on behalf, or it needs read_write and the business granted read_only.
connection_suspendedePay suspended this connection.
livemode_not_enabledLive isn't allowed yet: your app isn't approved, the connection is sandbox-only, or the business's KYB isn't verified.
product_disabledYou disabled the app in your dashboard.
product_not_availableePay suspended your app, or it was rejected.
connect_disabledConnect is turned off in this environment.

Errors from the endpoint itself (validation, not found…) are the same as without the header.


Next: App fees

On this page