Skip to main content

Payouts (B2C) API

Payouts API is an API used to make payments from a Business (Payouts) to Customers, Partners and Suppliers among others. Example use cases, among many
  • Salary payments
  • Lottery winnings payouts
  • Financial institutions funds withdrawals
  • Loans disbursements
  • Suppliers payments

Transaction flow description:

  • The Payout originator (Client) sets all the required parameters for the payout request and sends it to:
  1. POST https://sandbox.api.gateway.kasapay.com/v1/payouts/initiate for local payouts
  2. POST https://sandbox.api.gateway.kasapay.com/v1/payouts/imt/initiate for International Money Transfers
  • The request is validated and an acknowledgement is sent before proceeding with processing.
  • GATEWAY Payouts service receives the request, validates it and proceeds with processing
  • GATEWAY Payouts service then sends the payout result back to the payout originator (Client) via the callback URL created on our system. (URL Type: B2C Notifications)
  • GATEWAY Payouts service sends an SMS notification to the customer on the payments received.

NOTE :

  1. For you to use this API on production you are required to complete onboarding, fund your FLOAT Wallet and obtain production API Keys from https://dashboard.kasapay.com Settings>API Keys section
  2. For sandbox testing, test funds will be availed in your sandbox Float account. Use sandbox API Keys from https://sandbox.dashboard.kasapay.com Settings>API Keys section

Authentication

All requests made to GATEWAY Payouts APIs will require token authentication. Authentication requests are send to:

POST https://sandbox.api.gateway.kasapay.com/v1/auth

Authentication Request body

{
"consumer_key": "Xjpe948ixgdhlUrRNlOwc",
"consumer_secret": "hNjZK2JVm4Uc1whgskjsiY9G"
}

Response Body

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiIxNiIsImRlc2lnbmF0aW9uIjoiQXBpIFVzZXIiLCJhdXRob3JpemVkIjp0cnVlLCJpYXQiOjE2Nzc3MDY4ODgsImV4cCI6MTY3NzcxMjg4OH0.kADugWTjIrXokYYhDTXg4idmsLy6pUTv6N0Hi-ZMkrI",
"expiresIn": 6000
}

Use the token returned under access_token for all requests made to the Payouts APIs. The token should be passed as a Request Header x-access-token. The token will be valid for up to 1 hour.

Create Float Account

Endpoints:

  1. Sandbox: POST https://sandbox.api.gateway.kasapay.com/v1/accounts
  2. Live: POST https://api.gateway.kasapay.com/v1/accounts

Request Payload

{
"name":"Fred Delivery",
"currency":"KES"
}

Request Parameters Description

ParameterDescription
nameName of the float account
currencyFloat account currency

Response Payload

{
"name": "Test Account Creation",
"code": "FLO_DEMO_KES_XJB",
"account_number": "10000198"
}

Response parameters definition

ParameterDescription
nameName of the float account
codeFloat account unique code for use with payouts API requests
account_numberFloat account number

Float Account Balance

Endpoints:

  1. Sandbox: GET https://sandbox.api.gateway.kasapay.com/v1/accounts/{{account_number}}/balance
  2. Live: GET https://api.gateway.kasapay.com/v1/accounts/{{account_number}}/balance

Float account balance request response

{
"balance": "110.00",
"currency":"KES",
"status":"ACTIVE"
}

Response parameters definition

ParameterDescription
balanceFloat account available balance
currencyFloat account currency
statusFloat account balance

Payouts Destination Types

The gateway supports payouts to the following destinations. They are to be used as they are in the subsequent sections.

DestinationDescription
MOBILEPayouts to MOBILE MONEY wallets
BANKPayouts to bank accounts

Payout Types

The gateway supports payouts to the following destinations:

  1. Local B2C Payouts
  2. International Money Transfer

Local B2C Payouts

These are disbursements made to Kenyan mobile money wallets accounts.

Send Money Locally This endpoint allows you to submit a local payout request

Endpoint
https://sandbox.api.gateway.kasapay.com/v1/payouts/initiate
Method
POST
Header
key : x-access-token
value : <access_token_from_auth>

Request Body

{
"payout_reference": "134526781672", //Required
"wallet_account": "TEST", //Required
"service_code": "TEST", //Required
"recipient_first_name": "John", // Required
"recipient_last_name": "Doe", // Required
"destination_type": "MOBILE", // Required MOBILE or BANK
"destination_name":"MPESA_KEN", // Required
"recipient_phone_number": "254*******98", // Required
"recipient_account_number": "25626252525",// Required
"recipient_bank_code":"XYZ", //Required if destination_type is BANK
"recipient_account_name": "John Doe", // Required
"source_currency":"KES", // Required
"destination_currency": "KES", // Required
"exchange_rate": "1", // Required
"sender_amount": "100", // Required
"recipient_amount": "100", // Required
"payment_description": "Salary Payment", // Required
"callback_url": "https://payouts.com/result" // Required
}

Request Parameters Description

ParameterDescriptionParameter TypeSample ValuesRequired
payout_referenceMerchant generated Payout ReferenceStringf4401bd2Yes
wallet_accountWallet Account to make payouts from (Obtain from https://dev.dashboard.kasapay.com Wallets Section)StringKASAPAYWALLETYes
service_codeGATEWAY provided client-service code(Obtain from dashboard https://dev.dashboard.kasapay.com Settings > Services )StringCLIENTX_PAYOUTSYes
recipient_first_nameName of the payment recipientStringSupplier JobYes
recipient_last_nameRecipient First NameStringJohnYes
destination_typeGATEWAY defined destination types. Refer to Destination types sectionEnummobile_money_walletYes
mobile_money_operatorThe MNO of the recipient mobile money wallet(Refer to Mobile Money Operators section)EnumMPESA_KENYes
source_currencyFloat account currencyStringKES (Currency ISO code)Yes
destination_currencyMobile money wallet currencyStringKES (Currency ISO Code)Yes
sender_amountTotal Amount to be sent to receiverNumber100Yes
exchange_rateFX RatesDouble1Yes
recipient_amountThe amount the recipient recipientDouble100Yes
payment_descriptionPayout narrationStringSalary PaymentYes
callback_urlEndpoint to receive transaction resultstringhttps://payouts.com/resultYes

Response Body

{
"payout_reference": "134526781672",
"response_code": 720,
"response_description": "Payout request has been accepted for processing"
}

Response Parameters Description

ParameterDescription
payout_referencePayout Originator reference
response_codeGATEWAY Request acknowledgement code. Refer to Payouts Response Codes section
response_descriptionAcknowledgement description

Error Response Body

{
"payout_reference": "ms8367839",
"response_code": 722,
"response_description": "Payout with that reference exists",
"error_code": "DUPLICATE_IGNORED"
}

Error Response Parameters Description

ParameterDescription
payout_referencePayout Originator generated payout reference
response_codeGATEWAY Request acknowledgement code. Refer to Payouts Response Codes section
response_descriptionAcknowledgement description
error_codeRequest error code. Refer to Payouts Error Codes section

International Money Transfers

These are are cross border remmitance requests

Endpoint
https://sandbox.api.gateway.kasapay.com/v1/payouts/imt/initiate
Method
POST
Header
key : Authorization
value : <access_token_from_auth>

Request body

{
"payout_reference": "123245617892", //Required
"wallet_account": "TEST", // Required
"service_code": "TEST", // Required
"sender_first_name": "Fred", // Required
"sender_middle_name": "", // Optional
"sender_last_name": "Mtembezi", // Required
"sender_type": "INDIVIDUAL", // Required INDIVIDUAL or COMPANY
"sender_document_type": "National ID", // Optional
"sender_document_number": "xxxxxxxxxx", // Optional
"sender_country_code": "KEN", // Required
"sender_phone_number": "25400000000", // Optional
"recipient_first_name": "Fred", // Optional
"recipient_middle_name": "", // Optional
"recipient_last_name": "Mtembezi", // Optional
"recipient_type": "INDIVIDUAL", // Required INDIVIDUAL or COMPANY
"recipient_document_type": "ID", // Optional
"recipient_document_number": "xxxxxxxxx", // Optional
"recipient_phone_number": "25400000000", // Required
"recipient_account_number": "25400000000", // Required
"recipient_account_name": "John Mtembezi", // Required
"recipient_occupation": "Student", // Required
"destination_type": "MOBILE", // Required MOBILE Or BANK
"destination_name": "MPESA_KEN", // Required
"recipient_bank_code": "TEST", //Required if destination type is BANK
"source_currency": "KES", // Required
"destination_currency": "KES", // Required
"income_source": "Employment", // Required
"fund_purpose": "SCHOOL FEES", // Required
"exchange_rate": "1", // Required
"sender_amount": "100", // Required
"recipient_amount": "100", // Required
"payment_description": "School fees disbursement", // Required
"callback_url": "https://payouts.com/result" // Optional
}

Request Parameters Description

ParameterDescriptionParameter TypeSample ValuesRequired
payout_referencePayout originator defined payout referenceStringysus-teyhd-udhYes
wallet_accountFloat Account name to make payouts from (Obtain from https://dev.dashboard.kasapay.com Wallets Section)StringFLO_TEST-WT3SS5DYes
service_codeGATEWAY provided client-service code(Obtain from dashboard https://dev.dashboard.kasapay.com Settings > Services )StringCLIENTX_PAYOUTSYes
destination_typeGATEWAY defined destination types. Refer to Destination types sectionEnumbank_accountYes
destination_nameTerminal service provider nameStringMPESAYes
sender_first_nameSender first nameStringJohnYes
sender_middle_nameSender Middle NameStringDoeNo
sender_last_nameSender Last NameStringDoeYes
sender_typeSender TypeStringINDIVIDUALYes
sender_document_typeType of document for sender identificationStringNational IDNo
sender_document_numberDocument number for sender document typeString12345No
sender_country_codeCountry code for senderStringKESYes
sender_phone_numberPhone number of the senderStringYes
recipient_first_nameRecipient first nameStringJohnYes
recipient_middle_nameRecipient middle nameStringJohnNO
recipient_last_nameRecipient last nameStringJohnYes
recipient_typeRecipient categoryStringINDIVIDUALYes
recipient_document_typeType of document for identifying the payerStringNational IDNO
recipient_document_typeDocument number for the recipient document typeStringXXXXXXXXNO
recipient_phone_numberPhone number of the recipientString010000000Yes
recipient_account_numberAccount number of the recipientString010000000Yes
recipient_account_nameFull name of the recipientStringFred MtembeziYes
recipient_occupationOccupation of the recipientStringStudentYes
destination_typeType of destination (e.g., bank or mobile wallet)StringMOBILEYes
destination_nameName of the destination (e.g., M-Pesa, Bank name)StringMPESA_KENYes
recipient_bank_codeBank code of the recipient's bank (if applicable)StringKENBANKYes
source_currencyCurrency of the sender's transactionStringKESYes
destination_currencyCurrency in which the recipient receives the fundsStringKESYes
income_sourceSource of income for the senderStringEmploymentYes
fund_purposePurpose of the funds being sentStringSCHOOL FEESYes
exchange_rateExchange rate applied to the transactionString1Yes
sender_amountAmount being sent by the senderString100Yes
recipient_amountAmount received by the recipient after conversionString100Yes
payment_descriptionDescription of the paymentStringPayment for pending billsYes
callback_urlURL where transaction status updates will be sentStringhttps://payouts.api/resultYes

Response Body

{
"payout_reference": "123245617892",
"response_code": 720,
"response_description": "Payout request has been accepted for processing"
}

Response Parameters Description

ParameterDescription
payout_referencePayout Originator generated payout reference
response_codeGATEWAY Request acknowledgement code. Refer to Payouts Response Codes section
response_descriptionAcknowledgement description

Error Response Body

{
"payout_reference": "ms8367839",
"response_code": 722,
"response_description": "Payout with that reference exists",
"error_code": "DUPLICATE_IGNORED"
}

Error Response Parameters Description

ParameterDescription
payout_referencePayout Originator generated payout reference
response_codeGATEWAY Request acknowledgement code. Refer to Payouts Response Codes section
response_descriptionAcknowledgement description
error_codeRequest error code. Refer to Payouts Error Codes section

Callbacks

After a disbursement processing is completed, the disbursements service sends the result to the callback endpoint provided.

NOTE:

  1. Do not rely entirely on webhooks for payouts status. Use the GATEWAY Payouts Status API to verify a Payout Status.
  2. Acknowledge webhook receipt with a 200 http status code. Any non 200 Status code will be treated as a non-acknowledge and webhooks will be re-tried 3 times over the next 48 hours after which no further webhooks will be sent.

Callback Payload

{
"payout_reference": "ms83-367839",
"destination": "bank_account",
"data": {
"reference":"TLZYTFVAGHG"
"payment_status": 700,
"amount": "100.00",
"currency": "KES",
"account_number": "08292******849",
"destination_name":"BANKX",
"payout_description": "Test bank transfer",
"transaction_time": "2023-03-02T05:17:36.802Z",
"bank_code": "AD",
"result_description": "Payout was processed successfully"
"recipient_first_name": "Doe",
"recipient_middle_name":"",
"recipient_last_name": "John",
"recipient_phone_number":"01000000000"
}
}

Payout Result Parameters description

ParameterParameter DescriptionScope
payout_referencePayout Originator defined reference provided at payout requestAll
destinationPayout intended destinationAll
data.payment_statusPayout result. See Payouts Payment status codes SectionAll
data.amountPayout amountAll
data.currencyPayout destination currencyAll
data.recipient_phone_numberMOMO wallet phone numberAll
data.recipient_first_nameFirst name of RecipientAll
data.recipient_middle_nameRecipient middle nameAll
data.recipient_last_nameLast name of recipientAll
data.payout_descriptionPayout NarrationAll
data.transaction_timeDate payout was createdAll
data.destination_nameGATEWAY defined momo wallets providers IDs. Refer to Mobile Money Operators sectionAll
data.messageResult descriptionAll
data.account_numberRecipient bank or Mobile Money account numberAll
data.bank_codeRecipient bank pesalink codeBANK

Payout Status

For status verification or in the event when result callbacks fail, the Payout Status API can be employed. Requests to check payout status are sent to

GET https://sandbox.api.gateway.kasapay.com/v1/payouts/{payout_reference}/status

Payout Status Response Body

{
"payout_reference": "ms83-367839",
"destination": "bank_account",
"data": {
"reference":"TLZYTFVAGHG"
"payment_status": 700,
"amount": "100.00",
"currency": "KES",
"account_number": "08292******849",
"destination_name":"BANKX",
"payout_description": "Test bank transfer",
"transaction_time": "2023-03-02T05:17:36.802Z",
"bank_code": "AD",
"result_description": "Payout was processed successfully"
"recipient_first_name": "Doe",
"recipient_middle_name":"",
"recipient_last_name": "John",
"recipient_phone_number":"01000000000"
}
}

Payout Status Response Parameters Description NOTE: The Payout Status API Response Parameters are the same as callback result Parameters. Please refere to the Callbacks section for guidance

Payouts Response Codes

See below definition for the payout request-response codes

CodeDescription
720Payout request has been validated and accepted for processing
721Payout request is rejected for failing to meet certain criteria. See response_description and Error Code for more information
722Duplicate ignored code. A payout with the same response has already been submitted for processing
723Payout record not found for Status API - No payout record matches the reference provided

Payouts Error Codes

See below definitions for payouts error codes. These error codes serve to give more information on why a payout request was rejected.

CodeDescription
INSUFFICIENT_BALANCEFloat account does not have sufficient funds to complete the payout request
SERVICE_NOT_ALLOWEDPayouts service is forbidden for the originating client
INVALID_ACCESS_TOKENInvalid authentication token
INVALID_DESTINATION_TYPEThe destination type specified is not supported by GATEWAY Payouts service
INVALID_PHONE_NUMBERPhone number validation failed
INVALID_PAYMENT_METHODPayment method requested is not supported by GATEWAY Payouts service
INVALID_WALLETWallet provided does not exist
UNAUTHORIZEDGeneric authentication failure
RESOURCE_NOT_FOUNDGeneric resource not found error
DUPLICATE_IGNOREDDuplicate submission errror
FAILEDGeneric service outage error

Payout-Payment Status Codes

See below descriptions for various payouts payment status.

CodeDescription
700Payout was processed successfully
701Payout processing failed
702Payout processing was reversed
703Payout processing is Pending
704Payout processing is Jammed - Requires Manual intervention