Skip to main content
ScrubiMail

Authentication

Every request carries an API key in the X-API-Key header. A key can be limited to the scopes it needs, and it belongs on your server, never in browser or mobile code.

Related:Email validationEmail sending

Checked against the API source on

Send your key

Accepted authentication headers
HeaderFormatUse
X-API-KeyX-API-Key: <your key>Recommended.
AuthorizationAuthorization: ApiKey <your key>Also accepted. The word ApiKey, one space, then the key.
Authenticated request
curl "https://api.scrubimail.com/scrubimail/api/v1/validate/" \
  -H "X-API-Key: $SCRUBIMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]"}'

Create and manage keys

Create keys on the API keys page in the app. You can run several keys side by side, for example one for production, one for staging and one for a CI job, each with its own name, optional expiry date and scopes. Rotating is explicit: create the new key, switch your service over, then deactivate the old one. Creating a key never disables the others.

The same key also works as the password for the SMTP relay, as long as it has the send scope.

Scopes

A scope limits what a key can do. A key with no scopes can use every endpoint. Once you pick scopes, the key can only call endpoints that need one of them. Scopes restrict API keys only; they do not apply to dashboard sessions.

API key scopes
ScopeAllows
validatePOST /validate/, single email validation, and GET /domain-reputation/{domain}/.
validate:bulkPOST /validate-bulk/, bulk validation jobs.
sendPOST /send/, single sends, and SMTP relay login.
send:bulkPOST /send/bulk/ and the campaigns endpoints.
domains/send/domains/: add, list, verify and delete sending domains.
templates/send/templates/, including starter templates.
suppressions/send/suppressions/.
historyValidation history and analytics (/history/, /analytics/), and sending status, history and analytics (/send/status/, /send/history/, /send/analytics/).

Your plan can restrict which scopes are available. Asking for a scope your plan does not include is rejected when you create or edit the key with Your plan does not include these scopes.

A call that needs a scope the key lacks fails with 403 and error.code set to permission_denied.

403 missing scope
{
  "success": false,
  "error": {
    "code": "permission_denied",
    "message": "Your API key does not have the required scope for this endpoint.",
    "details": [
      {
        "field": "non_field_errors",
        "issue": "Your API key does not have the required scope for this endpoint."
      }
    ]
  }
}

IP allow-list

A key can be locked to a list of IP addresses or CIDR ranges, for example 203.0.113.7 or 198.51.100.0/24. A request from any other address is rejected before anything else runs. When the list is set it also applies to SMTP logins made with that key.

  • IP allow-listing is available on plans that include it. It is set up by ScrubiMail, not edited in the dashboard: email [email protected] with the key name and the addresses.
  • The address checked is the one our edge sees for your connection. An X-Forwarded-For header you send yourself is ignored.
  • An empty list means no restriction.

Authentication errors

Branch on error.code, not on the HTTP status. The codes are stable.

Authentication and permission errors
SituationStatuserror.codeMessage
No credentials sent401authentication_requiredAuthentication credentials were not provided.
Key unknown or deactivated401invalid_credentialsInvalid or inactive API key
Key past its expiry date401invalid_credentialsAPI key has expired
Request IP not on the key's list401invalid_credentialsRequest IP is not in the API key's whitelist
Key sent as a Bearer token401invalid_credentialsGiven token not valid for any token type
Key lacks the endpoint's scope403permission_deniedYour API key does not have the required scope for this endpoint.

Keep keys server-side

  • Never ship a key in browser, mobile or desktop code. Anyone who opens developer tools can read it. Call ScrubiMail from your backend and expose your own endpoint to the client.
  • Load keys from environment variables or a secrets manager. Keep them out of source control, build logs and error reports.
  • Use one key per service and give each only the scopes it needs. A signup form that only validates addresses needs just validate.
  • Set an expiry date on keys for short-lived jobs and contractors.
  • If a key leaks, deactivate it on the API keys page and create a replacement. Deactivated keys stop working immediately.

Something missing or wrong? Email [email protected].