{
  "openapi": "3.1.0",
  "info": {
    "title": "Motorical Public API: Onboarding (OAuth, sign-up, sandbox, free recipients, token minting)",
    "version": "1.12.0",
    "description": "Onboarding (OAuth, sign-up, sandbox, free recipients, token minting). Part of the full specification at https://docs.motorical.com/openapi.json (same version, same operationIds). Transactional email HTTP API and analytics for Motorical Sending SMTP — same job class as SendGrid/Postmark-style send APIs. One Motor Block per project: an isolated sending stream with its own domain, auth, keys, SMTP credentials, rates, logs, webhooks, and automation. Developer sandbox: unpaid agent onboarding uses a Motorical-owned `.sandbox` domain (instant, no DNS) or a sandbox Motor Block on your own fully verified domain (on a Free account, created automatically once DKIM and SPF pass when automatic provisioning is enabled; otherwise call the provision route), with outbound locked to an allowlist until convert + Motorical Plan. Onboarding auth: register → verify-code (returns a single-use setupToken) → set-password {email, password, setupToken} → dashboard JWT (~15m) + refreshToken (7d). Agents store refreshToken and POST /api/auth/refresh with JSON body (cookies optional). After domain ownership verify, call POST /api/public/v1/domains/{id}/check-dns (or re-call verify) to flip dkim_configured/spf_configured before /v1/send. Domains are account-wide, not Motor-Block-scoped (a Motor Block is created from a verified domain, not the reverse) — GET/POST /api/public/v1/domains* need no motorBlockId. Public API covers email sending, analytics, logs, configuration, domain management, domain health, webhooks, and exports. SMTP submission is an out-of-band protocol on mail.motorical.com:2587 (STARTTLS) or :2465 (implicit TLS) using password, OAuth 2.0 access token as SMTP password (or XOAUTH2), or mTLS + password — see https://docs.motorical.com/smtp-integration/authentication-methods. Do not use OAuth access tokens or Bearer tokens on POST /v1/send (Motor Block ApiKey mk_live_ only)."
  },
  "servers": [
    {
      "url": "https://api.motorical.com",
      "description": "Motorical production API. The only host that serves the HTTP Send API (/v1/*); also serves the Public API (/api/public/v1/*) and the dashboard/auth API (/api/*). Use this host for every API call except the Communications API (/comm-api/*): those operations name https://motorical.com as their own server, and api.motorical.com answers 404 for /comm-api."
    },
    {
      "url": "https://motorical.com",
      "description": "Dashboard host — OAuth AS endpoints. Also answers /api/* and /api/public/v1/*, but POST /v1/send is NOT served here (nginx answers 405)."
    }
  ],
  "tags": [
    {
      "name": "Motor Blocks",
      "description": "Isolated sending streams (Motor Blocks) — domains, keys, SMTP, rates, logs"
    },
    {
      "name": "OAuth",
      "description": "Motorical OAuth 2.0 authorization server (SMTP access tokens)"
    },
    {
      "name": "Onboarding Auth",
      "description": "Agent account signup, JWT access + refresh lifecycle, web handoff"
    },
    {
      "name": "Developer Sandbox",
      "description": "Unpaid agent onboarding — a Motorical-owned .sandbox domain or your own verified domain, with an outbound-locked Motor Block"
    },
    {
      "name": "Account Sandbox",
      "description": "OAuth-delegated / Public API bearer counterpart to Developer Sandbox — same underlying behavior, no dashboard session required"
    }
  ],
  "paths": {
    "/api/oauth2/authorize": {
      "get": {
        "tags": [
          "OAuth"
        ],
        "servers": [
          {
            "url": "https://motorical.com"
          }
        ],
        "summary": "OAuth 2.0 authorization endpoint (consent HTML)",
        "description": "Starts the authorization-code flow for a Motor Block OAuth app. Returns an HTML consent page. After approve, redirects to redirect_uri with ?code=. Use the access token from /api/oauth2/token as the SMTP password on mail.motorical.com — not on POST /v1/send.",
        "parameters": [
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "code"
              ]
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "email.send"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Consent HTML"
          },
          "400": {
            "description": "invalid_request / invalid_client / invalid_scope"
          }
        },
        "operationId": "oauthAuthorize"
      }
    },
    "/api/oauth2/token": {
      "post": {
        "tags": [
          "OAuth"
        ],
        "servers": [
          {
            "url": "https://motorical.com"
          }
        ],
        "summary": "OAuth 2.0 token endpoint",
        "description": "Exchange an authorization code or refresh token for an access token. The access_token JWT is used as the SMTP password (PLAIN/LOGIN) or via XOAUTH2 on mail.motorical.com:2587.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type",
                  "client_id",
                  "client_secret"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "authorization_code",
                      "refresh_token"
                    ]
                  },
                  "code": {
                    "type": "string",
                    "description": "Required for authorization_code"
                  },
                  "refresh_token": {
                    "type": "string",
                    "description": "Required for refresh_token"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "client_secret": {
                    "type": "string"
                  },
                  "redirect_uri": {
                    "type": "string",
                    "format": "uri",
                    "description": "Required for authorization_code; must match registration"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string",
                      "example": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer",
                      "example": 3600
                    },
                    "refresh_token": {
                      "type": "string"
                    },
                    "scope": {
                      "type": "string"
                    },
                    "motor_block": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "smtp_username": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_grant / invalid_client"
          }
        },
        "operationId": "oauthToken"
      }
    },
    "/api/oauth2/validate": {
      "get": {
        "tags": [
          "OAuth"
        ],
        "servers": [
          {
            "url": "https://motorical.com"
          }
        ],
        "summary": "Validate an OAuth access token",
        "description": "Optional helper to introspect a Motorical-issued SMTP access token (query or Authorization Bearer).",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "access_token",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <access_token>"
          }
        ],
        "responses": {
          "200": {
            "description": "Token metadata when valid"
          },
          "401": {
            "description": "Invalid or expired token"
          }
        },
        "operationId": "oauthValidateToken"
      }
    },
    "/api/public/token/account-key": {
      "post": {
        "tags": [
          "Motor Blocks"
        ],
        "summary": "Mint a Public Analytics API token with an Account API Key",
        "description": "Use an Account API Key (`ak_live_...`) to create a short-lived bearer token for `/api/public/v1` endpoints. The key can be supplied as `Authorization: ApiKey ak_live_...` or `X-Api-Key: ak_live_...`.",
        "security": [
          {
            "accountApiKeyAuth": []
          },
          {
            "xApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "motorBlockId"
                ],
                "properties": {
                  "motorBlockId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "ttlSeconds": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 900,
                    "default": 300
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token minted"
          },
          "401": {
            "description": "Account API key missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "mintPublicTokenFromAccountKey"
      }
    },
    "/api/public/token": {
      "post": {
        "tags": [
          "Motor Blocks"
        ],
        "summary": "Mint a Public Analytics API token with a dashboard JWT",
        "description": "Dashboard and trusted-session flow for creating a short-lived bearer token for `/api/public/v1` endpoints. Server-to-server integrations should prefer `/api/public/token/account-key`.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "motorBlockId"
                ],
                "properties": {
                  "motorBlockId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "ttlSeconds": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 900,
                    "default": 300
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token minted"
          },
          "401": {
            "description": "Dashboard JWT missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "mintPublicToken"
      }
    },
    "/api/auth/register": {
      "post": {
        "tags": [
          "Onboarding Auth"
        ],
        "summary": "Start agent signup (email verification code)",
        "description": "Sends a 6-digit verification code. Optional onboardingChannel: cli|agent marks the account for sandbox onboarding. Not for production send — after verify + set-password use dashboard JWT for sandbox APIs, then mk_live_ for /v1/send.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "onboardingChannel": {
                    "type": "string",
                    "enum": [
                      "cli",
                      "agent",
                      "web"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code sent (or equivalent success)"
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "register"
      }
    },
    "/api/auth/verify-code": {
      "post": {
        "tags": [
          "Onboarding Auth"
        ],
        "summary": "Verify email with 6-digit code",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "code"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email verified. The response carries a single-use setupToken (valid 30 minutes) that POST /api/auth/set-password requires as proof of email ownership.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "verified": {
                      "type": "boolean"
                    },
                    "needsPasswordSetup": {
                      "type": "boolean"
                    },
                    "setupToken": {
                      "type": "string",
                      "description": "Single use, expires in 30 minutes. Send it to /api/auth/set-password."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "verifySignupCode"
      }
    },
    "/api/auth/set-password": {
      "post": {
        "tags": [
          "Onboarding Auth"
        ],
        "summary": "Set password after email verification (returns JWT + refreshToken)",
        "description": "Access JWT expires ~15m. refreshToken (7d) is returned in JSON for agents and also set as HttpOnly cookie for browsers. Pass channel: cli|agent to keep cli_password_pending so first browser visit forces establish-password.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password",
                  "setupToken"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 8
                  },
                  "setupToken": {
                    "type": "string",
                    "description": "The setupToken returned by POST /api/auth/verify-code (or GET /api/auth/verify-email). Single use, 30 minutes."
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "cli",
                      "agent"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password set; token + refreshToken issued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "refreshToken": {
                      "type": "string"
                    },
                    "expiresIn": {
                      "type": "string",
                      "example": "15m"
                    },
                    "tokenType": {
                      "type": "string",
                      "example": "Bearer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error, or the setup token is invalid (code VALIDATION_ERROR).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "Too many requests (code rate_limit_exceeded or RATE_LIMIT_ANONYMOUS); wait X-RateLimit-Reset seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "setPassword"
      }
    },
    "/api/auth/login": {
      "post": {
        "tags": [
          "Onboarding Auth"
        ],
        "summary": "Password login (returns JWT + refreshToken)",
        "description": "Same token shape as set-password. MFA accounts get a challenge instead of tokens until MFA verify succeeds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login successful (token + refreshToken) or MFA required"
          },
          "401": {
            "description": "Invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "login"
      }
    },
    "/api/auth/refresh": {
      "post": {
        "tags": [
          "Onboarding Auth"
        ],
        "summary": "Rotate refresh token; issue new access JWT (non-interactive)",
        "description": "Browser: send `__Host-motorical_refresh` cookie. Agents and scripts: POST JSON `{ \"refreshToken\": \"...\" }` (no cookie required). Response includes new `token` + rotated `refreshToken`. Store the new refreshToken; old one has a short grace window.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "refreshToken": {
                    "type": "string",
                    "description": "Required for agents and scripts when the cookie is absent"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New access token + rotated refreshToken",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "refreshToken": {
                      "type": "string"
                    },
                    "expiresIn": {
                      "type": "string"
                    },
                    "tokenType": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid refresh token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "refreshSession"
      }
    },
    "/api/auth/web-handoff": {
      "post": {
        "tags": [
          "Onboarding Auth"
        ],
        "summary": "Mint a one-time browser handoff URL",
        "description": "Requires dashboard Bearer JWT. Returns a ~90s URL `https://motorical.com/auth/cli?code=…`. Open the link right away; if it says expired, ask for a new link or sign in with your password. Browser exchanges the code for a normal web session; if cli_password_pending, forces /auth/set-password.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string",
                    "description": "Optional in-app path after handoff (must start with /)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Handoff URL minted"
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "createWebHandoff"
      }
    },
    "/api/developer/sandbox": {
      "get": {
        "tags": [
          "Developer Sandbox"
        ],
        "summary": "Get developer sandbox status",
        "description": "Returns sandbox domain, Motor Block, outbound lock, allowlist, and caps. The allowlist is the effective list: sandbox recipients, link-confirmed recipients, the account address and the test sink, minus any address that clicked stop. domain.sandbox true means the Motorical-owned sandbox domain; false means your own domain. Requires a verified dashboard JWT (the same dashboard session obtained from login or set-password).",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Sandbox status"
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "getSandboxDashboard"
      }
    },
    "/api/developer/sandbox/provision": {
      "post": {
        "tags": [
          "Developer Sandbox"
        ],
        "summary": "Provision unpaid developer sandbox",
        "description": "Creates `<handle>.sandbox.motorical.com` (a Motorical-owned `.sandbox` domain, instant, no DNS for you to publish; a Free account that adds and fully verifies its own domain can instead get its sandbox Motor Block on that domain automatically when automatic provisioning is enabled), a transactional Motor Block with `product_allocation.developer_sandbox`, mints `mk_live_` once, and locks outbound to the account allowlist. Idempotent per account. Does not require a paid Motorical Plan.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "handle": {
                    "type": "string",
                    "description": "3–32 char label for the Motorical-owned handle.sandbox domain"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "cli",
                      "agent",
                      "web"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already provisioned (idempotent)"
          },
          "201": {
            "description": "Provisioned (credentials returned once)"
          },
          "401": {
            "description": "Missing, invalid or expired credential (code access_token_required, invalid_access_token or similar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "Too many requests (code rate_limit_exceeded or RATE_LIMIT_ANONYMOUS); wait X-RateLimit-Reset seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "503": {
            "description": "sandbox_dns_unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "provisionSandboxDashboard"
      }
    },
    "/api/developer/sandbox/outbound": {
      "patch": {
        "tags": [
          "Developer Sandbox"
        ],
        "summary": "Update sandbox outbound lock / allowlist",
        "description": "Widen or tighten the recipient allowlist. Never open-world while developer_sandbox is set; convert clears the lock.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "outboundLocked": {
                    "type": "boolean"
                  },
                  "allowedRecipients": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "email"
                    },
                    "maxItems": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated"
          },
          "404": {
            "description": "No sandbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "setSandboxOutboundDashboard"
      }
    },
    "/api/developer/sandbox/convert": {
      "post": {
        "tags": [
          "Developer Sandbox"
        ],
        "summary": "Convert sandbox Motor Block to a verified production domain",
        "description": "Requires an active Motorical subscription (CSV plans via sync-plans-from-csv.py). Re-points the sandbox Motor Block to a customer-owned verified domain, clears sandbox flags, applies plan limits, and reaps sandbox DNS.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domainId"
                ],
                "properties": {
                  "domainId": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted"
          },
          "403": {
            "description": "subscription_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "convertSandboxDashboard"
      }
    },
    "/api/public/v1/account/sandbox": {
      "get": {
        "tags": [
          "Account Sandbox"
        ],
        "summary": "Get account sandbox status (OAuth/Public API bearer)",
        "description": "Account-scoped counterpart to GET /api/developer/sandbox — same underlying service, reachable with an OAuth Delegation header or Public API bearer token instead of a dashboard session. The allowlist is the effective list (sandbox recipients, link-confirmed recipients, the account address and the test sink, minus any address that clicked stop); domain.sandbox true means the Motorical-owned sandbox domain, false means your own domain.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Sandbox status"
          },
          "401": {
            "description": "Missing, invalid or expired credential (code access_token_required, invalid_access_token or similar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "403": {
            "description": "The credential lacks a scope this operation needs, or does not cover the Motor Block named (code missing_scope or motor_block_not_authorized).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "Too many requests (code rate_limit_exceeded or RATE_LIMIT_ANONYMOUS); wait X-RateLimit-Reset seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "getSandboxStatus"
      }
    },
    "/api/public/v1/account/sandbox/provision": {
      "post": {
        "tags": [
          "Account Sandbox"
        ],
        "summary": "Provision account sandbox (OAuth/Public API bearer)",
        "description": "Account-scoped counterpart to POST /api/developer/sandbox/provision — creates `<handle>.sandbox.motorical.com` (a Motorical-owned `.sandbox` domain, instant, no DNS) and a locked, outbound-allowlisted Motor Block. A Free account that adds and fully verifies its own domain gets a sandbox Motor Block on that domain automatically, with no provisioning call, when automatic provisioning is enabled; otherwise call this route. Idempotent per account. Credentials are returned inline in the 201 body only for a plain Public API bearer token with no OAuth/Delegation grant attached (unlike the dashboard-JWT-only /api/developer/sandbox/provision above, which always returns them). When the caller is authenticated via an OAuth-delegated grant (MCP client or a Delegation header), the response instead returns `credentialsAvailable: false` plus a `credentialsNote`, and the raw credential is never included — retrieve it later via the `credentialsLocation` dashboard link returned by POST /account/sandbox/convert.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "handle": {
                    "type": "string",
                    "description": "3–32 char label for the Motorical-owned handle.sandbox domain"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "cli",
                      "agent",
                      "web"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already provisioned (idempotent)"
          },
          "201": {
            "description": "Provisioned. Credentials are returned inline only when there is no OAuth/Delegation grant on the request; otherwise the body has `credentialsAvailable: false` and `credentialsNote` instead of raw credentials."
          },
          "401": {
            "description": "Missing, invalid or expired credential (code access_token_required, invalid_access_token or similar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "403": {
            "description": "The credential lacks a scope this operation needs, or does not cover the Motor Block named (code missing_scope or motor_block_not_authorized).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "Too many requests (code rate_limit_exceeded or RATE_LIMIT_ANONYMOUS); wait X-RateLimit-Reset seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "503": {
            "description": "sandbox_dns_unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "provisionSandbox"
      }
    },
    "/api/public/v1/account/sandbox/convert": {
      "post": {
        "tags": [
          "Account Sandbox"
        ],
        "summary": "Convert account sandbox to a verified production domain (OAuth/Public API bearer)",
        "description": "Account-scoped counterpart to POST /api/developer/sandbox/convert — same pure service function, so behavior cannot drift between a dashboard session and an OAuth-delegated agent. Requires an active Motorical subscription and a domain already added + verified. The response always includes `activeAuthMethod` (the converted Motor Block's configured auth method — Password, API Key, OAuth 2.0, or mTLS; read-only). When authenticated via an OAuth/Delegation grant it additionally includes `credentialsLocation`, a dashboard URL where the actual credential value can be viewed or regenerated — this endpoint never returns the raw credential itself. Conversion is a one-way production identity transition: the block keeps its id, password, API keys, auth method and grant coverage, but takes the chosen (or a deterministic fallback) production `name` and `type`, and its SMTP username is REPLACED with a production-derived one. Existing SMTP clients must switch to the new username; the response states the change in `previousSmtpUsername`, `smtpUsername`, `credentialChanges` and `integrationActionRequired`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domainId"
                ],
                "properties": {
                  "domainId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string",
                    "description": "Optional production name; a deterministic name is chosen when omitted"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "transactional",
                      "general_purpose"
                    ],
                    "description": "Optional production type"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted. Response data includes `motorBlockId`, `previousName`/`name`, `type`, `previousSmtpUsername`/`smtpUsername`, `credentialChanges` (username changed; password, API keys and auth method unchanged), `activeAuthMethod` always, and `credentialsLocation` (a dashboard link, never a raw credential) when the caller holds an OAuth/Delegation grant."
          },
          "400": {
            "description": "domainId is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "403": {
            "description": "subscription_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "convertSandbox"
      }
    },
    "/api/public/v1/account/free-recipients": {
      "get": {
        "tags": [
          "Account Free Recipients"
        ],
        "summary": "List Free-account recipients (OAuth/Public API bearer)",
        "description": "Addresses this account has asked to allow test email, with their status (pending, confirmed, stopped), plus the recipient limit and current usage (`usage` is null when it cannot be read). `limitsNote` says the hourly, daily and monthly numbers are the Free-plan caps for non-sandbox Motor Blocks (a sandbox block is governed by the sandbox caps in the sandbox status). Requires `recipients.manage` (MCP `manage:recipients`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Recipients, limits and usage"
          },
          "403": {
            "description": "missing_scope (requires recipients.manage / MCP manage:recipients)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "listFreeRecipients"
      },
      "post": {
        "tags": [
          "Account Free Recipients"
        ],
        "summary": "Ask a recipient to allow test email (OAuth/Public API bearer)",
        "description": "REQUESTS confirmation only: emails the address a link, and the recipient must open it and click the button. This route can never confirm or stop an address on anyone's behalf. The response is identical whether the email was sent or withheld (for example because the address chose to stop), so it cannot be used to enumerate recipients. The account email is taken from the account, never from the request. The success body includes `data.recipient = { email, status }` (status `pending`, or `confirmed` when the address is already confirmed); a stopped address reports the same shape and status as a fresh request. `pending` means a person must still click the emailed link.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Requested (or already confirmed: `alreadyConfirmed: true`)"
          },
          "400": {
            "description": "invalid_email or own_address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "403": {
            "description": "missing_scope, or ACCOUNT_NOT_VERIFIED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "409": {
            "description": "recipient_limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "rate_limited (daily) or free_recipient_request_rate_limit (hourly burst)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "502": {
            "description": "email_send_failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "addFreeRecipient"
      }
    },
    "/api/public/v1/account/free-recipients/{id}": {
      "delete": {
        "tags": [
          "Account Free Recipients"
        ],
        "summary": "Remove a Free-account recipient (OAuth/Public API bearer)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "400": {
            "description": "invalid_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "removeFreeRecipient"
      }
    },
    "/api/public/v1/motor-blocks": {
      "get": {
        "tags": [
          "Motor Blocks"
        ],
        "summary": "List motor blocks bound to the token",
        "description": "Returns the Motor Block(s) associated with the current public API token.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MotorBlocksListResponse"
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "00000000-0000-4000-8000-000000000001",
                      "name": "Example 16",
                      "type": "transactional",
                      "active": true
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired credential (code access_token_required, invalid_access_token or similar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "403": {
            "description": "The credential lacks a scope this operation needs, or does not cover the Motor Block named (code missing_scope or motor_block_not_authorized).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "Too many requests (code rate_limit_exceeded or RATE_LIMIT_ANONYMOUS); wait X-RateLimit-Reset seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          }
        },
        "operationId": "listMotorBlocks"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Short-lived Public Analytics API token used for /api/public/v1 endpoints."
      },
      "dashboardBearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Dashboard session JWT used only to mint Public Analytics API tokens."
      },
      "accountApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Account API key for token minting. Format: ApiKey ak_live_..."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Motor Block API key. Format: ApiKey mk_live_..."
      },
      "xApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Alternative API key header. Use ak_live_... for token minting or mk_live_... for /v1/send."
      },
      "tenantHeaderAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Tenant-Id",
        "description": "Communications Block tenant identifier used to scope lists, templates, campaigns, suppressions, and analytics."
      }
    },
    "schemas": {
      "MotorBlocksListResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RateLimitsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "burst": {
                "$ref": "#/components/schemas/LimitBucket"
              },
              "hourly": {
                "$ref": "#/components/schemas/LimitBucket"
              },
              "daily": {
                "$ref": "#/components/schemas/LimitBucket"
              },
              "limits": {
                "type": "object",
                "description": "Raw customer-configured limits (unaffected by throttling)"
              },
              "throttled": {
                "type": "boolean",
                "description": "Whether a system-imposed throttle is currently lowering the effective ceiling below the configured limits"
              },
              "throttleReason": {
                "type": "string",
                "nullable": true,
                "description": "Reason for the active throttle, if any"
              },
              "timestamp": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "warning": {
            "type": "string",
            "description": "Present only when counter data was temporarily unavailable; the bucket values are then ceiling-only estimates, not live counts. Note this sits at the response root here, while AccountRateLimitsResponse carries it inside data."
          }
        }
      },
      "AccountRateLimitsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "hourly": {
                "$ref": "#/components/schemas/AccountLimitBucket"
              },
              "daily": {
                "$ref": "#/components/schemas/AccountLimitBucket"
              },
              "source": {
                "type": "string",
                "description": "Where the account ceiling came from -- \"plan\" or \"fallback\""
              },
              "timestamp": {
                "type": "string",
                "format": "date-time"
              },
              "warning": {
                "type": "string",
                "description": "Present only when account usage data was temporarily unavailable (e.g. a Redis outage); the bucket values above are then fallback estimates, not live counts"
              }
            }
          }
        }
      },
      "AccountLimitBucket": {
        "type": "object",
        "properties": {
          "used": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "remaining": {
            "type": "integer"
          },
          "resetIn": {
            "type": "integer"
          }
        }
      },
      "LimitBucket": {
        "type": "object",
        "properties": {
          "used": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "remaining": {
            "type": "integer"
          },
          "percentage": {
            "type": "integer"
          },
          "resetIn": {
            "type": "integer"
          }
        }
      },
      "LogsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LogItem"
                }
              },
              "nextCursor": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "MessageSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "smtpMessageId": {
            "type": "string",
            "nullable": true
          },
          "recipient": {
            "type": "string"
          },
          "currentOutcome": {
            "type": "string",
            "enum": [
              "queued",
              "processed",
              "deferred",
              "delivered",
              "bounced",
              "failed",
              "complained"
            ]
          },
          "smtpCode": {
            "type": "string",
            "nullable": true
          },
          "queuedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MessageResource": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "smtpMessageId": {
            "type": "string",
            "nullable": true
          },
          "currentOutcome": {
            "type": "string"
          },
          "isTerminal": {
            "type": "boolean"
          },
          "from": {
            "type": "string"
          },
          "recipient": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "queuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "processedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "deliveredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "bouncedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "smtpCode": {
            "type": "string",
            "nullable": true
          },
          "smtpResponse": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "event": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "smtpMessageId": {
            "type": "string",
            "nullable": true
          },
          "motorBlockId": {
            "type": "string",
            "format": "uuid"
          },
          "from": {
            "type": "string"
          },
          "recipient": {
            "type": "string"
          },
          "recipients": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "subject": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "currentOutcome": {
            "type": "string"
          },
          "isTerminal": {
            "type": "boolean"
          },
          "smtpCode": {
            "type": "string",
            "nullable": true
          },
          "smtpResponse": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "LogItem": {
        "$ref": "#/components/schemas/MessageSummary"
      },
      "MetricsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "series": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MetricsPoint"
                }
              },
              "totals": {
                "$ref": "#/components/schemas/MetricsTotals"
              }
            }
          }
        }
      },
      "MetricsPoint": {
        "type": "object",
        "properties": {
          "t": {
            "type": "string",
            "format": "date-time"
          },
          "total": {
            "type": "integer"
          },
          "processed": {
            "type": "integer"
          },
          "delivered": {
            "type": "integer"
          },
          "bounced": {
            "type": "integer"
          },
          "deferred": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "complained": {
            "type": "integer"
          }
        }
      },
      "MetricsTotals": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "processed": {
            "type": "integer"
          },
          "delivered": {
            "type": "integer"
          },
          "bounced": {
            "type": "integer"
          },
          "deferred": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "complained": {
            "type": "integer"
          }
        }
      },
      "OverviewResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "timeWindow": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "to": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              },
              "totals": {
                "type": "object",
                "properties": {
                  "sent": {
                    "type": "integer"
                  },
                  "delivered": {
                    "type": "integer"
                  },
                  "bounced": {
                    "type": "integer"
                  },
                  "complained": {
                    "type": "integer"
                  }
                }
              },
              "rates": {
                "type": "object",
                "properties": {
                  "deliveryRate": {
                    "type": "number"
                  },
                  "bounceRate": {
                    "type": "number"
                  },
                  "complaintRate": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      },
      "MessageResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/MessageResource"
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Every error body on this API. Branch on `code` (case-sensitive, never changes once published); never on `error` or `message` text. Every code: https://docs.motorical.com/api-reference/errors",
        "required": [
          "success",
          "error",
          "code"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "code": {
            "type": "string",
            "description": "Stable machine code. New codes are lower snake_case; some older codes are upper case and stay that way. Catalogue: https://docs.motorical.com/api-reference/errors",
            "examples": [
              "api_key_required",
              "VALIDATION_ERROR",
              "rate_limited_block"
            ]
          },
          "error": {
            "type": "string",
            "description": "Short description, or the code itself on some routes. For display, not for branching."
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation. Can change."
          },
          "requestId": {
            "type": "string",
            "description": "Same value as the X-Request-Id response header."
          },
          "details": {
            "description": "Per-field problems on validation errors, or extra context."
          },
          "nextAction": {
            "type": "object",
            "description": "When present: what to do next, and whether a person must do it (humanRequired).",
            "additionalProperties": true
          },
          "retryAfterSeconds": {
            "type": "integer",
            "description": "On some 429 and 503 answers: seconds to wait. The Retry-After header carries the same value where set."
          }
        },
        "additionalProperties": true,
        "example": {
          "success": false,
          "code": "api_key_required",
          "error": "API key required for /v1/send",
          "message": "API key required for /v1/send: send Authorization: ApiKey mk_live_<prefix>_<secret> (or X-Api-Key), or an OAuth token with send:transactional",
          "requestId": "req_5f0c2a9d4b7e41c3a8e2f6b1"
        }
      }
    },
    "headers": {
      "RequestId": {
        "description": "Unique id of this request, on every response. Quote it to support. A safe caller-supplied X-Request-Id is echoed back.",
        "schema": {
          "type": "string"
        }
      }
    }
  },
  "x-motorical-error-codes": [
    "api_key_required",
    "invalid_api_key",
    "access_token_required",
    "invalid_access_token",
    "invalid_token_type",
    "authorization_revoked",
    "INVALID_TOKEN",
    "TOKEN_EXPIRED",
    "unauthorized",
    "missing_scope",
    "grant_mismatch",
    "delegation_grant_mismatch",
    "motor_block_not_authorized",
    "motor_block_not_owned",
    "motor_block_not_found",
    "motor_block_id_required",
    "motor_block_id_conflict",
    "no_motor_block_covered",
    "oauth_grant_inactive",
    "subscription_required",
    "account_suspended",
    "ACCOUNT_NOT_VERIFIED",
    "use_comms_api",
    "feature_not_enabled",
    "forbidden",
    "MISSING_TOKEN",
    "AUTH_ERROR",
    "MISSING_REFRESH_TOKEN",
    "INVALID_REFRESH_TOKEN",
    "PASSWORD_NOT_SET",
    "PASSWORD_SETUP_NOT_REQUIRED",
    "ACCOUNT_SUSPENDED",
    "SIGNS_IN_ELSEWHERE",
    "VERIFIED_NO_PASSWORD",
    "UNVERIFIED_TOKEN_REFRESHED",
    "UNVERIFIED_EXPIRING_SOON",
    "EMAIL_CODE_REQUIRED",
    "EMAIL_CODE_NOT_APPLICABLE",
    "EMAIL_CODE_RATE_LIMITED",
    "NO_MFA_FACTOR",
    "TOTP_ALREADY_ENABLED",
    "AUTH_RATE_LIMIT",
    "signup_handoff_rate_limit",
    "signup_handoff_status_rate_limit",
    "ACCESS_DENIED",
    "DNS_TOKEN_MISMATCH",
    "DNS_RECORD_NOT_FOUND",
    "DNS_VERIFICATION_FAILED",
    "EMAIL_REQUIRED",
    "INVALID_EMAIL",
    "DOMAIN_HAS_MOTOR_BLOCKS",
    "VALIDATION_ERROR",
    "MISSING_REQUIRED_FIELD",
    "DISALLOWED_HEADERS",
    "ILLEGAL_HEADER_CHARS",
    "conflicting_fields",
    "invalid_attachment",
    "invalid_email",
    "invalid_id",
    "invalid_smtp_code",
    "IDEMPOTENCY_KEY_REQUIRED",
    "IDEMPOTENCY_KEY_INVALID",
    "idempotency_key_conflict",
    "webhook_url_blocked",
    "bad_request",
    "unprocessable",
    "DOMAIN_DNS_INCOMPLETE",
    "recipient_suppressed",
    "content_policy_rejected",
    "attachment_too_large",
    "attachments_total_too_large",
    "too_many_attachments",
    "attachment_type_not_allowed",
    "attachments_not_allowed",
    "payload_too_large",
    "message_too_large",
    "gateway_reply_unreadable",
    "delivery_status_unknown",
    "temporarily_unavailable",
    "sandbox_outbound_locked",
    "sandbox_recipient_denied",
    "allowlist_full",
    "sandbox_monthly_limit",
    "sandbox_dns_unavailable",
    "domain_has_motor_block",
    "free_recipient_not_confirmed",
    "free_policy_unavailable",
    "own_address",
    "recipient_limit",
    "invalid_code",
    "expired",
    "email_send_failed",
    "rate_limited_block",
    "rate_limited_account",
    "rate_limited_warmup",
    "rate_limit_exceeded",
    "RATE_LIMIT_EXCEEDED",
    "RATE_LIMIT_ANONYMOUS",
    "rate_limited",
    "dryrun_rate_limited",
    "too_many_large_requests",
    "allowlist_request_rate_limit",
    "free_recipient_request_rate_limit",
    "NOT_FOUND",
    "not_found",
    "domain_not_found",
    "account_not_found",
    "user_not_found",
    "grant_not_found",
    "not_an_oauth_grant",
    "DUPLICATE_RESOURCE",
    "FOREIGN_KEY_ERROR",
    "conflict",
    "method_not_allowed",
    "INTERNAL_ERROR",
    "APPLICATION_ERROR",
    "SERVICE_UNAVAILABLE",
    "FILE_TOO_LARGE",
    "TOO_MANY_FILES",
    "internal_error",
    "bad_gateway",
    "service_unavailable",
    "gateway_timeout"
  ]
}
