{
  "openapi": "3.1.0",
  "info": {
    "title": "Motorical Public API",
    "version": "1.4.1",
    "description": "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."
    },
    {
      "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": "Send",
      "description": "Transactional email via HTTP API (POST /v1/send)"
    },
    {
      "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": "Domains",
      "description": "Add/verify customer domains; check-dns flips send-readiness (DKIM/SPF) for /v1/send"
    },
    {
      "name": "Analytics",
      "description": "Metrics, deliverability, reputation, anomalies"
    },
    {
      "name": "Logs",
      "description": "Log search and message lookups"
    },
    {
      "name": "Config",
      "description": "Configuration & domain health"
    },
    {
      "name": "Webhooks",
      "description": "Webhook endpoints and delivery monitoring"
    },
    {
      "name": "Exports",
      "description": "Export jobs and previews"
    },
    {
      "name": "Communications",
      "description": "Communications Block lists, templates, campaigns, suppressions, and analytics"
    },
    {
      "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"
    },
    {
      "name": "Account Motor Blocks",
      "description": "Account-scoped production Motor Block lifecycle for OAuth-delegated agents (MCP scope manage:motor-blocks): list, create, rename, change type, assign domain, deactivate, reactivate, permanently delete. Hosted responses never contain a credential."
    }
  ],
  "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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/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"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/api/domains": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Add a customer domain",
        "description": "Returns verification DNS instructions. For cname_managed DKIM, publish the CNAME in verification.records.dkim / dnsRecords (not a TXT p= key).",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "type": "string"
                  },
                  "verificationMethod": {
                    "type": "string",
                    "enum": [
                      "dns",
                      "email"
                    ],
                    "default": "dns"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Domain added with verification instructions"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/domains/{id}/verify": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Verify ownership and refresh DKIM/SPF send-readiness",
        "description": "First call verifies ownership TXT. Re-calling after verified=true live-checks DKIM/SPF/DMARC and sets dkim_configured/spf_configured (required for /v1/send). Response includes sendReady + summary.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "method": {
                    "type": "string",
                    "enum": [
                      "dns",
                      "email"
                    ],
                    "default": "dns"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified and/or email-auth refreshed"
          },
          "400": {
            "description": "DNS ownership not found yet"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/domains/{id}/check-dns": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Check DKIM/SPF/DMARC and persist send-readiness flags",
        "description": "Same email-auth refresh as re-verify. Use when /v1/send returns DOMAIN_DNS_INCOMPLETE despite dig showing correct records. Requires dashboard JWT (not Public API bearer / domain-health token). For a Public API bearer or MCP OAuth/Delegation grant, use POST /api/public/v1/domains/{id}/check-dns instead — same handler, no motorBlockId.",
        "security": [
          {
            "dashboardBearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recordType": {
                    "type": "string",
                    "enum": [
                      "dkim",
                      "spf",
                      "dmarc",
                      "mx"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Flags updated; sendReady true when DKIM+SPF pass"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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)"
          },
          "503": {
            "description": "sandbox_dns_unavailable"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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"
          }
        }
      }
    },
    "/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."
          },
          "503": {
            "description": "sandbox_dns_unavailable"
          }
        }
      }
    },
    "/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"
          },
          "403": {
            "description": "subscription_required"
          }
        }
      }
    },
    "/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)"
          }
        }
      },
      "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"
          },
          "403": {
            "description": "missing_scope, or ACCOUNT_NOT_VERIFIED"
          },
          "409": {
            "description": "recipient_limit"
          },
          "429": {
            "description": "rate_limited (daily) or free_recipient_request_rate_limit (hourly burst)"
          },
          "502": {
            "description": "email_send_failed"
          }
        }
      }
    },
    "/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"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks": {
      "get": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "List the account's production Motor Blocks (OAuth/Public API bearer)",
        "description": "Account-scoped inventory of `transactional` and `general_purpose` Motor Blocks covered by the CURRENT authorization grant (read live from the backend, never from a token claim), including inactive blocks. Developer-sandbox and companion blocks are excluded. Each row carries `activeAuthMethod` (read-only) and `credentialsAvailable: false` with a `credentialsLocation` dashboard link — no credential is ever returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Blocks covered by the grant; empty array when it covers none"
          },
          "403": {
            "description": "missing_scope (requires config.read / MCP manage:motor-blocks)"
          }
        }
      },
      "post": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Create a production Motor Block (OAuth/Public API bearer)",
        "description": "Creates a `transactional` or `general_purpose` Motor Block on a verified, non-sandbox domain the account owns, subject to the plan's Motor Block limit. Requires an `Idempotency-Key` header (UUID v4): a replay with the same key and input returns the same block, one database row, and never a credential. The new block is appended to the calling grant in the same transaction, so it is usable by explicit `motorBlockId` immediately, WITHOUT a token refresh or re-authorization (`authorizationUpdated`). Hosted responses never contain a password, API-key secret or certificate — `credentialsAvailable: false` and `credentialsLocation` point to the dashboard. `nextAction` suggests a `dryRun` send from the new block.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "UUID v4. Reused with different input -> 409 idempotency_conflict."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "domainId"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "domainId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "A verified, non-sandbox domain owned by the account"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "transactional",
                      "general_purpose"
                    ],
                    "default": "general_purpose"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created (or an idempotent replay of the same creation)"
          },
          "400": {
            "description": "invalid_idempotency_key | domain_id_required | unsupported_motor_block_type | sandbox_domain_not_allowed | invalid_motor_block_description"
          },
          "403": {
            "description": "subscription_required | motor_block_limit_reached (see upgradeUrl)"
          },
          "404": {
            "description": "domain_not_found"
          },
          "409": {
            "description": "domain_not_verified | motor_block_name_conflict | idempotency_conflict"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks/{id}/name": {
      "patch": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Rename a Motor Block (display name only)",
        "description": "Changes the display name. Rename NEVER changes the SMTP username or any credential; an SMTP username changes only at the sandbox-to-production conversion boundary.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Renamed"
          },
          "400": {
            "description": "motor_block_id_conflict | motor_block_type_not_manageable"
          },
          "403": {
            "description": "motor_block_not_authorized (not covered by the grant)"
          },
          "409": {
            "description": "motor_block_name_conflict"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks/{id}/type": {
      "patch": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Switch a Motor Block between transactional and general_purpose",
        "description": "Requires `confirm: true` (else 400 confirmation_required). Only `transactional` and `general_purpose` are accepted; marketing, portal and sandbox blocks fail closed. Auth method is read-only and never changed by this route.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type",
                  "confirm"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "transactional",
                      "general_purpose"
                    ]
                  },
                  "confirm": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Type changed"
          },
          "400": {
            "description": "confirmation_required | unsupported_motor_block_type | motor_block_type_not_manageable | motor_block_id_conflict"
          },
          "403": {
            "description": "motor_block_not_authorized"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks/{id}/assign-domain": {
      "post": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Assign a verified domain to a Motor Block",
        "description": "Requires `confirm: true`. The target must be a verified, non-sandbox domain owned by the account.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domainId",
                  "confirm"
                ],
                "properties": {
                  "domainId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "confirm": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Domain assigned"
          },
          "400": {
            "description": "confirmation_required | domain_id_required | sandbox_domain_not_allowed | motor_block_id_conflict"
          },
          "403": {
            "description": "motor_block_not_authorized"
          },
          "404": {
            "description": "domain_not_found"
          },
          "409": {
            "description": "domain_not_verified"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks/{id}/deactivate": {
      "post": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Deactivate (pause) a Motor Block — reversible",
        "description": "Requires `confirm: true`. Sends from the block are refused until it is reactivated. This is NOT deletion: nothing is removed. The response includes `nextAction` pointing at reactivate. A block must be inactive before it can be permanently deleted.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm"
                ],
                "properties": {
                  "confirm": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deactivated"
          },
          "400": {
            "description": "confirmation_required | motor_block_id_conflict"
          },
          "403": {
            "description": "motor_block_not_authorized"
          },
          "409": {
            "description": "motor_block_delete_in_progress"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks/{id}/reactivate": {
      "post": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Reactivate a deactivated Motor Block",
        "description": "No confirmation needed (restores service). Refused with 409 motor_block_domain_required if the block has no verified production domain, or motor_block_delete_in_progress if deletion was already queued.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reactivated"
          },
          "400": {
            "description": "motor_block_id_conflict"
          },
          "403": {
            "description": "motor_block_not_authorized"
          },
          "409": {
            "description": "motor_block_domain_required | motor_block_delete_in_progress"
          }
        }
      }
    },
    "/api/public/v1/account/motor-blocks/{id}": {
      "delete": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Permanently delete a Motor Block — asynchronous and irrecoverable",
        "description": "Requires `confirm: true` AND an explicit boolean `deleteHistory` (true also deletes the block's message logs and events; false is refused with 409 motor_block_history_present if any exist). The block must already be deactivated. Deletion is queued: the response is 202 with a `jobId`; poll GET /account/motor-block-deletions/{jobId}. Only `transactional` and `general_purpose` blocks can be deleted here (409 motor_block_type_not_supported otherwise). Deletion never affects other blocks sharing the same domain.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm",
                  "deleteHistory"
                ],
                "properties": {
                  "confirm": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "deleteHistory": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Deletion queued; poll the status route with jobId"
          },
          "400": {
            "description": "confirmation_required | delete_history_required | motor_block_id_conflict"
          },
          "403": {
            "description": "motor_block_not_authorized"
          },
          "404": {
            "description": "motor_block_not_found"
          },
          "409": {
            "description": "motor_block_must_be_inactive | motor_block_history_present | motor_block_delete_in_progress | motor_block_type_not_supported"
          }
        }
      }
    },
    "/api/public/v1/account/motor-block-deletions/{jobId}": {
      "get": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Poll a permanent-deletion job",
        "description": "Status remains queryable by the authenticated account after the block row is gone. Scoped to the job owner.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job status"
          },
          "404": {
            "description": "motor_block_deletion_not_found"
          }
        }
      }
    },
    "/api/public/v1/account/authorization/motor-blocks/{id}": {
      "get": {
        "tags": [
          "Account Motor Blocks"
        ],
        "summary": "Live grant-coverage check for one Motor Block (infrastructure)",
        "description": "Used by the hosted MCP server to obtain a live authorization decision before serving task or resource state for an explicitly named block. Returns `authorized: true` only when the CURRENT grant covers the block and the caller owns it; otherwise 403. It is not a customer workflow and no tool is exposed for it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Covered and owned"
          },
          "403": {
            "description": "motor_block_not_authorized | motor_block_not_found | motor_block_not_owned"
          }
        }
      }
    },
    "/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"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/domains": {
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "List domains on the account",
        "description": "Account-wide — domains belong to the account (domains.user_id), not to a Motor Block, and no motorBlockId is required or read. A Motor Block is created FROM a verified domain (motor_blocks.domain_id), never the reverse, so this is the entry point for a new account before any Motor Block exists. Symmetric with, and reuses the same handler as, the dashboard's domain list.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK — id, domain, verified, verified_at, dkim_configured/spf_configured/dmarc_configured/mx_configured, email_auth_status, dkim_managed_type, dkim_selector, created_at per domain"
          }
        }
      },
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Add a customer domain (account-wide, OAuth/MCP-capable)",
        "description": "Same handler as POST /api/domains — identical validation, DKIM/Cloudflare setup, and verification-instruction generation — reached over a Public API bearer or MCP OAuth/Delegation grant instead of a dashboard session. Account-wide: no motorBlockId. Returns verification DNS instructions; for cname_managed DKIM publish the CNAME in verification.records.dkim / dnsRecords (not a TXT p= key).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "type": "string"
                  },
                  "verificationMethod": {
                    "type": "string",
                    "enum": [
                      "dns",
                      "email"
                    ],
                    "default": "dns"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Domain added with verification instructions"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "free_domain_limit: a Free account already has its one domain (when Free enforcement is on). The body carries `limit`, `count` and a `nextAction` (use the domain already added, or subscribe; human required)."
          }
        }
      }
    },
    "/api/public/v1/domains/{id}/verify": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Verify ownership and refresh DKIM/SPF send-readiness (account-wide, OAuth/MCP-capable)",
        "description": "Same handler as POST /api/domains/{id}/verify, reached over a Public API bearer or MCP OAuth/Delegation grant instead of a dashboard session. Account-wide: no motorBlockId. First call verifies ownership TXT. Re-calling after verified=true live-checks DKIM/SPF/DMARC and sets dkim_configured/spf_configured (required for /v1/send). Response includes sendReady + summary.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "method": {
                    "type": "string",
                    "enum": [
                      "dns",
                      "email"
                    ],
                    "default": "dns"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified and/or email-auth refreshed"
          },
          "400": {
            "description": "DNS ownership not found yet"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/public/v1/domains/{id}/check-dns": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Check DKIM/SPF/DMARC and persist send-readiness flags (account-wide, OAuth/MCP-capable)",
        "description": "Same handler as POST /api/domains/{id}/check-dns, reached over a Public API bearer or MCP OAuth/Delegation grant instead of a dashboard session. Account-wide: no motorBlockId. Use when /v1/send returns DOMAIN_DNS_INCOMPLETE despite dig showing correct records.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recordType": {
                    "type": "string",
                    "enum": [
                      "dkim",
                      "spf",
                      "dmarc",
                      "mx"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Flags updated; sendReady true when DKIM+SPF pass"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/overview": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Motor Block overview",
        "description": "One-call overview including totals, rates, reputation, rate limits, anomalies, and top domains.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OverviewResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/daily-summary": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Daily summary",
        "description": "Daily rollups for a recent window (sent, delivered, bounced, complained, plus rates).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/rate-limits": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Motor Block rate limits",
        "description": "Current usage vs burst, hourly, and daily rate limits.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/account/rate-limits": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Account-wide rate limits",
        "description": "Account-wide send-quota usage vs the hourly and daily account cap, aggregated across all of the account's motor blocks.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountRateLimitsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/account/state": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Composed account state",
        "description": "One composed answer for \"where does this account stand\": domain verification, DNS readiness, Motor Block existence, and sandbox status in a single call, account-wide (no motorBlockId needed, works before any Motor Block exists).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/domains/{id}": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "One sending domain",
        "description": "One domain of the account by id: verified, DNS authentication flags, DKIM mode, created. Read-only, no keys or tokens. 404 when the id is not one of your domains.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Domain not found"
          }
        }
      }
    },
    "/api/public/v1/domains/{id}/health": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Email-authentication health of one domain",
        "description": "SPF, DKIM, DMARC, status and issues for one domain by id, cache-first with a source field. Works for a domain that has no Motor Block yet. Add refresh=true for a live DNS check.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "refresh",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Domain not found"
          }
        }
      }
    },
    "/api/public/v1/domains/{id}/dns-records": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "DNS records to publish for one domain",
        "description": "The DNS records to publish for the domain and what each is for. Add lookup=true to also check what DNS currently answers (slower, live lookups).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "lookup",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Domain not found"
          }
        }
      }
    },
    "/api/public/v1/account/whoami": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Account identity, plan and grant",
        "description": "Who the credential acts for, account-wide (no motorBlockId needed): the account id, owner email and name, the plan name and status, and, for an OAuth grant, the client, the scopes it holds, the Motor Blocks it covers, when it was granted, canAdd (permissions it could still be given, available:false where the plan does not allow it) and addInDashboard. grant is null when the call is not made over an OAuth grant. account.billing carries the plan price (amount in minor units, currency, interval), trial end, current period end and next renewal date, whether it cancels at period end and when it ends, this month's sends against the plan cap (the dashboard figure), and whether the payment method is ok or failing. It is returned to every connection that can call whoami, needs no extra scope, and never includes invoices, receipts, card details or tax ids. A field that cannot be resolved is null with its reason under billing.unavailable.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Account not found"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/metrics": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Metrics series and totals",
        "description": "Aggregated metrics (sent, delivered, bounced, complained) over hour/day buckets.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "interval",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/deliverability": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Deliverability by recipient domain",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/reputation": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Delivery reputation score",
        "description": "The delivery reputation score (0-100), computed on request from this Motor Block delivery outcomes over the token retention window. It is not the dashboard Health score (a different formula over the dashboard timeframe), not the internal score behind automatic throttling, and not domain health (SPF, DKIM, DMARC), so those numbers differ by design; the response labels itself with kind, basis, formula and notTheSameAs. The overview reputation block is the same payload.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "score": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100,
                          "description": "Starts at 100, minus 50 points per 1% bounced, 20 points per 0.1% complained and 10 points per 1% failed (pro rata), limited to 0-100"
                        },
                        "windowDays": {
                          "type": "integer",
                          "description": "The window the score covers (the token retention window)"
                        },
                        "totals": {
                          "type": "object",
                          "properties": {
                            "total": {
                              "type": "integer"
                            },
                            "delivered": {
                              "type": "integer"
                            },
                            "bounced": {
                              "type": "integer",
                              "description": "Every bounce in the window"
                            },
                            "bouncedCounted": {
                              "type": "integer",
                              "description": "Present where the bounce-cause rule is active: the bounces that feed the score (address or domain does not exist, policy blocks, anything unclassified)"
                            },
                            "bouncedExcluded": {
                              "type": "integer",
                              "description": "Present where the bounce-cause rule is active: bounces not counted (full mailbox, network failure, a block on the platform own sending network)"
                            },
                            "complained": {
                              "type": "integer"
                            },
                            "failed": {
                              "type": "integer"
                            }
                          }
                        },
                        "rates": {
                          "type": "object",
                          "description": "Percentages. bounceRate is the counted rate where the bounce-cause rule is active",
                          "properties": {
                            "bounceRate": {
                              "type": "number"
                            },
                            "complaintRate": {
                              "type": "number"
                            },
                            "failRate": {
                              "type": "number"
                            }
                          }
                        },
                        "lowVolume": {
                          "type": "boolean",
                          "description": "Present (true) when the window has fewer than 50 sends: bounces are not scored yet, only complaints and failures"
                        },
                        "note": {
                          "type": "string",
                          "description": "Present with lowVolume: says so in words"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "delivery_reputation_score"
                          ],
                          "description": "Which score this is"
                        },
                        "label": {
                          "type": "string"
                        },
                        "basis": {
                          "type": "string",
                          "description": "What the score is computed from and over how many days. Where the bounce-cause rule is active it ends with a sentence saying which bounces are not counted"
                        },
                        "formula": {
                          "type": "string"
                        },
                        "notTheSameAs": {
                          "type": "string",
                          "description": "How it differs from the dashboard Health score, the internal sending-policy score and domain health"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/anomalies": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Anomaly detection (bounce spikes)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/providers": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Provider breakdown (gmail, outlook, yahoo, other)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/error-codes": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "SMTP error code diagnostics",
        "description": "The SMTP codes recorded for this Motor Block in the window, most frequent first, each with a specific diagnosis. Counts are recipient outcomes: the same rows GET /motor-blocks/{id}/logs?smtpCode=<code> returns. The stored code is basic (550), enhanced (5.7.1) or a bucket (200 delivered to a Motorical-hosted mailbox; 400 and 500 when the exact code was not recorded).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "to": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "description": "The stored SMTP code"
                              },
                              "count": {
                                "type": "integer",
                                "description": "Recipient outcomes with this code in the window"
                              },
                              "sampleStatus": {
                                "type": "string",
                                "nullable": true,
                                "description": "An outcome seen with this code (for example bounced, deferred, delivered)"
                              },
                              "category": {
                                "type": "string",
                                "enum": [
                                  "success",
                                  "temporary",
                                  "permanent",
                                  "unknown"
                                ]
                              },
                              "label": {
                                "type": "string",
                                "description": "What the code means, in one line"
                              },
                              "hint": {
                                "type": "string",
                                "description": "What to do about it"
                              },
                              "cause": {
                                "type": "string",
                                "description": "The platform bounce-classifier bucket (recipient_invalid, recipient_mailbox_full, recipient_dns_failure, policy_block_reputation, policy_block_content, policy_block_auth, temporary_deferral, network_failure, unclassified) or success, permanent_refusal, unrecorded_temporary, unrecorded_permanent, unrecorded"
                              },
                              "codeForm": {
                                "type": "string",
                                "enum": [
                                  "basic",
                                  "enhanced",
                                  "bucket",
                                  "other"
                                ]
                              },
                              "retryable": {
                                "type": "boolean",
                                "nullable": true,
                                "description": "true for a temporary failure the platform retries on its own; false for a permanent one; null for a success"
                              },
                              "suggestedAction": {
                                "type": "string",
                                "enum": [
                                  "none",
                                  "retry",
                                  "remove",
                                  "investigate"
                                ]
                              },
                              "lookup": {
                                "type": "object",
                                "description": "Pass these as query parameters to GET /motor-blocks/{id}/logs to list the messages behind this code",
                                "properties": {
                                  "smtpCode": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Token not bound to this Motor Block, or missing the analytics.read scope"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/logs": {
      "get": {
        "tags": [
          "Logs"
        ],
        "summary": "Search logs with cursor pagination",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "currentOutcome",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "processed",
                "deferred",
                "delivered",
                "bounced",
                "failed",
                "complained"
              ]
            }
          },
          {
            "name": "smtpCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by the SMTP code the receiving server reported. The stored value is either basic (550) or enhanced (5.7.1), so besides an exact code you can pass a class (5xx, 4xx or 5.x.x), a group (5.7.x), or a comma-separated list of up to 10 (for example 5.7.x,4xx). An invalid value is a 400 with error invalid_smtp_code.",
            "example": "5.7.x"
          },
          {
            "name": "query",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Space-separated key:value terms, all of which must match: recipient:<exact address>, domain:<exact domain>, code:<an SMTP code filter, same forms as smtpCode>, id:<message uuid>. Text without a known key is ignored."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includePII",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Requires logs.pii scope"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LogsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      }
    },
    "/api/public/v1/messages/{id}": {
      "get": {
        "tags": [
          "Logs"
        ],
        "summary": "Get message by send id (UUID)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "includePII",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Requires logs.pii scope"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/api/public/v1/messages": {
      "get": {
        "tags": [
          "Logs"
        ],
        "summary": "Lookup message by RFC Message-ID header",
        "description": "Not a collection/list endpoint. Requires query smtpMessageId (the RFC Message-ID / SMTP message id). For listing recent sends use GET /motor-blocks/{id}/logs. For lookup by send UUID use GET /messages/{id}.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "smtpMessageId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "RFC Message-ID value (with or without angle brackets)"
          },
          {
            "name": "includePII",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK — data.items has 0 or 1 match"
          },
          "400": {
            "description": "Missing smtpMessageId"
          }
        }
      }
    },
    "/api/public/v1/messages/{id}/events": {
      "get": {
        "tags": [
          "Logs"
        ],
        "summary": "Get message event timeline",
        "description": "Canonical lifecycle events from email_events.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "includePII",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Requires logs.pii scope"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/messages/{id}/recipients": {
      "get": {
        "tags": [
          "Logs"
        ],
        "summary": "Per-recipient outcomes for a multi-recipient send",
        "description": "GET /messages/{id} and GET /messages/{id}/events both collapse to a single email_events row (whichever recipient's log line landed first). This reads postfix_log_events grouped by recipient — the only place a multi-recipient send's individual recipient outcomes are visible.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "includePII",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Requires logs.pii scope"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/config": {
      "get": {
        "tags": [
          "Config"
        ],
        "summary": "Motor Block config snapshot",
        "description": "Read-only, non-sensitive configuration snapshot and domain status.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/domain-health": {
      "get": {
        "tags": [
          "Config"
        ],
        "summary": "Domain health (SPF/DKIM/DMARC): a set-up status, not a score",
        "description": "Cache-first: returns DB auth flags immediately (sub-second). Stale/cold checks schedule an async DNS refresh. Pass refresh=true to wait for a live re-check (capped; may still return prior cache on timeout).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "If true, attempt a synchronous live DNS refresh before responding"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhooks",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create webhook",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "events": {
                    "type": "array",
                    "description": "Defaults to all six events when omitted.",
                    "items": {
                      "type": "string",
                      "enum": [
                        "message.processed",
                        "message.deferred",
                        "message.delivered",
                        "message.bounced",
                        "message.failed",
                        "message.complained"
                      ]
                    }
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. The signing secret is returned once and is not retrievable afterwards.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "url": {
                          "type": "string"
                        },
                        "events": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "secret": {
                          "type": "string",
                          "description": "Shown once. Store it — required for X-Motorical-Signature verification."
                        },
                        "secretMasked": {
                          "type": "string"
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/webhooks/{webhookId}": {
      "put": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Update webhook",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete webhook",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/webhooks/{webhookId}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Enqueue a test webhook delivery",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/webhooks/{webhookId}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Webhook delivery history",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/webhooks/{webhookId}/stats": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Webhook delivery stats",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "hours",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 168
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/events/stream": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Event stream (SSE)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/exports": {
      "post": {
        "tags": [
          "Exports"
        ],
        "summary": "Create export job",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jobType": {
                    "type": "string",
                    "enum": [
                      "logs",
                      "metrics"
                    ]
                  },
                  "params": {
                    "type": "object"
                  },
                  "includePII": {
                    "type": "boolean",
                    "description": "Requires logs.pii scope. Default false — recipient addresses are masked in the generated file otherwise."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      },
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "List recent export jobs",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/motor-blocks/{id}/exports/preview": {
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "Preview recent logs (no job creation)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "includePII",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Requires logs.pii scope"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/exports/{jobId}": {
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "Get export job status",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/public/v1/exports/{jobId}/download": {
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "Download export file (signed token, single-use)",
        "description": "The file is deleted on a successful download — exports are not retained. GET the job status again for a fresh token against the same file if the download did not complete. An unretrieved file is deleted automatically 24 hours after the job completes.",
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/test-email": {
      "post": {
        "tags": [
          "Send"
        ],
        "summary": "Test SMTP setup parameters",
        "description": "Validate SMTP setup parameters for customer setup flows. Authenticated with a Motor Block API key supplied as `Authorization: ApiKey mk_live_...` or `X-Api-Key: mk_live_...`.",
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "xApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "method",
                  "host",
                  "port",
                  "username",
                  "to",
                  "subject"
                ],
                "properties": {
                  "method": {
                    "type": "string",
                    "enum": [
                      "basic_auth",
                      "starttls",
                      "api_key",
                      "oauth2",
                      "mtls"
                    ]
                  },
                  "host": {
                    "type": "string"
                  },
                  "port": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 65535
                  },
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string",
                    "format": "email"
                  },
                  "subject": {
                    "type": "string"
                  },
                  "requireTLS": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SMTP test accepted"
          },
          "401": {
            "description": "Motor Block API key missing or invalid"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/v1/send": {
      "post": {
        "tags": [
          "Send"
        ],
        "summary": "Send or validate an email",
        "description": "Queue an email for immediate delivery, or validate the payload only when `dryRun: true`. `dryRun` defaults to false on this route: the email is sent unless you pass `dryRun: true`, so always set it explicitly. Authenticated via Motor Block API key (`Authorization: ApiKey mk_live_...` or `X-Api-Key: mk_live_...`).\n\n**Dry run:** `dryRun: true` performs the same authentication, domain, DNS, recipient, subject, and body-size checks but does not insert an email log or push delivery work to Redis.\n\n**Idempotency:** Include an `Idempotency-Key` header to prevent duplicate sends on retries (24h window).\n\n**Webhook verification:** Delivery events are posted to your webhook endpoints with an `X-Motorical-Signature` header containing an HMAC-SHA256 hex digest computed over the JSON body using the webhook secret you received at creation time. Verify with: `crypto.createHmac(\"sha256\", secret).update(body).digest(\"hex\")`.",
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "xApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "from",
                  "to",
                  "subject"
                ],
                "properties": {
                  "from": {
                    "type": "string",
                    "format": "email",
                    "description": "Sender address (must match motor block domain). Bare email only — use fromName for display name."
                  },
                  "fromName": {
                    "type": "string",
                    "maxLength": 78,
                    "description": "Optional From display name (e.g. \"Acme Billing\"). Produces From: \"Acme Billing\" <addr@domain>. Do not set a From custom header (DISALLOWED_HEADERS).",
                    "example": "Acme Billing"
                  },
                  "to": {
                    "oneOf": [
                      {
                        "type": "string",
                        "format": "email"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "email"
                        },
                        "maxItems": 50
                      }
                    ],
                    "description": "Recipient address, or a list of addresses. One request is one message: every recipient receives the same message and the To header shows the addresses as written. For a separate message per person, send one request each."
                  },
                  "cc": {
                    "oneOf": [
                      {
                        "type": "string",
                        "format": "email"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "email"
                        },
                        "maxItems": 50
                      }
                    ],
                    "description": "Copy recipients, named in the Cc header. to, cc and bcc together take at most 50 addresses. Rolling out per Motor Block: 422 feature_not_enabled where not available."
                  },
                  "bcc": {
                    "oneOf": [
                      {
                        "type": "string",
                        "format": "email"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "email"
                        },
                        "maxItems": 50
                      }
                    ],
                    "description": "Blind-copy recipients: they receive the message but are named in no header. Rolling out per Motor Block."
                  },
                  "replyTo": {
                    "type": "string",
                    "format": "email",
                    "description": "Reply-To address. Not allowed together with a Reply-To custom header (422 conflicting_fields). Rolling out per Motor Block."
                  },
                  "subject": {
                    "type": "string",
                    "maxLength": 998,
                    "description": "Email subject"
                  },
                  "text": {
                    "type": "string",
                    "description": "Plain text body"
                  },
                  "html": {
                    "type": "string",
                    "description": "HTML body"
                  },
                  "headers": {
                    "type": "object",
                    "description": "Custom headers applied to the outgoing message and DKIM-signed (e.g. In-Reply-To, References, Reply-To, List-Unsubscribe, custom X-*). Reserved/spoofable headers are rejected with 400 DISALLOWED_HEADERS: From, Sender, Return-Path, To, Cc, Bcc, Subject, Date, Message-ID, MIME-Version, Content-*, DKIM-Signature, Received, Authentication-Results, ARC-*, X-Motorical-*. Header values containing CR/LF are also rejected.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "description": "Files to attach. Your plan decides how many, how large (per file and in total) and which types, exactly as over SMTP; a refusal names the plan and the limit. Rolling out per Motor Block: 422 feature_not_enabled where not available.",
                    "items": {
                      "type": "object",
                      "required": [
                        "filename",
                        "content"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "filename": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 255,
                          "description": "No path separators or control characters"
                        },
                        "content": {
                          "type": "string",
                          "description": "The file bytes, base64 (standard alphabet, no data: prefix; line breaks are tolerated)"
                        },
                        "contentType": {
                          "type": "string",
                          "maxLength": 127,
                          "description": "MIME type; derived from the filename when omitted"
                        },
                        "contentId": {
                          "type": "string",
                          "maxLength": 128,
                          "description": "For an inline image: reference it in html as cid:<contentId>"
                        },
                        "disposition": {
                          "type": "string",
                          "enum": [
                            "attachment",
                            "inline"
                          ],
                          "description": "inline requires a contentId"
                        }
                      }
                    }
                  },
                  "dryRun": {
                    "type": "boolean",
                    "default": false,
                    "description": "Validate without queueing or writing email logs. With attachments it also runs the plan check (not the virus and content scan)."
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Unique key to prevent duplicate sends (24h window)"
          }
        ],
        "responses": {
          "200": {
            "description": "Email queued, or payload validated when dryRun=true",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dryRun": {
                      "type": "boolean"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "acceptanceStatus": {
                          "type": "string",
                          "enum": [
                            "queued",
                            "validated"
                          ]
                        },
                        "from": {
                          "type": "string"
                        },
                        "fromName": {
                          "type": "string",
                          "nullable": true
                        },
                        "to": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "subject": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "bodySize": {
                          "type": "integer"
                        },
                        "recipientCount": {
                          "type": "integer"
                        },
                        "cc": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Echoed when cc was sent"
                        },
                        "bcc": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Echoed when bcc was sent"
                        },
                        "replyTo": {
                          "type": "string",
                          "description": "Echoed when replyTo was sent"
                        },
                        "skipped": {
                          "type": "array",
                          "description": "Recipients that were not sent to (today: suppressed)",
                          "items": {
                            "type": "object",
                            "properties": {
                              "address": {
                                "type": "string"
                              },
                              "role": {
                                "type": "string",
                                "enum": [
                                  "to",
                                  "cc",
                                  "bcc"
                                ]
                              },
                              "reason": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "attachments": {
                          "type": "array",
                          "description": "dryRun only: what would be attached, with decoded sizes in bytes",
                          "items": {
                            "type": "object",
                            "properties": {
                              "filename": {
                                "type": "string"
                              },
                              "size": {
                                "type": "integer"
                              },
                              "contentType": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "attachmentBytes": {
                          "type": "integer",
                          "description": "dryRun only: total decoded size of the attachments"
                        },
                        "timestamp": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "validated"
                          ],
                          "description": "Present on dryRun responses only"
                        },
                        "hasText": {
                          "type": "boolean",
                          "description": "dryRun only"
                        },
                        "hasHtml": {
                          "type": "boolean",
                          "description": "dryRun only"
                        },
                        "motorBlockId": {
                          "type": "string",
                          "format": "uuid",
                          "description": "dryRun only"
                        },
                        "sandboxPreview": {
                          "type": "object",
                          "description": "dryRun on a sandbox Motor Block only: what a real send would be refused for. Nothing is refused by the dry run itself.",
                          "properties": {
                            "allowlistChecked": {
                              "type": "boolean"
                            },
                            "wouldRefuse": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Recipients a real send would refuse; empty when fine"
                            },
                            "code": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "sandbox_outbound_locked",
                                "sandbox_recipient_denied",
                                null
                              ]
                            },
                            "allowlist": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "sandboxRedirect": {
                          "type": "object",
                          "nullable": true,
                          "deprecated": true,
                          "description": "No longer returned; sandbox sends to a recipient outside the allowlist are refused with 403 sandbox_outbound_locked (a locked sandbox, the default) or sandbox_recipient_denied (after an explicit unlock).",
                          "properties": {
                            "requestedTo": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "format": "email"
                              }
                            },
                            "deliveredTo": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "format": "email"
                              }
                            },
                            "reason": {
                              "type": "string",
                              "example": "sandbox_outbound_locked"
                            }
                          }
                        }
                      }
                    },
                    "idempotent": {
                      "type": "boolean",
                      "description": "true when an Idempotency-Key matched a send from the last 24h"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Disallowed custom header(s) (code DISALLOWED_HEADERS) or invalid from address"
          },
          "401": {
            "description": "API key missing or invalid for /v1/send"
          },
          "403": {
            "description": "Domain mismatch, unverified, DOMAIN_DNS_INCOMPLETE (hint: check-dns), `no_motor_block_covered` (the authorization covers no Motor Block yet; reconnect), a sandbox or Free recipient refusal (`sandbox_recipient_denied` or `sandbox_outbound_locked` for a recipient outside the sandbox allowlist, with `denied` and `allowlist`, never redirected; `free_recipient_not_confirmed` for an unconfirmed Free recipient; each with a `nextAction`), or `use_comms_api`: the API key belongs to a marketing motor block. Marketing blocks send only through Communications (campaigns in the dashboard, or the Comms Block API with your account API key and a workspace); use a transactional block for transactional email."
          },
          "404": {
            "description": "Motor block not found"
          },
          "413": {
            "description": "Request body or attachments too large. `error` is attachment_too_large or attachments_total_too_large (the body names the plan, the limit and the actual size) or payload_too_large (the JSON body is over the platform message capacity)."
          },
          "422": {
            "description": "Validation error (VALIDATION_ERROR), or a refusal that names its reason in `code`: feature_not_enabled (cc, bcc, replyTo or attachments are not enabled for this Motor Block yet), conflicting_fields, invalid_attachment (not valid base64), too_many_attachments, attachment_type_not_allowed, attachments_not_allowed, content_policy_rejected."
          },
          "429": {
            "description": "Send quota exceeded. `error` is one of free_limit_hour, free_limit_day or free_limit_month (Free account window cap on non-sandbox Motor Blocks; `nextAction` says whether to retry after Retry-After or subscribe), sandbox_monthly_limit (the sandbox real-send cap for the month; subscribe and convert), rate_limited_block (Motor Block burst/hourly/daily ceiling, enforced today), rate_limited_account (account-wide hourly/daily ceiling, enforced), or rate_limited_warmup (sending domain is warming up and its buffer is full, enforced). Large requests are also bounded: too_many_large_requests (too many large bodies in flight for the Motor Block or the platform) and dryrun_rate_limited (dryRun checks with large attachments, per minute). Retry-After (seconds) is always set. RateLimit-Limit / RateLimit-Remaining / RateLimit-Reset are set for the block and account ceilings, but not for rate_limited_warmup.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until the bound window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "The ceiling that bound (absent on rate_limited_warmup)"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "0 on a quota refusal (absent on rate_limited_warmup)"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until reset (absent on rate_limited_warmup)"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "rate_limited_block",
                        "rate_limited_account",
                        "rate_limited_warmup",
                        "too_many_large_requests",
                        "dryrun_rate_limited"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "retryAfterSeconds": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The sending service is briefly unavailable, or an attachment scan could not run. Nothing was sent: retry after Retry-After, with the same Idempotency-Key.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/v1/status": {
      "get": {
        "tags": [
          "Send"
        ],
        "summary": "Get HTTP Send API service status",
        "responses": {
          "200": {
            "description": "Service status"
          }
        }
      }
    },
    "/api/comm/tenant": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Discover or provision Communications workspaces",
        "servers": [
          {
            "url": "https://api.motorical.com",
            "description": "Motorical production API"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/comm-api/api/health": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Communications API health",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/comm-api/api/workspaces": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List Communications workspaces",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a Communications workspace",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/comm-api/api/workspaces/{id}": {
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update a Communications workspace",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete a Communications workspace and everything in it (irreversible)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`. Permanently deletes the workspace and everything in it: its people, lists, templates, campaigns and webhooks. This cannot be undone. Call it first with { \"dryRun\": true } to get the counts that would go (willDelete: people, lists, templates, campaigns) and nothing is deleted. The real call must repeat the workspace name exactly: { \"confirmName\": \"<name>\" } (400 CONFIRM_NAME_MISMATCH). Refused with 409 WORKSPACE_IS_DEFAULT for the default workspace (make another workspace the default first) and with 409 WORKSPACE_HAS_ACTIVE_CAMPAIGNS, listing the campaigns, while any campaign is scheduled or sending. Account suppressions are shared by every workspace and are not touched, and the sending Motor Block stays in your account. Another account's workspace answers 404. This is a dashboard-grade action: an MCP assistant can never delete a workspace.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "CONFIRM_NAME_MISMATCH"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Workspace not found"
          },
          "409": {
            "description": "WORKSPACE_IS_DEFAULT or WORKSPACE_HAS_ACTIVE_CAMPAIGNS"
          }
        }
      }
    },
    "/comm-api/api/workspaces/{id}/motor-blocks": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List Motor Blocks assigned to a workspace",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "put": {
        "tags": [
          "Communications"
        ],
        "summary": "Replace workspace Motor Block assignments",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/comm-api/api/workspaces/{id}/motor-blocks/from-domain": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Resolve a sending domain to a companion marketing Motor Block",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/comm-api/api/workspaces/{id}/settings/consent": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get workspace consent settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update workspace consent settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/comm-api/api/workspaces/{id}/settings/open-tracking": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get workspace open-tracking settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update workspace open-tracking settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/comm-api/api/workspaces/{id}/settings/unsubscribe": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get workspace unsubscribe landing page",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`.",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update workspace unsubscribe landing page",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Account-scoped Communications Block endpoint. Requires caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...`. Does not require `X-Tenant-Id`. The same setting as PATCH /settings/unsubscribe, for any workspace of your account without switching X-Tenant-Id. Another account's workspace answers 404 before anything is checked or saved. Body: { \"unsubscribe_landing_url\": \"https://...\" }, or null to use the default Motorical page. The URL must be https, at most 2048 characters, without credentials, on a domain verified in your account or a subdomain of one (400 LANDING_URL_INVALID, 400 LANDING_DOMAIN_NOT_VERIFIED).",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "LANDING_URL_INVALID or LANDING_DOMAIN_NOT_VERIFIED"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Workspace not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/comm-api/api/lists": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List contact lists",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Each list is returned as a card: description, kind, source_label, provenance, snapshot and computed counts (see GET /lists/{id}), plus description_check.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a contact list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). A list explains itself. Card fields: description (what it is for, max 1000, no counts), kind (one of subscribers, customers, leads, event, test, reengagement, derived, system_view, other) and source_label (where the contacts came from, max 200). The API only warns about a thin description (description_check); the MCP and the dashboard insist on a good one. Send X-Motorical-Actor: agent, dashboard or api to record who made it (informational, never a permission).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "X-Motorical-Actor",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "dashboard",
                "api"
              ]
            },
            "description": "Optional. Who is acting; recorded on the list card (provenance.created_by). Informational: it never grants or limits anything. Defaults to api."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_KIND or INVALID_FIELD"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Bulk delete contact lists",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Lists in use are refused and named in failed[] with reason LIST_IN_USE (same rule as the single delete); the rest are deleted. Takes the same contacts (keep or delete_orphans) and dry_run fields as the single delete. If every list is in use the answer is 409 LIST_IN_USE.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "LIST_IN_USE for every list"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/from-filter": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a smart list from filters",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Copies the matching contacts into a new list ONCE (max 10000): a snapshot, which does not follow the filter later. The card says so (snapshot: true) and records the filter. Accepts the same card fields as POST /lists.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "X-Motorical-Actor",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "dashboard",
                "api"
              ]
            },
            "description": "Optional. Who is acting; recorded on the list card (provenance.created_by). Informational: it never grants or limits anything. Defaults to api."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}": {
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update a contact list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). This is a partial update: only the fields you send change (name, description, kind, source_label); null clears one. The card keeps its provenance (who made the list, how, when, with dated notes). Warnings about a thin description come back in description_check, never as a refusal.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Motorical-Actor",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "dashboard",
                "api"
              ]
            },
            "description": "Optional. Who is acting; recorded on the list card (provenance.created_by). Informational: it never grants or limits anything. Defaults to api."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_KIND or INVALID_FIELD"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete a contact list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). A list that a draft, scheduled or sending campaign sends to, or that ANY campaign excludes (finished or not), cannot be deleted: 409 LIST_IN_USE names the campaigns (used_by with role include or exclude, used_by_count). Deleting it would silently change who those campaigns reach. Query or body field contacts: keep (default) leaves the people in the workspace; delete_orphans also erases the people who are on no other list. People who unsubscribed, bounced, complained or are suppressed are always kept. dry_run=true returns the numbers (candidates, would_delete, kept) and changes nothing. The answer carries contacts: { mode, candidates, deleted, kept }.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "LIST_IN_USE"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get one contact list as a card",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). One list as a card. Written by you: name, description, kind, source_label. Recorded: provenance (created_by, origin, sources, excludes, filter, snapshot_at and dated notes). Computed on every read, never stored: member_count, eligible_count (active, not deleted, not suppressed), unsubscribed_count, bounced_count, other_inactive_count, suppressed_count; used_by and used_by_count (campaigns that send to OR exclude it, each with role include or exclude, recycle bin included); snapshot (true when the membership was copied once and will not follow its source); description_check (warnings only).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "List not found in this workspace"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/contacts": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List contacts in a list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Add contacts to a list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/contacts/{contactId}": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Remove a contact from a list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/contacts/import": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Import list contacts from CSV",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Imports a CSV file (multipart field file, at most 10 MB). Query or form fields: dryRun=true validates without writing; consentGiven=true is the list owner's own statement that these people agreed to receive marketing email. Tolerates a UTF-8 BOM, a semicolon delimiter, a title row above the header and common header aliases (for example Email Address). An unsubscribed or bounced contact is never re-activated or given consent. A name or company value that looks like a spreadsheet formula rejects the whole file (400, with the rows named); the JSON route rejects only that row. At most 10 uploads per 15 minutes per workspace. For up to 1001 rows prefer the JSON route (per-row results).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Motorical-Actor",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "dashboard",
                "api"
              ]
            },
            "description": "Optional. Who is acting; recorded on the list card (provenance.created_by). Informational: it never grants or limits anything. Defaults to api."
          },
          {
            "name": "dryRun",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "consentGiven",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Import (or dry run) result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "processed": {
                          "type": "integer"
                        },
                        "added": {
                          "type": "integer",
                          "description": "Put on the list"
                        },
                        "upserts": {
                          "type": "integer",
                          "description": "Already on the list"
                        },
                        "errors": {
                          "type": "integer"
                        },
                        "errorSamples": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "duplicatesCollapsed": {
                          "type": "integer"
                        },
                        "skippedTitleRow": {
                          "type": "boolean"
                        },
                        "delimiter": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No email column found (the detected columns are listed), invalid CSV, or CSV injection detected"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "List not found"
          },
          "413": {
            "description": "File larger than 10 MB"
          },
          "429": {
            "description": "More than 10 CSV uploads in 15 minutes"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "dryRun": {
                    "type": "boolean"
                  },
                  "consentGiven": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/contacts/export": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Export list contacts",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/contacts/upsert": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create or update a contact",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/contacts/{id}": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete a contact",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/contacts/{id}/erase-impact": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "What erasing a contact would remove (lists, campaign statistics, consent records), before you confirm",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). What DELETE /contacts/{id} would remove, without removing anything: the contact (email, whether it has a name, status), lists[] it is on, campaign_events_unlinked, consent_records_deleted, and whether a suppression exists (it stays). Read-only.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Contact not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/contacts/{id}/unsubscribe": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Unsubscribe a contact",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/contacts/{id}/resubscribe": {
      "put": {
        "tags": [
          "Communications"
        ],
        "summary": "Resubscribe a contact",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List templates",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Each template also carries description, kind, derived_from and description_check. Lists the workspace templates (no bodies). Each carries used_by_count: how many campaigns use it, including finished campaigns and campaigns in the recycle bin.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a template",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Card fields: description (max 1000; what it is for and when to use it), kind (one of newsletter, promotion, announcement, welcome, reengagement, event, notice, test, other) and derived_from (the id of a template of this workspace it was copied from). The response carries description_check (warnings only). Creates a template after the same validation as templates/validate; any error is refused (422 TEMPLATE_INVALID, with the full validation result in validation). Warnings do not block saving a draft template, but those marked blocksScheduling: true will block scheduling. Name at most 200 characters. type is html or text and cannot be changed later.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_KIND"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "TEMPLATE_NOT_FOUND (derived_from)"
          },
          "422": {
            "description": "TEMPLATE_INVALID: validation errors; the response carries validation"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Bulk delete templates",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Deletes several templates: body { \"ids\": [...] }, at most 100 (400 IDS_REQUIRED, 400 TOO_MANY_IDS). Every id gets its own result: deleted[] lists the ones deleted; failed[] lists the rest with a reason: INVALID_ID, NOT_FOUND (never reported as deleted) or TEMPLATE_IN_USE (with used_by and used_by_count). When nothing was deleted the status is 409 (in use), 404 (all not found) or 400.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "IDS_REQUIRED, TOO_MANY_IDS, or every id invalid"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "None of the templates exist"
          },
          "409": {
            "description": "TEMPLATE_IN_USE for every id"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/validate": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Validate a template without saving",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). validate checks the rules a template must meet to be saved and scheduled; lint (POST /templates/lint) additionally explains and fixes. Both read the same rulebook. Checks a template without saving it. Returns valid, errors[], warnings[], metrics and a preview rendered by the same renderer the sender uses (so {{name|there}} previews exactly as it will be sent). A warning with blocksScheduling: true means scheduling a campaign that uses this template will be refused: missing_unsubscribe_url (no {{unsubscribe_url}} in either body) and unknown_merge_variable (a tag outside the available set; the warning names it and lists the available variables). Other warnings: missing_text_fallback, unsubscribe_url_missing_in_body (the HTML or text version alone has no link), merge_variable_without_fallback (a hint: add {{name|there}}), missing_consent_url. Errors: missing_name, missing_subject, missing_type, invalid_type, invalid_field_type, name_too_long, subject_too_long, missing_body_html, missing_body_text, fallback_not_allowed, fallback_too_long, html_size_exceeded. Merge variables: name, first_name (derived from name; skips Mr, Mrs, Ms, Miss, Mx, Dr, Prof), email, identity_name, plus the system links unsubscribe_url and consent_url. A fallback is written {{name|there}} (at most 100 characters, not allowed on system links). Link findings: merge_variable_in_url (a merge variable inside a link or image address; blocksScheduling: true; url and variables name it) and non_web_link_scheme (sms:, whatsapp: and similar; not click-tracked; does not block). Only web links are click-tracked; mailto, tel, relative, anchor, unsubscribe and consent links are left as written. The text version: the template's own body_text is sent exactly as written; only a template with no body_text gets one generated from the HTML (paragraphs, bullets, every web link as text (url)).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/{id}": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get a template",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). One template with its bodies, updated_at, used_by (the most recent campaigns that use it: id, name, status, in_recycle_bin) and used_by_count (the total).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update a template",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The card (description, kind) is saved on its own: a card-only change never re-validates or touches the body, so an older template can still be described. Sending a body field validates the merged result as before. Updates a template. The merged result (your changes on top of the stored template) is validated as a whole, so a partial update cannot leave an invalid template (422 TEMPLATE_INVALID, with validation). type cannot be changed (400 TYPE_IMMUTABLE): create a new template instead. The response includes updated_at. A campaign that is already scheduled keeps the compiled copy it was scheduled with.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "TYPE_IMMUTABLE"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "TEMPLATE_INVALID"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete a template",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Deletes a template that no campaign uses. A campaign keeps its template until the campaign is permanently deleted, so finished campaigns and campaigns in the recycle bin also block it: the answer is 409 TEMPLATE_IN_USE with used_by (id, name, status, in_recycle_bin) and used_by_count naming them. 404 when there is no such template in this workspace. Add ?dry_run=true to delete nothing and get { dry_run: true, would_delete, template, used_by_count, used_by }: what would be deleted and which campaigns use it.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Template not found in this workspace"
          },
          "409": {
            "description": "TEMPLATE_IN_USE: used_by and used_by_count name the campaigns"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/{id}/test-send": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Send a template as a test to the account owner only, without a campaign",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Sends one copy of the template, with sample merge values, to the account owner only, without needing a campaign: the recipient is always the owner's verified email and cannot be chosen (409 TEST_RECIPIENT_UNAVAILABLE when the owner has none, or is suspended). Body: { \"motor_block_id\": \"<a marketing Motor Block of this workspace>\" (required; it decides the From domain and DKIM), \"sample\": { \"name\": \"...\", \"identity_name\": \"...\" } (optional) }. The message is marked [TEST], links are placeholders pointing to https://motorical.com/ (links.note says so), and there is no tracking pixel and no List-Unsubscribe header. It writes no events. Limits are the same as a campaign test send (429 TEST_SEND_LIMIT). The response is { sent_to, from, subject, warnings[], links: { placeholder_url, note } }.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "TEMPLATE_NOT_FOUND or MOTOR_BLOCK_NOT_FOUND"
          },
          "409": {
            "description": "TEST_RECIPIENT_UNAVAILABLE"
          },
          "429": {
            "description": "TEST_SEND_LIMIT"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/workspaces/current/motor-blocks": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List marketing Motor Blocks assigned to the workspace",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List campaigns",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Lists the workspace campaigns. Each carries pacing {state, reason, resumes_at}: state is not_started, running, waiting_for_cap, done or stopped; while waiting_for_cap, reason names the sending limit reached and resumes_at says when it continues. compact=true omits compiled bodies. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a campaign",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Optional: description (max 1000; what this campaign is and why) and exclude_list_ids (up to 50 lists whose ACTIVE members are never sent to, even if they are on a list in list_ids). Exclusions are fixed at creation, must be lists of this workspace, cannot be built-in system views, and cannot also be in list_ids (400 EXCLUDE_OVERLAPS_LISTS). Other codes: TOO_MANY_EXCLUDE_LISTS, LIST_NOT_FOUND, SYSTEM_LIST_NOT_ALLOWED. An excluded list can never be deleted while a campaign excludes it. Creates a draft. Required: name (max 200 characters), template_id, list_ids (1 to 50), motor_block_id (a marketing Motor Block assigned to the workspace). Optional: from_address (must be an address at the Motor Block's own domain, default noreply@<domain>; otherwise 400 FROM_DOMAIN_MISMATCH), from_name (cleaned, not rejected: control characters, quotes, < > and @ are removed; at most 100 characters; when empty, recipients see the workspace name as the From name), reply_to (one email address on any domain, replies go there; 400 INVALID_REPLY_TO; without it replies go to the From address), google_analytics, consent_request. The template and every list must belong to this workspace (404 TEMPLATE_NOT_FOUND / LIST_NOT_FOUND). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "description": "Optional. Retrying with the same key and the same request replays the stored answer (response header Idempotent-Replay: true); the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; while the first request is still running it is 409 IDEMPOTENCY_IN_PROGRESS. Keys are per workspace and kept 24 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "EXCLUDE_OVERLAPS_LISTS, TOO_MANY_EXCLUDE_LISTS, SYSTEM_LIST_NOT_ALLOWED"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "MOTOR_BLOCK_FORBIDDEN: the Motor Block belongs to another account"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "A request with this Idempotency-Key is still running (IDEMPOTENCY_IN_PROGRESS)"
          },
          "422": {
            "description": "The Idempotency-Key was already used with a different request (IDEMPOTENCY_KEY_REUSED)"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get campaign details",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Also returns description, list_ids and exclude_list_ids. One campaign with its latest artifact and audience snapshot, and pacing {state, reason, resumes_at}: state is not_started, running, waiting_for_cap, done or stopped; a waiting_for_cap campaign continues by itself at resumes_at. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete a campaign",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Moves the campaign to the recycle bin. A scheduled campaign is cancelled in the same step so it cannot send from the bin; a campaign that is sending cannot be deleted (409). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "The campaign is currently sending"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/settings": {
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update campaign settings (what can change depends on the status)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). description (null clears it) can be changed in any status except completed and cancelled. Editable fields by status. draft: from_address, from_name, reply_to (null clears it), timezone, scheduled_at (null clears it), chunk_size (1-1000), delay_seconds_between_chunks (1-86400). scheduled: when it goes (scheduled_at, timezone) and the pacing. sending: pacing only. completed and cancelled: nothing (409 INVALID_STATE). scheduled_at must be in the future (400 SCHEDULED_AT_IN_PAST). reply_to and from_name can only change while the campaign is a draft (409 INVALID_STATE otherwise); an invalid reply_to is 400 INVALID_REPLY_TO. The template, lists and Motor Block of a campaign cannot be changed: duplicate it instead. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "INVALID_STATE: that change is not allowed in the campaign's current status"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/schedule": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Schedule a draft campaign: compiles it, then sends now or at scheduled_at",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The response carries the same audience breakdown. A campaign with nobody left to send to is refused with 400 EMPTY_AUDIENCE and the breakdown shows why. Only a draft (or an already scheduled campaign, to reschedule) can be scheduled. In one step it re-checks the Motor Block, template, lists and From address, compiles the campaign (sanitising the HTML and freezing the audience), and moves it to scheduled. With no scheduled_at it sends as soon as the sender picks it up (send_immediately: true). Refused with 400 EMPTY_AUDIENCE when no recipient is eligible, 400 MISSING_CONSENT_URL for a consent-request campaign whose template lacks {{consent_url}}, 400 UNSUBSCRIBE_LINK_MISSING when neither the template html nor its text contains {{unsubscribe_url}}, 400 UNKNOWN_MERGE_VARIABLE when the subject or a body uses a {{tag}} outside the available set (the response lists the offending tags in variables[]; validate the template first), 400 SCHEDULED_AT_IN_PAST, 409 INVALID_STATE for a sending, completed or cancelled campaign. The response carries total_recipients, artifact_version, from_address, forecast and warnings. forecast {estimated_completion_at, estimated_duration_seconds, limiting_cap, caps, assumes_no_other_traffic, enforced} says how long the campaign takes under the Motor Block and account sending limits (limiting_cap: chunk_pacing, burst, hourly, daily, acct_hourly or acct_daily); enforced false means the limits are not applied to campaigns yet. warnings[].type is will_take_hours or will_span_multiple_days (only when enforced). 400 CAMPAIGN_CANNOT_COMPLETE (reason too_long when it would take longer than 7 days, or cap_zero) when the limits are enforced and the campaign could never be sent; nothing is scheduled. forecast is null when it cannot be known; that never blocks scheduling. 400 MERGE_VARIABLE_IN_URL when a link or image address in the template contains a merge variable (it cannot be filled there; urls[] lists each link; only {{unsubscribe_url}} and {{consent_url}} as the whole address are allowed). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "description": "Optional. Retrying with the same key and the same request replays the stored answer (response header Idempotent-Replay: true); the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; while the first request is still running it is 409 IDEMPOTENCY_IN_PROGRESS. Keys are per workspace and kept 24 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "EMPTY_AUDIENCE: nobody is left to send to (see audience)"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "INVALID_STATE"
          },
          "422": {
            "description": "The Idempotency-Key was already used with a different request (IDEMPOTENCY_KEY_REUSED)"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/cancel": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Cancel a draft, scheduled or sending campaign (final)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Allowed for draft, scheduled and sending campaigns. Cancelled is final: a cancelled or completed campaign answers 409 INVALID_STATE. Duplicate a cancelled campaign to send it again. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "INVALID_STATE"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/duplicate": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Duplicate a campaign into a new draft",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Works on a campaign in any status. Creates a new draft named \"<name> (copy)\" with the same template, lists, Motor Block, From address and name, Reply-To, consent flag, tracking settings, timezone and pacing. The schedule, compile and all results are not copied. The Motor Block, template and lists are re-checked; lists deleted since are dropped, and if none are left the answer is 409 SOURCE_LISTS_GONE. A From address on a domain the Motor Block no longer uses falls back to noreply@<block domain>. Returns the new campaign with list_ids and copied_from. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "description": "Optional. Retrying with the same key and the same request replays the stored answer (response header Idempotent-Replay: true); the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; while the first request is still running it is 409 IDEMPOTENCY_IN_PROGRESS. Keys are per workspace and kept 24 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "SOURCE_LISTS_GONE"
          },
          "422": {
            "description": "The Idempotency-Key was already used with a different request (IDEMPOTENCY_KEY_REUSED)"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/test-send": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Send the campaign as a test to the account owner only",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Sends the campaign, as it would be sent, to the account owner only: the recipient is always the owner's verified email and cannot be chosen (409 TEST_RECIPIENT_UNAVAILABLE when the owner has none, or is suspended). It uses the current template (a template edited after scheduling is not what a scheduled campaign sends) and the real sending path, so the From domain, DKIM and gateway rules are the real ones. The message is marked [TEST], links are placeholders, and there is no tracking pixel and no List-Unsubscribe header. It writes no campaign events, statistics or webhooks. Works in any campaign status. Optional body: { \"sample\": { \"name\": \"...\", \"identity_name\": \"...\" } } supplies the merge values (defaults \"Test Recipient\" and \"Example Co\"). Limits: 5 per campaign per hour and 20 per account per day (429 TEST_SEND_LIMIT, with retryAfter in seconds). The response is { sent_to, subject, warnings[], links: { placeholder_url, note } }: links says that the links in the copy are placeholders pointing to https://motorical.com/ (expected, not a fault); unknown merge variables do not block a test, they are listed in warnings. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "CAMPAIGN_NOT_FOUND or TEMPLATE_NOT_FOUND"
          },
          "409": {
            "description": "TEST_RECIPIENT_UNAVAILABLE"
          },
          "429": {
            "description": "TEST_SEND_LIMIT"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/deleted": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List deleted campaigns",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/restore": {
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Restore a campaign",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/permanent": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Permanently delete a campaign",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/cleanup": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Cleanup deleted campaigns",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/compile": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Preview-compile a draft campaign (optional: scheduling compiles by itself)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The response carries audience: why the audience is the size it is. lists[] (member_count, eligible_count each), list_members_total, unique_contacts, overlap_removed, included (= the recipient count), and excluded { unsubscribed, bounced, other_inactive, suppressed, excluded_by_list, consent_not_eligible }; adds_up is true when included plus excluded equals unique_contacts. A person excluded for several reasons counts once, under the first reason in that order. Optional preview of the compiled message (sanitised HTML, tracked links, audience snapshot) for a draft or scheduled campaign. Scheduling always compiles by itself, so this is never a required step. 400 SECURITY_VALIDATION_FAILED when the content fails the security check; a sending, completed or cancelled campaign answers 409 INVALID_STATE. Also returns totalRecipients and a forecast (same shape as in schedule: how long the campaign takes under the Motor Block and account sending limits, with enforced telling whether they apply to campaigns yet; null when it cannot be known) and warnings, so call it before schedule. It never refuses on the forecast. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "INVALID_STATE"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/events": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List campaign events",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Paged (page, pageSize up to 200). status filters by event type. redact=true removes the recipient IP address and user agent from each event. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "sending",
                "sent",
                "delivered",
                "bounced",
                "complained",
                "failed",
                "blocked",
                "opened",
                "clicked",
                "unsubscribed"
              ]
            }
          },
          {
            "name": "redact",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/stats": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get campaign stats",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Counts come from the same per-recipient report as /report and /analytics: sent, delivered, bounced, opened, clicked, unique_opened (security scanners excluded), unique_clicked, the three rates, unsubscribed, and the full report. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/report": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get the per-recipient delivery report for a campaign",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Also carries sync { synced, ... }: delivery outcomes arrive from the mail servers with a delay, so a zero in accepted or delivered while synced is false means not known yet, not failed. The single source of campaign results: one row per recipient reduced to the furthest stage reached. Returns funnel (handed_off, accepted, delivered, opened, clicked), outcomes (bounced, failed, complained), engagement, rates, and a basis sentence that says how each number is counted. Apple Mail Privacy Protection and image-proxy opens cannot be told from real opens and are included. Also returns pacing {state, reason, resumes_at, sent, remaining}: state is not_started, running, waiting_for_cap, done or stopped; while waiting_for_cap, reason (burst, hourly, daily, acct_hourly or acct_daily) names the sending limit that was reached and resumes_at says when the campaign continues by itself. A waiting campaign is not stuck. Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/analytics": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get campaign analytics",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/click-breakdown": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get click breakdown",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/recipients": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List campaign recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/recipient-consent": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get campaign recipient consent status",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/campaigns/{id}/clicks": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List campaign clicks",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Errors are `{ success:false, error, code }`; a malformed id in the path is `400 INVALID_ID`.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Search recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/search": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Search the whole audience with a structured filter (domain, status, campaign, import batch, dates, on no list, not on these lists); returns each person with the lists they are on",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Searches EVERY contact in the workspace (the recycle bin is left out). Body: { filter?, limit? (1 to 100, default 25), offset?, sort? (recent, email, activity) }. Filter keys (all optional, combined with AND, unknown keys are refused with 400 UNKNOWN_FILTER_KEY): status[] (new, sent, delivered, engaged, bounced, unsubscribed, complained), engagement[] (none, low, medium, high), consent_kind (explicit, inferred, none), suppressed (boolean), list_id[], list_id_not[] (on none of these lists), no_list (boolean), campaign_id[], batch_id (an import batch), email_domain (exactly the part after the at sign, for example example.com), search, date_from, date_to (when the person was added), last_activity_from, last_activity_to, never_active (boolean). Returns { total, limit, offset, has_more, filter, rows[] } where each row has id, email, name, status, engagement, created_at, last_activity, suppression_reason, list_count and lists[] ({ id, name }, up to 5). Real addresses are returned to the caller; the MCP masks them. Read-only.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "UNKNOWN_FILTER_KEY, INVALID_FILTER, INVALID_SORT"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/summary": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Counts for the whole audience or a filter: by status, consent, engagement, domain and list; no addresses",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Counts only, for the whole audience or a filter. Body: { filter?, top? (1 to 20, default 10) }. Filter keys (all optional, combined with AND, unknown keys are refused with 400 UNKNOWN_FILTER_KEY): status[] (new, sent, delivered, engaged, bounced, unsubscribed, complained), engagement[] (none, low, medium, high), consent_kind (explicit, inferred, none), suppressed (boolean), list_id[], list_id_not[] (on none of these lists), no_list (boolean), campaign_id[], batch_id (an import batch), email_domain (exactly the part after the at sign, for example example.com), search, date_from, date_to (when the person was added), last_activity_from, last_activity_to, never_active (boolean). Returns { total, filter, by_status, by_consent, by_engagement, top_domains[], top_lists[], on_no_list }. No addresses. Read-only.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "UNKNOWN_FILTER_KEY, INVALID_FILTER"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/campaigns": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List recipient campaign groupings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/facets": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List recipient filter facets",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/filter": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Filter recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/export": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Export recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/bulk-delete": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Bulk delete recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/bulk-delete-by-filter": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Bulk delete recipients matching a filter",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/bulk-move": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Bulk move recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/restore": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Restore recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/deleted": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List deleted recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/{id}/restore": {
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Restore a recipient",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/{id}/permanent": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Permanently delete a recipient",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/bulk-permanent-delete": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Permanently delete several deleted recipients at once",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Permanently deletes several contacts that are already in the recycle bin, in one request. Body: { \"recipient_ids\": [\"...\"] } (or \"ids\"). Only this workspace's deleted contacts are touched; anything else in the list is ignored. Irreversible: the contacts, their list memberships and their event history are removed. Returns { deleted_count }; 400 when the id list is missing or empty.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "recipient_ids missing or empty"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/recipients/cleanup": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Cleanup deleted recipients",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/suppressions": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List suppressions",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Add a suppression",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Account-wide: the address is suppressed for every workspace of the account. reason defaults to manual; the recipient-initiated reason is unsubscribe (older records may read unsubscribed, which is treated the same).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/suppressions/{id}": {
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Remove a suppression (a spam-complaint one needs acknowledge_complaint=true)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Suppressions are account-wide, shared by every workspace of the account. A suppression whose reason is a spam complaint is removed only on purpose: without acknowledge_complaint=true the answer is 409 COMPLAINT_ACKNOWLEDGEMENT_REQUIRED.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "acknowledge_complaint",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Must be true to remove a spam-complaint suppression."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "COMPLAINT_ACKNOWLEDGEMENT_REQUIRED"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/suppressions/bulk": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Bulk import suppressions",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/suppressions/stats": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get suppression stats",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/suppressions/lookup": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Is one address suppressed: the reason, the source and since when (account-wide)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Query: email (the full address). Returns { suppressed: false } or { suppressed: true, reason, source, since }. Suppressions are account-wide. Read-only.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "email",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_EMAIL"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/suppressions/import-bounces": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Import bounces into suppressions",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/tracking/events": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Search tracking events",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Tracking events, summary counts, and CSV export share these filters and hide queued lifecycle rows superseded by a later outcome.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "event_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated event types, such as opened,clicked."
          },
          {
            "name": "campaign_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated campaign UUIDs."
          },
          {
            "name": "contact_email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "chronological",
                "recipient"
              ]
            },
            "description": "Defaults to chronological (the raw per-event timeline, unchanged). recipient collapses each campaign recipient to one row at their furthest send-funnel stage (queued, sent, delivered-or-bounced, opened, clicked). complained and unsubscribed are reported as independent flags rather than funnel stages, since a recipient can carry either at any stage -- they never compete with or hide the funnel stage they occurred at. In recipient view, event_type filters on the winning stage (or the flag) rather than on raw per-event rows."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/tracking/export": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Export tracking events",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Tracking events, summary counts, and CSV export share these filters and hide queued lifecycle rows superseded by a later outcome.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "event_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated event types, such as opened,clicked."
          },
          {
            "name": "campaign_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated campaign UUIDs."
          },
          {
            "name": "contact_email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "chronological",
                "recipient"
              ]
            },
            "description": "Defaults to chronological (the raw per-event timeline, unchanged). recipient collapses each campaign recipient to one row at their furthest send-funnel stage (queued, sent, delivered-or-bounced, opened, clicked). complained and unsubscribed are reported as independent flags rather than funnel stages, since a recipient can carry either at any stage -- they never compete with or hide the funnel stage they occurred at. In recipient view, event_type filters on the winning stage (or the flag) rather than on raw per-event rows."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/tracking/stats": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get tracking stats",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Tracking events, summary counts, and CSV export share these filters and hide queued lifecycle rows superseded by a later outcome. The total and by_type values describe the same visible population returned by the tracking events endpoint. In recipient view, the response instead carries by_status (the non-overlapping funnel breakdown, one recipient per stage), plus separate complained and unsubscribed counts.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "event_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated event types, such as opened,clicked."
          },
          {
            "name": "campaign_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated campaign UUIDs."
          },
          {
            "name": "contact_email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "chronological",
                "recipient"
              ]
            },
            "description": "Defaults to chronological (the raw per-event timeline, unchanged). recipient collapses each campaign recipient to one row at their furthest send-funnel stage (queued, sent, delivered-or-bounced, opened, clicked). complained and unsubscribed are reported as independent flags rather than funnel stages, since a recipient can carry either at any stage -- they never compete with or hide the funnel stage they occurred at. In recipient view, event_type filters on the winning stage (or the flag) rather than on raw per-event rows."
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Optional rolling-day window. When omitted with no date_from, the summary covers all visible events."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/unsubscribe-events": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List unsubscribe events",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/unsubscribe-analytics": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get unsubscribe analytics",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/unsubscribe-trends": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get unsubscribe trends",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/settings/consent": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get current workspace consent settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update current workspace consent settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/settings/open-tracking": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get current workspace open-tracking settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update current workspace open-tracking settings",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/settings/unsubscribe": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get the current workspace unsubscribe landing page",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Set or clear the current workspace unsubscribe landing page",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Sets or clears the page recipients are sent to after they confirm an unsubscribe. Body: { \"unsubscribe_landing_url\": \"https://...\" }, or null to use the default Motorical page. The URL must be https, at most 2048 characters, without credentials, on a domain verified in your account or a subdomain of one (400 LANDING_URL_INVALID, 400 LANDING_DOMAIN_NOT_VERIFIED). It is checked again each time a recipient is redirected; if it no longer qualifies, the default page is shown. Only the confirmation page redirects (303); the one-click unsubscribe from a mail client never does, and the List-Unsubscribe header always points at Motorical.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "LANDING_URL_INVALID or LANDING_DOMAIN_NOT_VERIFIED"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/workspaces/{id}/webhooks": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List the webhooks of a workspace",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Lists the workspace webhooks with url, events, enabled, failure_count (consecutive failed attempts) and last_delivery_status. The secret is never returned.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a workspace webhook",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Creates a webhook for this workspace; X-Tenant-Id must equal the workspace id in the path (otherwise 404 WORKSPACE_NOT_FOUND). Body: url (https, a public address) and events (a non-empty list of campaign.completed, message.delivered, message.bounced, message.complained, contact.unsubscribed, contact.consent_given). The 201 response returns the signing secret once; it is never shown again. Each delivery is a POST of a JSON body signed with HMAC-SHA256 in X-Motorical-Signature, with the event name in X-Motorical-Event. 400 INVALID_EVENTS, 400 WEBHOOK_URL_UNSAFE, 409 WEBHOOK_LIMIT (10 webhooks per workspace).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Created; includes the secret, shown once"
          },
          "400": {
            "description": "INVALID_EVENTS or WEBHOOK_URL_UNSAFE"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "WEBHOOK_LIMIT"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/workspaces/{id}/webhooks/{webhookId}": {
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update a workspace webhook",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Changes url, events and/or enabled. Setting enabled to true resets the failure count; a webhook the system disabled after repeated failures stays off until you do this. A new url is checked like a new webhook (400 WEBHOOK_URL_UNSAFE). 404 WEBHOOK_NOT_FOUND.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "WEBHOOK_NOT_FOUND"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete a workspace webhook",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Deletes the webhook together with its undelivered events. 404 WEBHOOK_NOT_FOUND.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "WEBHOOK_NOT_FOUND"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/workspaces/{id}/webhooks/{webhookId}/test": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Queue a test event for a workspace webhook",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Queues one event named test for this webhook; it is sent like any other delivery. 202 when queued; 404 WEBHOOK_NOT_FOUND.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Queued"
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "WEBHOOK_NOT_FOUND"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/archive": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Archive a list (hidden from the default list view, refused by campaigns)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/unarchive": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Restore an archived list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/imports": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "The import batches of a list",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/imports/{batchId}/undo": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Undo one import batch, with a dry run",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "batchId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/contacts/cleanup-orphans": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Delete contacts that are on no list, with a dry run",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/contacts/bulk": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Add up to 1001 contacts as JSON, with a dry run and a result for every row",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Adds up to 1001 contacts as JSON: { contacts: [{ email, name?, identity_name?, phone? }], dry_run?, on_existing: keep (default) or update, source_label?, consent_given? }. Every row gets its own result and the summary adds up to the number received. Row outcomes: created, added_existing, already_in_list, invalid, duplicate_in_request, rejected_unsafe, skipped_unsubscribed, skipped_bounced, skipped_inactive, skipped_suppressed. People who unsubscribed, bounced or are suppressed are never re-added. With dry_run true nothing is written and the result shows what WOULD change (would_change). Use the CSV import for larger files. Import notes are added to the list card.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Motorical-Actor",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "dashboard",
                "api"
              ]
            },
            "description": "Optional. Who is acting; recorded on the list card (provenance.created_by). Informational: it never grants or limits anything. Defaults to api."
          }
        ],
        "responses": {
          "200": {
            "description": "A result for every row",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dry_run": {
                          "type": "boolean"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "row": {
                                "type": "integer"
                              },
                              "email": {
                                "type": "string",
                                "nullable": true,
                                "description": "Masked"
                              },
                              "reason": {
                                "type": "string"
                              },
                              "outcome": {
                                "type": "string",
                                "enum": [
                                  "created",
                                  "added_existing",
                                  "already_in_list",
                                  "invalid",
                                  "duplicate_in_request",
                                  "rejected_unsafe",
                                  "skipped_unsubscribed",
                                  "skipped_bounced",
                                  "skipped_inactive",
                                  "skipped_suppressed"
                                ]
                              }
                            }
                          }
                        },
                        "summary": {
                          "type": "object",
                          "properties": {
                            "received": {
                              "type": "integer"
                            },
                            "would_change": {
                              "type": "integer"
                            },
                            "adds_up": {
                              "type": "boolean"
                            }
                          },
                          "additionalProperties": {
                            "type": "integer"
                          }
                        },
                        "list": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "CONTACTS_REQUIRED, TOO_MANY_CONTACTS (more than 1001 rows: use the CSV import or the dashboard), INVALID_ON_EXISTING"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "List not found"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "contacts"
                ],
                "properties": {
                  "contacts": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 1001,
                    "items": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "email": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string",
                          "maxLength": 200
                        },
                        "phone": {
                          "type": "string",
                          "maxLength": 50
                        },
                        "identity_type": {
                          "type": "string",
                          "maxLength": 20
                        },
                        "identity_name": {
                          "type": "string",
                          "maxLength": 200
                        }
                      }
                    }
                  },
                  "dry_run": {
                    "type": "boolean",
                    "description": "true: nothing is written; the answer shows what WOULD change."
                  },
                  "on_existing": {
                    "type": "string",
                    "enum": [
                      "keep",
                      "update"
                    ],
                    "default": "keep"
                  },
                  "source_label": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Where these contacts came from. Optional on this call."
                  },
                  "consent_given": {
                    "type": "boolean",
                    "description": "The list owner's own statement that these people agreed to receive marketing email. Never assumed."
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/derive": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Make a new list from other lists (union, intersection or difference) or from an audience filter (operation filter)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Makes a new list from other lists, or from an audience filter, and records how. Body: { name, operation: union | intersection | difference | filter, filter (only for operation filter, with at least one key; the same keys as POST /recipients/search; give no source or exclude lists then), source_list_ids (1 to 10; an intersection needs two), exclude_list_ids (only for a difference), description?, kind? (default derived), source_label?, dry_run? }. The result is a snapshot (members copied once, max 10000; later changes to the sources do not flow in). Members are active contacts; suppressed ones are copied but stay ineligible and are counted separately. The card records the sources and exclusions, and they are readable with GET /lists/{id}/relations. dry_run true returns the counts without creating anything.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "X-Motorical-Actor",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "dashboard",
                "api"
              ]
            },
            "description": "Optional. Who is acting; recorded on the list card (provenance.created_by). Informational: it never grants or limits anything. Defaults to api."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "NAME_REQUIRED, INVALID_OPERATION, SOURCES_REQUIRED, TOO_MANY_SOURCES, FILTER_REQUIRED, FILTER_AND_LISTS, UNKNOWN_FILTER_KEY, INVALID_FILTER, INTERSECTION_NEEDS_TWO, EXCLUDE_REQUIRED, EXCLUDE_NOT_ALLOWED, SOURCES_OVERLAP_EXCLUDES, INVALID_ID"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "LIST_NOT_FOUND"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/compare": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Compare two lists: who is only in one, who is in both",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Query: a and b (two different list ids). Returns only_a, only_b, both and union (people), and the same four counts for the ELIGIBLE people (eligible), so the overlap between two lists is a number instead of a guess.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "a",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "b",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "LISTS_REQUIRED, INVALID_ID or SAME_LIST"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "LIST_NOT_FOUND (missing[] names the ids)"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/lists/{id}/relations": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Where a list came from and what was made from it",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Where a list came from and what depends on it: derived_from (its sources), excludes, children (lists made from it), excluded_by, and graph { nodes, edges } for the connected lists (up to 50). Use it before deleting or changing a list.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "List not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/map": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "The workspace at a glance: lists, campaigns, templates and how they connect",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The workspace in one call: lists (as short cards), the 50 most recent campaigns (with list_ids, exclude_list_ids and pacing), templates (with used_by_count) and edges between them: sends_to, excludes and uses (campaign to list or template), derived_from and excludes (list to list). truncated tells whether lists or campaigns were cut off.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/readiness": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "What is still missing before a campaign can be sent",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). What stands between this workspace and a sent campaign, in a fixed order: plan, workspace, domain, marketing_block, list, template. Returns ready, next (the FIRST missing step with a message and a fix hint, or null), steps[] with ok and detail, and the sending limits (hourly, daily) of the workspace campaign Motor Blocks. Read-only. The plan step only says the account is admitted to this API; plans and prices are in the main API.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/preview": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Render a template for a contact or a sample",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). What a recipient will see, rendered by the same renderer the sender uses. Body: template_id OR an unsaved draft (subject with body_html and/or body_text), and optionally contact_id (a real contact of this workspace) or sample { name, email, identity_name }. Returns renders[]: with_name, and without_name when the template uses a name variable (so the fallback text is visible), each with subject, body_html and body_text; text_source (template when it has its own text, generated otherwise); a links table (tracked or not, and why); and notes. Unsubscribe and consent links are example addresses. Read-only; sends nothing.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "MISSING_TEMPLATE or INVALID_ID"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "TEMPLATE_NOT_FOUND or CONTACT_NOT_FOUND"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/rules": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "The template rulebook",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The template rulebook, generated from the same constants the validator and the lint use: limits, merge variables (and the fallback syntax), what is removed at compile, what is kept but risky, which links are tracked, the text-version rule, and the closed list of finding types with their severity (blocks_scheduling, altered, risk, tip). Read it before drafting or repairing a template.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/lint": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Check a template against the rulebook",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Checks a saved template (template_id) or a draft against the rulebook. Findings come from a closed vocabulary; each has id, type, severity, blocks_scheduling, location { field, line, selector, excerpt }, why, and where one exists fix { summary, before, after, auto_applicable }. Also returns summary counts, blocks_scheduling and fixable (the types fixTemplate can repair). Read-only.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "MISSING_TEMPLATE or INVALID_ID"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "TEMPLATE_NOT_FOUND"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/fix": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Apply the safe fixes to a template in memory",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Applies only the safe, deterministic fixes (an unsubscribe link, a generated text version, a fallback on a bare name tag, removal of scripts, event handlers and javascript: addresses) IN MEMORY and returns result { subject, body_html, body_text }, changes[] and the re-lint (lint_after). Pass types[] to apply only some. It never saves anything (applied is false): to keep the result, PATCH the template with result. Anything that needs a human (alt text, link destinations, wording, http links) stays a suggestion.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/check-links": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Check every link of a template",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Every link in the HTML with its kind (link, mailto, tel, unsubscribe, consent), tracked (and the reason when not), and problems[] from: merge_variable_in_url, relative_link, non_web_link_scheme, http_not_https, url_shortener, link_text_domain_mismatch. Returns totals (total, tracked, with_problems). Read-only.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/{id}/duplicate": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Duplicate a template",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Copies the template (bodies, kind, description) into a new one named \"<name> (copy)\" with derived_from set to the original. The original is never touched.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "description": "Optional. Retrying with the same key and the same request replays the stored answer (response header Idempotent-Replay: true); the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; while the first request is still running it is 409 IDEMPOTENCY_IN_PROGRESS. Keys are per workspace and kept 24 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Template not found"
          },
          "409": {
            "description": "A request with this Idempotency-Key is still running (IDEMPOTENCY_IN_PROGRESS)"
          },
          "422": {
            "description": "The Idempotency-Key was already used with a different request (IDEMPOTENCY_KEY_REUSED)"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/starters": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List the template starters",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The seven starter skeletons: newsletter, promotion, announcement, welcome, reengagement, event, notice. Each lists its slots (key, type text, paragraph or url, required, max length). Starters produce table-based, inline-CSS email with a hidden preheader, a greeting with a fallback, a footer with the sender and postal address and an unsubscribe link, and a plain-text twin.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/starters/{key}": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get one template starter",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). One starter with its slots and the order of its blocks.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "STARTER_NOT_FOUND"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/starters/{key}/render": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Render a starter with a brand kit, without saving",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Dry run: the finished email for the stored brand kit (a brand object in the body overrides it field by field) and slots, plus its lint. Nothing is saved. Refusals are named: BRAND_KIT_INCOMPLETE (missing[] lists sender_name and/or postal_address: ask the person, never invent them), MISSING_SLOT and UNKNOWN_SLOT (slots[]), SLOT_TOO_LONG, INVALID_SLOT_URL (links must be full https addresses without merge tags), STARTER_NOT_FOUND.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "STARTER_NOT_FOUND"
          },
          "422": {
            "description": "BRAND_KIT_INCOMPLETE, MISSING_SLOT, UNKNOWN_SLOT, SLOT_TOO_LONG, INVALID_SLOT_URL"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/templates/from-starter": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Create a template from a starter and the brand kit",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Builds the email from a starter, slots and the workspace brand kit (an inline brand overrides it field by field) and SAVES it as a normal html template. Body: starter, name (required), slots, subject? (defaults to the headline), description?, kind? (defaults to the starter kind), brand?. Returns template, lint, kit_source (stored, inline or stored+inline) and starter. Later edits are normal edits; nothing stays linked to the starter. Same named refusals as the render (BRAND_KIT_INCOMPLETE and the slot codes), plus MISSING_NAME and INVALID_KIND; nothing is written when it refuses.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "description": "Optional. Retrying with the same key and the same request replays the stored answer (response header Idempotent-Replay: true); the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; while the first request is still running it is 409 IDEMPOTENCY_IN_PROGRESS. Keys are per workspace and kept 24 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "STARTER_NOT_FOUND"
          },
          "409": {
            "description": "A request with this Idempotency-Key is still running (IDEMPOTENCY_IN_PROGRESS)"
          },
          "422": {
            "description": "The Idempotency-Key was already used with a different request (IDEMPOTENCY_KEY_REUSED)"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/settings/brand-kit": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get the workspace brand kit",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). The workspace brand kit: brand_kit as stored, missing (what a starter still needs: sender_name, postal_address), ready_for_starters and effective (the kit with the design defaults a starter would use). Fields: sender_name, postal_address, logo_url (https), colors { text, background, card, primary } as #rrggbb, font (system_sans, arial_sans, verdana_sans, trebuchet_sans, georgia_serif, courier_mono), button_radius (0 to 24), footer_text, reply_to, tone_notes, language, description.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Communications"
        ],
        "summary": "Update the workspace brand kit",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Partial: only the fields you send change; null clears a field (null clears a colour back to its default); colours merge one by one. An invalid value is 400 INVALID_BRAND_KIT with the field named. Legal identity (sender_name, postal_address) is never filled in on the person's behalf.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_BRAND_KIT (field names the offender) or NO_FIELDS"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/consent-events": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "List consent events",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/consent-events/analytics": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get consent-event analytics",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`).",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/analytics/overview": {
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Get Communications analytics overview",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Ranks every campaign active in the window and reads the same per-recipient report as the campaign endpoints, so the numbers agree.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    },
    "/comm-api/api/gdpr/export": {
      "post": {
        "tags": [
          "Communications"
        ],
        "summary": "Email a contact their GDPR data export",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Sends the export for the address in the body (email, format json or csv) to that address. This sends mail, which is why POST is the supported method. 400 INVALID_EMAIL / INVALID_FORMAT, 404 when the contact does not exist in this workspace.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "Communications"
        ],
        "summary": "Email a contact their GDPR data export (deprecated: use POST)",
        "servers": [
          {
            "url": "https://motorical.com",
            "description": "Communications API gateway"
          }
        ],
        "description": "Communications Block endpoint. Requires `X-Tenant-Id` (workspace id) plus caller auth: `Authorization: Bearer <dashboard JWT>` or `Authorization: ApiKey ak_live_...` (must own the workspace). Discover default workspace via `GET /api/comm/tenant` (returns `tenantId` + `workspaces[]`). Deprecated: it sends mail, so a prefetch or a stray link can trigger it. Use POST.",
        "parameters": [
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <dashboard JWT> or ApiKey ak_live_..."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Tenant entitlement required"
          },
          "404": {
            "description": "Not found"
          }
        },
        "security": [
          {
            "tenantHeaderAuth": []
          }
        ]
      }
    }
  },
  "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"
          }
        }
      }
    }
  }
}
