Authentication

Every call to the Oblic API carries an API key, created in Oblic's settings with a role and the scopes it needs. A key may be held to the addresses on your organization's IP allowlist. API v2 takes OAuth access tokens instead.

Creating a key

Create keys under Settings → API Integration in Oblic. Give each key a name, a role (Owner, Admin or User) and the scopes its application needs. The key is shown once, when it is created: store it in a secret manager or a protected environment variable. A lost key can't be shown again; create another, then delete the lost one.

Sending the key

Send the key in the Authorization header, as Bearer, one space, and the key:

A call with a key

curl https://api.oblic.app/external/v1/key \
  -H 'Authorization: Bearer YOUR_API_KEY'

The API is for servers: it answers no browser's cross-origin request, so a key never needs to be in a web page or an app, where anyone could read it.

Scopes

A key holds the scopes it was created with, and a route lists the scopes it takes: a key holding any one of them may call it. A key created before scopes existed holds every scope but events:write, which records your contacts' events: to send events, create a key that holds it.

ScopeLets a key
email:sendSend email, and read the email templates and sender identities it sends with
sms:sendSend SMS, and read the SMS account, headers and templates
whatsapp:sendSend WhatsApp messages, and read the WhatsApp number, templates and recipients
messages:readList messages, read what became of each, and read the report summary
templates:manageManage email templates, SMS headers and templates, and the WhatsApp number and templates
identities:manageManage sender identities
contacts:manageMake and list contact lists, and add contacts to them
events:writeRecord your contacts' events, such as their orders (see Events)
webhooks:manageManage webhooks and their failed deliveries
accounts:manageManage sub-accounts

mcp:read and mcp:write are for Oblic's MCP server, not this API. The endpoints list the scopes each route takes, and so does the OpenAPI document, in x-oblic-scopes.

Roles

A key's role decides the routes it may call, whatever its scopes:

  • Owner and Admin keys may call every route.
  • User keys may call every route but those that change templates, SMS headers or the WhatsApp number, manage webhooks or sub-accounts, or check /external/v1/health. A User key can't be created with templates:manage, webhooks:manage or accounts:manage; one that holds every scope, as a key made before scopes or a sub-account's does, lists them but can't use them.

A User key on one of those routes is 403 INSUFFICIENT_SCOPE, since it holds none of their scopes, or 403 ROLE_NOT_ALLOWED on /external/v1/health, which takes no scope, and when it holds every scope.

IP allowlist

Under Settings → API Integration → Whitelisted IPs, list the addresses your servers call from: single IPv4 or IPv6 addresses, or ranges such as 203.0.113.0/24. While the list is empty, a key works from any address; once it holds one, a key works only from the addresses on it. A change applies within a minute.

A request from elsewhere is 403 IP_NOT_ALLOWED, and its message names the address Oblic saw, which is the one to add. A request for a sub-account is held to your organization's list.

GET/external/v1/key

Checking a key

Any key may read itself: its name, role and scopes, and what it can do now.

Response, in part

{
  "status": "success",
  "data": {
    "name": "Order service",
    "role": "USER",
    "scopes": ["email:send", "messages:read"],
    "allScopes": false,
    "organizationId": "ORG000R7ZM4Q2VXH00",
    "capabilities": {
      "scopes": [
        { "scope": "email:send", "action": "send email", "ownerOnly": false, "granted": true, "ready": true }
      ],
      "verifiedSenders": [{ "identity": "example.com", "type": "Domain", "status": "verified" }],
      "unverifiedSenders": [],
      "defaultSender": "hello@example.com",
      "allowedIps": ["203.0.113.0/24"],
      "subAccount": false
    }
  },
  "errors": null
}

capabilities says, for each scope, whether the key may use it (granted) and whether the organization is ready for it (ready), such as having a verified sender to send email from, with reason saying why not.

Refusals

StatuscdWhen
401MISSING_API_KEYNo Authorization: Bearer header
401INVALID_API_KEYA key Oblic doesn't know: mistyped, or deleted
403IP_NOT_ALLOWEDA valid key from an address the IP allowlist doesn't hold
403INSUFFICIENT_SCOPEThe key holds none of the route's scopes; the message names them, and so does the WWW-Authenticate header
403ROLE_NOT_ALLOWEDA User key on /external/v1/health, or one holding every scope on a route that needs an Owner or Admin key
404ACCOUNT_NOT_FOUNDX-Oblic-On-Behalf-Of names no active sub-account
503AUTHENTICATION_UNAVAILABLEOblic couldn't check the key just then; nothing was done, so try again

Keeping keys safe

  • One key for each application and environment, holding only the scopes it needs, so a key that leaks can do little, and deleting it stops one application only.
  • Keep keys on your servers, out of code, logs and anything a browser or an app downloads.
  • Rotate by creating the new key, deploying it, then deleting the old one. A deleted key stops working at once.
Was this page helpful?