Videos
Check out our tutorial video series.
Reduce HTTP API Rate-Limit Exceptions: A Guide to Identify Causes, Batch Requests & Use Webhook Push with MailSlurp API
MailSlurp's API imposes a limit of 150 requests per second. This is to ensure smooth operation of the API for all users and to catch common exceptions such as infinite loops. When a rate limit is reached your request may fail with a 429 response status code.
If your system is being rate-limited please identify the cause. There is typically a place in your code that is calling MailSlurp very frequently. Common causes of rate limiting are:
Plans that support bulk operations allow you to batch operations. This can reduce requests significantly. If you create inboxes or send emails within a loop use the loop to build a request object and then send the request once outside the loop using the BulkActionsControllerApi. Here is an example in Java:
You can configure MailSlurp to send emails and other events directly to your server using HTTP Push Webhooks. You can create webhooks in the dashboard or using code. Each inbox can be assigned a new webhook or use an existing one. New inboxes must be connected to a webhook if you wish to receive events for the inbox. Here is an example of creating a webhook in Java:
To setup the webhook see the webhook creation options. You will need to create a publicly accessible endpoint (you can add basic auth if you wish) so that MailSlurp can POST the event payload to your server. Each webhook can consume a single event type. Each event type has a different payload. These payload classes are included in each SDK. The event payload for the Java API can be found here.
If you are calling MailSlurp within a loop it is best to avoid this all together. If you cannot then try adding a sleep or timeout of 20 milliseconds between requests. This will slow down your loop slightly but will also reduce the number of requests per second that are reaching MailSlurp and likely prevent rate limit exceptions.
If you have tried these techniques please open a ticket with support to discuss raising your rate limit. Please tell support what your use case is so they can more accurately diagnose the case and offer increases.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.