GET /api/v1/me
The first call of an integration. It answers the one question a key alone cannot: whose data am I
about to touch, and with what rights?
| Field | Description |
|---|---|
organization.id | The organization the key belongs to — the entire scope of the key |
organization.name | Its display name |
organization.slug | Its slug, the one that appears in the app URLs |
organizationRole | The role the key acts with: owner, admin or member |
keyId | The identifier of the key itself |
json
{
"success": true,
"data": {
"organization": {"id": "…", "name": "Acme", "slug": "acme"},
"organizationRole": "admin",
"keyId": "…"
}
}The value of the key is never returned.
keyId names the key, it does not let anyone
authenticate with it — a /me response that leaks is an organization name that leaks, not a
credential. No endpoint of /api/v1 ever echoes a secret back.role is the useful half of the answer. A key made by a member can read and render, nothing more;
admin is what creating, tagging and sending require — the table is on the
API reference. Reading the role before the first write is how an agent finds out it
is read-only, rather than by collecting a 403 halfway through a run it cannot undo.
Authorization
| Role in the organization | This endpoint |
|---|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Allowed |
Example
bash
curl -H "x-api-key: $AGENTMAIL_API_KEY" \
"https://www.agentsmail.io/api/v1/me"Response
200 OK— the call succeeded.401 Unauthorized— missing or invalid key, or its owner left the organization.429 Too Many Requests— over 120 requests in a minute for this key.
Response fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the operation was successful |
data.organization | object | {id, name, slug} of the organization the key opens |
data.organizationRole | string | owner, admin or member — the role its creator holds |
data.keyId | string | Identifier of the key itself |
data.sending.ready | boolean | Whether a campaign can leave right now |
data.sending.blockers | string[] | Stable machine codes — branch on these, never on a message |
data.sending.setup | object | {status, provisioning} — the same state the account owner reads on screen |
Example response
json
{
"success": true,
"data": {
"organization": {
"id": "a19f4c02",
"name": "Example",
"slug": "example"
},
"organizationRole": "admin",
"keyId": "f3c7d221",
"sending": {
"ready": true,
"blockers": [],
"setup": {
"status": "verified",
"provisioning": "provisioned"
}
}
}
}Agent recipe
Two calls turn a bare key into a working context — and tell you what stands in the way before you build anything.js
const base = 'https://www.agentsmail.io/api/v1'
const headers = {'x-api-key': process.env.AGENTMAIL_API_KEY}
const me = await (await fetch(`${base}/me`, {headers})).json()
if (!me.data.sending.ready) {
// `blockers` is a stable vocabulary — branch on it, never on a message
throw new Error(`cannot send yet: ${me.data.sending.blockers.join(', ')}`)
}
const lists = await (await fetch(`${base}/lists`, {headers})).json()
const newsletter = lists.data.find((list) => list.name === 'Newsletter')