Product•3 min read

Understanding Piisend Sending Quotas and Rate Limits

Learn about Piisend's email API rate limits and sending quotas, including the free email API quota of 3000 emails per month. Discover how Piisend plans are structured and best practices for handling HTTP 429 responses to ensure reliable email delivery.

Understanding Piisend Sending Quotas and Rate Limits

Section 1

Understanding Piisend's Email Sending Quotas and Rate Limits

Email API rate limits and sending quotas are essential mechanisms that protect the stability and deliverability of any email service. At Piisend, we implement these limits to ensure fair usage, prevent abuse, and maintain high deliverability rates for all our users. By understanding these limits, developers can design robust applications that send transactional emails reliably without unexpected interruptions.

Section 2

Piisend's Free Tier and Scalable Pro Plans

Piisend offers a generous free email API quota, allowing you to send up to 3000 emails per month without any cost. This is perfect for testing, small projects, or applications with lower sending volumes. As your application grows, Piisend plans seamlessly scale to accommodate higher sending volumes, ensuring you always have the capacity you need. Monitoring your usage is key to staying within your plan's limits.

bash
1curl -X POST https://api.piisend.com/api/v1/emails \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "to": ["recipient@example.com"],
6 "subject": "Welcome to Piisend!",
7 "html": "<p>Hello from Piisend! Your account is ready.</p>",
8 "text": "Hello from Piisend! Your account is ready."
9 }'

Section 3

Gracefully Handling HTTP 429 "Too Many Requests"

When your application exceeds its allocated email API rate limits, Piisend will respond with an HTTP 429 Too Many Requests status code. It's crucial to implement proper error handling for these responses. Instead of immediately retrying, which can exacerbate the issue, you should implement an exponential backoff strategy or queue your emails for later processing. This approach prevents overwhelming the API and ensures your emails are eventually sent, often leveraging an Idempotency-Key for safe retries.

python
1import requests
2import time
3
4def send_email_with_retry(to_email, subject, html_content, text_content, api_key, max_retries=5):
5 url = "https://api.piisend.com/api/v1/emails"
6 headers = {
7 "Authorization": f"Bearer {api_key}",
8 "Content-Type": "application/json"
9 }
10 payload = {
11 "to": [to_email],
12 "subject": subject,
13 "html": html_content,
14 "text": text_content
15 }
16
17 for i in range(max_retries):
18 response = requests.post(url, headers=headers, json=payload)
19 if response.status_code == 200:
20 print("Email sent successfully!")
21 return response.json()
22 elif response.status_code == 429:
23 wait_time = 2 ** i # Exponential backoff
24 print(f"Rate limit hit. Retrying in {wait_time} seconds...")
25 time.sleep(wait_time)
26 else:
27 print(f"Error sending email: {response.status_code} - {response.text}")
28 return None
29 print("Failed to send email after multiple retries.")
30 return None
31
32# Example usage:
33# send_email_with_retry("user@example.com", "Test Subject", "<p>Hello!</p>", "Hello!", "YOUR_API_KEY")

Section 4

Optimizing Your Sending Strategy to Avoid Limits

To efficiently manage your email API quota and minimize the chances of hitting rate limits, consider several best practices. For applications sending many similar emails, batching can be a powerful tool, though Piisend's API currently processes emails individually for optimal deliverability. Additionally, leveraging Piisend's webhooks for real-time delivery event notifications allows you to process events asynchronously, reducing the immediate load on your system and providing valuable insights into your email performance. This proactive approach helps maintain a smooth sending flow.

javascript
1async function sendEmail(toEmail, subject, htmlContent, textContent, apiKey) {
2 const url = 'https://api.piisend.com/api/v1/emails';
3 const headers = {
4 'Authorization': `Bearer ${apiKey}`,
5 'Content-Type': 'application/json'
6 };
7 const payload = {
8 'to': [toEmail],
9 'subject': subject,
10 'html': htmlContent,
11 'text': textContent
12 };
13
14 try {
15 const response = await fetch(url, {
16 method: 'POST',
17 headers: headers,
18 body: JSON.stringify(payload)
19 });
20
21 if (response.ok) {
22 console.log('Email sent successfully!');
23 return await response.json();
24 } else if (response.status === 429) {
25 console.error('Rate limit hit. Implement retry logic.');
26 // Implement exponential backoff or queueing here
27 } else {
28 const errorData = await response.json();
29 console.error(`Error sending email: ${response.status} - ${JSON.stringify(errorData)}`);
30 }
31 } catch (error) {
32 console.error('Network or other error:', error);
33 }
34}
35
36// Example usage:
37// sendEmail('user@example.com', 'Your Order Confirmation', '<p>Thanks for your order!</p>', 'Thanks for your order!', 'YOUR_API_KEY');

Start sending

Ship transactional email in minutes

Create an API key, verify a domain, and send your first message with Piisend.