{
  "$schema": "https://docs.motorical.com/schemas/onboarding-sandbox-journey.schema.json",
  "id": "motorical-developer-sandbox-onboarding",
  "title": "Motorical developer sandbox onboarding journey",
  "version": "2.1.1",
  "updated": "2026-10-13",
  "audience": "AI agents onboarding the unpaid developer sandbox (a Motorical-owned .sandbox domain, or a sandbox Motor Block on the account's own fully verified domain) over REST or the hosted MCP server",
  "canonicalDiscovery": [
    "https://docs.motorical.com/llms.txt",
    "https://docs.motorical.com/llms-full.txt",
    "https://docs.motorical.com/openapi.json",
    "https://api.motorical.com/api/public/openapi.json"
  ],
  "install": {
    "note": "Nothing to install for the REST steps below or for the hosted MCP server (the default; connect steps at https://docs.motorical.com/ai-mcp#connect). The local package is only for API-key or stdio-only clients. Package versions are intentionally not listed here; see the registry.",
    "hostedMcp": {
      "signup": "https://mcp.motorical.com/v1/signup/mcp",
      "everything": "https://mcp.motorical.com/v1/motorical/mcp",
      "doc": "https://docs.motorical.com/ai-mcp-hosted"
    },
    "localMcp": {
      "package": "@motorical/mcp",
      "command": "npm install -g @motorical/mcp  (local stdio only; not needed for the hosted server)",
      "doc": "https://docs.motorical.com/ai-mcp-local"
    }
  },
  "authLifecycle": {
    "canonicalDoc": "https://docs.motorical.com/api-reference/authentication",
    "credentials": [
      {
        "id": "dashboard_jwt",
        "header": "Authorization: Bearer <accessJwt>",
        "ttl": "15m access + 7d refreshToken",
        "obtain": [
          "POST /api/auth/set-password",
          "POST /api/auth/login",
          "POST /api/auth/refresh"
        ],
        "useFor": [
          "/api/auth/*",
          "/api/domains*",
          "/api/developer/sandbox*",
          "POST /api/domains/{id}/check-dns",
          "POST /api/domains/{id}/verify",
          "POST /api/auth/web-handoff",
          "POST /api/public/token (mint a read token for message status)"
        ],
        "notFor": [
          "POST /v1/send",
          "GET /api/public/v1/motor-blocks/{id}/domain-health"
        ]
      },
      {
        "id": "mk_live",
        "header": "Authorization: ApiKey mk_live_… (or X-Api-Key)",
        "obtain": [
          "sandbox provision credentials.mkApiKey",
          "Motor Block API keys UI"
        ],
        "useFor": [
          "POST /v1/send"
        ],
        "notFor": [
          "domain ops",
          "sandbox APIs",
          "minting public tokens"
        ]
      },
      {
        "id": "ak_live_public_bearer",
        "header": "Authorization: Bearer <minted>",
        "obtain": [
          "POST /api/public/token/account-key with ak_live_"
        ],
        "useFor": [
          "/api/public/v1/* including domain-health"
        ],
        "notFor": [
          "POST /v1/send",
          "dashboard domain verify/check-dns (use dashboard JWT instead)"
        ]
      }
    ],
    "accessJwt": {
      "ttl": "15m",
      "header": "Authorization: Bearer <token>",
      "issuedBy": [
        "POST /api/auth/set-password",
        "POST /api/auth/login",
        "POST /api/auth/refresh",
        "POST /api/auth/web-handoff/exchange"
      ]
    },
    "refreshToken": {
      "ttl": "7d",
      "storage": "Agents store it securely; browsers use the __Host-motorical_refresh cookie",
      "nonInteractiveRefresh": "POST /api/auth/refresh with JSON body { refreshToken }"
    },
    "sendAuth": {
      "note": "Dashboard JWT is NOT used for POST /v1/send. Use mk_live_ ApiKey from sandbox provision. Optional fromName for display name (not a From header)."
    }
  },
  "steps": [
    {
      "id": "A",
      "name": "Discover",
      "actor": "agent",
      "actions": [
        "GET https://docs.motorical.com/llms.txt",
        "GET https://docs.motorical.com/onboarding-sandbox-journey.json",
        "GET https://docs.motorical.com/openapi.json (Onboarding Auth + Developer Sandbox tags)"
      ]
    },
    {
      "id": "B",
      "name": "Choose a route",
      "actor": "agent",
      "actions": [
        "With a person present and an OAuth-capable client: connect the main hosted MCP server and authenticate; the person creates the account in the browser and sets up MFA, then authenticates again to reach consent (no credential is held by the agent)",
        "From a script or shell with no MCP client: the REST steps below"
      ]
    },
    {
      "id": "C",
      "name": "Signup + verify",
      "actor": "agent",
      "humanGated": [
        "retrieve 6-digit email code"
      ],
      "actions": [
        "POST /api/auth/register { email }",
        "POST /api/auth/verify-code { email, code } -> returns setupToken (single use, 30 min)",
        "POST /api/auth/set-password { email, password, setupToken, channel: agent }",
        "Store token + refreshToken from the response"
      ]
    },
    {
      "id": "D",
      "name": "Provision sandbox",
      "actor": "agent",
      "actions": [
        "Path 1 (only trying things, no domain yet, or no human at the keyboard): POST /api/developer/sandbox/provision  OR  hosted MCP motorical_sandbox_provision creates the sandbox on a Motorical-owned .sandbox domain (instant, no DNS)",
        "Path 2 (the person has a domain whose DNS they control and want to keep): add and fully verify it (POST /api/public/v1/domains, then check-dns until DKIM and SPF pass); on a Free account, when automatic provisioning is enabled, a sandbox Motor Block is created on that domain automatically with no provisioning call; otherwise call provision",
        "Save mk_live_ (returned once, REST only), sandbox domain, SMTP creds"
      ],
      "notes": [
        "Decision rule and how both paths are limited: https://docs.motorical.com/ai#two-ways-to-start",
        "motorical_sandbox_status: domain.sandbox true = the Motorical-owned sandbox domain, false = your own domain"
      ]
    },
    {
      "id": "E",
      "name": "Dry-run / allowlisted send",
      "actor": "agent",
      "actions": [
        "POST /v1/send with Authorization: ApiKey mk_live_... and dryRun:true, from an address on the sandbox domain (the Motorical-owned .sandbox domain, or your own domain on Path 2) to an allowlisted address. HTTP dryRun defaults to false (the request is sent unless you pass dryRun:true); the MCP tool motorical_send_email defaults to dryRun true and needs confirmRealSend true for a real send. Always set dryRun explicitly."
      ],
      "notes": [
        "Outbound locked to allowlist while developer_sandbox is set; HTTP and SMTP both refuse a recipient outside it (403 sandbox_outbound_locked while locked, the default; sandbox_recipient_denied after an explicit unlock)",
        "To add a recipient over OAuth, motorical_free_recipient_add (scope manage:recipients; an authorization granted before that scope existed must be re-approved to include it) emails a confirmation link the recipient must click",
        "dryRun always allowed"
      ]
    },
    {
      "id": "E2",
      "name": "Check delivery",
      "actor": "agent",
      "actions": [
        "Hosted MCP: motorical_wait_for_outcome with the taskId from the send response's nextAction (the taskId is not the message id); it reads the outcome for you",
        "REST: mint a read token with POST /api/public/token using the dashboard JWT and { motorBlockId, scopes: [\"logs.read\"] } (or POST /api/public/token/account-key with an ak_live_ key), then GET /api/public/v1/messages/{id} with Authorization: Bearer <minted>"
      ],
      "notes": [
        "The mk_live_ send key cannot read message status, and a 202 means accepted, not delivered. Minting does not change any auth behaviour: scope logs.read is required by the message-status routes."
      ]
    },
    {
      "id": "F",
      "name": "Browser password (optional for send, required for dashboard)",
      "actor": "human",
      "agentCanMint": true,
      "actions": [
        "POST /api/auth/web-handoff  OR  local MCP motorical_web_handoff",
        "Open https://motorical.com/auth/cli?code=… so the human can set the dashboard password"
      ],
      "notes": [
        "The link is short-lived (expiresInSeconds in the response): open it right away; if it says expired, ask for a new link or sign in with your password."
      ]
    },
    {
      "id": "G",
      "name": "Convert prerequisites",
      "actor": "mixed",
      "humanGated": [
        "Stripe checkout for Motorical Plan",
        "publish DNS on customer domain"
      ],
      "actions": [
        "Human: subscribe to a Motorical Plan in the dashboard (checkout)",
        "POST /api/domains  OR  MCP motorical_domain_add",
        "Publish verification + DKIM CNAME (cname_managed: use records.dkim as CNAME, not TXT p=)",
        "POST /api/domains/{id}/verify  OR  MCP motorical_domain_verify (also refreshes sendReady)",
        "If sendReady false after DNS is live: POST /api/domains/{id}/check-dns  OR  MCP motorical_domain_check_dns"
      ]
    },
    {
      "id": "H",
      "name": "Convert to production domain",
      "actor": "agent",
      "actions": [
        "POST /api/developer/sandbox/convert { domainId }  OR  hosted MCP motorical_sandbox_convert",
        "Response includes sendReady; if false, run check-dns / re-verify",
        "Sandbox DNS reaped; Motor Block re-pointed; outbound lock cleared"
      ]
    },
    {
      "id": "I",
      "name": "Send-ready + production send",
      "actor": "agent",
      "actions": [
        "Confirm sendReady:true via domain verify or check-dns (persists dkim_configured + spf_configured)",
        "POST /v1/send with Authorization: ApiKey mk_live_... from=<addr@domain> optional fromName display name",
        "Do not set a From custom header (DISALLOWED_HEADERS) — use fromName field instead",
        "If 403 DOMAIN_DNS_INCOMPLETE: check-dns then retry (do not assume dig alone is enough)"
      ],
      "notes": [
        "Ownership verified ≠ send-ready. /v1/send gates on persisted DKIM/SPF flags.",
        "GET /api/public/v1/motor-blocks/{id}/domain-health uses Public API bearer (ak_live_ mint), not dashboard JWT."
      ]
    }
  ],
  "dkimRule": {
    "cname_managed": "Publish CNAME motorical1._domainkey → <target>. Do not publish legacy TXT p= from stale agents reading old records.dkim shapes; API now returns CNAME in records.dkim and dnsRecords[]."
  },
  "sendReadiness": {
    "requiredFlags": [
      "dkim_configured",
      "spf_configured"
    ],
    "agentEndpoints": [
      "POST /api/domains/{id}/verify (re-call after ownership)",
      "POST /api/domains/{id}/check-dns"
    ],
    "errorCode": "DOMAIN_DNS_INCOMPLETE",
    "mcp": [
      "motorical_domain_verify",
      "motorical_domain_check_dns"
    ]
  },
  "related": {
    "humanReport": "https://docs.motorical.com is not the ops report host; ops report lives in motorical-docs runbooks",
    "mcpPage": "https://docs.motorical.com/ai-mcp",
    "aiQuickstart": "https://docs.motorical.com/ai"
  }
}
