API keys and webhooks

Edited

APIs make it possible for different applications or systems to communicate and share data with each other efficiently. In our case, Paystack's APIs allow your website or mobile app to communicate and share data with Paystack's server.

Because APIs allow our server to share data with your website or mobile app when you make a request, we need to be able to confirm that you are the one making a request from your website. This is where API Keys come into play. When your website sends or requests data from Paystack servers, it must send the data along with the API Keys from your Dashboard. If the API keys aren’t included, the request will be denied.

When you sign up on Paystack, we encourage you to test our platform to fully understand the payment flow before you begin accepting real payments. This is why we have Test Mode available. You can carry out transactions using our test payment details in Test Mode.


Test API Keys

To get your Test API keys, go to your Dashboard Settings page and click the API Keys & Webhooks tab to get your Test API Keys. Scroll to where it says ’API Configuration - Test Mode,’ and you’ll find your Test Secret Key and Test Public Key as seen below:

test keys page.gif

After you're done testing and are satisfied with your integration, you'll need your Live API Keys to be able to receive real money from your customers.

To view your secret keys, click on the eye icon beside it. You’ll be prompted to fill in your account password, after which you’ll see the key.


Live API Keys

To get your Live API Keys, go to your dashboard settings and click the API Keys & Webhooks tab.  Scroll to where it says ’API Configuration - Live Mode,’ here you will find your Live Secret Key and Live Public Key as captured below:

live mode.png

You can only toggle to Live Mode if your account has been activated. Learn more about how to activate your business here.


Generating new API keys

If you need to generate new API keys for your business, you can do so from your Dashboard with a few clicks. This lets you deactivate your secret key and get a new one instantly. You may find this particularly useful if your secret key has been accidentally shared or compromised in any other way.

Once you've generated a new secret key, you cannot process transactions until you update your secret key on your website or server. Only admins and the main owner of the business can generate new API keys. Every change made to your API keys will be recorded on your audit logs.

You can follow these steps to generate new API keys:

generate new api keys.gif

  1. On your Dashboard, go to the Settings page and click on the 'API Keys & Webhooks' tab

  2. Underneath your live and test secret keys, you will see a button that reads 'Generate new secret key'. Click on this.

  3. When you select this, you can choose when your old key expires and provide your account password to complete the process. Once you're done, click 'Generate new secret key.' We'll deactivate your old secret key based on the specified time, but you will get your new keys immediately.

Callback URL

The callback URL is a web address where you want your customers to be redirected after a successful payment is made.

This could be your social media page or your website - you can even redirect them to send you a message on WhatsApp. If you want to set up a callback URL, simply paste the link in the appropriate callback URL field.

callback url.png

Webhook URL

A Webhook is a link on your server to which Paystack sends information for successful transactions that go through your account.

This is important in cases where, for example, a customer doesn't get redirected to your callback URL after a successful transaction. In this case, our server sends your webhook URL a notification so you can provide value. If you would like to set up webhooks, simply paste the link on your server in the appropriate webhook URL field.

You can learn more about setting up webhooks here.

webhook url.png

If you use any of our Paystack-hosted tools to collect payments, you do not need to set up live keys or webhooks because they are already integrated into the tools. Paystack-hosted tools, such as Invoices and Storefront, handle the payment collection process for you and automatically update your payment records on the Dashboard.