Skip to main content
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.me();
console.log(result);
{
  "api_key": {
    "id": "key_01JZXD7R9T1V3X5Z7B9D1F3H5K",
    "prefix": "mk_live_a1b2",
    "name": "Production server",
    "mode": "live",
    "scopes": ["send", "read"],
    "agent_id": null,
    "last_used_at": "2026-06-24T17:30:00.000Z",
    "created_at": "2026-06-01T09:12:44.000Z"
  },
  "workspace": {
    "id": "wsk_01JZ8A1B2C3D4E5F6G7H8J9K0M",
    "slug": "acme",
    "display_name": "Acme, Inc.",
    "tier": "pro",
    "tier_status": "active"
  },
  "agent": null
}

Identify the current key

Returns the authenticating API key, its workspace, and its bound agent (if any).
GET/v1/me
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.me();
console.log(result);
{
  "api_key": {
    "id": "key_01JZXD7R9T1V3X5Z7B9D1F3H5K",
    "prefix": "mk_live_a1b2",
    "name": "Production server",
    "mode": "live",
    "scopes": ["send", "read"],
    "agent_id": null,
    "last_used_at": "2026-06-24T17:30:00.000Z",
    "created_at": "2026-06-01T09:12:44.000Z"
  },
  "workspace": {
    "id": "wsk_01JZ8A1B2C3D4E5F6G7H8J9K0M",
    "slug": "acme",
    "display_name": "Acme, Inc.",
    "tier": "pro",
    "tier_status": "active"
  },
  "agent": null
}

Any valid key works — no scope required.

Response

api_keyobject

The credential that made this request: an API key, or an access token from a connected app such as the mails CLI.

Show propertiesHide properties
idstring

Key id (key_…). For an access token from a connected app, such as the mails CLI, the app's grant id (oag_…), as GET /v1/oauth/grants lists it.

prefixstring

The first 12 characters of the key or token, as key lists show them.

namestring | null

The key's name. Null when it has none, and for an access token.

modestring

live or test: whether this credential's sends are real. An access token is always live.

One of: live, test

scopesstring[]

The scopes this credential holds, such as send, read, manage or draft; each endpoint names the scope it needs.

agent_idstring | null

The agent (agt_…) the key is tied to; null when it may act for every agent. Always null for an access token.

last_used_atstring | null

When the key last authenticated a request; it may already show this one. Null before its first recorded use, and for an access token.

created_atstring | null

When the key was created (ISO 8601, UTC). Null for an access token.

workspaceobject | null

The workspace the credential belongs to. Null only if it can no longer be found.

agentobject | null

The agent the key is tied to. Null for a key that may act for every agent, and for an access token.

Was this page helpful?