Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.
openapi: 3.2.0
info:
description: 'REST API for provisioning and operating governed email accounts for AI
agents, on mbag.ai and mailbuttons.com. Authenticate with a Bearer API
key: `mbk_`-prefixed when obtained via the OTP flow below (see `/auth/otp/cli-exchange`);
dashboard-issued keys carry no prefix.'
title: Mailbuttons Agent Mail Auth API
version: 1.0.0
servers:
- url: https://mbag.ai/api
- url: https://mailbuttons.com/api
security:
- apiKey: []
tags:
- description: OTP signup/sign-in (sign-in is sign-up)
name: Auth
paths:
/auth/otp/cli-exchange:
post:
description: 'Same verification as `/auth/otp/verify`, but instead of a browser
session it returns a new `mbk_...` API key (named "CLI") for the
verified user. No cookie is set.'
operationId: cliExchangeOtp
requestBody:
content:
application/json:
schema:
properties:
code:
type: string
email:
type: string
required:
- email
- code
type: object
required: true
responses:
'200':
content:
application/json:
schema:
properties:
api_key:
description: Bearer key, prefixed `mbk_`.
type: string
required:
- api_key
type: object
description: Verified; API key issued.
'401':
content:
application/json:
schema:
properties:
error:
enum:
- invalid_or_expired_code
type: string
type: object
description: Code is wrong, expired, already used, or locked out.
'500':
content:
application/json:
schema:
properties:
error:
enum:
- database_error
- internal_error
- key_creation_failed
type: string
type: object
description: Database or internal error while verifying, or while creating the API key.
security: []
summary: Verify a one-time code and mint a CLI API key
tags:
- Auth
/auth/otp/request:
post:
description: 'Issues a 6-digit code (10-minute expiry) and emails it to the given
address. Signing in is signing up: the first successful verify for a
new email provisions a user and a free-tier welcome mailbox. Rate
limited to 5 requests per email per rolling 15-minute window.'
operationId: requestOtp
requestBody:
content:
application/json:
schema:
properties:
email:
type: string
required:
- email
type: object
required: true
responses:
'200':
content:
application/json:
schema:
type: object
description: Code issued and emailed. Body is always an empty object.
'400':
content:
application/json:
schema:
properties:
error:
enum:
- invalid_email
type: string
type: object
description: '`email` does not contain an `@`.'
'429':
content:
application/json:
schema:
properties:
error:
enum:
- too_many_requests
type: string
type: object
description: Too many recent requests for this email (5 per 15 minutes).
'500':
content:
application/json:
schema:
type: object
description: Failed to issue or send the code. Body is an empty object.
security: []
summary: Request a one-time login/signup code by email
tags:
- Auth
/auth/otp/verify:
post:
description: 'Verifies the code, sets the `mailbuttons_session` cookie
(HttpOnly, Strict, 7-day expiry), and returns where the dashboard
should redirect the browser next. Up to 5 wrong guesses are allowed
against a live code before every outstanding code for the email is
invalidated.'
operationId: verifyOtp
requestBody:
content:
application/json:
schema:
properties:
code:
type: string
email:
type: string
required:
- email
- code
type: object
required: true
responses:
'200':
content:
application/json:
schema:
properties:
redirect_to:
description: '`/dashboard` once onboarding is complete, else `/dashboard/welcome`.'
type: string
required:
- redirect_to
type: object
description: Verified. Sets the session cookie.
headers:
Set-Cookie:
description: '`mailbuttons_session=...; HttpOnly; SameSite=Strict; Path=/; Max-Age=604800`'
schema:
type: string
'401':
content:
application/json:
schema:
properties:
error:
enum:
- invalid_or_expired_code
type: string
type: object
description: Code is wrong, expired, already used, or locked out.
'500':
content:
application/json:
schema:
properties:
error:
enum:
- database_error
- internal_error
- session_error
type: string
type: object
description: Database or internal error while verifying, creating the session, or provisioning the account.
security: []
summary: Verify a one-time code and start a browser session
tags:
- Auth
components:
securitySchemes:
apiKey:
bearerFormat: API key
scheme: bearer
type: http