Scheduled Payments
Schedule payments to execute automatically at a future date and time. Perfect for bill payments, payroll, or any planned disbursements.
Overview
The Scheduled Payments API allows you to create payments that will be automatically processed at a specified future time. Features include:
- Schedule transfers, withdrawals, or bill payments
- Specify exact date and time with timezone support
- Update or cancel scheduled payments before execution
- Receive webhooks when payments are processed
- Track payment status from scheduled to completed
Payment Lifecycle
| Status | Description |
|---|---|
SCHEDULED | Payment is scheduled and waiting for execution time |
PROCESSING | Payment is being executed |
COMPLETED | Payment was successful |
FAILED | Payment execution failed |
CANCELLED | Payment was cancelled before execution |
API Reference
Create Scheduled Payment
Schedule a new payment for future execution. The payment will be automatically processed at the specified time.
Get Scheduled Payment
Retrieve details of a specific scheduled payment.
/partner/scheduled-payments/:scheduledPaymentIdList Scheduled Payments
List all scheduled payments with optional filters.
/partner/scheduled-paymentsUpdate Scheduled Payment
Update a scheduled payment before it's processed. Only payments with status SCHEDULED can be updated.
/partner/scheduled-payments/:scheduledPaymentIdCancel Scheduled Payment
Cancel a scheduled payment. Only payments with status SCHEDULED can be cancelled.
/partner/scheduled-payments/:scheduledPaymentIdCode Examples
Schedule a Payroll Transfer (JavaScript)
1async function schedulePayrollTransfer(walletId, recipientAccount, amount, payDate) {2 const API_KEY = process.env.WASAAPAY_API_KEY;3 const BASE_URL = 'https://api.wasaapay.com/api/v1/partner';45 const response = await fetch(`${BASE_URL}/scheduled-payments`, {6 method: 'POST',7 headers: {8 'Content-Type': 'application/json',9 'X-API-Key': API_KEY,10 'X-Idempotency-Key': `payroll_${payDate}_${recipientAccount}`,11 },12 body: JSON.stringify({13 sourceWalletId: walletId,14 type: 'TRANSFER',15 amount: amount,16 scheduledAt: payDate, // ISO 8601 format17 timezone: 'Africa/Nairobi',18 destinationAccountNumber: recipientAccount,19 externalReference: `PAYROLL-${new Date().toISOString().slice(0,7)}`,20 metadata: {21 paymentType: 'salary',22 payPeriod: new Date(payDate).toISOString().slice(0,7)23 }24 }),25 });2627 const result = await response.json();2829 if (!result.success) {30 throw new Error(result.message);31 }3233 console.log(`Payment scheduled: ${result.data.reference}`);34 console.log(`Will execute at: ${result.data.scheduledAt}`);3536 return result.data;37}3839// Schedule salary for the 25th at 9 AM40const payDate = new Date();41payDate.setDate(25);42payDate.setHours(9, 0, 0, 0);4344schedulePayrollTransfer(45 'wallet_abc123',46 '0712345678',47 50000,48 payDate.toISOString()49).catch(console.error);
Webhooks
Receive notifications when scheduled payments are processed. See the Webhooks documentation for setup.
Scheduled Payment Events
| Event | Description |
|---|---|
scheduled_payment.created | A new scheduled payment was created |
scheduled_payment.processing | Payment execution has started |
scheduled_payment.completed | Payment was successfully processed |
scheduled_payment.failed | Payment execution failed |
scheduled_payment.cancelled | Payment was cancelled |
Best Practices
- Use idempotency keys: Include unique keys to prevent duplicate scheduled payments
- Schedule during business hours: For M-Pesa transactions, schedule during active hours for better success rates
- Monitor webhooks: Set up webhook handlers to track payment outcomes
- Handle failures: Check balance before scheduling and handle insufficient funds gracefully
- Use timezones: Always specify timezone to avoid confusion with execution times