--- title: "PAYG Email API For Every Stage Of Growth" description: "Discover AhaSend's Pay-as-you-go (usage-based) Email API for fast, reliable email delivery. Enjoy advanced features like real-time tracking, email routing, and domain protection. Perfect for e-commerce, SaaS, and more." url: https://ahasend.com/payg-usage-based-email-api markdown_url: https://ahasend.com/payg-usage-based-email-api.md lang: en type: page_builder published: 2025-12-16 updated: 2026-09-02 --- # PAYG Email API For Every Stage Of Growth Begin with **1000 free monthly emails**. Move to Pro or Max to unlock usage-based pricing that grows with your email volume. - [Start Now For Free](https://dash.ahasend.com/user/register) - [Pricing](https://ahasend.com/pricing) ## Start sending emails in minutes Our APIs come with OpenAPI specs for easy and fast integration ### CLI #### cURL ```bash curl --request POST \ --url https://api.ahasend.com/v2/accounts/{account_id}/messages \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: UNIQUE-KEY' \ --data '{ "from": { "email": "noreply@example.com", "name": "Example Corp" }, "recipients": [ { "email": "user@example.com", "name": "John Doe" } ], "subject": "Welcome to Example Corp", "html_content": "

Welcome {{first_name}}!

", "text_content": "Welcome {{first_name}}!", "substitutions": { "first_name": "John" } }' ``` #### AhaSend CLI ```bash ahasend messages send \ --account-id YOUR-ACCOUNT-ID \ --api-key 'aha-sk-YOUR-API-KEY' \ --from noreply@awesomeinc.com \ --to recipient@email.com \ --subject "Welcome to AhaSend" \ --html "

Welcome!

Thank you for using AhaSend.

" ``` Need help getting started? [Check out our documentation](https://ahasend.com/docs) or [contact our support team](https://ahasend.com/contact) ### Go #### Go ```go package main import ( "context" "github.com/AhaSend/ahasend-go" "github.com/AhaSend/ahasend-go/api" "github.com/AhaSend/ahasend-go/models/common" "github.com/AhaSend/ahasend-go/models/requests" "github.com/google/uuid" ) func main() { client := api.NewAPIClient( api.WithAPIKey("aha-sk-your-64-character-key"), ) accountID := uuid.New() ctx := context.Background() // SDK automatically handles Idempotency and retries client.MessagesAPI.CreateMessage( ctx, accountID, requests.CreateMessageRequest{ From: common.SenderAddress{ Email: "info@example.com", Name: ahasend.String("Example Corp."), }, Recipients: []common.Recipient{ { Email: "john@example.com", Name: ahasend.String("John Smith"), }, }, Subject: "Hello", TextContent: ahasend.String("Hello world!"), Sandbox: ahasend.Bool(true), }, ) } ``` Need help getting started? [Check out our documentation](https://ahasend.com/docs) or [contact our support team](https://ahasend.com/contact) ### JavaScript Install dependencies: ```bash npm install @ahasend/sdk ``` #### Node.js ```javascript import { AhaSendClient } from "@ahasend/sdk"; const ahasend = new AhaSendClient({ apiKey: process.env.AHASEND_API_KEY, accountId: process.env.AHASEND_ACCOUNT_ID, }); const result = await ahasend.messages.send({ from: { email: "hello@yourdomain.com", name: "Your App" }, recipients: [{ email: "user@example.com", name: "Jane" }], subject: "Welcome to Your App", html_content: "

Welcome aboard

", text_content: "Welcome aboard", sandbox: true, // validates and queues without delivering }); const accepted = result.data.filter((entry) => entry.status === "queued" || entry.status === "scheduled" ); const rejected = result.data.length - accepted.length; if (rejected > 0 || accepted.length === 0) { console.error("AhaSend rejected recipients", { count: rejected }); process.exitCode = 1; } else { console.log("Sandbox messages accepted", { count: accepted.length }); } ``` Need help getting started? [Check out our documentation](https://ahasend.com/docs) or [contact our support team](https://ahasend.com/contact) ### Python #### Python ```python import requests url = "https://api.ahasend.com/v2/accounts/{account_id}/messages" payload = { "from": { "email": "noreply@example.com", "name": "Example Corp" }, "recipients": [ { "email": "user@example.com", "name": "John Doe", "substitutions": { "first_name": "John" } } ], "subject": "Welcome to Example Corp", "html_content": "

Welcome {{first_name}}!

", "text_content": "Welcome {{first_name}}!" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json", "Idempotency-Key": "UNIQUE-KEY", } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` Need help getting started? [Check out our documentation](https://ahasend.com/docs) or [contact our support team](https://ahasend.com/contact) ### PHP #### PHP ```php [ 'email' => 'noreply@example.com', 'name' => 'Example Corp' ], 'recipients' => [ [ 'email' => 'user@example.com', 'name' => 'John Doe', 'substitutions' => [ 'first_name' => 'John' ] ] ], 'subject' => 'Welcome to Example Corp', 'html_content' => '

Welcome {{first_name}}!

', 'text_content' => 'Welcome {{first_name}}!', ]; $headers = [ 'Content-type: application/json', 'Authorization: Bearer ', 'Idempotency-Key: UNIQUE-KEY' ]; $options = [ 'http' => [ 'header' => implode("\r\n", $headers), 'method' => 'POST', 'content' => json_encode($email) ] ]; $context = stream_context_create($options); $resp = file_get_contents('https://api.ahasend.com/v2/account/{account_id}/messages', FALSE, $context); var_export($resp, TRUE); ``` #### Symfony ```php from('noreply@example.com') ->to($userEmail) ->subject('Welcome to Example Corp') ->html('

Welcome {{first_name}}!

') ->text('Welcome {{first_name}}!') ->getHeaders() ->addTextHeader('X-AhaSend-Substitutions', json_encode([ 'first_name' => $firstName ])); $this->mailer->send($email); } } // Configuration in .env: // MAILER_DSN=ahasend+api://API_KEY@default ``` Need help getting started? [Check out our documentation](https://ahasend.com/docs) or [contact our support team](https://ahasend.com/contact) ### Ruby #### Ruby ```ruby require 'uri' require 'net/http' require 'json' # Required to convert the hash to a JSON string url = URI("https://api.ahasend.com/v2/accounts/{account_id}/messages") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request["Idempotency-Key"] = 'UNIQUE-KEY' # Create a Ruby hash object for the request body payload = { from: { email: "noreply@example.com", name: "Example Corp" }, recipients: [ { email: "user@example.com", name: "John Doe", substitutions: { first_name: "John" } } ], subject: "Welcome to Example Corp", html_content: "

Welcome {{first_name}}!

", text_content: "Welcome {{first_name}}!" } # Encode the Ruby hash into a JSON string for the request body request.body = payload.to_json response = http.request(request) puts response.read_body ``` #### Rails ```ruby # Using Rails ActionMailer with AhaSend configuration # config/environments/production.rb config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.ahasend.com', port: 587, domain: 'yourdomain.com', user_name: 'your_smtp_username', password: 'your_smtp_password', authentication: 'plain', enable_starttls_auto: true } # app/mailers/application_mailer.rb class ApplicationMailer < ActionMailer::Base default from: 'noreply@example.com' layout 'mailer' end # app/mailers/welcome_mailer.rb class WelcomeMailer < ApplicationMailer def welcome_email(user) @user = user @first_name = user.first_name mail( to: @user.email, subject: 'Welcome to Example Corp', template_name: 'welcome' ) end end # Usage: WelcomeMailer.welcome_email(user).deliver_now ``` Need help getting started? [Check out our documentation](https://ahasend.com/docs) or [contact our support team](https://ahasend.com/contact) ## Fair and simple usage-based pricing Usage-based, Pay As You Go (PAYG) Pricing plan, so that you only pay for what you use. - Free for the first 1000 emails / month - $10 (€9 / £8) / month for 25,000 emails included - Pay-as-you-go pricing (volume discounts apply) [Check Pricing](https://ahasend.com/pricing) ### Features Thoughtfully crafted for sending transactional emails at any scale - Unlimited domains - Unlimited team members - Unlimited webhooks - Unlimited message routes - RESTful APIs & SMTP relay - Open and click tracking - Customizable retention policies (up to 30 days) - Automated bounce and blocklist management - Automated SPAM monitoring - Priority support --- ### Ensure Reliable and Fast Email Delivery With millions of emails delivered each month, AhaSend offers fast, reliable email delivery. Our focus on transactional emails ensures industry-leading speed and optimized inbox placement. - Proven track record with millions of emails sent monthly - Industry-leading delivery times for faster communication - Optimized for fast transactional email delivery - Enhanced inbox placement for critical emails ### Detailed Insights on Email Performance Get full visibility into your email performance with AhaSend's detailed reporting tools. From delivery times to bounce reasons, our reports provide the data you need to optimize every campaign. - Real-time tracking for sent emails - Monitor delivery times and status updates - Detailed bounce reason reports to improve future sends ### Stay Informed with Webhook Alerts Stay up-to-date with real-time notifications using AhaSend's Webhooks. Receive instant updates on delivery events, so you're always informed about the status of your emails, from sent to delivered and everything in between. - Real-time alerts for email delivery events - Track statuses like queued, delivered, bounced, opened, clicked and more - Easily integrate with your apps and dashboards for seamless email experience ### Seamlessly Integrate Incoming Emails into Apps AhaSend's Email Routing feature allows you to automatically direct incoming emails to the right applications. By parsing and forwarding messages based on predefined criteria, you can streamline workflows and enhance automation within your system. - Parse incoming emails and extract key data - Route messages to specific applications or endpoints - Separate replies from quoted text - Customize routing rules to fit your unique needs ### Safeguard Your Domain and Deliverability AhaSend helps protect your sending domain with best-in-class tools for DNS configuration and monitoring. With automated setup and real-time monitoring, we ensure your domain's reputation stays intact, enhancing deliverability and preventing errors that can impact inbox placement. - Enforce best practices for DNS setup to optimize deliverability - Automated DNS configuration in seconds - Continuous monitoring of domain and DNS status - Proactive alerts to prevent reputation damage from misconfigurations ### Keep Your Email Data Safe and Compliant At AhaSend, email security is a top priority. Our customizable retention policies and automated blocking features protect your email data while keeping you compliant with privacy standards. Reduce risks and safeguard your communications with proactive security measures designed to prevent threats like typo-squatting and toxic domain activity. - Customizable data retention periods to meet compliance needs - Automated blocking of emails to tempmail and suspicious/toxic domains - Prevention of typo-squatting attacks by filtering domains with typos _Industry-specific use cases_ ## How Businesses Use AhaSend's Email API AhaSend's transactional email solutions are tailored to meet the unique needs of various industries. Whether you're in e-commerce, SaaS, or fintech, our flexible API supports seamless integration and reliable email delivery, helping you communicate effectively with your users. - [Sign Up Free](https://dash.ahasend.com/user/register) ### E-commerce Send order confirmations, shipping updates, and personalized notifications to enhance customer experience and boost engagement. ### SaaS Manage user authentication, account notifications, and feature updates with ease using our reliable API for smooth, timely communication. ### Social Networks Deliver notifications, friend requests, and activity updates to keep users connected and engaged on your platform. ### Recruitment Job Boards Send job alerts, application updates, and interview reminders to streamline the hiring process for candidates and recruiters. ### Online Education Platforms Automate course enrollment confirmations, assignment notifications, and progress reports to improve student engagement and retention. ### Fintech and Financial Services Provide real-time transaction alerts, account updates, and security notifications for a seamless customer experience. ### Support and Ticketing Systems Ensure prompt response times by automating ticket confirmations, status updates, and resolution notifications. ### Booking and Reservations Send booking confirmations, reminders, and cancellation notifications to keep customers informed and satisfied. ### Real Estate Platforms Automate property alerts, appointment confirmations, and follow-up emails to keep buyers, renters, and agents informed throughout the property search and transaction process. ## Join Thousands Of Developers Using AhaSend Start sending emails with our reliable SMTP server. No complex setup required, just plug and play. - [Get Started For Free](https://dash.ahasend.com/user/register)