Getting MPESA API Credentials

To integrate MPESA with your plugin or application, you need to obtain MPESA API credentials. These credentials allow your application to securely communicate with MPESA’s services. Here’s a step-by-step guide on how to get MPESA API credentials:


To start integrating MPESA’s payment services with your application, you need to obtain API credentials from Safaricom. These credentials include the API Key, API Secret, and other required information. Follow these steps to get your MPESA API credentials.

Step-by-Step Guide

1. Register as a Safaricom Developer

  1. Sign Up: Go to the Safaricom Developer Portal. If you do not have an account, you need to sign up.
  2. Fill Out the Registration Form: Provide your details such as name, email address, phone number, and organization information.
  3. Verify Your Email: Safaricom will send a verification email. Click the verification link to activate your account.

2. Create a New Application

  1. Log In: Log in to the Safaricom Developer Portal using your credentials.
  2. Navigate to My Apps: Go to the My Apps section from the dashboard.
  3. Create New App: Click on the Create New App button.
  4. Fill Application Details:
  • Application Name: Enter a name for your application.
  • Description: Provide a brief description of what your application does.
  • Website URL: Enter the URL of your website (if applicable).
  • Callback URL: Enter the URL where Safaricom should send notifications about transactions. This URL is crucial for handling transaction status updates.
  1. Select APIs: Choose the APIs you need (e.g., Payment API, C2B API, B2C API).
  2. Submit: Click the Submit button to create your application.

3. Obtain API Credentials

Once your application is created, you will receive the following API credentials:

  1. API Key: A unique identifier for your application.
  2. API Secret: A secret key used in conjunction with the API Key to authenticate API requests.
  3. Shortcode: A unique identifier for the MPESA account used to receive payments.
  4. Shortcode Secret: A secret associated with the shortcode for secure transactions.

4. Configure Your Application

  1. Set Up Your Application: Use the obtained API credentials to configure your application or plugin.
  2. Add API Credentials: Enter the API Key, API Secret, Shortcode, and Shortcode Secret into your application’s configuration settings.

5. Test Your Integration

  1. Use Sandbox Environment: Safaricom provides a sandbox environment for testing. Use the sandbox credentials to test your integration before going live.
  2. Perform Test Transactions: Execute test transactions to ensure that your integration is working correctly and that you can handle responses and errors.

6. Go Live

  1. Request Production Credentials: Once testing is complete, you will need to request production credentials from Safaricom.
  2. Update Your Application: Replace the sandbox credentials with the production credentials in your application’s configuration.
  3. Verify and Monitor: Monitor transactions and ensure that everything is functioning correctly in the live environment.

Troubleshooting

  • Missing Credentials: Ensure you have followed all steps and that you have received all required credentials.
  • Invalid Requests: Double-check the credentials and ensure they are correctly configured in your application.

Contact Support

If you encounter any issues or have questions regarding MPESA API credentials, you can contact Safaricom’s support team through the Safaricom Developer Portal.


This guide should help you obtain and configure your MPESA API credentials effectively. Make sure to follow Safaricom’s documentation and best practices for a smooth integration process.

Leave a Reply

Chat with us 1