Polling vs. Webhooks

Let's say a customer enters your website/application and makes a purchase. Your shopping service will receive a request, which will send it to the payment service, which will then call a payment gateway from Asaas, correct?

After that, you have two ways to receive information from Asaas:


After creating a charge, your application makes several requests to Asaas to check the payment status until Asaas returns that it has been paid.

However, this practice has drawbacks. Polling implies using resources both on the side of your application and on the side of Asaas. It can even lead to your API key being blocked due to quota limits.


Essentially, it's a "notify me back on a certain URL when you have updates on this charge." When Asaas finishes processing a payment, you will receive the status on your configured URL.

This way, the paradigm shifts, and your payment service doesn't need to spend resources to check the status of a charge.

Some interesting tips when using Webhooks:

  • You should develop an API on your side responsible for receiving the Webhook requests;
  • It's advisable to create rules on your endpoint for security reasons. Asaas allows you to define an authToken for each Webhook, for example;
  • If any problem occurs in communication with your API, your queue is interrupted, and you receive a warning email.

Besides saving resources, Webhooks ensure that your application will receive an event whenever something changes in the gateway. Polling might work to check if a charge has been paid, but it won't notify you in case of a delay in paying a billet or when the payment of a credit card effectively lands in your account.

Using Webhooks is the most practical and secure way to keep your application updated on everything happening in the Asaas gateway.