Purchase electricity
X-API-KeyPOST
/electricity/purchaseVend prepaid / postpaid electricity. Pending purchases return 201 — poll GET /transactions/{id}.
Language
curl -X POST "https://api.vendpower.ng/api/v1/electricity/purchase" \
-H "X-API-Key: YOUR_X_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"disco_code": "IKDC",
"meter_type": "PREPAID",
"meter_number": "12345678901",
"amount": 2000,
"customer_phone": "08031234567",
"idempotency_key": "VP_UNIQUE_KEY_001"
}'Authentication
Send your approved API key on every request. Keep it on your server only.
| Header | Value | Required |
|---|---|---|
| X-API-Key | YOUR_X_API_KEY | Yes |
| Content-Type | application/json | Yes |
| Accept | application/json | Recommended |
Authentication failures (401 / 403 / 429) are listed in Authentication.
Parameters
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
| disco_code | string | Yes | From GET /electricity/discos |
| meter_type | string | Yes | PREPAID or POSTPAID |
| meter_number | string | Yes | Validated meter number |
| amount | number | Yes | Face amount in NGN |
| customer_phone | string | Yes | Customer phone |
| idempotency_key | string | Yes | Your unique purchase key (recommended VP…). Re-sending the same key returns 409 with the original transaction — never charges twice. |
Responses
200 OK — Success · 201 Created — Pending
{
"success": true,
"message": "Electricity purchase completed successfully.",
"data": {
"id": 101,
"reference": "VP_UNIQUE_KEY_001",
"idempotency_key": "VP_UNIQUE_KEY_001",
"status": "success",
"category": "electricity",
"amount": 2000,
"charge": 2000,
"token": "1234-5678-9012-3456",
"units": "45.2"
}
}Errors
Errors specific to this endpoint, in addition to common authentication and validation failures.
| Code | HTTP | When |
|---|---|---|
| VALIDATION_ERROR | 422 | Request body failed validation or business rules. |
| INSUFFICIENT_BALANCE | 400 / 402 | Wallet balance is too low for this purchase. |
| DUPLICATE_IDEMPOTENCY | 409 | This idempotency_key was already used — requery the returned transaction. |
| SERVICE_UNAVAILABLE | 503 | Upstream provider or service is temporarily unavailable. |
Notes
- Pending purchases return HTTP 201 — poll
GET /transactions/{id}untilsuccess,failed, orrefunded.