Skip to content

Reference ​

Exports ​

ExportKindDescription
createMpesafunctionCreates a client (Mpesa) from an MpesaConfig.
MemoryTokenStoreclassThe default in-memory TokenStore.
parseStkCallback, parseResult, parseC2BNotification, parseBalancesfunctionCallback parsers.
c2bValidationResponseobjectBuilds C2B validation replies.
MpesaError, ValidationError, AuthError, DarajaApiError, NetworkErrorclassErrors.
Mpesa, MpesaConfig, Environment, InitiatortypeThe client, its configuration and credentials.
TokenStore, CachedTokentypeThe token store interface and its value.
StkPushApi, StkPushInput, StkPushResponse, StkQueryInput, StkQueryResponsetypeM-Pesa Express.
C2BApi, C2BRegisterInput, C2BSimulateInput, C2BResponsetypeC2B.
B2CApi, B2CInput, B2CCommandtypeB2C; B2CCommand is the commandId union.
TransactionStatusApi, TransactionStatusInputtypeTransaction Status.
AccountBalanceApi, AccountBalanceInputtypeAccount Balance.
ReversalApi, ReversalInputtypeReversal.
InitiatorResponsetypeThe acknowledgement from the four initiator APIs.
IdentifierTypetype'shortcode' | 'till' | 'msisdn', for identifierType.
StkCallback, StkCallbackMetadata, DarajaResult, C2BNotification, AccountBalanceEntry, C2BValidationResponse, C2BRejectionCodetypeCallback parser results and the validation reply.
ValidationIssuetypeOne entry of ValidationError.issues: { path, message }.

Responses ​

Every call returns camelCase fields plus raw, Daraja's unmodified response body.

CallReturns (type)
stkPush.sendStkPushResponse: merchantRequestId, checkoutRequestId, responseCode, responseDescription, customerMessage
stkPush.queryStkQueryResponse: merchantRequestId, checkoutRequestId, responseCode, responseDescription, resultCode, resultDesc
c2b.registerUrls, c2b.simulateC2BResponse: originatorConversationId, responseCode, responseDescription
b2c.pay, transactionStatus.query, accountBalance.query, reversal.requestInitiatorResponse: conversationId, originatorConversationId, responseCode, responseDescription

Released under the MIT License.