Skip to main content

Getting an API key

API keys are created from your Messages.dev dashboard.
  1. Go to API Keys in the sidebar
  2. Click Create Key
  3. Give it a name and copy the key. It starts with sk_live_ and is only shown once
Store your API key securely. It won’t be displayed again after creation. If you lose it, revoke it and create a new one.

Authenticating requests

import { createClient } from "@messages-dev/sdk";

const client = createClient();

const client = createClient({ apiKey: "sk_live_..." });

Scopes

Each API key has scopes that control which endpoints it can access.
ScopeGrants access to
messages:readGET /messages
messages:writePOST /messages
chats:readGET /chats
lines:readGET /lines
reactions:readGET /reactions
reactions:writePOST /reactions
typing:readGET /typing
typing:writePOST /typing
receipts:readGET /receipts
receipts:writePOST /receipts
webhooks:readGET /webhooks
webhooks:writePOST, DELETE /webhooks
outbox:readGET /outbox

Line restrictions

API keys can be restricted to specific lines. A line-restricted key can only read and write data for its allowed lines. Requests to other lines return 403. This is useful when you have multiple integrations or want to limit blast radius. You can configure line restrictions when creating a key in the dashboard.
All API keys automatically have access to the sandbox line, regardless of line restrictions.

Errors

ScenarioStatusCode
No Authorization header401missing_api_key
Invalid or revoked key401invalid_api_key
Key lacks required scope403insufficient_scope
Key can’t access this line403line_not_accessible