{"openapi":"3.1.0","info":{"title":"CloudSend REST API","version":"1.0.0","description":"Comprehensive REST API for CloudSend: Multi-tenant Audience CRM, Dynamic Template Studio, Segmented Outreach via Amazon SES, Ephemeral File Transfers, Engagement Telemetry, and Model Context Protocol (MCP) AI Service.","contact":{"name":"CloudSend Engineering","url":"https://cloudsend.n3tw0rk.co.uk"},"license":{"name":"Proprietary / Closed Source"}},"servers":[{"url":"https://cloudsend.n3tw0rk.co.uk","description":"Production CloudFront CDN + Lambda"},{"url":"http://localhost:3000","description":"Local Development Server"}],"tags":[{"name":"System","description":"Platform health and service status"},{"name":"Auth","description":"User authentication and session tokens"},{"name":"Accounts","description":"Tenant workspace account discovery and membership"},{"name":"Transfers","description":"Ephemeral encrypted package sharing and downloads"},{"name":"CRM Targets","description":"Contact management, attributes, mail groups, and GDPR consent"},{"name":"CRM Templates","description":"Email template editor, variable tags, and free starter templates"},{"name":"CRM Campaigns","description":"Campaign drafts, preview interpolation, and live email dispatch"},{"name":"CRM Engagement","description":"Open tracking pixels, click redirects, and CTR analytics"},{"name":"GDPR Compliance","description":"One-click public unsubscribe and Article 15 SAR dossiers"},{"name":"Sending Domains","description":"Custom sender domains, SPF, 2048-bit RSA DKIM, and DMARC verification"},{"name":"Billing","description":"Subscription tiers, usage quotas, and plan upgrades"},{"name":"MCP","description":"Model Context Protocol (JSON-RPC 2.0) for AI assistants"}],"paths":{"/api/health":{"get":{"tags":["System"],"summary":"Health check and platform status","description":"Returns the health status of CloudSend services, current version, and outbound email maintenance status.","responses":{"200":{"description":"Service is healthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthStatus"},"example":{"status":"healthy","service":"cloud-send","system":"crm-platform","version":"1.0.0","emailSendsDisabled":false,"timestamp":"2026-11-08T14:30:00.000Z"}}}}}}},"/api/auth/register":{"post":{"tags":["Auth"],"summary":"Register new user","description":"Registers a new user account and automatically initializes their primary workspace.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","example":"user@example.com"},"password":{"type":"string","minLength":8,"example":"SecurePass123!"},"name":{"type":"string","example":"Jane Doe"}}}}}},"responses":{"201":{"description":"User registered successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthRegisterResponse"},"example":{"user":{"sub":"b2f63f51-2856-4299","email":"user@example.com","name":"Jane Doe","confirmed":true},"userConfirmed":true,"message":"User registered successfully."}}}},"400":{"$ref":"#/components/responses/400BadRequest"}}}},"/api/auth/confirm":{"post":{"tags":["Auth"],"summary":"Confirm user registration","description":"Confirms a newly registered user account using the 6-digit verification code sent via email.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","code"],"properties":{"email":{"type":"string","format":"email","example":"user@example.com"},"code":{"type":"string","minLength":6,"maxLength":6,"example":"123456"}}}}}},"responses":{"200":{"description":"User confirmed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"User confirmed successfully"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"}}}},"/api/auth/login":{"post":{"tags":["Auth"],"summary":"Authenticate and obtain JWT Bearer token","description":"Validates user credentials and issues a Bearer JWT token required for authenticated operations.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","example":"user@example.com"},"password":{"type":"string","example":"SecurePass123!"}}}}}},"responses":{"200":{"description":"Authentication successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthLoginResponse"},"example":{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...","user":{"sub":"b2f63f51-2856-4299","email":"user@example.com","name":"Jane Doe"},"expiresIn":86400}}}},"401":{"$ref":"#/components/responses/401Unauthorized"}}}},"/api/accounts":{"get":{"tags":["Accounts"],"summary":"List accessible workspace accounts","description":"Returns all workspace accounts the authenticated user belongs to. The returned `accountId` must be supplied in subsequent `X-Account-Id` headers.","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"List of accessible workspace accounts","content":{"application/json":{"schema":{"type":"object","properties":{"accounts":{"type":"array","items":{"$ref":"#/components/schemas/AccountSummary"}}}},"example":{"accounts":[{"accountId":"acct-b2f63f51","name":"Primary Workspace","role":"owner","createdAt":"2026-11-08T10:00:00.000Z"}]}}}},"401":{"$ref":"#/components/responses/401Unauthorized"}}},"post":{"tags":["Accounts"],"summary":"Create a new workspace account","description":"Creates a new workspace account isolated with blank-slate transfers and registers the calling user as the account owner.","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"Marketing Workspace"}}}}}},"responses":{"201":{"description":"Workspace account created","content":{"application/json":{"schema":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountSummary"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"401":{"$ref":"#/components/responses/401Unauthorized"}}}},"/api/accounts/members":{"get":{"tags":["Accounts"],"summary":"List account team members","description":"Returns all members and pending invitations for the workspace specified by X-Account-Id.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"List of account members","content":{"application/json":{"schema":{"type":"object","properties":{"accountId":{"type":"string"},"userRole":{"type":"string","enum":["owner","admin","member"]},"members":{"type":"array","items":{"$ref":"#/components/schemas/AccountMember"}}}}}}},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"}}},"post":{"tags":["Accounts"],"summary":"Invite or add user to workspace account","description":"Invites a user by email to join the workspace with a specified role (owner, admin, or member). If the user is already registered, they are immediately granted access; otherwise, an invitation is recorded and resolved on signup.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email","example":"colleague@example.com"},"role":{"type":"string","enum":["owner","admin","member"],"default":"member"},"name":{"type":"string","example":"Alex Smith"}}}}}},"responses":{"201":{"description":"Member added or invited","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"$ref":"#/components/schemas/AccountMember"},"status":{"type":"string","example":"active"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"},"409":{"description":"Member already belongs to account"}}},"patch":{"tags":["Accounts"],"summary":"Update member role","description":"Updates a workspace member role. Requires owner or admin permissions. Owners cannot be demoted if they are the sole owner.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["role"],"properties":{"sub":{"type":"string","description":"User unique sub"},"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["owner","admin","member"]}}}}}},"responses":{"200":{"description":"Member role updated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"member":{"$ref":"#/components/schemas/AccountMember"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"},"404":{"$ref":"#/components/responses/404NotFound"}}},"delete":{"tags":["Accounts"],"summary":"Remove user or cancel invite","description":"Removes a user from the workspace or cancels a pending invite. Sole owner cannot be removed.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"sub":{"type":"string","description":"User unique sub"},"email":{"type":"string","format":"email"}}}}}},"responses":{"200":{"description":"Member removed or invite canceled","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"removed":{"type":"string"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"},"404":{"$ref":"#/components/responses/404NotFound"}}}},"/api/transfers":{"get":{"tags":["Transfers"],"summary":"List workspace file transfers","description":"Lists all active, expired, or exhausted ephemeral file packages in the workspace.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"List of transfers","content":{"application/json":{"schema":{"type":"object","properties":{"transfers":{"type":"array","items":{"$ref":"#/components/schemas/Transfer"}}}}}}},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"}}},"post":{"tags":["Transfers"],"summary":"Create ephemeral file transfer package","description":"Creates a new short-lived, encrypted file package with configurable expiration (up to 7 days) and download limits.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTransferRequest"}}}},"responses":{"201":{"description":"Transfer package created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"402":{"$ref":"#/components/responses/402TierLimit"}}}},"/api/transfers/{id}":{"delete":{"tags":["Transfers"],"summary":"Delete transfer package","description":"Permanently removes a transfer package and invalidates its public download token.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Transfer ID"}],"responses":{"200":{"description":"Transfer deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"deletedId":{"type":"string","example":"xfer-7a9b1c"}}}}}}}}},"/api/share/{shareToken}":{"get":{"tags":["Transfers"],"summary":"Public recipient transfer lookup","description":"Allows unauthenticated recipients to look up transfer package metadata prior to downloading.","parameters":[{"name":"shareToken","in":"path","required":true,"schema":{"type":"string"},"description":"24-character URL-safe share token"}],"responses":{"200":{"description":"Transfer metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicTransferInfo"}}}},"404":{"$ref":"#/components/responses/404NotFound"}}}},"/api/share/{shareToken}/download":{"post":{"tags":["Transfers"],"summary":"Record recipient download","description":"Records a successful download for the transfer package, decrementing remaining downloads.","parameters":[{"name":"shareToken","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Download registered","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"downloadCount":{"type":"integer","example":1},"maxDownloads":{"type":"integer","nullable":true,"example":5},"remainingDownloads":{"type":"integer","nullable":true,"example":4},"exhausted":{"type":"boolean","example":false}}}}}}}}},"/api/crm/targets":{"get":{"tags":["CRM Targets"],"summary":"List & filter contacts","description":"Lists all contacts in the CRM workspace with flexible attribute filtering, search, group matching, and GDPR marketing status filters.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"search","in":"query","schema":{"type":"string"},"description":"Search email or attributes"},{"name":"marketingStatus","in":"query","schema":{"type":"string","enum":["subscribed","unsubscribed","pending_consent"]}},{"name":"group","in":"query","schema":{"type":"string"},"description":"Filter by mail group (e.g. default, or a custom group ID)"},{"name":"filterField","in":"query","schema":{"type":"string"},"description":"Custom attribute key (e.g. plan, stage)"},{"name":"filterOperator","in":"query","schema":{"type":"string","enum":["equals","contains","exists"]}},{"name":"filterValue","in":"query","schema":{"type":"string"},"description":"Target value to match"}],"responses":{"200":{"description":"Contacts list","content":{"application/json":{"schema":{"type":"object","properties":{"targets":{"type":"array","items":{"$ref":"#/components/schemas/Target"}},"count":{"type":"integer","example":1}}}}}}}},"post":{"tags":["CRM Targets"],"summary":"Add or upsert contact","description":"Creates a new contact or updates an existing contact by email address. Encrypted under AES-256-GCM with tenant-bound AAD.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpsertTargetRequest"}}}},"responses":{"201":{"description":"Contact created or updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Target"}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"402":{"$ref":"#/components/responses/402TierLimit"}}}},"/api/crm/targets/{id}":{"get":{"tags":["CRM Targets"],"summary":"Get single contact","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Contact details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Target"}}}},"404":{"$ref":"#/components/responses/404NotFound"}}},"put":{"tags":["CRM Targets"],"summary":"Update contact profile","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"attributes":{"type":"object"},"replace":{"type":"boolean","default":false},"mailGroups":{"type":"object"},"gdprLawfulBasis":{"type":"string"}}}}}},"responses":{"200":{"description":"Contact updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Target"}}}}}},"delete":{"tags":["CRM Targets"],"summary":"Delete contact (GDPR Art. 17 Erasure)","description":"Permanently removes the contact and anonymizes their email address in historical delivery logs in compliance with GDPR Article 17.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Target erased and logs anonymized","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"deletedTargetId":{"type":"string"},"email":{"type":"string"},"anonymizedDispatchesCount":{"type":"integer"}}}}}}}}},"/api/crm/targets/{id}/export":{"get":{"tags":["GDPR Compliance"],"summary":"Export subject dossier (GDPR Art. 15 Right of Access)","description":"Generates a complete, portable JSON dossier of all personal data, consent history, dynamic attributes, and outbound dispatch records held on the subject.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Complete GDPR subject data export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GdprExportResponse"}}}}}}},"/api/crm/targets/{id}/preferences":{"get":{"tags":["CRM Targets"],"summary":"Get marketing preferences","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Marketing preferences","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TargetPreferences"}}}}}},"put":{"tags":["CRM Targets"],"summary":"Update marketing preferences","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"marketingStatus":{"type":"string","enum":["subscribed","unsubscribed","pending_consent"]},"mailGroups":{"type":"object"}}}}}},"responses":{"200":{"description":"Updated preferences","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TargetPreferences"}}}}}}},"/api/crm/groups":{"get":{"tags":["CRM Mail Groups"],"summary":"List dynamic mail groups","description":"Lists all audience mail groups in the workspace with member target counts and default group status.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Mail groups list","content":{"application/json":{"schema":{"type":"object","properties":{"groups":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","example":"default"},"name":{"type":"string","example":"Default"},"description":{"type":"string","example":"Default workspace audience group for all contacts"},"isDefault":{"type":"boolean","example":true},"targetCount":{"type":"integer","example":12},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}},"defaultGroup":{"type":"string","example":"default"},"count":{"type":"integer","example":1}}}}}}}},"post":{"tags":["CRM Mail Groups"],"summary":"Create dynamic mail group","description":"Creates a new audience mail group. Optionally designates it as the workspace default group.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"VIP Clients"},"description":{"type":"string","example":"High-value enterprise clients"},"isDefault":{"type":"boolean","default":false}}}}}},"responses":{"201":{"description":"Mail group created","content":{"application/json":{"schema":{"type":"object","properties":{"group":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"409":{"description":"Group already exists"}}}},"/api/crm/groups/{id}":{"get":{"tags":["CRM Mail Groups"],"summary":"Get mail group details","description":"Retrieves details and member counts for a specific mail group.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Mail group details","content":{"application/json":{"schema":{"type":"object","properties":{"group":{"type":"object"}}}}}},"404":{"$ref":"#/components/responses/404NotFound"}}},"put":{"tags":["CRM Mail Groups"],"summary":"Update mail group","description":"Updates a mail group name, description, or default status.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"isDefault":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated mail group","content":{"application/json":{"schema":{"type":"object","properties":{"group":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/400BadRequest"},"404":{"$ref":"#/components/responses/404NotFound"}}},"delete":{"tags":["CRM Mail Groups"],"summary":"Delete mail group","description":"Deletes a dynamic mail group. The default workspace group CANNOT be deleted.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Mail group deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"deletedId":{"type":"string"},"message":{"type":"string"}}}}}},"400":{"description":"Cannot delete the default group","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"$ref":"#/components/responses/404NotFound"}}}},"/api/crm/groups/{id}/default":{"post":{"tags":["CRM Mail Groups"],"summary":"Set default mail group","description":"Designates a specific mail group as the workspace default group, unsetting the previous default.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Default group updated","content":{"application/json":{"schema":{"type":"object","properties":{"group":{"type":"object"},"defaultGroup":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/404NotFound"}}}},"/api/crm/templates/free":{"get":{"tags":["CRM Templates"],"summary":"List built-in free starter templates","description":"Returns the catalog of ready-to-use, professionally crafted starter templates available to all workspaces.","responses":{"200":{"description":"Free starter templates","content":{"application/json":{"schema":{"type":"object","properties":{"freeTemplates":{"type":"array","items":{"$ref":"#/components/schemas/Template"}},"count":{"type":"integer","example":5}}}}}}}}},"/api/crm/templates":{"get":{"tags":["CRM Templates"],"summary":"List all workspace templates","description":"Returns all custom saved templates for the workspace along with unlocked free starter templates.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Workspace templates list","content":{"application/json":{"schema":{"type":"object","properties":{"templates":{"type":"array","items":{"$ref":"#/components/schemas/Template"}},"count":{"type":"integer"},"freeTemplates":{"type":"array","items":{"$ref":"#/components/schemas/Template"}}}}}}}}},"post":{"tags":["CRM Templates"],"summary":"Create custom email template","description":"Creates a custom HTML/text template with dynamic mustache placeholder tags (e.g. {{firstName}}, {{company}}).","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTemplateRequest"}}}},"responses":{"201":{"description":"Template created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"402":{"$ref":"#/components/responses/402TierLimit"}}}},"/api/crm/templates/{id}":{"get":{"tags":["CRM Templates"],"summary":"Get single template","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Template details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}}}},"put":{"tags":["CRM Templates"],"summary":"Update template","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTemplateRequest"}}}},"responses":{"200":{"description":"Template updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}}}},"delete":{"tags":["CRM Templates"],"summary":"Delete custom template","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Template deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"deletedTemplateId":{"type":"string"}}}}}}}}},"/api/crm/campaigns":{"get":{"tags":["CRM Campaigns"],"summary":"List campaigns","description":"Returns all saved campaign drafts, scheduled campaigns, and historical dispatches.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Campaign list","content":{"application/json":{"schema":{"type":"object","properties":{"campaigns":{"type":"array","items":{"$ref":"#/components/schemas/Campaign"}},"count":{"type":"integer"}}}}}}}},"post":{"tags":["CRM Campaigns"],"summary":"Save or schedule campaign draft","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SaveCampaignRequest"}}}},"responses":{"201":{"description":"Campaign saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}}}}},"/api/crm/campaigns/scheduled":{"get":{"tags":["CRM Campaigns"],"summary":"List scheduled campaigns","description":"Returns upcoming scheduled campaigns for the workspace sorted by scheduledAt ascending.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Scheduled campaigns list","content":{"application/json":{"schema":{"type":"object","properties":{"scheduled":{"type":"array","items":{"$ref":"#/components/schemas/Campaign"}},"count":{"type":"integer"},"dueCount":{"type":"integer"},"nextScheduledAt":{"type":"string","format":"date-time","nullable":true}}}}}}}}},"/api/crm/campaigns/scheduled/process":{"post":{"tags":["CRM Campaigns"],"summary":"Process due scheduled campaigns for workspace","description":"Immediately checks and dispatches any scheduled campaigns in the workspace whose scheduledAt timestamp has passed.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Scheduler processing summary"}}}},"/api/crm/campaigns/{campaignId}/schedule":{"post":{"tags":["CRM Campaigns"],"summary":"Schedule or reschedule a campaign send","description":"Schedules a draft, new, or existing campaign for automated future dispatch at scheduledAt via EventBridge and SQS.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"campaignId","in":"path","required":true,"schema":{"type":"string"},"description":"Existing campaign ID or \"new\""}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScheduleCampaignRequest"}}}},"responses":{"200":{"description":"Campaign scheduled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}},"400":{"$ref":"#/components/responses/400BadRequest"}}}},"/api/crm/campaigns/{campaignId}/unschedule":{"post":{"tags":["CRM Campaigns"],"summary":"Cancel a scheduled campaign send","description":"Cancels the scheduled send and reverts the campaign back to draft status.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"campaignId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Campaign unscheduled and reverted to draft","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}}}}},"/api/crm/campaigns/{campaignId}/send-now":{"post":{"tags":["CRM Campaigns"],"summary":"Immediately dispatch a saved or scheduled campaign","description":"Clears any pending schedule and immediately queues or dispatches the saved campaign.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"campaignId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Campaign dispatched"},"202":{"description":"Campaign queued to SQS"}}}},"/api/crm/preview":{"post":{"tags":["CRM Campaigns"],"summary":"Dry-run preview campaign rendering","description":"Renders the campaign template with dynamic audience variables and evaluates segmentation filters without sending any emails or consuming quotas.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreviewCampaignRequest"}}}},"responses":{"200":{"description":"Campaign preview result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreviewCampaignResponse"}}}}}}},"/api/crm/send":{"post":{"tags":["CRM Campaigns"],"summary":"Dispatch live outreach campaign via AWS SES","description":"Sends personalized emails to all matched contacts. Strictly suppresses unsubscribed contacts, injects GDPR one-click unsubscribe links and engagement tracking pixels, and checks hourly rate limits and global maintenance kill-switches.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendCampaignRequest"}}}},"responses":{"200":{"description":"Campaign dispatched successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendCampaignResponse"}}}},"403":{"description":"Outbound sends disabled by platform administration"},"429":{"description":"Hourly or daily email quota exceeded"}}}},"/api/crm/quota":{"get":{"tags":["CRM Campaigns"],"summary":"Get outbound email rate limit status","description":"Returns the current hourly and daily send counts, remaining email allowance, and rolling window reset time.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Rate limit quota status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailQuotaStatus"}}}}}}},"/api/crm/send-control":{"get":{"tags":["CRM Campaigns"],"summary":"Get account Emergency Stop & active send status","description":"Returns whether outbound sends are paused for the account along with active, queued, and paused dispatch summaries.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Account send-control state"}}}},"/api/crm/send-control/emergency-stop":{"post":{"tags":["CRM Campaigns"],"summary":"Activate Emergency Stop (pause all active sends)","description":"Immediately pauses all queued, processing, and scheduled sends for the specified account and blocks new dispatches until resumed.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Emergency Stop activated and active sends paused"}}}},"/api/crm/send-control/resume":{"post":{"tags":["CRM Campaigns"],"summary":"Resume paused sends for account","description":"Deactivates Emergency Stop for the account and re-queues all paused sends.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Sending resumed and paused jobs re-queued"}}}},"/api/crm/send-control/clear":{"post":{"tags":["CRM Campaigns"],"summary":"Clear all active and paused sends for account","description":"Permanently cancels all queued, processing, paused, and scheduled sends for the account and purges parked queue jobs.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"All active and paused sends cleared"}}}},"/api/crm/track/open":{"get":{"tags":["CRM Engagement"],"summary":"Email open tracking pixel","description":"Embeddable 1x1 GIF tracking pixel that registers unique email opens, increments recipient open counters, and logs client telemetry.","parameters":[{"name":"token","in":"query","required":true,"schema":{"type":"string"},"description":"Cryptographically signed engagement token"},{"name":"format","in":"query","schema":{"type":"string","enum":["gif","json"]},"description":"Return transparent GIF or JSON receipt"}],"responses":{"200":{"description":"Tracking pixel image or JSON confirmation","content":{"image/gif":{"schema":{"type":"string","format":"binary"}},"application/json":{"schema":{"type":"object","properties":{"tracked":{"type":"boolean"},"eventType":{"type":"string"}}}}}}}}},"/api/crm/track/click":{"get":{"tags":["CRM Engagement"],"summary":"Email link click redirect & CTR tracking","description":"Redirects recipient to the destination URL while atomically registering a click event and updating campaign CTR metrics.","parameters":[{"name":"token","in":"query","required":true,"schema":{"type":"string"}},{"name":"url","in":"query","required":true,"schema":{"type":"string","format":"uri"}},{"name":"format","in":"query","schema":{"type":"string","enum":["redirect","json"]}}],"responses":{"200":{"description":"JSON receipt if format=json"},"302":{"description":"Redirect to target URL"}}}},"/api/crm/engagement":{"get":{"tags":["CRM Engagement"],"summary":"Get workspace engagement summary & KPIs","description":"Returns Open Rates, Click-Through Rates (CTR), Click-to-Open Rates, per-campaign engagement statistics, and recent activity logs.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Engagement telemetry summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EngagementSummary"}}}}}},"post":{"tags":["CRM Engagement"],"summary":"Record or simulate engagement event","description":"Manually records an open or click event for testing and telemetry pipelines.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["targetId","targetEmail","eventType"],"properties":{"campaignId":{"type":"string"},"targetId":{"type":"string"},"targetEmail":{"type":"string","format":"email"},"eventType":{"type":"string","enum":["open","click"]},"url":{"type":"string"}}}}}},"responses":{"200":{"description":"Event recorded successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"recordedAt":{"type":"string","format":"date-time"}}}}}}}}},"/api/crm/track/event":{"post":{"tags":["CRM Engagement"],"summary":"Ingest website tracking event (Public Key + Integrity Verified)","description":"Public ingestion endpoint called by the hosted CloudSend JS SDK (`/sdk/cloudsend-track.js`) or server backends. Resolves the workspace via `publicKey`, verifies origin allowlists, client SHA-256 payload digest, optional/required HMAC-SHA256 signature (`X-CloudSend-Signature`), and HMAC-signed `cs_tid` link attribution token, then updates `events.<campaign_slug>.<event_name>` attributes on the matched contact.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["publicKey","event"],"properties":{"publicKey":{"type":"string","example":"cs_pk_9f4b2a1c8e7d6f5a4b3c2d1e"},"event":{"type":"string","example":"purchase_completed"},"attributionToken":{"type":"string","description":"Signed cs_tid token captured from email link URL"},"timestamp":{"type":"number","example":1794362400000},"nonce":{"type":"string","example":"a1b2c3d4e5f6"},"properties":{"type":"object","example":{"orderId":"ORD-1024","value":149,"currency":"GBP"}},"integrity":{"type":"object","properties":{"algorithm":{"type":"string","example":"sha256"},"digest":{"type":"string","example":"sha256-..."}}},"signature":{"type":"string","description":"Optional HMAC-SHA256 signature: t=<ms>,v1=<hex>"}}}}}},"responses":{"200":{"description":"Event processed"},"401":{"description":"Invalid publicKey or HMAC event signature"},"403":{"description":"Origin not allowed or tenant attribution mismatch"}}}},"/api/sdk/integrity":{"get":{"tags":["CRM Engagement"],"summary":"Get hosted JS SDK Subresource Integrity (SRI) hashes","description":"Returns the exact SHA-384 and SHA-256 Subresource Integrity digests for `/sdk/cloudsend-track.js`.","responses":{"200":{"description":"SDK SRI metadata"}}}},"/api/crm/tracking/config":{"get":{"tags":["CRM Engagement"],"summary":"Get workspace website tracking config, publicKey & SRI snippet","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Tracking config & embed snippet"}}},"put":{"tags":["CRM Engagement"],"summary":"Update website tracking settings","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"autoAppendLinks":{"type":"boolean"},"allowedOrigins":{"type":"array","items":{"type":"string"}},"requireSignedEvents":{"oneOf":[{"type":"boolean"},{"type":"array","items":{"type":"string"}}]}}}}}},"responses":{"200":{"description":"Updated tracking config"}}}},"/api/crm/tracking/rotate-key":{"post":{"tags":["CRM Engagement"],"summary":"Rotate workspace tracking Public Key","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Rotated publicKey"}}}},"/api/crm/tracking/rotate-secret":{"post":{"tags":["CRM Engagement"],"summary":"Rotate write-only HMAC event signing secret (returned once)","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Rotated signing secret (shown once)"}}}},"/api/crm/tracking/events":{"get":{"tags":["CRM Engagement"],"summary":"List attributed website tracking events and conversion revenue","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"targetId","in":"query","schema":{"type":"string"}},{"name":"campaignSlug","in":"query","schema":{"type":"string"}},{"name":"event","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Website tracking analytics and events"}}}},"/api/crm/unsubscribe":{"get":{"tags":["GDPR Compliance"],"summary":"One-click unsubscribe (GET link)","parameters":[{"name":"token","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Unsubscribed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnsubscribeResponse"}}}}}},"post":{"tags":["GDPR Compliance"],"summary":"One-click unsubscribe (RFC 8058 POST)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token"],"properties":{"token":{"type":"string"}}}}}},"responses":{"200":{"description":"Unsubscribed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnsubscribeResponse"}}}}}}},"/api/crm/domains":{"get":{"tags":["Sending Domains"],"summary":"List custom sending domains","description":"Lists all registered sending domains and their DNS verification statuses.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Sending domains list","content":{"application/json":{"schema":{"type":"object","properties":{"domains":{"type":"array","items":{"$ref":"#/components/schemas/SendingDomain"}},"count":{"type":"integer"}}}}}}}},"post":{"tags":["Sending Domains"],"summary":"Register custom sending domain","description":"Registers a new sending domain and generates SPF TXT, 2048-bit RSA DKIM TXT, 3x Easy-DKIM CNAMEs, DMARC TXT, and Return-Path MX records.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"},"defaultFromUser":{"type":"string","example":"hello"}}}}}},"responses":{"201":{"description":"Domain registered with required DNS records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendingDomain"}}}},"402":{"$ref":"#/components/responses/402TierLimit"}}}},"/api/crm/domains/{domain}/verify":{"post":{"tags":["Sending Domains"],"summary":"Verify domain DNS records","description":"Queries DNS servers to verify SPF, DKIM, and DMARC configuration.","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"parameters":[{"name":"domain","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"forceVerify":{"type":"boolean","default":true}}}}}},"responses":{"200":{"description":"DNS verification result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DomainVerificationResult"}}}}}}},"/api/billing/tiers":{"get":{"tags":["Billing"],"summary":"List available pricing tiers","description":"Returns the catalog of plans (Free, Personal, Business, Enterprise) with resource limits and feature matrix.","responses":{"200":{"description":"Pricing tier catalog","content":{"application/json":{"schema":{"type":"object","properties":{"defaultTier":{"type":"string","example":"free"},"tiers":{"type":"array","items":{"$ref":"#/components/schemas/PricingTier"}},"count":{"type":"integer","example":4}}}}}}}}},"/api/billing":{"get":{"tags":["Billing"],"summary":"Get workspace billing status & usage quotas","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"responses":{"200":{"description":"Account billing and resource usage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountBillingDetails"}}}}}}},"/api/billing/tier":{"put":{"tags":["Billing"],"summary":"Upgrade or change subscription tier","security":[{"BearerAuth":[],"AccountIdHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["tierId"],"properties":{"tierId":{"type":"string","enum":["free","starter","personal","pro","business","enterprise"]},"billingCycle":{"type":"string","enum":["monthly","annual"],"default":"monthly"}}}}}},"responses":{"200":{"description":"Subscription tier updated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"billing":{"$ref":"#/components/schemas/AccountBillingDetails"}}}}}}}}},"/api/mcp":{"get":{"tags":["MCP"],"summary":"MCP server discovery","description":"Returns Model Context Protocol (2024-11-05) server info, available AI tools count, and SSE endpoints.","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"MCP server info","content":{"application/json":{"schema":{"type":"object","properties":{"protocolVersion":{"type":"string","example":"2024-11-05"},"serverInfo":{"type":"object"},"accountId":{"type":"string"},"toolsCount":{"type":"integer","example":13},"endpoints":{"type":"object"}}}}}}}},"post":{"tags":["MCP"],"summary":"Execute MCP JSON-RPC 2.0 call","description":"Handles MCP methods: initialize, tools/list, tools/call, resources/list, resources/read, prompts/list.","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["jsonrpc","method","id"],"properties":{"jsonrpc":{"type":"string","example":"2.0"},"id":{"type":["integer","string"],"example":1},"method":{"type":"string","example":"tools/call"},"params":{"type":"object"}}}}}},"responses":{"200":{"description":"JSON-RPC response"},"202":{"description":"Accepted (Notification)"}}}}},"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT User Token obtained via `POST /api/auth/login`."},"AccountIdHeader":{"type":"apiKey","in":"header","name":"X-Account-Id","description":"Tenant workspace account ID obtained via `GET /api/accounts`."}},"responses":{"400BadRequest":{"description":"Bad Request — invalid parameters or malformed payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardError"},"example":{"error":"Email address is required and must be valid","code":"INVALID_EMAIL"}}}},"401Unauthorized":{"description":"Unauthorized — missing or expired authentication token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardError"},"example":{"error":"Authentication required. Missing or invalid Bearer token."}}}},"402TierLimit":{"description":"Payment Required / Tier Limit Exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TierLimitError"},"example":{"error":"Free tier limit reached: maximum 10 contacts allowed on the Free plan. Upgrade your plan to add more contacts.","code":"TIER_LIMIT_EXCEEDED","tierId":"free","limit":10,"resource":"targets"}}}},"403Forbidden":{"description":"Forbidden — insufficient privileges or account isolation failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardError"},"example":{"error":"Account not found or access denied for this user."}}}},"404NotFound":{"description":"Resource Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardError"},"example":{"error":"Target not found"}}}}},"schemas":{"StandardError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human readable error description"},"code":{"type":"string","description":"Programmatic machine-readable error code"}}},"TierLimitError":{"allOf":[{"$ref":"#/components/schemas/StandardError"},{"type":"object","properties":{"tierId":{"type":"string","example":"free"},"limit":{"type":"integer","example":3},"resource":{"type":"string","example":"targets"}}}]},"HealthStatus":{"type":"object","properties":{"status":{"type":"string","example":"healthy"},"service":{"type":"string","example":"cloud-send"},"system":{"type":"string","example":"crm-platform"},"version":{"type":"string","example":"1.0.0"},"emailSendsDisabled":{"type":"boolean","example":false},"timestamp":{"type":"string","format":"date-time"}}},"AuthRegisterResponse":{"type":"object","properties":{"user":{"type":"object","properties":{"sub":{"type":"string"},"email":{"type":"string"},"name":{"type":"string"},"confirmed":{"type":"boolean"}}},"userConfirmed":{"type":"boolean"},"message":{"type":"string"}}},"AuthLoginResponse":{"type":"object","properties":{"token":{"type":"string","description":"JWT Bearer Token"},"user":{"type":"object","properties":{"sub":{"type":"string"},"email":{"type":"string"},"name":{"type":"string"}}},"expiresIn":{"type":"integer","example":86400}}},"AccountSummary":{"type":"object","properties":{"accountId":{"type":"string","example":"acct-b2f63f51"},"name":{"type":"string","example":"Primary Workspace"},"role":{"type":"string","example":"owner"},"createdAt":{"type":"string","format":"date-time"}}},"AccountMember":{"type":"object","properties":{"sub":{"type":"string","nullable":true,"example":"b2f63f51-2856-4299"},"email":{"type":"string","format":"email","example":"alex@example.com"},"name":{"type":"string","example":"Alex Smith"},"role":{"type":"string","enum":["owner","admin","member"],"example":"admin"},"status":{"type":"string","enum":["active","invited"],"example":"active"},"addedAt":{"type":"string","format":"date-time"},"invitedAt":{"type":"string","format":"date-time"}}},"Target":{"type":"object","properties":{"id":{"type":"string","example":"tgt-3a8f10c7"},"email":{"type":"string","format":"email","example":"sarah.connor@example.com"},"marketingStatus":{"type":"string","enum":["subscribed","unsubscribed","pending_consent"],"example":"subscribed"},"mailGroups":{"type":"object"},"attributes":{"type":"object","example":{"firstName":"Sarah","company":"Cyberdyne Systems","plan":"enterprise"}},"gdpr":{"type":"object","properties":{"status":{"type":"string","example":"compliant"},"lawfulBasis":{"type":"string","example":"consent"},"consentTimestamp":{"type":"string","format":"date-time"},"consentSource":{"type":"string","example":"api"}}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"UpsertTargetRequest":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email","example":"sarah.connor@example.com"},"marketingStatus":{"type":"string","enum":["subscribed","unsubscribed","pending_consent"],"default":"subscribed"},"attributes":{"type":"object","example":{"firstName":"Sarah","company":"Cyberdyne Systems"}},"mailGroups":{"type":"object"},"gdprLawfulBasis":{"type":"string","enum":["consent","contractual","legitimate_interest","legal_obligation"],"default":"consent"}}},"TargetPreferences":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"marketingStatus":{"type":"string"},"mailGroups":{"type":"object"},"unsubscribedAt":{"type":"string","nullable":true}}},"Template":{"type":"object","properties":{"id":{"type":"string","example":"tpl-1e2d3c4b"},"name":{"type":"string","example":"Welcome & Onboarding"},"subject":{"type":"string","example":"Welcome to CloudSend, {{firstName}}!"},"htmlBody":{"type":"string","example":"<h1>Hi {{firstName}}</h1><p>Welcome!</p>"},"textBody":{"type":"string"},"free":{"type":"boolean","example":false},"createdAt":{"type":"string","format":"date-time"}}},"CreateTemplateRequest":{"type":"object","required":["name","subject","htmlBody"],"properties":{"name":{"type":"string","example":"Product Release Announcement"},"subject":{"type":"string","example":"New updates for {{company}}"},"htmlBody":{"type":"string","example":"<h1>Hi {{firstName}}</h1><p>Here are the updates...</p>"},"textBody":{"type":"string"},"description":{"type":"string"}}},"Campaign":{"type":"object","properties":{"id":{"type":"string","example":"camp-90a1b2"},"name":{"type":"string","example":"Enterprise Outreach"},"status":{"type":"string","enum":["draft","scheduled","queued","processing","sent","partial","failed"],"example":"sent"},"templateName":{"type":"string"},"scheduledAt":{"type":"string","format":"date-time","nullable":true},"timezone":{"type":"string","example":"UTC"},"totalMatched":{"type":"integer"},"successCount":{"type":"integer"},"openCount":{"type":"integer"},"clickCount":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"}}},"ScheduleCampaignRequest":{"type":"object","required":["scheduledAt"],"properties":{"name":{"type":"string","example":"Q4 Product Announcement"},"templateId":{"type":"string","example":"starter-welcome"},"scheduledAt":{"type":"string","format":"date-time","example":"2026-11-12T09:00:00Z"},"timezone":{"type":"string","example":"America/New_York","default":"UTC"},"fromEmail":{"type":"string","format":"email"},"channelType":{"type":"string","enum":["marketing","transactional"],"default":"marketing"},"filter":{"type":"object"}}},"SaveCampaignRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"Enterprise Q4 Followup"},"status":{"type":"string","enum":["draft","scheduled","sent"],"default":"draft"},"templateId":{"type":"string"},"fromEmail":{"type":"string","format":"email"},"channelType":{"type":"string","enum":["marketing","transactional"],"default":"marketing"},"filter":{"type":"object"}}},"PreviewCampaignRequest":{"type":"object","properties":{"templateId":{"type":"string"},"customSubject":{"type":"string"},"customBodyHtml":{"type":"string"},"filter":{"type":"object"},"mailGroup":{"type":"string"},"channelType":{"type":"string","enum":["marketing","transactional"]}}},"PreviewCampaignResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"previewOnly":{"type":"boolean","example":true},"totalMatched":{"type":"integer","example":1},"suppressedUnsubscribedCount":{"type":"integer","example":0},"samplePreviews":{"type":"array"},"quota":{"type":"object"}}},"SendCampaignRequest":{"type":"object","properties":{"campaignName":{"type":"string"},"templateId":{"type":"string"},"customSubject":{"type":"string"},"customBodyHtml":{"type":"string"},"filter":{"type":"object"},"mailGroup":{"type":"string"},"channelType":{"type":"string","enum":["marketing","transactional"],"default":"marketing"},"scheduledAt":{"type":"string","format":"date-time","description":"Optional future ISO 8601 timestamp to schedule the send instead of immediate dispatch"},"timezone":{"type":"string","example":"UTC"}}},"SendCampaignResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"campaignId":{"type":"string"},"dispatchedCount":{"type":"integer","example":1},"matchedCount":{"type":"integer","example":1},"suppressedUnsubscribedCount":{"type":"integer","example":0},"failedCount":{"type":"integer","example":0},"deliveries":{"type":"array"},"quota":{"type":"object"}}},"EmailQuotaStatus":{"type":"object","properties":{"limit":{"type":"integer","example":5},"dailyLimit":{"type":"integer","example":50},"tierId":{"type":"string","example":"starter"},"sentInLastHour":{"type":"integer","example":1},"sentInLastDay":{"type":"integer","example":4},"remaining":{"type":"integer","example":4},"resetInMinutes":{"type":"integer","example":52},"emailSendsDisabled":{"type":"boolean","example":false}}},"EngagementSummary":{"type":"object","properties":{"totalDelivered":{"type":"integer","example":10},"uniqueOpens":{"type":"integer","example":7},"totalOpens":{"type":"integer","example":12},"openRate":{"type":"number","example":70},"uniqueClicks":{"type":"integer","example":3},"totalClicks":{"type":"integer","example":5},"clickRate":{"type":"number","example":30},"perTarget":{"type":"array"},"recentEvents":{"type":"array"}}},"Transfer":{"type":"object","properties":{"id":{"type":"string","example":"xfer-7a9b1c"},"name":{"type":"string","example":"Financial Statements"},"description":{"type":"string"},"fileCount":{"type":"integer","example":2},"totalSizeBytes":{"type":"integer","example":1048576},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"},"maxDownloads":{"type":"integer","nullable":true},"downloadsCount":{"type":"integer","example":0},"status":{"type":"string","enum":["active","expired","exhausted"],"example":"active"},"shareToken":{"type":"string"},"shareUrl":{"type":"string","example":"/share/#4fa8c1e2b790d98412efaa81"}}},"CreateTransferRequest":{"type":"object","properties":{"name":{"type":"string","example":"Financial Statements"},"description":{"type":"string"},"fileCount":{"type":"integer","default":1},"totalSizeBytes":{"type":"integer","default":0},"expiresInHours":{"type":"integer","default":24,"minimum":1,"maximum":168},"maxDownloads":{"type":"integer","nullable":true},"isClientEncrypted":{"type":"boolean","default":false},"hasPassword":{"type":"boolean","default":false}}},"PublicTransferInfo":{"type":"object","properties":{"accountId":{"type":"string"},"transferId":{"type":"string"},"name":{"type":"string"},"fileCount":{"type":"integer"},"totalSizeBytes":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"},"maxDownloads":{"type":"integer","nullable":true},"downloadsCount":{"type":"integer"},"status":{"type":"string","example":"active"}}},"SendingDomain":{"type":"object","properties":{"domain":{"type":"string","example":"example.com"},"status":{"type":"string","enum":["pending_verification","verified"],"example":"pending_verification"},"spfRecord":{"type":"object"},"dkimTxtRecord":{"type":"object"},"dkimCnameRecords":{"type":"array"},"dmarcRecord":{"type":"object"},"returnPathMxRecord":{"type":"object"}}},"DomainVerificationResult":{"type":"object","properties":{"domain":{"type":"string"},"verified":{"type":"boolean"},"status":{"type":"string"},"dnsStatus":{"type":"object"}}},"PricingTier":{"type":"object","properties":{"id":{"type":"string","example":"starter"},"name":{"type":"string","example":"Starter"},"priceMonthly":{"type":"number","example":19},"currency":{"type":"string","example":"USD"},"limits":{"type":"object"},"features":{"type":"array","items":{"type":"string"}}}},"AccountBillingDetails":{"type":"object","properties":{"billing":{"type":"object"},"usage":{"type":"object"},"allTiers":{"type":"array"}}},"UnsubscribeResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"email":{"type":"string"},"unsubscribedAt":{"type":"string","format":"date-time"},"message":{"type":"string"}}},"GdprExportResponse":{"type":"object","properties":{"exportTimestamp":{"type":"string","format":"date-time"},"compliance":{"type":"object"},"subject":{"$ref":"#/components/schemas/Target"},"communicationHistory":{"type":"array"}}}}}}