API Reference
Create API key
POST /api-keys — create a new API key. The token is returned once.
POST
/api-keysCreates a new API key and returns the full mb_... token once. Only the hash and prefix are stored, so copy the token immediately. An API-key caller must hold full_access to create keys.
Body parameters
namestringrequiredA label for the key. Maximum 50 characters.
permissionfull_access | sending_accessoptionalThe access level. full_access (default) can create, delete, get, and update any resource; sending_access can only send emails.
domain_idstringoptionalRestrict the key to send only from a specific domain — enforced on every send surface (POST /emails, batch, campaign sends, and the SMTP relay). Only applies when permission is sending_access.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.apiKeys.create({
"name": "Production server",
"permission": "sending_access"
});
console.log({ data, error });Response
{
"id": "dacf4072-4119-4d88-932f-6202748ac7c8",
"object": "api_key",
"token": "mb_AbC123dEf456GhI789jKl012mNoPqRs",
"domain_id": null
}The
token is shown exactly once. Errors: missing_required_field if name is absent; validation_error if permission is not full_access or sending_access; invalid_access if the calling key lacks full access.