Webhooks
If your own systems confirm disbursements/collections after the fact rather than synchronously (common for real bank settlement), you can notify OfficeUG of the final outcome via a webhook instead of expecting an immediate answer in the original API response.
POST /webhooks/{partner_slug}{partner_slug} is a value specific to your partner registration — you'll be given this alongside your credentials.
A separate secret
Webhooks are signed with a webhook_secret, never your api_secret. They're deliberately independent: a leaked webhook secret can never be used to call the API, and a leaked API secret can never be used to forge a webhook.
Required headers
| Header | Description |
|---|---|
X-Webhook-Timestamp |
Unix timestamp (seconds). Must be within 5 minutes of the server's clock. |
X-Webhook-Signature |
HMAC-SHA256 signature, hex-encoded. |
Building the signature
Simpler than the main API's signature — no method or path involved, just the timestamp and raw body:
canonical_string = "{timestamp}|{raw_request_body}"
signature = HMAC_SHA256(canonical_string, your_webhook_secret)Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
external_reference |
string | yes | Must match the external_reference you originally sent on the disbursement or collection call. |
status |
string | yes | completed or failed. |
failure_reason |
string | no | Only meaningful when status is failed. |
Only pending operations can be finalised
A webhook transitions an operation from pending to completed/failed once. If the operation is already finalised — because a duplicate webhook arrived, a retry replayed within the timestamp window, or the operation completed synchronously at creation — the webhook is acknowledged with 200 and the operation's current state in data.status, and nothing changes. Your retry loops terminate cleanly, and a late or duplicated webhook can never flip a settled operation (and the money movement it represents) into the opposite state. Compare data.status against what you sent if you need to detect this case.
Example request
TIMESTAMP=$(date +%s)
BODY='{"external_reference":"LOAN-8841","status":"completed"}'
SIGNATURE=$(printf '%s' "${TIMESTAMP}|${BODY}" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | sed 's/^.* //')
curl -X POST "https://prodsacco.officeug.com/api/partner/v1/webhooks/your-partner-slug" \
-H "X-Webhook-Timestamp: $TIMESTAMP" \
-H "X-Webhook-Signature: $SIGNATURE" \
-H "Content-Type: application/json" \
-d "$BODY"
<?php
$body = json_encode(['external_reference' => 'LOAN-8841', 'status' => 'completed']);
$timestamp = (string) time();
$signature = hash_hmac('sha256', "{$timestamp}|{$body}", $webhookSecret);
$ch = curl_init('https://prodsacco.officeug.com/api/partner/v1/webhooks/your-partner-slug');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Webhook-Timestamp: {$timestamp}",
"X-Webhook-Signature: {$signature}",
'Content-Type: application/json',
],
]);
echo curl_exec($ch);
import json
body = json.dumps({"external_reference": "LOAN-8841", "status": "completed"})
timestamp = str(int(time.time()))
signature = hmac.new(webhook_secret.encode(), f"{timestamp}|{body}".encode(), hashlib.sha256).hexdigest()
response = requests.post(
"https://prodsacco.officeug.com/api/partner/v1/webhooks/your-partner-slug",
data=body,
headers={
"X-Webhook-Timestamp": timestamp,
"X-Webhook-Signature": signature,
"Content-Type": "application/json",
},
)
print(response.json())
const body = JSON.stringify({ external_reference: 'LOAN-8841', status: 'completed' });
const timestamp = Math.floor(Date.now() / 1000).toString();
const signature = crypto.createHmac('sha256', webhookSecret).update(`${timestamp}|${body}`).digest('hex');
const response = await fetch('https://prodsacco.officeug.com/api/partner/v1/webhooks/your-partner-slug', {
method: 'POST',
body,
headers: {
'X-Webhook-Timestamp': timestamp,
'X-Webhook-Signature': signature,
'Content-Type': 'application/json',
},
});
console.log(await response.json());
Example response
{
"success": true,
"message": "OK",
"data": { "operation_id": 412, "status": "completed" },
"request_id": "..."
}Errors specific to webhooks
| HTTP | error_code | Meaning |
|---|---|---|
| 404 | UNKNOWN_PARTNER |
The {partner_slug} doesn't match a registered, active partner with webhooks configured. |
| 401 | MISSING_SIGNATURE |
X-Webhook-Timestamp/X-Webhook-Signature headers missing. |
| 401 | WEBHOOK_EXPIRED |
Timestamp more than 5 minutes from the server's clock. |
| 401 | INVALID_SIGNATURE |
Signature didn't match. |
| 404 | OPERATION_NOT_FOUND |
No disbursement/collection was found matching this external_reference. |