API reference
Base URL (sandbox): https://sandbox-api.aegispay8.com. Every request except /v1/platform-keys must be signed.
Conventions #
- Request and response bodies are JSON (UTF-8). Unknown fields are rejected, so typos don't pass silently.
- Money is a string with exactly two decimals, e.g.
"150.00". Never a float. - Times are ISO 8601 in UTC, e.g.
2026-11-25T08:00:00.000Z. - IDs have a prefix:
mch_merchant,key_API key,pay_payment,evt_webhook event. - HTTPS only: plain HTTP gets
403 HTTPS_REQUIRED. Maximum body size is 64 KiB. - Errors look like
{"error":{"code":…,"message":…,"request_id":…}}. See Errors.
Test your signing #
Does nothing except check your signature. Use it first. POST /v1/ping (any JSON object body, with an Idempotency-Key) also checks body signing and returns the body_sha256 AegisPay computed.
{
"object": "ping",
"authenticated": true,
"merchant_id": "mch_xxxxxxxxxxxxxxxxxxxx",
"key_id": "key_xxxxxxxxxxxxxxxxxxxx",
"server_time": 1795400000,
"request_id": "req_xxxxxxxxxxxxxxxxxxxx"
}Create a payment #
Creates an FPX or DuitNow QR payment and returns its checkout_url. Requires an Idempotency-Key.
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| amount | string | Yes | Two decimals, "1.00" to "30000.00". |
| currency | string | No | Only "MYR" (the default). |
| method | string | Yes | "fpx" or "duitnow_qr". Must be enabled for your account. |
| merchant_reference | string | Yes | Your order ID. 1–64 chars of A-Z a-z 0-9 . _ : / -. Unique forever per merchant: one payment per reference. |
| description | string | No | Up to 255 printable characters. Shown in your dashboard. |
| customer | object | Yes | The payer. |
| customer.name | string | Yes | 1–100 printable characters. |
| customer.email | string | No | Payer's email address. |
| return_url | string | No | https:// URL where the payer's browser returns, with ?aegis_payment_id=… added. Not proof of payment. |
| callback_url | string | No | https:// URL for this payment's webhooks. Overrides the default in Settings → Webhooks. |
{
"amount": "150.00",
"currency": "MYR",
"method": "fpx",
"merchant_reference": "ORDER-1001",
"description": "Order #1001",
"customer": { "name": "Siti Aminah", "email": "siti@example.com" },
"return_url": "https://shop.example.com/orders/1001/return",
"callback_url": "https://shop.example.com/aegis/webhook"
}Response
201 Created with a payment object. Normally status is pending and checkout_url is set.
{
"object": "payment",
"id": "pay_7Hq2xK9mN4pR8sT1aB3c",
"status": "pending",
"amount": "150.00",
"currency": "MYR",
"method": "fpx",
"merchant_reference": "ORDER-1001",
"description": "Order #1001",
"fee": "2.25",
"net_amount": "147.75",
"checkout_url": "https://sandbox-api.aegispay8.com/c/pay_7Hq2xK9mN4pR8sT1aB3c",
"expires_at": "2026-11-25T08:15:00.000Z",
"paid_at": null,
"created_at": "2026-11-25T08:00:00.000Z",
"updated_at": "2026-11-25T08:00:01.000Z"
}| Status / code | When | What to do |
|---|---|---|
| 409 DUPLICATE_MERCHANT_REFERENCE | A payment with this merchant_reference exists. | Use GET to find it, or a new reference for a new attempt. |
| 422 METHOD_NOT_ENABLED | The method isn't enabled for your account. | Ask AegisPay or your agent. |
| 422 AMOUNT_TOO_SMALL | The amount doesn't cover the fee. | Use a larger amount. |
| 503 PROVIDER_UNAVAILABLE | The bank network didn't answer in time; outcome unknown. | Retry with the SAME Idempotency-Key. |
| 502 PROVIDER_REJECTED | The bank network refused it; the payment is failed. | New payment, new merchant_reference. |
Examples
const { status, body } = await aegis.createPayment(
{
amount: "150.00",
method: "fpx",
merchant_reference: "ORDER-1001",
customer: { name: "Siti Aminah", email: "siti@example.com" },
return_url: "https://shop.example.com/orders/1001/return",
},
"order-1001-create", // Idempotency-Key
);
if (status === 201) redirectBrowserTo(body.checkout_url);import json, requests
from aegis1 import sign_request, verify_response
body = json.dumps({
"amount": "150.00", "method": "fpx", "merchant_reference": "ORDER-1001",
"customer": {"name": "Siti Aminah"}, "return_url": "https://shop.example.com/orders/1001/return",
}, separators=(",", ":")).encode() # serialise once; send these exact bytes
headers = sign_request(PRIVATE_KEY_PEM, method="POST", host="sandbox-api.aegispay8.com", path="/v1/payments",
merchant_id=MERCHANT_ID, key_id=KEY_ID, body=body, idempotency_key="order-1001-create")
headers["Content-Type"] = "application/json"
r = requests.post("https://sandbox-api.aegispay8.com/v1/payments", data=body, headers=headers, allow_redirects=False)
ok = verify_response(PLATFORM_KEYS, status=r.status_code, method="POST", path="/v1/payments", merchant_id=MERCHANT_ID,
request_nonce=headers["X-Aegis-Nonce"], headers=r.headers, body=r.content)
if not ok:
raise RuntimeError("Unverified response: outcome unknown, retry with the same Idempotency-Key")
payment = r.json()Retrieve a payment #
Returns your payment by its pay_… ID: the source of truth for its status. Use it on your return page, when a webhook seems late, or to reconcile. Other merchants' payments return 404 PAYMENT_NOT_FOUND.
const { status, body: payment } = await aegis.getPayment("pay_7Hq2xK9mN4pR8sT1aB3c");
if (status === 200 && payment.status === "succeeded" && payment.amount === order.amount) {
// fulfil
}200 OK with a payment object.
The payment object #
| Parameter | Type | Required | Description |
|---|---|---|---|
| object | string | Yes | Always "payment". |
| id | string | Yes | AegisPay payment ID, pay_…. |
| status | string | Yes | processing, pending, succeeded, failed or expired. See statuses. |
| amount | string | Yes | Amount the payer pays. |
| currency | string | Yes | "MYR". |
| method | string | Yes | fpx or duitnow_qr. |
| merchant_reference | string | Yes | Your order ID, as sent. |
| description | string | null | Yes | As sent. |
| fee | string | Yes | AegisPay's fee, fixed at creation. |
| net_amount | string | Yes | amount − fee: what you receive if it succeeds. |
| checkout_url | string | null | Yes | Where to send the payer. Set only while pending and not expired. |
| expires_at | string | null | Yes | When the payer can no longer pay. |
| paid_at | string | null | Yes | When it succeeded. |
| created_at | string | Yes | Creation time. |
| updated_at | string | Yes | Last change. |
AegisPay's public keys #
Public, no signature needed. Returns the keys AegisPay signs responses and webhooks with. Fetch once and pin them; don't fetch on every request (limit: 120 per minute per IP).
{
"object": "list",
"algorithm": "RSASSA-PSS-SHA256 (MGF1-SHA256, salt 32)",
"keys": [
{
"key_id": "aegis_xxxxx",
"status": "active",
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkq...\n-----END PUBLIC KEY-----\n",
"created_at": "2026-11-23T00:00:00.000Z"
}
]
}Idempotency #
Every POST needs an Idempotency-Key. Use one key per business operation (e.g. order-1001-create) and reuse it when you retry after a timeout or network error. Each retry still needs a fresh nonce, timestamp and signature.
| Situation | Result |
|---|---|
| First request with this key | Processed normally. |
| Same key + same request, first one finished | The original response, returned again (re-signed for your new request). |
| Same key while the first is still running | 409 IDEMPOTENCY_IN_PROGRESS: wait a moment and retry. |
| Same key, different body or path | 422 IDEMPOTENCY_KEY_REUSED |
Keys are kept for 24 hours. merchant_reference is unique forever, so an order can never be charged twice.