Create an API key
Get started sending email by creating an API key to authenticate your MailBlastr requests.
What is an API key?
API keys are secret tokens used to authenticate your requests. They are unique to your account and should be kept confidential.
You must create at least one API key to use the MailBlastr platform through code — for example from your server, a script, or any HTTP client.
Create an API key
You can create API keys in two ways:
- In the API Keys dashboard page.
- Using the MailBlastr API.
To create a new API key from the MailBlastr dashboard:
- 1Open the API Keys page
In your MailBlastr dashboard, navigate to the API Keys page.
- 2Click Create API Key
Click the Create API Key button to open the creation modal.
- 3Name your key
Choose a name (maximum 50 characters) to identify your key — for example
production-serverorstaging. - 4Select a permission
Choose Sending access to grant access to only sending email, unless your key needs Full access to create, delete, get, and update any resource. This permission can be updated at any time.
- 5(Optional) Restrict to a domain
If you selected Sending access, you can further restrict the key to a single verified domain, so it can only send
fromaddresses on that domain.
Use the API key in your code
Authenticate your requests by adding your MailBlastr API key to your project as an environment variable, then sending it as a Bearer token on every request.
- 1Create and store an environment variable
Store your API key as an environment variable rather than hardcoding it. For example, Node.js projects commonly keep secrets in a
.envfile at the project root. - 2Pass the variable to your code
Read the variable at runtime and send it in the
Authorizationheader. Your environment variables are not automatically available to MailBlastr — you must pass the value explicitly on each request.
MAILBLASTR_API_KEY=mb_xxxxxxxxx.gitignore to keep it out of version control. Many frameworks add .env to .gitignore by default, so this may already be done.v20 and later you can load a .env file into process.env with the built-in --env-file=.env flag (for example node --env-file=.env app.js). On earlier versions, use a loader such as the dotenv package.Read the key from the environment and send it as a Bearer token:
curl -X POST 'https://api.mailblastr.com/emails' \
-H "Authorization: Bearer $MAILBLASTR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"from": "Acme <hello@yourdomain.com>",
"to": ["delivered@example.com"],
"subject": "Hello from MailBlastr",
"html": "<p>It works!</p>"
}'Next steps
- Add a domain you own and verify it to start sending.
- Send your first transactional email with the Quickstart.
- Review the Authentication permission levels and error codes.