{
	"openapi": "3.1.0",
	"info": {
		"title": "PostStack API",
		"version": "1.0",
		"summary": "European email API — send transactional and marketing email, manage contacts, domains, templates, broadcasts and webhooks.",
		"description": "The PostStack REST API, served at `https://api.poststack.dev` (paths have no `/api` prefix there). Authenticate every request except `POST /signup-forms/{id}/submit` and `GET /public/regions` with `Authorization: Bearer <token>`: an API key (`sk_live_…` / `sk_test_…`) or an OAuth 2.0 access token (`pat_…`). A `full_access` key holds every scope; a `sending_access` key holds only `email:send`, `email:read` and `mcp:send`, so other routes answer `403 insufficient_scope`. Errors are JSON `{ \"error\": string, \"code\": string }`. Validation failures are `400` with `error` listing `field: message` pairs; semantic rejections are `422`. Every response carries `X-Request-Id`; rate-limited routes send `X-RateLimit-Limit/Remaining/Reset` and, on `429`, `Retry-After` (limits are per credential, halved on the free plan). During maintenance any route may answer `503`. See https://poststack.dev/docs for guides and SDKs.",
		"termsOfService": "https://poststack.dev/terms",
		"contact": {
			"name": "PostStack Support",
			"url": "https://poststack.dev/contact",
			"email": "support@poststack.dev"
		},
		"license": {
			"name": "Proprietary",
			"url": "https://poststack.dev/terms"
		}
	},
	"servers": [
		{
			"url": "https://api.poststack.dev",
			"description": "Production"
		}
	],
	"externalDocs": {
		"description": "PostStack docs",
		"url": "https://poststack.dev/docs"
	},
	"security": [
		{
			"bearerApiKey": []
		},
		{
			"bearerOAuth": []
		}
	],
	"tags": [
		{
			"name": "Emails",
			"description": "Send and inspect individual emails."
		},
		{
			"name": "Domains",
			"description": "Add and verify sending domains (SPF / DKIM / DMARC)."
		},
		{
			"name": "Brands",
			"description": "Partitions inside a team for platforms that send for many merchants: each brand has its own domains, audience, unsubscribes, webhooks and (optionally) API keys."
		},
		{
			"name": "Contacts",
			"description": "Manage subscribers and custom properties."
		},
		{
			"name": "Segments",
			"description": "Dynamic and manual audiences."
		},
		{
			"name": "Broadcasts",
			"description": "Bulk campaigns with scheduling and analytics."
		},
		{
			"name": "Templates",
			"description": "Reusable email templates with {{variable}} placeholders."
		},
		{
			"name": "Webhooks",
			"description": "Real-time event delivery with HMAC signatures."
		},
		{
			"name": "Suppressions",
			"description": "Bounce, complaint, unsubscribe suppression list."
		},
		{
			"name": "Subscription topics",
			"description": "Fine-grained email preferences per contact."
		},
		{
			"name": "Mailboxes",
			"description": "IMAP/POP3 mailboxes, aliases and server-side filters."
		},
		{
			"name": "API keys",
			"description": "Manage API keys."
		},
		{
			"name": "Contact properties",
			"description": "Custom contact attributes (string / number / date / boolean) for segmentation."
		},
		{
			"name": "Workflows",
			"description": "Automated email sequences triggered by contact events or schedules."
		},
		{
			"name": "Signup forms",
			"description": "Hosted contact-collection forms with custom fields and double-opt-in."
		},
		{
			"name": "Email validations",
			"description": "Pre-send email-address validation (syntax, MX, disposable, role)."
		},
		{
			"name": "Inbound emails",
			"description": "Mail received on your domains: read, download attachments, reply and forward."
		},
		{
			"name": "Notification channels",
			"description": "Slack, Discord and Telegram alerts for account events."
		},
		{
			"name": "Regions",
			"description": "Public region catalogue."
		}
	],
	"paths": {
		"/emails": {
			"post": {
				"tags": ["Emails"],
				"operationId": "sendEmail",
				"summary": "Send an email",
				"description": "Queues one email and answers `202 Accepted` with its id. Delivery happens asynchronously — follow it with `GET /emails/{id}`, `GET /emails/{id}/events` or webhooks. Either give `subject` plus `html`/`text`, or a published `template_id` (+ `variables`). Attachment limits apply to the decoded bytes: 10 MB per file, 25 MB per email, 10 files.",
				"x-required-scope": "email:send",
				"parameters": [
					{
						"name": "Idempotency-Key",
						"in": "header",
						"required": false,
						"description": "Optional dedupe key (printable ASCII, max 64 chars). Used only when the body has no `idempotency_key`. The official SDKs send one automatically. On batch, element *i* gets `<key>:<i>`.",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/SendEmailInput"
							}
						}
					}
				},
				"responses": {
					"202": {
						"description": "Accepted and queued (or replayed — see `replayed`).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/SendEmailResponse"
								}
							}
						}
					},
					"400": {
						"description": "Body missing, not JSON, or failed validation (the JSON error for a missing field lists `missingFields`).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `email:send` scope; team suspended or sending paused; or the API key is restricted to a different domain.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "template_id does not exist.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Semantically invalid: unverified/unknown `from` domain, all recipients suppressed, template not published, attachment too large, or `idempotency_key` reused with a different payload.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Branch on `code`. `rate_limit_exceeded`: request rate limited (60 req/min per key; halved on the free plan) — retry after `Retry-After`. Not retryable: `monthly_limit_exceeded` (monthly plan limit reached), `daily_limit_exceeded` (rolling 24h cap on external recipients for new/free accounts), `send_limit_exceeded` (sending from new accounts paused platform-wide).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Emails"],
				"operationId": "listEmails",
				"summary": "List emails",
				"description": "Newest first. Body columns are omitted.",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "cursor",
						"in": "query",
						"description": "Accepted but not used — paginate with `page`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "brand_id",
						"in": "query",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					},
					{
						"name": "status",
						"in": "query",
						"description": "Filter by status.",
						"schema": {
							"type": "string",
							"enum": [
								"queued",
								"sending",
								"deferred",
								"delivered",
								"bounced",
								"complained",
								"failed"
							]
						}
					},
					{
						"name": "domain_id",
						"in": "query",
						"description": "Numeric domain id.",
						"schema": {
							"type": "number"
						}
					},
					{
						"name": "to",
						"in": "query",
						"description": "Recipient address.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "tag",
						"in": "query",
						"description": "Tag.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "date_from",
						"in": "query",
						"description": "ISO 8601 date or datetime.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "date_to",
						"in": "query",
						"description": "ISO 8601 date or datetime.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "provider",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "country",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "device",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "from",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "subject",
						"in": "query",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of emails.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Email"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/emails/send": {
			"post": {
				"tags": ["Emails"],
				"operationId": "sendEmailAlias",
				"summary": "Send an email (alias)",
				"description": "Identical to `POST /emails`; kept for clients that expect this path.",
				"x-required-scope": "email:send",
				"parameters": [
					{
						"name": "Idempotency-Key",
						"in": "header",
						"required": false,
						"description": "Optional dedupe key (printable ASCII, max 64 chars). Used only when the body has no `idempotency_key`. The official SDKs send one automatically. On batch, element *i* gets `<key>:<i>`.",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/SendEmailInput"
							}
						}
					}
				},
				"responses": {
					"202": {
						"description": "Accepted and queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/SendEmailResponse"
								}
							}
						}
					},
					"400": {
						"description": "Body missing, not JSON, or failed validation (the JSON error for a missing field lists `missingFields`).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `email:send` scope; team suspended or sending paused; or the API key is restricted to a different domain.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "template_id does not exist.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Semantically invalid: unverified/unknown `from` domain, all recipients suppressed, template not published, attachment too large, or `idempotency_key` reused with a different payload.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Branch on `code`. `rate_limit_exceeded`: request rate limited (60 req/min per key; halved on the free plan) — retry after `Retry-After`. Not retryable: `monthly_limit_exceeded` (monthly plan limit reached), `daily_limit_exceeded` (rolling 24h cap on external recipients for new/free accounts), `send_limit_exceeded` (sending from new accounts paused platform-wide).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/emails/batch": {
			"post": {
				"tags": ["Emails"],
				"operationId": "sendBatch",
				"summary": "Send up to 100 emails",
				"description": "Each element is validated as a `POST /emails` body and sent independently. The response is `202` even when some elements fail: each result is `{ id }` or `{ error, code? }`, in request order (`code` is set for quota rejections such as `monthly_limit_exceeded`).",
				"x-required-scope": "email:send",
				"parameters": [
					{
						"name": "Idempotency-Key",
						"in": "header",
						"required": false,
						"description": "Optional dedupe key (printable ASCII, max 64 chars). Used only when the body has no `idempotency_key`. The official SDKs send one automatically. On batch, element *i* gets `<key>:<i>`.",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/BatchSendInput"
							}
						}
					}
				},
				"responses": {
					"202": {
						"description": "One result per element, in order.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/BatchSendResult"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/emails/{id}": {
			"get": {
				"tags": ["Emails"],
				"operationId": "getEmail",
				"summary": "Get an email",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The email with bodies and its event timeline.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["email"],
									"properties": {
										"email": {
											"allOf": [
												{
													"$ref": "#/components/schemas/Email"
												},
												{
													"type": "object",
													"properties": {
														"htmlBody": {
															"type": ["string", "null"]
														},
														"textBody": {
															"type": ["string", "null"]
														},
														"attachments": {
															"type": ["array", "null"],
															"items": {
																"type": "object",
																"required": [
																	"filename",
																	"content_type",
																	"size"
																],
																"properties": {
																	"filename": {
																		"type": "string"
																	},
																	"content_type": {
																		"type": ["string", "null"]
																	},
																	"size": {
																		"type": "integer",
																		"description": "Decoded size in bytes."
																	}
																}
															},
															"description": "Attachment metadata only — the content is never returned."
														},
														"events": {
															"type": "array",
															"items": {
																"$ref": "#/components/schemas/EmailEvent"
															}
														}
													}
												}
											]
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Emails"],
				"operationId": "rescheduleEmail",
				"summary": "Reschedule a scheduled email",
				"x-required-scope": "email:send",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/RescheduleEmailInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Rescheduled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "Only queued, future-scheduled emails can be rescheduled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/emails/{id}/cancel": {
			"post": {
				"tags": ["Emails"],
				"operationId": "cancelEmail",
				"summary": "Cancel a scheduled email",
				"x-required-scope": "email:send",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Cancelled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "Only queued, future-scheduled emails can be cancelled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/emails/{id}/events": {
			"get": {
				"tags": ["Emails"],
				"operationId": "getEmailEvents",
				"summary": "List an email’s events",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Events, oldest first.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["events"],
									"properties": {
										"events": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/EmailEvent"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/emails/{id}/attachments/{index}": {
			"get": {
				"tags": ["Emails"],
				"operationId": "downloadEmailAttachment",
				"summary": "Download an attachment of a sent email",
				"description": "`index` is the attachment’s zero-based position in the `attachments` array of `GET /emails/{id}` — the order the send request listed them in.",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "index",
						"in": "path",
						"required": true,
						"description": "Zero-based position in `attachments`.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Raw bytes with the attachment’s `Content-Type` and `Content-Disposition`.",
						"content": {
							"application/octet-stream": {
								"schema": {
									"type": "string",
									"contentMediaType": "application/octet-stream"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "No such email, or it has no attachment at that index.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/emails/{id}/conversation": {
			"get": {
				"tags": ["Emails"],
				"operationId": "getEmailConversation",
				"summary": "Get the conversation an email belongs to",
				"description": "The inbound email it replies to, the messages its `In-Reply-To`/`References` name, other replies to those, and inbound mail answering any of them — oldest first. Also returns the Message-ID it was sent with.",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The conversation.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["conversation"],
									"properties": {
										"conversation": {
											"$ref": "#/components/schemas/EmailConversation"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/emails/{id}/insights": {
			"get": {
				"tags": ["Emails"],
				"operationId": "getEmailInsights",
				"summary": "Get deliverability warnings for an email",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Email public id (`em_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Warnings computed from the stored message.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["warnings"],
									"properties": {
										"warnings": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/EmailInsightWarning"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/emails/preview": {
			"post": {
				"tags": ["Emails"],
				"operationId": "previewEmail",
				"summary": "Render and spam-check without sending",
				"description": "Renders the template (or the given html/text), measures it, runs the spam check and deliverability analysis. Stores nothing.",
				"x-required-scope": "email:send",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/EmailPreviewInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Preview.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"rendered_subject": {
											"type": "string"
										},
										"rendered_html": {
											"type": ["string", "null"]
										},
										"rendered_text": {
											"type": ["string", "null"]
										},
										"size": {
											"type": "object",
											"properties": {
												"html_bytes": {
													"type": "integer"
												},
												"text_bytes": {
													"type": "integer"
												}
											}
										},
										"spam": {
											"type": "object",
											"properties": {
												"score": {
													"type": "number"
												},
												"action": {
													"type": "string"
												},
												"symbols": {
													"type": "array",
													"items": {
														"$ref": "#/components/schemas/SpamSymbol"
													}
												},
												"skipped": {
													"type": "boolean"
												}
											}
										},
										"warnings": {
											"type": "array",
											"items": {
												"type": "object"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed, or no subject / no body after rendering.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "template_id does not exist.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/emails/spam-preview": {
			"post": {
				"tags": ["Emails"],
				"operationId": "spamPreview",
				"summary": "Spam-score a draft",
				"description": "Runs only the rspamd check. Stores nothing.",
				"x-required-scope": "email:send",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/SpamPreviewInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Spam verdict.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"score": {
											"type": "number"
										},
										"action": {
											"type": "string"
										},
										"symbols": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/SpamSymbol"
											}
										},
										"skipped": {
											"type": "boolean",
											"description": "True when the spam checker was unreachable (fails open)."
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/email-validations": {
			"post": {
				"tags": ["Email validations"],
				"operationId": "validateEmail",
				"summary": "Validate one address",
				"description": "Syntax, MX, disposable, role and free-provider checks. Results are cached per address.",
				"x-required-scope": "email:send",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ValidateEmailInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Validation result.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/EmailValidation"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/email-validations/batch": {
			"post": {
				"tags": ["Email validations"],
				"operationId": "validateEmailBatch",
				"summary": "Validate up to 100 addresses",
				"x-required-scope": "email:send",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ValidateEmailBatchInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "One result per address.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["results"],
									"properties": {
										"results": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/EmailValidation"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/domains": {
			"post": {
				"tags": ["Domains"],
				"operationId": "createDomain",
				"summary": "Add a domain",
				"description": "Creates the domain with a fresh DKIM key and the DNS records to publish (`dnsRecords`).",
				"x-required-scope": "domains:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateDomainInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["domain"],
									"properties": {
										"domain": {
											"$ref": "#/components/schemas/Domain"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing scope, the account email is not verified yet, or the plan’s domain limit is reached.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "Domain already registered.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Domain name rejected.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Domains"],
				"operationId": "listDomains",
				"summary": "List domains",
				"description": "All domains on the team with their DNS records, newest first. Not paginated.",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "brand_id",
						"in": "query",
						"description": "`brd_…` to list one brand’s rows, `none` for the team’s own (unbranded) rows; omit for all. A brand-restricted key always lists its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Domains.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["domains"],
									"properties": {
										"domains": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Domain"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/domains/check-deliverability": {
			"get": {
				"tags": ["Domains"],
				"operationId": "checkDeliverability",
				"summary": "Check a from-address before sending",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "from",
						"in": "query",
						"required": true,
						"description": "Address or `Name <address>`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Verification state of the sending domain, 30-day bounce/complaint rates and warnings.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"from": {
											"type": "string"
										},
										"domain": {
											"type": "string"
										},
										"domain_id": {
											"type": "integer"
										},
										"domain_verified": {
											"type": "boolean"
										},
										"domain_status": {
											"type": "string"
										},
										"dkim": {
											"type": "object",
											"properties": {
												"configured": {
													"type": "boolean"
												},
												"verified": {
													"type": "boolean"
												}
											}
										},
										"spf": {
											"type": "object",
											"properties": {
												"configured": {
													"type": "boolean"
												},
												"verified": {
													"type": "boolean"
												}
											}
										},
										"dmarc": {
											"type": "object",
											"properties": {
												"configured": {
													"type": "boolean"
												},
												"verified": {
													"type": "boolean"
												}
											}
										},
										"return_path": {
											"type": "object",
											"properties": {
												"configured": {
													"type": "boolean"
												},
												"verified": {
													"type": "boolean"
												}
											}
										},
										"volume_30d": {
											"type": "object"
										},
										"bounce_rate": {
											"type": "number"
										},
										"complaint_rate": {
											"type": "number"
										},
										"warnings": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"severity": {
														"type": "string"
													},
													"code": {
														"type": "string"
													},
													"message": {
														"type": "string"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "`from` missing or has no domain.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/domains/{id}": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDomain",
				"summary": "Get a domain",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The domain with DNS records.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["domain"],
									"properties": {
										"domain": {
											"$ref": "#/components/schemas/Domain"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Domains"],
				"operationId": "updateDomain",
				"summary": "Update domain settings",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateDomainInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["domain"],
									"properties": {
										"domain": {
											"$ref": "#/components/schemas/Domain"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed, or catch-all set without an active destination mailbox on this domain.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "`stream_preference` conflicts with the stream of the dedicated IP bound to this domain.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Domains"],
				"operationId": "deleteDomain",
				"summary": "Delete a domain",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/verify": {
			"post": {
				"tags": ["Domains"],
				"operationId": "verifyDomain",
				"summary": "Queue a DNS verification",
				"description": "Queues a verification job and returns immediately with the current snapshot. Poll `GET /domains/{id}` for the result.",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Queued.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["queued", "domain"],
									"properties": {
										"queued": {
											"type": "boolean",
											"const": true
										},
										"domain": {
											"$ref": "#/components/schemas/Domain"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10 per 15 min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/domains/{id}/dkim/rotate": {
			"post": {
				"tags": ["Domains"],
				"operationId": "startDkimRotation",
				"summary": "Start a DKIM key rotation",
				"description": "Generates a new key under a new selector and returns the TXT record to publish. Signing is unchanged until activation.",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"201": {
						"description": "Rotation staged.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["rotation"],
									"properties": {
										"rotation": {
											"$ref": "#/components/schemas/DkimRotation"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "A rotation is already in progress, or the domain is not in a rotatable state.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (5/hour). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Domains"],
				"operationId": "cancelDkimRotation",
				"summary": "Cancel a staged DKIM rotation",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Cancelled.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["rotation"],
									"properties": {
										"rotation": {
											"$ref": "#/components/schemas/DkimRotation"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "No rotation in progress.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/hour). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/domains/{id}/dkim/rotate/activate": {
			"post": {
				"tags": ["Domains"],
				"operationId": "activateDkimRotation",
				"summary": "Activate the staged DKIM key",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "force",
						"in": "query",
						"description": "`true` skips the propagation wait — never the DNS proof.",
						"schema": {
							"type": "string",
							"enum": ["true", "false"]
						}
					}
				],
				"responses": {
					"200": {
						"description": "Cut over.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["rotation"],
									"properties": {
										"rotation": {
											"$ref": "#/components/schemas/DkimRotation"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "No rotation in progress, the new record is missing/mismatched, or the propagation window has not elapsed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (20 per 15 min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"503": {
						"description": "DNS could not be read; nothing changed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/domains/{id}/ip": {
			"post": {
				"tags": ["Domains"],
				"operationId": "assignDomainIp",
				"summary": "Assign a dedicated IP",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/AssignIpInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Assigned.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing scope, or the IP is not assignable by this team.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Domain or IP not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Domains"],
				"operationId": "unassignDomainIp",
				"summary": "Remove the dedicated IP",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Unassigned.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/domains/{id}/dmarc/reports": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDmarcReports",
				"summary": "List DMARC aggregate reports",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "page",
						"in": "query",
						"description": "Default 1.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "perPage",
						"in": "query",
						"description": "Default 20. Note the camelCase name.",
						"schema": {
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					}
				],
				"responses": {
					"200": {
						"description": "Reports, newest first.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["reports", "pagination"],
									"properties": {
										"reports": {
											"type": "array",
											"items": {
												"type": "object"
											}
										},
										"pagination": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/dmarc/stats": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDmarcStats",
				"summary": "DMARC pass-rate totals and daily series",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "days",
						"in": "query",
						"description": "Look-back window in days (default 30). Anything but a whole number from 1 to 90 is a `400`.",
						"schema": {
							"type": "integer",
							"minimum": 1,
							"maximum": 90
						}
					}
				],
				"responses": {
					"200": {
						"description": "Stats.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"totals": {
											"type": "object",
											"properties": {
												"totalMessages": {
													"type": "integer"
												},
												"passed": {
													"type": "integer"
												},
												"spfPassed": {
													"type": "integer"
												},
												"dkimPassed": {
													"type": "integer"
												}
											}
										},
										"daily": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"date": {
														"type": "string"
													},
													"total": {
														"type": "integer"
													},
													"passed": {
														"type": "integer"
													},
													"failed": {
														"type": "integer"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/dmarc/sources": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDmarcSources",
				"summary": "DMARC results by sending IP",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "days",
						"in": "query",
						"description": "Look-back window in days (default 30). Anything but a whole number from 1 to 90 is a `400`.",
						"schema": {
							"type": "integer",
							"minimum": 1,
							"maximum": 90
						}
					}
				],
				"responses": {
					"200": {
						"description": "Sources.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["sources"],
									"properties": {
										"sources": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"sourceIp": {
														"type": "string"
													},
													"total": {
														"type": "integer"
													},
													"passed": {
														"type": "integer"
													},
													"failed": {
														"type": "integer"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/dmarc/providers": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDmarcProviders",
				"summary": "DMARC results by reporting provider",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "days",
						"in": "query",
						"description": "Look-back window in days (default 30). Anything but a whole number from 1 to 90 is a `400`.",
						"schema": {
							"type": "integer",
							"minimum": 1,
							"maximum": 90
						}
					}
				],
				"responses": {
					"200": {
						"description": "Providers.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["providers"],
									"properties": {
										"providers": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"provider": {
														"type": "string"
													},
													"total": {
														"type": "integer"
													},
													"passed": {
														"type": "integer"
													},
													"spfPassed": {
														"type": "integer"
													},
													"dkimPassed": {
														"type": "integer"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/placement": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getInboxPlacement",
				"summary": "What receiving providers did with this domain’s mail",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "days",
						"in": "query",
						"description": "Look-back window in days (default 30). Anything but a whole number from 1 to 90 is a `400`.",
						"schema": {
							"type": "integer",
							"minimum": 1,
							"maximum": 90
						}
					}
				],
				"responses": {
					"200": {
						"description": "Placement summary.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"windowDays": {
											"type": "integer"
										},
										"totals": {
											"type": "object"
										},
										"senderSignals": {
											"type": "array",
											"items": {
												"type": "object"
											}
										},
										"recipientSignals": {
											"type": "array",
											"items": {
												"type": "object"
											}
										},
										"providers": {
											"type": "array",
											"items": {
												"type": "object"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/deliverability-signals": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDeliverabilitySignals",
				"summary": "Mailbox-provider signals (Gmail Postmaster, SNDS, FBL)",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Signals.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"domainId": {
											"type": "integer"
										},
										"signals": {
											"type": "array",
											"items": {
												"type": "object"
											}
										},
										"gmailSpamRate": {
											"type": ["number", "null"]
										},
										"outlookHealth": {
											"type": ["string", "null"]
										},
										"fblComplaints30d": {
											"type": "integer"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/domains/{id}/reputation": {
			"get": {
				"tags": ["Domains"],
				"operationId": "getDomainReputation",
				"summary": "Current sender-reputation snapshot",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Domain `publicId` (`dom_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Snapshot.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["reputation"],
									"properties": {
										"reputation": {
											"type": ["object", "null"]
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/api-keys": {
			"post": {
				"tags": ["API keys"],
				"operationId": "createApiKey",
				"summary": "Create an API key",
				"description": "The plaintext `key` is in this response only.",
				"x-required-scope": "api-keys:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateApiKeyInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ApiKeySecret"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Calling key is not `full_access`; a `full_access` key was requested without `allow_full_access: true`; an OAuth client asked for `full_access`; or the plan’s key limit is reached.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "`domain_id` not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["API keys"],
				"operationId": "listApiKeys",
				"summary": "List API keys",
				"description": "Not paginated. `domainName` is joined in for restricted keys.",
				"x-required-scope": "api-keys:manage",
				"responses": {
					"200": {
						"description": "Keys (never the secret).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["keys"],
									"properties": {
										"keys": {
											"type": "array",
											"items": {
												"allOf": [
													{
														"$ref": "#/components/schemas/ApiKey"
													},
													{
														"type": "object",
														"properties": {
															"domainName": {
																"type": ["string", "null"]
															}
														}
													}
												]
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "OAuth tokens need `api-keys:manage`; API keys of either permission may read the keyring.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/api-keys/{id}": {
			"get": {
				"tags": ["API keys"],
				"operationId": "getApiKey",
				"summary": "Get an API key",
				"x-required-scope": "api-keys:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "API key numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "The key (bare object, not wrapped).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ApiKey"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "OAuth tokens need `api-keys:manage`.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"delete": {
				"tags": ["API keys"],
				"operationId": "revokeApiKey",
				"summary": "Revoke an API key",
				"x-required-scope": "api-keys:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "API key numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Revoked.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Calling key is not `full_access`, or missing scope.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/api-keys/{id}/rotate": {
			"post": {
				"tags": ["API keys"],
				"operationId": "rotateApiKey",
				"summary": "Rotate an API key",
				"description": "Creates a replacement with the same name, permission, mode and domain, and deletes the old key immediately. The response has a new `id` and the plaintext `key`.",
				"x-required-scope": "api-keys:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "API key numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"201": {
						"description": "Rotated.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ApiKeySecret"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Calling key is not `full_access`, or missing scope.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/contacts": {
			"post": {
				"tags": ["Contacts"],
				"operationId": "createContact",
				"summary": "Create a contact",
				"x-required-scope": "contacts:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateContactInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["contact"],
									"properties": {
										"contact": {
											"$ref": "#/components/schemas/Contact"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A contact with this email already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "A required custom property is missing or a value does not match its type.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Contacts"],
				"operationId": "listContacts",
				"summary": "List contacts",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "brand_id",
						"in": "query",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					},
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "segment_id",
						"in": "query",
						"description": "Only members of this segment (public id). An unknown id is a `404`.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "search",
						"in": "query",
						"description": "Matches email and names.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "engagement_segment",
						"in": "query",
						"schema": {
							"type": "string",
							"enum": ["active", "at_risk", "dormant"]
						}
					},
					{
						"name": "unsubscribed",
						"in": "query",
						"description": "`true` or `false`.",
						"schema": {
							"anyOf": [
								{
									"type": "string",
									"const": "true"
								},
								{
									"type": "string",
									"const": "false"
								}
							]
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of contacts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Contact"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "`segment_id` not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/contacts/import": {
			"post": {
				"tags": ["Contacts"],
				"operationId": "importContacts",
				"summary": "Import up to 10,000 contacts",
				"description": "Existing emails are skipped, not updated.",
				"x-required-scope": "contacts:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ImportContactsInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Import summary.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["imported", "skipped", "errors"],
									"properties": {
										"imported": {
											"type": "integer"
										},
										"skipped": {
											"type": "integer"
										},
										"errors": {
											"type": "array",
											"items": {
												"type": "object"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/contacts/export": {
			"get": {
				"tags": ["Contacts"],
				"operationId": "exportContacts",
				"summary": "Export contacts as CSV",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "segment_id",
						"in": "query",
						"description": "Export only this segment. An unknown id is a 404.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "CSV file (`Content-Disposition: attachment; filename=\"contacts.csv\"`).",
						"content": {
							"text/csv": {
								"schema": {
									"type": "string"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "segment_id not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (5/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/contacts/by-email/{email}": {
			"get": {
				"tags": ["Contacts"],
				"operationId": "getContactByEmail",
				"summary": "Get a contact by email",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "email",
						"in": "path",
						"required": true,
						"description": "URL-encoded email address.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "brand_id",
						"in": "query",
						"description": "The brand whose contact to return (`brd_…`); omit for the team’s own. An address can be a contact of several brands. A brand-restricted key always looks in its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The contact.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["contact"],
									"properties": {
										"contact": {
											"$ref": "#/components/schemas/Contact"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/contacts/{id}": {
			"get": {
				"tags": ["Contacts"],
				"operationId": "getContact",
				"summary": "Get a contact",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The contact.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["contact"],
									"properties": {
										"contact": {
											"$ref": "#/components/schemas/Contact"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Contacts"],
				"operationId": "updateContact",
				"summary": "Update a contact",
				"description": "`properties` is merged into the existing properties.",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateContactInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["contact"],
									"properties": {
										"contact": {
											"$ref": "#/components/schemas/Contact"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "A custom property value does not match its type.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Contacts"],
				"operationId": "deleteContact",
				"summary": "Delete a contact",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/contacts/{id}/unsubscribe": {
			"post": {
				"tags": ["Contacts"],
				"operationId": "unsubscribeContact",
				"summary": "Unsubscribe a contact",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The updated contact.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["contact"],
									"properties": {
										"contact": {
											"$ref": "#/components/schemas/Contact"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/contacts/{id}/activity": {
			"get": {
				"tags": ["Contacts"],
				"operationId": "getContactActivity",
				"summary": "Email events for a contact, grouped",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "limit",
						"in": "query",
						"description": "Max events (1–200).",
						"schema": {
							"type": "integer",
							"minimum": 1,
							"maximum": 200
						}
					},
					{
						"name": "since",
						"in": "query",
						"description": "ISO 8601 lower bound.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Activity.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"contact_id": {
											"type": "string"
										},
										"email": {
											"type": "string"
										},
										"total": {
											"type": "integer"
										},
										"events": {
											"type": "object",
											"description": "Events bucketed by kind.",
											"properties": {
												"sent": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"delivered": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"opened": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"clicked": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"bounced": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"complained": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"failed": {
													"type": "array",
													"items": {
														"type": "object"
													}
												},
												"other": {
													"type": "array",
													"items": {
														"type": "object"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/contacts/{id}/engagement": {
			"get": {
				"tags": ["Contacts"],
				"operationId": "getContactEngagement",
				"summary": "Engagement summary for a contact",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Summary.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"segment": {
											"type": ["string", "null"],
											"enum": ["active", "at_risk", "dormant"]
										},
										"last_engaged_at": {
											"type": ["string", "null"],
											"format": "date-time"
										},
										"engagement_calculated_at": {
											"type": ["string", "null"],
											"format": "date-time"
										},
										"lifetime_sent": {
											"type": "integer"
										},
										"lifetime_delivered": {
											"type": "integer"
										},
										"lifetime_opened": {
											"type": "integer"
										},
										"lifetime_clicked": {
											"type": "integer"
										},
										"open_rate": {
											"type": "number"
										},
										"click_rate": {
											"type": "number"
										},
										"last_open": {
											"type": ["string", "null"],
											"format": "date-time"
										},
										"last_click": {
											"type": ["string", "null"],
											"format": "date-time"
										},
										"top_tags": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"tag": {
														"type": "string"
													},
													"count": {
														"type": "integer"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/contact-properties": {
			"get": {
				"tags": ["Contact properties"],
				"operationId": "listContactProperties",
				"summary": "List custom properties",
				"x-required-scope": "contacts:read",
				"responses": {
					"200": {
						"description": "Properties.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["properties"],
									"properties": {
										"properties": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/ContactProperty"
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			},
			"post": {
				"tags": ["Contact properties"],
				"operationId": "createContactProperty",
				"summary": "Create a custom property",
				"x-required-scope": "contacts:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateContactPropertyInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["property"],
									"properties": {
										"property": {
											"$ref": "#/components/schemas/ContactProperty"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A property with this name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/contact-properties/{id}": {
			"patch": {
				"tags": ["Contact properties"],
				"operationId": "updateContactProperty",
				"summary": "Update a custom property",
				"description": "`name` and `type` cannot be changed.",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact property numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateContactPropertyInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["property"],
									"properties": {
										"property": {
											"$ref": "#/components/schemas/ContactProperty"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Contact properties"],
				"operationId": "deleteContactProperty",
				"summary": "Delete a custom property",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact property numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/contact-properties/{id}/option-usage": {
			"get": {
				"tags": ["Contact properties"],
				"operationId": "getContactPropertyOptionUsage",
				"summary": "How many contacts use each option of a select property",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Contact property numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Counts keyed by option.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["usage"],
									"properties": {
										"usage": {
											"type": "object",
											"additionalProperties": {
												"type": "integer"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/segments": {
			"post": {
				"tags": ["Segments"],
				"operationId": "createSegment",
				"summary": "Create a segment",
				"description": "With `rules` the segment is dynamic; without, it is manual (add contacts explicitly).",
				"x-required-scope": "contacts:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateSegmentInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["segment"],
									"properties": {
										"segment": {
											"$ref": "#/components/schemas/Segment"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A segment with that name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Segments"],
				"operationId": "listSegments",
				"summary": "List segments",
				"description": "Not paginated. Each segment carries `contactCount`.",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "brand_id",
						"in": "query",
						"description": "`brd_…` to list one brand’s rows, `none` for the team’s own (unbranded) rows; omit for all. A brand-restricted key always lists its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Segments.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["segments"],
									"properties": {
										"segments": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Segment"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/segments/preview": {
			"post": {
				"tags": ["Segments"],
				"operationId": "previewSegmentRules",
				"summary": "Count contacts matching a rules tree",
				"description": "Nothing is saved.",
				"x-required-scope": "contacts:read",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/PreviewSegmentRulesInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Match count.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["count"],
									"properties": {
										"count": {
											"type": "integer"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/segments/{id}": {
			"get": {
				"tags": ["Segments"],
				"operationId": "getSegment",
				"summary": "Get a segment",
				"description": "Includes the first 100 members as `contacts`.",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The segment.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["segment"],
									"properties": {
										"segment": {
											"allOf": [
												{
													"$ref": "#/components/schemas/Segment"
												},
												{
													"type": "object",
													"properties": {
														"contacts": {
															"type": "array",
															"items": {
																"$ref": "#/components/schemas/Contact"
															}
														}
													}
												}
											]
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Segments"],
				"operationId": "updateSegment",
				"summary": "Update a segment",
				"description": "Partial update: send only what changes. `rules: null` turns a dynamic segment into a manual one; omitting `rules` keeps them.",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateSegmentInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["segment"],
									"properties": {
										"segment": {
											"$ref": "#/components/schemas/Segment"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "Another segment already has that name.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Segments"],
				"operationId": "deleteSegment",
				"summary": "Delete a segment",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/segments/{id}/members": {
			"get": {
				"tags": ["Segments"],
				"operationId": "listSegmentMembers",
				"summary": "List segment members",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 50,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of contacts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Contact"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/segments/{id}/broadcasts": {
			"get": {
				"tags": ["Segments"],
				"operationId": "listSegmentBroadcasts",
				"summary": "Broadcasts that target this segment",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Broadcasts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["broadcasts"],
									"properties": {
										"broadcasts": {
											"type": "array",
											"items": {
												"type": "object"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/segments/{id}/contacts": {
			"post": {
				"tags": ["Segments"],
				"operationId": "addContactsToSegment",
				"summary": "Add contacts to a manual segment",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/AddContactsToSegmentInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Number of contacts added.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["added"],
									"properties": {
										"added": {
											"type": "integer"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed, or none of the contact ids exist.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/segments/{id}/contacts/{contactId}": {
			"delete": {
				"tags": ["Segments"],
				"operationId": "removeContactFromSegment",
				"summary": "Remove a contact from a manual segment",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Segment public id (`seg_…`).",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "contactId",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Removed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/broadcasts": {
			"post": {
				"tags": ["Broadcasts"],
				"operationId": "createBroadcast",
				"summary": "Create a draft broadcast",
				"x-required-scope": "broadcasts:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateBroadcastInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created (status `draft`).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["broadcast"],
									"properties": {
										"broadcast": {
											"$ref": "#/components/schemas/Broadcast"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Segment or topic not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "A/B variant weights do not sum to 100.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "listBroadcasts",
				"summary": "List broadcasts",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "cursor",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "brand_id",
						"in": "query",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					},
					{
						"name": "search",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "status",
						"in": "query",
						"schema": {
							"type": "string",
							"enum": ["draft", "queued", "sending", "sent", "cancelled"]
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of broadcasts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Broadcast"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/performance": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "listBroadcastPerformance",
				"summary": "Rank sent broadcasts by a metric",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "metric",
						"in": "query",
						"schema": {
							"type": "string",
							"enum": ["open_rate", "click_rate", "delivered"],
							"default": "click_rate"
						}
					},
					{
						"name": "since",
						"in": "query",
						"description": "ISO 8601; unparseable values are ignored.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "limit",
						"in": "query",
						"description": "Default 20, max 100.",
						"schema": {
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Ranked broadcasts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"metric": {
											"type": "string"
										},
										"since": {
											"type": ["string", "null"],
											"format": "date-time"
										},
										"broadcasts": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/BroadcastPerformance"
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "getBroadcast",
				"summary": "Get a broadcast",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The broadcast.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["broadcast"],
									"properties": {
										"broadcast": {
											"$ref": "#/components/schemas/Broadcast"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Broadcasts"],
				"operationId": "updateBroadcast",
				"summary": "Update a draft broadcast",
				"x-required-scope": "broadcasts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateBroadcastInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["broadcast"],
									"properties": {
										"broadcast": {
											"$ref": "#/components/schemas/Broadcast"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "Only draft broadcasts can be updated, or variant weights do not sum to 100.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}/send": {
			"post": {
				"tags": ["Broadcasts"],
				"operationId": "sendBroadcast",
				"summary": "Send (or schedule) a draft broadcast",
				"x-required-scope": "broadcasts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Broadcast or its segment not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Not a draft; no segment; segment empty; from-domain unknown or unverified; or no content.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}/test": {
			"post": {
				"tags": ["Broadcasts"],
				"operationId": "sendBroadcastTest",
				"summary": "Send a test copy to one address",
				"x-required-scope": "broadcasts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/TestBroadcastInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Sent.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "From-domain unknown or unverified, or no content.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}/cancel": {
			"post": {
				"tags": ["Broadcasts"],
				"operationId": "cancelBroadcast",
				"summary": "Cancel a queued or sending broadcast",
				"x-required-scope": "broadcasts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Cancelled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "Only queued or sending broadcasts can be cancelled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}/resend": {
			"post": {
				"tags": ["Broadcasts"],
				"operationId": "resendBroadcast",
				"summary": "Clone to non-openers or non-clickers",
				"description": "Snapshots the audience into a new manual segment and creates a new draft. Review and send it with `POST /broadcasts/{id}/send`.",
				"x-required-scope": "broadcasts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ResendBroadcastInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Draft created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"broadcast": {
											"type": "object",
											"properties": {
												"id": {
													"type": "string"
												},
												"subject": {
													"type": "string"
												},
												"status": {
													"type": "string"
												}
											}
										},
										"segment": {
											"type": "object",
											"properties": {
												"id": {
													"type": "string"
												},
												"name": {
													"type": "string"
												}
											}
										},
										"recipientCount": {
											"type": "integer"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "Source not sent, has no content, or nobody matches.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}/performance": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "getBroadcastPerformance",
				"summary": "Headline metrics for one broadcast",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Metrics (+ A/B variant stats when enabled).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"broadcast": {
											"allOf": [
												{
													"$ref": "#/components/schemas/BroadcastPerformance"
												},
												{
													"type": "object",
													"properties": {
														"in_progress": {
															"type": "integer"
														},
														"held_for_review": {
															"type": "integer"
														}
													}
												}
											]
										},
										"variants": {
											"oneOf": [
												{
													"$ref": "#/components/schemas/BroadcastVariantStats"
												},
												{
													"type": "null"
												}
											]
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/broadcasts/{id}/non-clickers": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "findBroadcastNonClickers",
				"summary": "Recipients who did not click",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "limit",
						"in": "query",
						"description": "Default 500, max 5000.",
						"schema": {
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Contacts.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/NonResponders"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/broadcasts/{id}/non-openers": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "findBroadcastNonOpeners",
				"summary": "Recipients who did not open",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "limit",
						"in": "query",
						"description": "Default 500, max 5000.",
						"schema": {
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Contacts.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/NonResponders"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/broadcasts/{id}/variants": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "getBroadcastVariants",
				"summary": "A/B variants",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Variants.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["variants"],
									"properties": {
										"variants": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/BroadcastVariant"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/broadcasts/{id}/variant-stats": {
			"get": {
				"tags": ["Broadcasts"],
				"operationId": "getBroadcastVariantStats",
				"summary": "A/B variant performance",
				"x-required-scope": "broadcasts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Stats.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/BroadcastVariantStats"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "The broadcast has no A/B test.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/broadcasts/{id}/end-ab-test": {
			"post": {
				"tags": ["Broadcasts"],
				"operationId": "endBroadcastAbTest",
				"summary": "Pick the A/B winner now",
				"x-required-scope": "broadcasts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Broadcast public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Winner picked; remainder sends with it.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `broadcasts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "No A/B test, or the winner was already picked.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/templates": {
			"post": {
				"tags": ["Templates"],
				"operationId": "createTemplate",
				"summary": "Create a template",
				"x-required-scope": "templates:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateTemplateInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created (unpublished).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A template with that name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Templates"],
				"operationId": "listTemplates",
				"summary": "List templates",
				"x-required-scope": "templates:read",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "cursor",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "brand_id",
						"in": "query",
						"schema": {
							"type": "string",
							"maxLength": 64
						}
					},
					{
						"name": "search",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "published",
						"in": "query",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of templates (bodies omitted) plus published/draft counts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Template"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										},
										"counts": {
											"type": "object",
											"properties": {
												"published": {
													"type": "integer"
												},
												"draft": {
													"type": "integer"
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/templates/presets": {
			"get": {
				"tags": ["Templates"],
				"operationId": "listTemplatePresets",
				"summary": "List starter presets",
				"x-required-scope": "templates:read",
				"responses": {
					"200": {
						"description": "Presets.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/TemplatePreset"
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/templates/presets/{presetId}/use": {
			"post": {
				"tags": ["Templates"],
				"operationId": "useTemplatePreset",
				"summary": "Create a template from a preset",
				"x-required-scope": "templates:manage",
				"parameters": [
					{
						"name": "presetId",
						"in": "path",
						"required": true,
						"description": "Preset id — a lowercase slug from `GET /templates/presets`, e.g. `welcome`.",
						"schema": {
							"type": "string",
							"minLength": 1,
							"maxLength": 64,
							"pattern": "^[a-z0-9-]+$"
						}
					}
				],
				"responses": {
					"201": {
						"description": "Created (unpublished).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "No preset with that id.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"409": {
						"description": "A template with the preset’s name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/templates/{id}": {
			"get": {
				"tags": ["Templates"],
				"operationId": "getTemplate",
				"summary": "Get a template",
				"x-required-scope": "templates:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The template.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Templates"],
				"operationId": "updateTemplate",
				"summary": "Update a template",
				"x-required-scope": "templates:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateTemplateInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "Another template already has that name.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Templates"],
				"operationId": "deleteTemplate",
				"summary": "Delete a template",
				"x-required-scope": "templates:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/templates/{id}/publish": {
			"post": {
				"tags": ["Templates"],
				"operationId": "publishTemplate",
				"summary": "Publish a template",
				"description": "Only published templates can be sent with `template_id`.",
				"x-required-scope": "templates:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Published.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/templates/{id}/unpublish": {
			"post": {
				"tags": ["Templates"],
				"operationId": "unpublishTemplate",
				"summary": "Unpublish a template",
				"x-required-scope": "templates:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Unpublished.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/templates/{id}/duplicate": {
			"post": {
				"tags": ["Templates"],
				"operationId": "duplicateTemplate",
				"summary": "Duplicate a template",
				"x-required-scope": "templates:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"201": {
						"description": "The copy.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["template"],
									"properties": {
										"template": {
											"$ref": "#/components/schemas/Template"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "A template with the copy’s name already exists — rename it, then duplicate again.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/templates/{id}/render": {
			"post": {
				"tags": ["Templates"],
				"operationId": "renderTemplate",
				"summary": "Render a template with variables",
				"x-required-scope": "templates:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Template public id (`tpl_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/RenderTemplateInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Rendered output.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"subject": {
											"type": "string"
										},
										"html": {
											"type": ["string", "null"]
										},
										"text": {
											"type": ["string", "null"]
										},
										"missing_variables": {
											"type": "array",
											"items": {
												"type": "string"
											}
										},
										"template_variables": {
											"type": "array",
											"items": {
												"type": "string"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `templates:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/webhooks": {
			"post": {
				"tags": ["Webhooks"],
				"operationId": "createWebhook",
				"summary": "Create a webhook",
				"x-required-scope": "webhooks:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateWebhookInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created. `signingSecret` is shown only here.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/WebhookWithSecret"
								}
							}
						}
					},
					"400": {
						"description": "Validation failed or the URL is not allowed (private/internal hosts are rejected).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing scope, plan below Pro, or the per-team webhook limit is reached.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Webhooks"],
				"operationId": "listWebhooks",
				"summary": "List webhooks",
				"description": "Not paginated.",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "brand_id",
						"in": "query",
						"description": "`brd_…` to list one brand’s rows, `none` for the team’s own (unbranded) rows; omit for all. A brand-restricted key always lists its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Webhooks.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["webhooks"],
									"properties": {
										"webhooks": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Webhook"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/webhooks/{id}": {
			"get": {
				"tags": ["Webhooks"],
				"operationId": "getWebhook",
				"summary": "Get a webhook",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "The webhook.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["webhook"],
									"properties": {
										"webhook": {
											"$ref": "#/components/schemas/Webhook"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Webhooks"],
				"operationId": "updateWebhook",
				"summary": "Update a webhook",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateWebhookInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["webhook"],
									"properties": {
										"webhook": {
											"$ref": "#/components/schemas/Webhook"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed or the URL is not allowed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Webhooks"],
				"operationId": "deleteWebhook",
				"summary": "Delete a webhook",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/webhooks/{id}/test": {
			"post": {
				"tags": ["Webhooks"],
				"operationId": "testWebhook",
				"summary": "Send a test event",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Test delivery queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "The webhook is disabled — enable it first.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/webhooks/{id}/deliveries": {
			"get": {
				"tags": ["Webhooks"],
				"operationId": "listWebhookDeliveries",
				"summary": "Delivery history",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of deliveries. Note the keys: `deliveries` and `pagination`.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["deliveries", "pagination"],
									"properties": {
										"deliveries": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/WebhookDelivery"
											}
										},
										"pagination": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/webhooks/{id}/deliveries/{did}/replay": {
			"post": {
				"tags": ["Webhooks"],
				"operationId": "replayWebhookDelivery",
				"summary": "Replay one delivery",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "did",
						"in": "path",
						"required": true,
						"description": "Delivery id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Re-queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Delivery not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"409": {
						"description": "The webhook is disabled — enable it first.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/webhooks/{id}/deliveries/batch-replay": {
			"post": {
				"tags": ["Webhooks"],
				"operationId": "batchReplayWebhookDeliveries",
				"summary": "Replay every failed delivery",
				"description": "Oldest first, max 1,000 per call. Successful deliveries are never re-sent. Call again while `remaining` > 0.",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/BatchReplayWebhookDeliveriesInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Counts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["replayed", "remaining"],
									"properties": {
										"replayed": {
											"type": "integer"
										},
										"remaining": {
											"type": "integer"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "The webhook is disabled — enable it first.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (3/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/webhooks/{id}/rotate-secret": {
			"post": {
				"tags": ["Webhooks"],
				"operationId": "rotateWebhookSecret",
				"summary": "Rotate the signing secret",
				"description": "During the grace window (default 24 h, max 168, `0` = immediate) deliveries are signed with both secrets.",
				"x-required-scope": "webhooks:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Webhook numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": false,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/RotateWebhookSecretInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Rotated. The new `signingSecret` is shown only here.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/WebhookWithSecret"
								}
							}
						}
					},
					"400": {
						"description": "Validation failed or `graceHours` out of range.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `webhooks:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/suppressions": {
			"get": {
				"tags": ["Suppressions"],
				"operationId": "listSuppressions",
				"summary": "List suppressions",
				"x-required-scope": "email:read",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of suppressions.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Suppression"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			},
			"post": {
				"tags": ["Suppressions"],
				"operationId": "addSuppression",
				"summary": "Suppress an address",
				"x-required-scope": "email:send",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/AddSuppressionInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Added.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/suppressions/{email}": {
			"delete": {
				"tags": ["Suppressions"],
				"operationId": "removeSuppression",
				"summary": "Remove a suppression",
				"description": "Succeeds whether or not the address was suppressed. Needs `contacts:manage`: re-opening an address that bounced, complained or unsubscribed is audience management, so a `sending_access` key cannot do it.",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "email",
						"in": "path",
						"required": true,
						"description": "URL-encoded address.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Removed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/suppressions/stats": {
			"get": {
				"tags": ["Suppressions"],
				"operationId": "getSuppressionStats",
				"summary": "Counts by reason",
				"x-required-scope": "email:read",
				"responses": {
					"200": {
						"description": "Counts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["stats"],
									"properties": {
										"stats": {
											"type": "object",
											"properties": {
												"hard_bounce": {
													"type": "integer"
												},
												"complaint": {
													"type": "integer"
												},
												"manual": {
													"type": "integer"
												},
												"unsubscribe": {
													"type": "integer"
												},
												"repeated_soft_bounce": {
													"type": "integer"
												},
												"total": {
													"type": "integer"
												}
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/suppressions/export": {
			"get": {
				"tags": ["Suppressions"],
				"operationId": "exportSuppressions",
				"summary": "Export as CSV",
				"x-required-scope": "email:read",
				"responses": {
					"200": {
						"description": "CSV (`email,reason,created_at`).",
						"content": {
							"text/csv": {
								"schema": {
									"type": "string"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/suppressions/import": {
			"post": {
				"tags": ["Suppressions"],
				"operationId": "importSuppressions",
				"summary": "Suppress up to 10,000 addresses",
				"x-required-scope": "email:send",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ImportSuppressionsInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Import summary.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"added": {
											"type": "integer"
										},
										"skipped": {
											"type": "integer"
										},
										"invalid": {
											"type": "array",
											"items": {
												"type": "string"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `email:send` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/brands": {
			"get": {
				"tags": ["Brands"],
				"operationId": "listBrands",
				"summary": "List brands",
				"x-required-scope": "domains:read",
				"responses": {
					"200": {
						"description": "The team’s brands, by name.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["brands"],
									"properties": {
										"brands": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Brand"
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			},
			"post": {
				"tags": ["Brands"],
				"operationId": "createBrand",
				"summary": "Create a brand",
				"x-required-scope": "domains:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateBrandInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["brand"],
									"properties": {
										"brand": {
											"$ref": "#/components/schemas/Brand"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A brand with that name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/brands/current": {
			"get": {
				"tags": ["Brands"],
				"operationId": "getCurrentBrand",
				"summary": "The calling key’s brand",
				"responses": {
					"200": {
						"description": "The brand a brand-restricted API key belongs to; `null` for any other caller.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"brand": {
											"oneOf": [
												{
													"$ref": "#/components/schemas/Brand"
												},
												{
													"type": "null"
												}
											]
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/brands/{id}": {
			"get": {
				"tags": ["Brands"],
				"operationId": "getBrand",
				"summary": "Get a brand",
				"x-required-scope": "domains:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Brand public id (`brd_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The brand.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["brand"],
									"properties": {
										"brand": {
											"$ref": "#/components/schemas/Brand"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Brands"],
				"operationId": "updateBrand",
				"summary": "Rename a brand",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Brand public id (`brd_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateBrandInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["brand"],
									"properties": {
										"brand": {
											"$ref": "#/components/schemas/Brand"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "Another brand already has that name.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Brands"],
				"operationId": "deleteBrand",
				"summary": "Delete an empty brand",
				"x-required-scope": "domains:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Brand public id (`brd_…`) or numeric `id`.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"deleted": {
											"type": "boolean"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `domains:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "The brand still has domains, keys, contacts or other data; the message lists them.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/subscription-topics": {
			"get": {
				"tags": ["Subscription topics"],
				"operationId": "listSubscriptionTopics",
				"summary": "List topics",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "brand_id",
						"in": "query",
						"description": "`brd_…` to list one brand’s rows, `none` for the team’s own (unbranded) rows; omit for all. A brand-restricted key always lists its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Topics with `subscriberCount`.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["topics"],
									"properties": {
										"topics": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/SubscriptionTopic"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			},
			"post": {
				"tags": ["Subscription topics"],
				"operationId": "createSubscriptionTopic",
				"summary": "Create a topic",
				"x-required-scope": "contacts:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateSubscriptionTopicInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["topic"],
									"properties": {
										"topic": {
											"$ref": "#/components/schemas/SubscriptionTopic"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A topic with that name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/subscription-topics/{id}": {
			"get": {
				"tags": ["Subscription topics"],
				"operationId": "getSubscriptionTopic",
				"summary": "Get a topic",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Subscription topic public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The topic and its counts.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"topic": {
											"$ref": "#/components/schemas/SubscriptionTopic"
										},
										"subscriberCount": {
											"type": "integer"
										},
										"unsubscribedCount": {
											"type": "integer"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Subscription topics"],
				"operationId": "updateSubscriptionTopic",
				"summary": "Update a topic",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Subscription topic public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateSubscriptionTopicInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["topic"],
									"properties": {
										"topic": {
											"$ref": "#/components/schemas/SubscriptionTopic"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "Another topic already has that name.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Subscription topics"],
				"operationId": "deleteSubscriptionTopic",
				"summary": "Delete a topic",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Subscription topic public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/subscription-topics/{id}/subscribers": {
			"get": {
				"tags": ["Subscription topics"],
				"operationId": "listTopicSubscribers",
				"summary": "List a topic’s subscribers",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Subscription topic public id.",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 50,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "subscribed",
						"in": "query",
						"description": "`false` lists explicit opt-outs. Default `true`.",
						"schema": {
							"type": "string",
							"enum": ["true", "false"]
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of subscribers.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"type": "object",
												"properties": {
													"contactId": {
														"type": "integer"
													},
													"contactPublicId": {
														"type": "string"
													},
													"email": {
														"type": "string"
													},
													"firstName": {
														"type": ["string", "null"]
													},
													"lastName": {
														"type": ["string", "null"]
													},
													"subscribedAt": {
														"type": "string",
														"format": "date-time"
													}
												}
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/subscription-topics/contacts/{contactId}/subscriptions": {
			"get": {
				"tags": ["Subscription topics"],
				"operationId": "getContactSubscriptions",
				"summary": "A contact’s topic preferences",
				"description": "An unknown contact returns an empty list, not 404.",
				"x-required-scope": "contacts:read",
				"parameters": [
					{
						"name": "contactId",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Subscriptions with their topic.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["subscriptions"],
									"properties": {
										"subscriptions": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/ContactSubscription"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			},
			"post": {
				"tags": ["Subscription topics"],
				"operationId": "subscribeContactToTopic",
				"summary": "Subscribe a contact to a topic",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "contactId",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/SubscribeToTopicInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Subscribed — this call created the subscription record. An existing record (subscribed or not) is updated in place and answers `200` with the same body.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["subscription"],
									"properties": {
										"subscription": {
											"$ref": "#/components/schemas/ContactSubscription"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Contact or topic not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/subscription-topics/contacts/{contactId}/subscriptions/{topicId}": {
			"delete": {
				"tags": ["Subscription topics"],
				"operationId": "unsubscribeContactFromTopic",
				"summary": "Record an opt-out from a topic",
				"description": "Stores `subscribed: false` rather than deleting the row.",
				"x-required-scope": "contacts:manage",
				"parameters": [
					{
						"name": "contactId",
						"in": "path",
						"required": true,
						"description": "Contact public id (`con_…`).",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "topicId",
						"in": "path",
						"required": true,
						"description": "Topic public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Opted out.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["subscription"],
									"properties": {
										"subscription": {
											"$ref": "#/components/schemas/ContactSubscription"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `contacts:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Contact or topic not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/mailboxes": {
			"post": {
				"tags": ["Mailboxes"],
				"operationId": "createMailbox",
				"summary": "Create a mailbox",
				"x-required-scope": "mailboxes:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateMailboxInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["mailbox"],
									"properties": {
										"mailbox": {
											"$ref": "#/components/schemas/Mailbox"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed, domain not verified, or inbound not enabled on the domain.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"402": {
						"description": "The mailbox needs a paid seat that could not be charged.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"403": {
						"description": "Missing scope or the plan’s mailbox limit is reached.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Domain not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"409": {
						"description": "A mailbox or alias with this address already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Mailboxes"],
				"operationId": "listMailboxes",
				"summary": "List mailboxes",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "cursor",
						"in": "query",
						"schema": {
							"type": "string"
						}
					},
					{
						"name": "domain_id",
						"in": "query",
						"schema": {
							"type": "string",
							"minLength": 1
						}
					},
					{
						"name": "sort",
						"in": "query",
						"schema": {
							"type": "string",
							"enum": ["created", "domain"]
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of mailboxes. With `sort=domain`, `domainCounts` gives every domain its full total, since a page can split one.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Mailbox"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										},
										"domainCounts": {
											"type": "array",
											"items": {
												"type": "object",
												"required": ["domainId", "total"],
												"properties": {
													"domainId": {
														"type": "integer"
													},
													"total": {
														"type": "integer"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/mailboxes/{id}": {
			"get": {
				"tags": ["Mailboxes"],
				"operationId": "getMailbox",
				"summary": "Get a mailbox",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Mailbox public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["mailbox"],
									"properties": {
										"mailbox": {
											"$ref": "#/components/schemas/Mailbox"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` scope, team suspended, or no access to this mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Mailboxes"],
				"operationId": "updateMailbox",
				"summary": "Update a mailbox",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Mailbox public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateMailboxInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["mailbox"],
									"properties": {
										"mailbox": {
											"$ref": "#/components/schemas/Mailbox"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed, or the assigned user is not a team member.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` scope, team suspended, or no access to this mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Mailboxes"],
				"operationId": "deleteMailbox",
				"summary": "Delete a mailbox",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Mailbox public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` scope, team suspended, or no access to this mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/mailboxes/{id}/password": {
			"post": {
				"tags": ["Mailboxes"],
				"operationId": "changeMailboxPassword",
				"summary": "Set a mailbox password",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Mailbox public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ChangeMailboxPasswordInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Changed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` scope, team suspended, or no access to this mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/mailboxes/{id}/filters": {
			"get": {
				"tags": ["Mailboxes"],
				"operationId": "listMailboxFilters",
				"summary": "List server-side filter rules",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Mailbox public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Rules in evaluation order.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["rules"],
									"properties": {
										"rules": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/MailboxFilterRule"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` scope, team suspended, or no access to this mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"put": {
				"tags": ["Mailboxes"],
				"operationId": "replaceMailboxFilters",
				"summary": "Replace all filter rules",
				"description": "Full replace; array order is evaluation order. An empty array removes every rule.",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Mailbox public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ReplaceMailboxFiltersInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "The saved rules.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["rules"],
									"properties": {
										"rules": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/MailboxFilterRule"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` scope, team suspended, or no access to this mailbox.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/mailboxes/aliases": {
			"post": {
				"tags": ["Mailboxes"],
				"operationId": "createMailboxAlias",
				"summary": "Create an alias",
				"x-required-scope": "mailboxes:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateMailboxAliasInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["alias"],
									"properties": {
										"alias": {
											"$ref": "#/components/schemas/MailboxAlias"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Domain or destination mailbox not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"409": {
						"description": "A mailbox or alias with this address already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Mailboxes"],
				"operationId": "listMailboxAliases",
				"summary": "List aliases",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of aliases.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/MailboxAlias"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/mailboxes/aliases/{id}": {
			"delete": {
				"tags": ["Mailboxes"],
				"operationId": "deleteMailboxAlias",
				"summary": "Delete an alias",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Alias numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/inbound": {
			"get": {
				"tags": ["Inbound emails"],
				"operationId": "listInboundEmails",
				"summary": "List received emails",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "domain",
						"in": "query",
						"description": "Restrict to one of your domains (by name). An unknown domain returns an empty page.",
						"schema": {
							"type": "string",
							"minLength": 1
						}
					},
					{
						"name": "to",
						"in": "query",
						"description": "Restrict to mail delivered to this address (exact, case-insensitive).",
						"schema": {
							"type": "string",
							"minLength": 1,
							"maxLength": 320
						}
					},
					{
						"name": "q",
						"in": "query",
						"description": "Search the subject, sender address and sender name.",
						"schema": {
							"type": "string",
							"minLength": 1,
							"maxLength": 200
						}
					},
					{
						"name": "reports",
						"in": "query",
						"description": "DMARC and TLS-RPT aggregate reports: `include` (default), `exclude`, or `only`.",
						"schema": {
							"type": "string",
							"enum": ["include", "exclude", "only"]
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of inbound emails, newest first.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/InboundEmail"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/inbound/recipients": {
			"get": {
				"tags": ["Inbound emails"],
				"operationId": "listInboundRecipients",
				"summary": "List the addresses mail was received on",
				"x-required-scope": "mailboxes:manage",
				"responses": {
					"200": {
						"description": "Delivered-to addresses with message counts, busiest first (at most 200).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["recipients"],
									"properties": {
										"recipients": {
											"type": "array",
											"items": {
												"type": "object",
												"required": ["address", "count"],
												"properties": {
													"address": {
														"type": "string"
													},
													"count": {
														"type": "integer"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/inbound/{id}": {
			"get": {
				"tags": ["Inbound emails"],
				"operationId": "getInboundEmail",
				"summary": "Get a received email",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Inbound email numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "The email, and the emails sent in reply to it (oldest first).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["inboundEmail", "replies"],
									"properties": {
										"inboundEmail": {
											"$ref": "#/components/schemas/InboundEmail"
										},
										"replies": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/InboundReplySummary"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/inbound/{id}/attachments": {
			"get": {
				"tags": ["Inbound emails"],
				"operationId": "listInboundAttachments",
				"summary": "List attachments",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Inbound email numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Attachment metadata.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["attachments"],
									"properties": {
										"attachments": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/InboundAttachment"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/inbound/{id}/attachments/{aid}": {
			"get": {
				"tags": ["Inbound emails"],
				"operationId": "downloadInboundAttachment",
				"summary": "Download an attachment",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Inbound email numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "aid",
						"in": "path",
						"required": true,
						"description": "Attachment id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Raw bytes with the attachment’s `Content-Type` and `Content-Disposition`.",
						"content": {
							"application/octet-stream": {
								"schema": {
									"type": "string",
									"contentMediaType": "application/octet-stream"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"410": {
						"description": "The stored file is gone (`code: attachment_file_missing`). Retrying will not help.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/inbound/{id}/draft-reply": {
			"post": {
				"tags": ["Inbound emails"],
				"operationId": "draftInboundReply",
				"summary": "Build a reply skeleton",
				"description": "Suggested from/subject, threading headers and quoted original. Sends nothing.",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Inbound email numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": false,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/DraftReplyInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Draft.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/InboundReplyDraft"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `mailboxes:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/inbound/{id}/reply": {
			"post": {
				"tags": ["Inbound emails"],
				"operationId": "replyToInboundEmail",
				"summary": "Reply (threaded)",
				"description": "Sends through the normal send pipeline with `In-Reply-To`/`References` set, under the calling API key exactly as `POST /emails` does (an `sk_test_` key stays in test mode; a domain-restricted key can only send from its domain, and only reply to mail its domain received), so the same 403/422/429 conditions apply. Needs `mailboxes:manage` as well as `email:send`, since it reads the inbound message. The original is quoted under the reply unless `quote_original` is false, and a `from` that is one of your mailboxes adds its signature between the reply and the quote and saves a copy to its Sent folder.",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Inbound email numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ReplyInboundInput"
							}
						}
					}
				},
				"responses": {
					"202": {
						"description": "Queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/SendEmailResponse"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` or `email:send` scope, team suspended or sending paused, or the API key is restricted to a different domain.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "From-domain not verified or recipients suppressed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Branch on `code`. `rate_limit_exceeded`: request rate limited (60 req/min per key; halved on the free plan) — retry after `Retry-After`. Not retryable: `monthly_limit_exceeded` (monthly plan limit reached), `daily_limit_exceeded` (rolling 24h cap on external recipients for new/free accounts), `send_limit_exceeded` (sending from new accounts paused platform-wide).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/inbound/{id}/forward": {
			"post": {
				"tags": ["Inbound emails"],
				"operationId": "forwardInboundEmail",
				"summary": "Forward with attachments",
				"description": "Forwards the message (with its attachments) to `to`, plus optional `cc` / `bcc` (max 50 each, like `POST /emails`). Sent through the normal send pipeline under the calling API key, so suppressed recipients are dropped and the same 403/422/429 conditions apply. Needs `mailboxes:manage` as well as `email:send`, since it reads the inbound message and its attachments.",
				"x-required-scope": "mailboxes:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Inbound email numeric id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/ForwardInboundInput"
							}
						}
					}
				},
				"responses": {
					"202": {
						"description": "Queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/SendEmailResponse"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing `mailboxes:manage` or `email:send` scope, team suspended or sending paused, or the API key is restricted to a different domain.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "From-domain not verified or recipients suppressed.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Branch on `code`. `rate_limit_exceeded`: request rate limited (60 req/min per key; halved on the free plan) — retry after `Retry-After`. Not retryable: `monthly_limit_exceeded` (monthly plan limit reached), `daily_limit_exceeded` (rolling 24h cap on external recipients for new/free accounts), `send_limit_exceeded` (sending from new accounts paused platform-wide).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows": {
			"get": {
				"tags": ["Workflows"],
				"operationId": "listWorkflows",
				"summary": "List workflows",
				"description": "Not paginated.",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "brand_id",
						"in": "query",
						"description": "`brd_…` to list one brand’s rows, `none` for the team’s own (unbranded) rows; omit for all. A brand-restricted key always lists its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Workflows.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Workflow"
											}
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			},
			"post": {
				"tags": ["Workflows"],
				"operationId": "createWorkflow",
				"summary": "Create a workflow",
				"x-required-scope": "workflows:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateWorkflowInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created (status `draft`).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["workflow"],
									"properties": {
										"workflow": {
											"$ref": "#/components/schemas/Workflow"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"409": {
						"description": "A workflow with that name already exists.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows/{id}": {
			"get": {
				"tags": ["Workflows"],
				"operationId": "getWorkflow",
				"summary": "Get a workflow",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The workflow with `runsCount`.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["workflow"],
									"properties": {
										"workflow": {
											"$ref": "#/components/schemas/Workflow"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Workflows"],
				"operationId": "updateWorkflow",
				"summary": "Update name or trigger",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateWorkflowInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["workflow"],
									"properties": {
										"workflow": {
											"$ref": "#/components/schemas/Workflow"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "Name already used.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Pause the workflow before changing its trigger type.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Workflows"],
				"operationId": "deleteWorkflow",
				"summary": "Delete a workflow",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "Cannot delete an active workflow. Pause it first.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows/{id}/graph": {
			"get": {
				"tags": ["Workflows"],
				"operationId": "getWorkflowGraph",
				"summary": "Get the node/edge graph",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Graph.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["graph"],
									"properties": {
										"graph": {
											"$ref": "#/components/schemas/WorkflowGraph"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"put": {
				"tags": ["Workflows"],
				"operationId": "putWorkflowGraph",
				"summary": "Replace the graph",
				"description": "Atomic full replace (max 500 nodes, 1,000 edges).",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/PutWorkflowGraphInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "The stored graph.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["graph"],
									"properties": {
										"graph": {
											"$ref": "#/components/schemas/WorkflowGraph"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"409": {
						"description": "The workflow is active — pause it before editing.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Duplicate node id, self-edge, an edge to a missing node, or more than one edge per branch out of a node.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows/{id}/validate": {
			"post": {
				"tags": ["Workflows"],
				"operationId": "validateWorkflowGraph",
				"summary": "Validate the stored graph",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Result.",
						"content": {
							"application/json": {
								"schema": {
									"oneOf": [
										{
											"type": "object",
											"required": ["valid"],
											"properties": {
												"valid": {
													"type": "boolean",
													"const": true
												}
											}
										},
										{
											"type": "object",
											"required": ["valid", "errors"],
											"properties": {
												"valid": {
													"type": "boolean",
													"const": false
												},
												"errors": {
													"type": "array",
													"items": {
														"type": "string"
													}
												}
											}
										}
									]
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/workflows/{id}/activate": {
			"post": {
				"tags": ["Workflows"],
				"operationId": "activateWorkflow",
				"summary": "Activate",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Activated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["workflow"],
									"properties": {
										"workflow": {
											"$ref": "#/components/schemas/Workflow"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"422": {
						"description": "The graph is invalid (`Workflow graph is invalid: …`).",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows/{id}/pause": {
			"post": {
				"tags": ["Workflows"],
				"operationId": "pauseWorkflow",
				"summary": "Pause",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Paused.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["workflow"],
									"properties": {
										"workflow": {
											"$ref": "#/components/schemas/Workflow"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows/{id}/trigger": {
			"post": {
				"tags": ["Workflows"],
				"operationId": "triggerWorkflow",
				"summary": "Start a run for one contact",
				"description": "Only for workflows with `trigger_type: manual` that are active.",
				"x-required-scope": "workflows:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Workflow public id (`wf_…`).",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/TriggerWorkflowInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Run started.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["run"],
									"properties": {
										"run": {
											"type": "object",
											"description": "The workflow run row."
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Workflow or contact not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Not a manual-trigger workflow, or not active.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/workflows/events": {
			"post": {
				"tags": ["Workflows"],
				"operationId": "postWorkflowEvent",
				"summary": "Post an application event",
				"description": "Enrols the contact into every active `custom` workflow whose event name matches. Check `matched` — an unknown event name is accepted and enrols nobody.",
				"x-required-scope": "workflows:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/WorkflowEventInput"
							}
						}
					}
				},
				"responses": {
					"202": {
						"description": "Accepted.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["event", "matched"],
									"properties": {
										"event": {
											"type": "string"
										},
										"matched": {
											"type": "integer",
											"description": "Number of workflows the contact was enrolled into."
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `workflows:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Contact not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (300/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/signup-forms": {
			"post": {
				"tags": ["Signup forms"],
				"operationId": "createSignupForm",
				"summary": "Create a form",
				"x-required-scope": "signup-forms:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateSignupFormInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["signupForm"],
									"properties": {
										"signupForm": {
											"$ref": "#/components/schemas/SignupForm"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `signup-forms:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Segment or topic not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Signup forms"],
				"operationId": "listSignupForms",
				"summary": "List forms",
				"x-required-scope": "signup-forms:manage",
				"parameters": [
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					},
					{
						"name": "brand_id",
						"in": "query",
						"description": "`brd_…` to list one brand’s rows, `none` for the team’s own (unbranded) rows; omit for all. A brand-restricted key always lists its own brand.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of forms.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["data", "meta"],
									"properties": {
										"data": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/SignupForm"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `signup-forms:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/signup-forms/{id}": {
			"get": {
				"tags": ["Signup forms"],
				"operationId": "getSignupForm",
				"summary": "Get a form",
				"x-required-scope": "signup-forms:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Signup form public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The form.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["signupForm"],
									"properties": {
										"signupForm": {
											"$ref": "#/components/schemas/SignupForm"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `signup-forms:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"patch": {
				"tags": ["Signup forms"],
				"operationId": "updateSignupForm",
				"summary": "Update a form",
				"x-required-scope": "signup-forms:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Signup form public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateSignupFormInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["signupForm"],
									"properties": {
										"signupForm": {
											"$ref": "#/components/schemas/SignupForm"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `signup-forms:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Form, segment or topic not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Signup forms"],
				"operationId": "deleteSignupForm",
				"summary": "Delete a form",
				"x-required-scope": "signup-forms:manage",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Signup form public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `signup-forms:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (30/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/signup-forms/{id}/submit": {
			"post": {
				"tags": ["Signup forms"],
				"operationId": "submitSignupForm",
				"summary": "Submit a form (public)",
				"description": "Unauthenticated and CORS-open (`*`), for embedding on your site. Also accepts `application/x-www-form-urlencoded` / `multipart/form-data` from a plain HTML form, in which case it answers with an HTML page or a `303` redirect to the form’s redirect URL. Extra fields are stored as contact properties.",
				"security": [],
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"description": "Signup form public id.",
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/SubmitSignupFormInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Submitted (JSON callers).",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["success", "message"],
									"properties": {
										"success": {
											"type": "boolean",
											"const": true
										},
										"message": {
											"type": "string"
										},
										"redirect_url": {
											"type": "string"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Body unreadable or `email` invalid.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"404": {
						"description": "Form not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"422": {
						"description": "Form is not active, or a property value is invalid.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min per IP). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/notification-channels": {
			"post": {
				"tags": ["Notification channels"],
				"operationId": "createNotificationChannel",
				"summary": "Create a Slack/Discord/Telegram channel",
				"x-required-scope": "notifications:manage",
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateNotificationChannelInput"
							}
						}
					}
				},
				"responses": {
					"201": {
						"description": "Created.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["channel"],
									"properties": {
										"channel": {
											"$ref": "#/components/schemas/NotificationChannel"
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Validation failed or the channel config was rejected.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "Missing scope or channel limit reached.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Domain or mailbox not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (20/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"get": {
				"tags": ["Notification channels"],
				"operationId": "listNotificationChannels",
				"summary": "List channels",
				"x-required-scope": "notifications:read",
				"responses": {
					"200": {
						"description": "Channels.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["channels"],
									"properties": {
										"channels": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/NotificationChannel"
											}
										}
									}
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					}
				}
			}
		},
		"/notification-channels/{publicId}": {
			"get": {
				"tags": ["Notification channels"],
				"operationId": "getNotificationChannel",
				"summary": "Get a channel",
				"x-required-scope": "notifications:read",
				"parameters": [
					{
						"name": "publicId",
						"in": "path",
						"required": true,
						"description": "Notification channel id (`nc_` + 24 lowercase alphanumerics).",
						"schema": {
							"type": "string",
							"pattern": "^nc_[a-z0-9]{24}$"
						}
					}
				],
				"responses": {
					"200": {
						"description": "The channel.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["channel"],
									"properties": {
										"channel": {
											"$ref": "#/components/schemas/NotificationChannel"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			},
			"put": {
				"tags": ["Notification channels"],
				"operationId": "updateNotificationChannel",
				"summary": "Update a channel",
				"x-required-scope": "notifications:manage",
				"parameters": [
					{
						"name": "publicId",
						"in": "path",
						"required": true,
						"description": "Notification channel id (`nc_` + 24 lowercase alphanumerics).",
						"schema": {
							"type": "string",
							"pattern": "^nc_[a-z0-9]{24}$"
						}
					}
				],
				"requestBody": {
					"required": true,
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateNotificationChannelInput"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Updated.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["channel"],
									"properties": {
										"channel": {
											"$ref": "#/components/schemas/NotificationChannel"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Channel, domain or mailbox not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			},
			"delete": {
				"tags": ["Notification channels"],
				"operationId": "deleteNotificationChannel",
				"summary": "Delete a channel",
				"x-required-scope": "notifications:manage",
				"parameters": [
					{
						"name": "publicId",
						"in": "path",
						"required": true,
						"description": "Notification channel id (`nc_` + 24 lowercase alphanumerics).",
						"schema": {
							"type": "string",
							"pattern": "^nc_[a-z0-9]{24}$"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Deleted.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (60/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/notification-channels/{publicId}/deliveries": {
			"get": {
				"tags": ["Notification channels"],
				"operationId": "listNotificationDeliveries",
				"summary": "Delivery history",
				"x-required-scope": "notifications:read",
				"parameters": [
					{
						"name": "publicId",
						"in": "path",
						"required": true,
						"description": "Notification channel id (`nc_` + 24 lowercase alphanumerics).",
						"schema": {
							"type": "string",
							"pattern": "^nc_[a-z0-9]{24}$"
						}
					},
					{
						"name": "page",
						"in": "query",
						"schema": {
							"default": 1,
							"type": "integer",
							"minimum": 1
						}
					},
					{
						"name": "per_page",
						"in": "query",
						"schema": {
							"default": 20,
							"type": "integer",
							"minimum": 1,
							"maximum": 100
						}
					}
				],
				"responses": {
					"200": {
						"description": "A page of deliveries.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["deliveries", "meta"],
									"properties": {
										"deliveries": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/NotificationDelivery"
											}
										},
										"meta": {
											"$ref": "#/components/schemas/PaginationMeta"
										}
									}
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:read` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					}
				}
			}
		},
		"/notification-channels/{publicId}/test": {
			"post": {
				"tags": ["Notification channels"],
				"operationId": "testNotificationChannel",
				"summary": "Send a test message",
				"x-required-scope": "notifications:manage",
				"parameters": [
					{
						"name": "publicId",
						"in": "path",
						"required": true,
						"description": "Notification channel id (`nc_` + 24 lowercase alphanumerics).",
						"schema": {
							"type": "string",
							"pattern": "^nc_[a-z0-9]{24}$"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Result of the synchronous send.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"properties": {
										"success": {
											"type": "boolean"
										},
										"statusCode": {
											"type": ["integer", "null"]
										},
										"responseBody": {
											"type": ["string", "null"]
										}
									}
								}
							}
						}
					},
					"400": {
						"description": "Channel is disabled.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"$ref": "#/components/responses/NotFound"
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/notification-channels/{publicId}/deliveries/{deliveryId}/replay": {
			"post": {
				"tags": ["Notification channels"],
				"operationId": "replayNotificationDelivery",
				"summary": "Replay a delivery",
				"x-required-scope": "notifications:manage",
				"parameters": [
					{
						"name": "publicId",
						"in": "path",
						"required": true,
						"description": "Notification channel id (`nc_` + 24 lowercase alphanumerics).",
						"schema": {
							"type": "string",
							"pattern": "^nc_[a-z0-9]{24}$"
						}
					},
					{
						"name": "deliveryId",
						"in": "path",
						"required": true,
						"description": "Delivery id.",
						"schema": {
							"type": "integer",
							"minimum": 1
						}
					}
				],
				"responses": {
					"200": {
						"description": "Re-queued.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Success"
								}
							}
						}
					},
					"400": {
						"$ref": "#/components/responses/ValidationError"
					},
					"401": {
						"$ref": "#/components/responses/Unauthorized"
					},
					"403": {
						"description": "The credential lacks the `notifications:manage` scope (body `{ error: \"insufficient_scope\", required, missing }`), or the team is suspended.",
						"content": {
							"application/json": {
								"schema": {
									"anyOf": [
										{
											"$ref": "#/components/schemas/InsufficientScopeError"
										},
										{
											"$ref": "#/components/schemas/Error"
										}
									]
								}
							}
						}
					},
					"404": {
						"description": "Channel or delivery not found.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (10/min). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/public/regions": {
			"get": {
				"tags": ["Regions"],
				"operationId": "listRegions",
				"summary": "List regions",
				"description": "Public, unauthenticated, cached for 60 s.",
				"security": [],
				"responses": {
					"200": {
						"description": "Regions.",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": ["regions"],
									"properties": {
										"regions": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/Region"
											}
										}
									}
								}
							}
						}
					},
					"429": {
						"description": "Rate limited (30/min per IP). `Retry-After` gives the seconds to wait; `X-RateLimit-*` headers are sent on every response.",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		}
	},
	"components": {
		"securitySchemes": {
			"bearerApiKey": {
				"type": "http",
				"scheme": "bearer",
				"bearerFormat": "PostStack API key (sk_live_… / sk_test_…)"
			},
			"bearerOAuth": {
				"type": "oauth2",
				"description": "OAuth 2.0 with PKCE. Dark-launched behind OAUTH_AS_ENABLED; when live, discover at /.well-known/oauth-authorization-server.",
				"flows": {
					"authorizationCode": {
						"authorizationUrl": "https://poststack.dev/oauth/authorize",
						"tokenUrl": "https://poststack.dev/oauth/token",
						"refreshUrl": "https://poststack.dev/oauth/token",
						"scopes": {
							"email:send": "Send emails on your behalf",
							"email:read": "Read email history, analytics, and suppressions",
							"domains:manage": "Create, verify, and delete sending domains",
							"domains:read": "View sending domains and their verification status",
							"mailboxes:manage": "Create and manage IMAP/POP3 mailboxes",
							"api-keys:manage": "Create, rotate, and revoke API keys",
							"mcp:read": "Use read-only MCP tools (list, get, search, analytics)",
							"mcp:send": "Use MCP tools that send email or stage broadcasts",
							"mcp:admin": "Use MCP tools that mutate account state (domains, keys, mailboxes)",
							"contacts:manage": "Create, update, and delete contacts, segments, and properties",
							"contacts:read": "Read contact records, segments, properties, and subscription topics",
							"templates:manage": "Create, update, and delete email templates",
							"templates:read": "Read email templates",
							"broadcasts:manage": "Create, send, and manage broadcast campaigns",
							"broadcasts:read": "Read broadcast campaigns and recipient analytics",
							"webhooks:manage": "Configure webhook subscriptions and inbound mail receivers",
							"workflows:manage": "Define and run automation workflows",
							"signup-forms:manage": "Create and embed contact signup forms",
							"notifications:manage": "Configure Slack, Discord, and Telegram notification channels",
							"notifications:read": "Read notification channels and delivery history"
						}
					}
				}
			}
		},
		"responses": {
			"ValidationError": {
				"description": "Validation failed — `error` names each offending field (`field: message`).",
				"content": {
					"application/json": {
						"schema": {
							"$ref": "#/components/schemas/Error"
						}
					}
				}
			},
			"Unauthorized": {
				"description": "Missing, malformed or unknown credentials (`WWW-Authenticate: Bearer …` is set).",
				"content": {
					"application/json": {
						"schema": {
							"$ref": "#/components/schemas/Error"
						}
					}
				}
			},
			"NotFound": {
				"description": "No such resource on this team.",
				"content": {
					"application/json": {
						"schema": {
							"$ref": "#/components/schemas/Error"
						}
					}
				}
			}
		},
		"schemas": {
			"Error": {
				"type": "object",
				"required": ["error"],
				"properties": {
					"error": {
						"type": "string",
						"description": "Human-readable message. May change; branch on `code`."
					},
					"code": {
						"type": "string",
						"enum": [
							"invalid_request",
							"unauthorized",
							"forbidden",
							"not_found",
							"method_not_allowed",
							"conflict",
							"payload_too_large",
							"unprocessable_entity",
							"rate_limit_exceeded",
							"monthly_limit_exceeded",
							"daily_limit_exceeded",
							"send_limit_exceeded",
							"internal_error",
							"service_unavailable",
							"attachment_file_missing",
							"external_sending_rejected",
							"external_sending_backlog_full"
						],
						"description": "Stable machine-readable code derived from the HTTP status (a handler may set a more specific one). A `429` is `rate_limit_exceeded` (request throttling: wait `Retry-After` seconds and retry) or a quota that retrying will not clear: `monthly_limit_exceeded` (plan allowance used up), `daily_limit_exceeded` (rolling 24h cap on external recipients for new/free accounts), `send_limit_exceeded` (sending from new accounts paused platform-wide) or `external_sending_backlog_full` (a new account awaiting review already has the maximum number of emails waiting). A `403` `external_sending_rejected` means the account was not approved to email recipients outside its own domain."
					}
				}
			},
			"InsufficientScopeError": {
				"type": "object",
				"description": "Returned when the credential lacks a scope the route needs — e.g. a `sending_access` API key (which holds only `email:send`, `email:read`, `mcp:send`) calling a management route.",
				"required": ["error", "required", "missing"],
				"properties": {
					"error": {
						"type": "string",
						"enum": ["insufficient_scope"]
					},
					"code": {
						"type": "string",
						"enum": ["forbidden"]
					},
					"required": {
						"type": "array",
						"items": {
							"type": "string"
						},
						"description": "Scopes the route requires."
					},
					"missing": {
						"type": "array",
						"items": {
							"type": "string"
						},
						"description": "Required scopes the credential does not hold."
					}
				}
			},
			"Success": {
				"type": "object",
				"required": ["success"],
				"properties": {
					"success": {
						"type": "boolean",
						"const": true
					}
				}
			},
			"PaginationMeta": {
				"type": "object",
				"required": ["page", "perPage", "total", "totalPages"],
				"properties": {
					"page": {
						"type": "integer"
					},
					"perPage": {
						"type": "integer"
					},
					"total": {
						"type": "integer"
					},
					"totalPages": {
						"type": "integer"
					}
				}
			},
			"SpamSymbol": {
				"type": "object",
				"required": ["name", "score"],
				"properties": {
					"name": {
						"type": "string"
					},
					"score": {
						"type": "number"
					},
					"description": {
						"type": "string"
					}
				}
			},
			"SendEmailResponse": {
				"type": "object",
				"required": ["id"],
				"properties": {
					"id": {
						"type": "string",
						"description": "Public email id (`em_…`). Every email endpoint is addressed by this id.",
						"example": "em_8c1f3a2b9d4e5f60718293a4"
					},
					"replayed": {
						"type": "boolean",
						"description": "Present and `true` when `idempotency_key` (or the `Idempotency-Key` header) matched an earlier send: `id` is that email and nothing was sent. The response also carries `X-Idempotent-Replay: true`."
					},
					"test_mode": {
						"type": "boolean",
						"const": true,
						"description": "Present only when authenticated with an `sk_test_` key: the email was recorded and marked delivered but never handed to a mail server."
					},
					"held_for_review": {
						"type": "boolean",
						"const": true,
						"description": "Present only while a new account is awaiting approval to email recipients outside its own verified domains and team: the email was accepted and stored and is sent automatically once the account is approved (usually within seconds, otherwise after a short manual review). Nothing needs to be resent."
					},
					"spam_score": {
						"type": "number",
						"description": "rspamd score of the rendered message (omitted when the spam check was skipped)."
					},
					"spam_warnings": {
						"type": "array",
						"items": {
							"$ref": "#/components/schemas/SpamSymbol"
						}
					}
				}
			},
			"BatchSendResult": {
				"oneOf": [
					{
						"type": "object",
						"required": ["id"],
						"properties": {
							"id": {
								"type": "string",
								"description": "Public email id (`em_…`)."
							},
							"replayed": {
								"type": "boolean"
							},
							"test_mode": {
								"type": "boolean",
								"const": true
							},
							"held_for_review": {
								"type": "boolean",
								"const": true,
								"description": "Same meaning as on the single-send response."
							}
						}
					},
					{
						"type": "object",
						"required": ["error"],
						"properties": {
							"error": {
								"type": "string",
								"description": "Why this element was rejected (unverified domain, suppressed recipients, …)."
							},
							"code": {
								"type": "string",
								"description": "Present when the rejection has a specific code, e.g. `monthly_limit_exceeded`, `daily_limit_exceeded` or `send_limit_exceeded` — none of which a retry will clear."
							}
						}
					}
				]
			},
			"Email": {
				"type": "object",
				"description": "An email row, camelCased. List responses omit `htmlBody`, `textBody` and `attachments`.",
				"required": ["id", "publicId", "fromAddress", "toAddresses", "status", "createdAt"],
				"properties": {
					"id": {
						"type": "integer",
						"description": "Internal numeric id. Not accepted by any endpoint — use `publicId`."
					},
					"publicId": {
						"type": "string",
						"description": "`em_…` id used by every email endpoint."
					},
					"domainId": {
						"type": ["integer", "null"]
					},
					"fromAddress": {
						"type": "string"
					},
					"fromName": {
						"type": ["string", "null"]
					},
					"toAddresses": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"ccAddresses": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"bccAddresses": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"replyTo": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"subject": {
						"type": "string"
					},
					"headers": {
						"type": ["object", "null"]
					},
					"tags": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"status": {
						"type": "string",
						"enum": [
							"queued",
							"sending",
							"deferred",
							"delivered",
							"bounced",
							"complained",
							"failed"
						]
					},
					"testMode": {
						"type": "boolean",
						"description": "True when sent with an `sk_test_` key. Such emails report `delivered` but never left PostStack."
					},
					"recipientProvider": {
						"type": ["string", "null"],
						"description": "Mailbox provider of the first recipient, e.g. `gmail`."
					},
					"unsubscribeEnabled": {
						"type": "boolean"
					},
					"attachmentCount": {
						"type": "integer",
						"description": "Number of files the message carried. Present on list responses too, where `attachments` itself is omitted."
					},
					"spamScore": {
						"type": ["string", "null"],
						"description": "Numeric column, serialised as a decimal string."
					},
					"spamWarnings": {
						"type": ["array", "null"],
						"items": {
							"$ref": "#/components/schemas/SpamSymbol"
						}
					},
					"scheduledAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"sentAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"heldForReviewAt": {
						"type": ["string", "null"],
						"format": "date-time",
						"description": "Set while the email waits for the account to be approved for external sending (`status` stays `queued`). Cleared when it is released, or when it fails because the account was not approved."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"EmailEvent": {
				"type": "object",
				"required": ["id", "emailId", "eventType", "createdAt"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"emailId": {
						"type": "integer"
					},
					"eventType": {
						"type": "string",
						"enum": [
							"queued",
							"sent",
							"delivered",
							"deferred",
							"bounced",
							"soft_bounced",
							"opened",
							"clicked",
							"complained",
							"unsubscribed",
							"failed"
						]
					},
					"metadata": {
						"type": ["object", "null"]
					},
					"geoCountry": {
						"type": ["string", "null"]
					},
					"geoRegion": {
						"type": ["string", "null"]
					},
					"geoCity": {
						"type": ["string", "null"]
					},
					"uaClientName": {
						"type": ["string", "null"]
					},
					"uaClientType": {
						"type": ["string", "null"]
					},
					"uaOs": {
						"type": ["string", "null"]
					},
					"uaDeviceType": {
						"type": ["string", "null"]
					},
					"isPrefetch": {
						"type": "boolean",
						"description": "True for machine fetches excluded from engagement metrics: Apple MPP prefetches, known security-scanner IPs, and hits within 15 s of hand-off. Gmail image-proxy opens are real opens and are not flagged."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"EmailInsightWarning": {
				"type": "object",
				"required": ["type", "message", "severity"],
				"properties": {
					"type": {
						"type": "string"
					},
					"message": {
						"type": "string"
					},
					"severity": {
						"type": "string",
						"enum": ["low", "medium", "high"]
					}
				}
			},
			"DnsRecord": {
				"type": "object",
				"required": ["id", "recordType", "name", "value", "purpose", "verified"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"domainId": {
						"type": "integer"
					},
					"recordType": {
						"type": "string",
						"enum": ["TXT", "CNAME", "MX", "SRV"]
					},
					"name": {
						"type": "string"
					},
					"value": {
						"type": "string"
					},
					"purpose": {
						"type": "string",
						"enum": [
							"spf",
							"dkim",
							"dkim_rotation",
							"dmarc",
							"return_path",
							"mx",
							"tracking",
							"bimi",
							"imap",
							"submission",
							"postmaster"
						]
					},
					"verified": {
						"type": "boolean"
					},
					"lastCheckedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"lastCheckCode": {
						"type": ["string", "null"]
					},
					"lastCheckHint": {
						"type": ["string", "null"]
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"Domain": {
				"type": "object",
				"description": "A sending domain. Private DKIM keys are never returned.",
				"required": ["id", "publicId", "name", "status"],
				"properties": {
					"id": {
						"type": "integer",
						"description": "Numeric id. Domain routes accept this or `publicId`."
					},
					"publicId": {
						"type": "string",
						"description": "`dom_…` id."
					},
					"name": {
						"type": "string"
					},
					"region": {
						"type": "string",
						"enum": ["eu-west-1", "us-east-1", "sa-east-1", "ap-northeast-1"]
					},
					"status": {
						"type": "string",
						"enum": ["pending", "verified", "failed"]
					},
					"dkimSelector": {
						"type": ["string", "null"]
					},
					"dkimPublicKey": {
						"type": ["string", "null"]
					},
					"customReturnPath": {
						"type": ["string", "null"]
					},
					"openTracking": {
						"type": "boolean"
					},
					"clickTracking": {
						"type": "boolean"
					},
					"trackingDomain": {
						"type": ["string", "null"]
					},
					"tlsMode": {
						"type": "string",
						"enum": ["opportunistic", "enforced"]
					},
					"inboundEnabled": {
						"type": "boolean"
					},
					"catchAll": {
						"type": "boolean"
					},
					"catchAllMailboxId": {
						"type": ["integer", "null"]
					},
					"bimiLogoUrl": {
						"type": ["string", "null"]
					},
					"ipAddressId": {
						"type": ["integer", "null"]
					},
					"verifiedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					},
					"dnsRecords": {
						"type": "array",
						"items": {
							"$ref": "#/components/schemas/DnsRecord"
						},
						"description": "Present on list, get, create and verify."
					}
				}
			},
			"DkimRotation": {
				"type": "object",
				"required": ["domainId", "state"],
				"properties": {
					"domainId": {
						"type": "integer"
					},
					"state": {
						"type": "string",
						"enum": ["idle", "pending_dns", "ready", "retiring"]
					},
					"activeSelector": {
						"type": ["string", "null"]
					},
					"pendingSelector": {
						"type": ["string", "null"]
					},
					"pendingPublicKey": {
						"type": ["string", "null"]
					},
					"pendingRecordName": {
						"type": ["string", "null"],
						"description": "TXT record name to publish."
					},
					"pendingRecordValue": {
						"type": ["string", "null"],
						"description": "TXT record value to publish."
					},
					"startedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"publishedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"activatesAfter": {
						"type": ["string", "null"],
						"format": "date-time",
						"description": "Earliest moment an un-forced activation succeeds."
					},
					"retiredSelector": {
						"type": ["string", "null"]
					},
					"retireAfter": {
						"type": ["string", "null"],
						"format": "date-time"
					}
				}
			},
			"ApiKey": {
				"type": "object",
				"required": ["id", "name", "keyPrefix", "permission", "mode"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"name": {
						"type": "string"
					},
					"keyPrefix": {
						"type": "string",
						"description": "First characters of the key, for recognition."
					},
					"permission": {
						"type": "string",
						"enum": ["full_access", "sending_access"]
					},
					"mode": {
						"type": "string",
						"enum": ["live", "test"]
					},
					"domainId": {
						"type": ["integer", "null"],
						"description": "Domain the key is restricted to, if any."
					},
					"lastUsedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"expiresAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"ApiKeySecret": {
				"type": "object",
				"required": ["key", "id", "name", "permission", "mode", "keyPrefix"],
				"properties": {
					"key": {
						"type": "string",
						"description": "The plaintext key. Returned only here — store it now."
					},
					"id": {
						"type": "integer"
					},
					"name": {
						"type": "string"
					},
					"permission": {
						"type": "string",
						"enum": ["full_access", "sending_access"]
					},
					"mode": {
						"type": "string",
						"enum": ["live", "test"]
					},
					"keyPrefix": {
						"type": "string"
					}
				}
			},
			"Contact": {
				"type": "object",
				"required": ["id", "publicId", "email", "unsubscribed"],
				"properties": {
					"id": {
						"type": "integer",
						"description": "Internal numeric id."
					},
					"publicId": {
						"type": "string",
						"description": "`con_…` id used by contact endpoints."
					},
					"email": {
						"type": "string"
					},
					"firstName": {
						"type": ["string", "null"]
					},
					"lastName": {
						"type": ["string", "null"]
					},
					"unsubscribed": {
						"type": "boolean"
					},
					"properties": {
						"type": ["object", "null"],
						"description": "Custom property values keyed by property name."
					},
					"engagementSegment": {
						"type": ["string", "null"],
						"enum": ["active", "at_risk", "dormant"]
					},
					"lastEngagedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"ContactProperty": {
				"type": "object",
				"required": ["id", "name", "label", "type", "required"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"name": {
						"type": "string"
					},
					"label": {
						"type": "string"
					},
					"type": {
						"type": "string",
						"enum": ["text", "number", "boolean", "date", "select"]
					},
					"options": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"required": {
						"type": "boolean"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"Segment": {
				"type": "object",
				"required": ["id", "publicId", "name"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`seg_…` id."
					},
					"name": {
						"type": "string"
					},
					"rules": {
						"type": ["object", "null"],
						"description": "Rules tree for a dynamic segment; null for a manual segment."
					},
					"contactCount": {
						"type": "integer"
					},
					"countUnavailable": {
						"type": "boolean",
						"description": "Present and `true` when the count could not be computed."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"Template": {
				"type": "object",
				"required": ["id", "publicId", "name", "published"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`tpl_…` id."
					},
					"name": {
						"type": "string"
					},
					"subject": {
						"type": ["string", "null"]
					},
					"htmlBody": {
						"type": ["string", "null"],
						"description": "Omitted from list responses."
					},
					"textBody": {
						"type": ["string", "null"],
						"description": "Omitted from list responses."
					},
					"variables": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"published": {
						"type": "boolean"
					},
					"version": {
						"type": "integer"
					},
					"builderType": {
						"type": "string",
						"enum": ["html", "visual"]
					},
					"builderBlocks": {
						"type": ["array", "null"],
						"items": {
							"type": "object"
						},
						"description": "Omitted from list responses."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"TemplatePreset": {
				"type": "object",
				"required": ["id", "name", "subject", "html", "variables"],
				"properties": {
					"id": {
						"type": "string",
						"description": "e.g. `welcome`."
					},
					"name": {
						"type": "string"
					},
					"subject": {
						"type": "string"
					},
					"html": {
						"type": "string"
					},
					"variables": {
						"type": "array",
						"items": {
							"type": "string"
						}
					}
				}
			},
			"Broadcast": {
				"type": "object",
				"required": ["id", "publicId", "name", "subject", "status"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`bc_…` id used by broadcast endpoints."
					},
					"name": {
						"type": "string"
					},
					"fromAddress": {
						"type": "string"
					},
					"fromName": {
						"type": ["string", "null"]
					},
					"subject": {
						"type": "string"
					},
					"htmlBody": {
						"type": ["string", "null"]
					},
					"textBody": {
						"type": ["string", "null"]
					},
					"replyTo": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"segmentId": {
						"type": ["integer", "null"]
					},
					"segmentPublicId": {
						"type": ["string", "null"]
					},
					"topicId": {
						"type": ["integer", "null"]
					},
					"topicPublicId": {
						"type": ["string", "null"]
					},
					"status": {
						"type": "string",
						"enum": ["draft", "queued", "sending", "sent", "cancelled"]
					},
					"scheduledAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"sentAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"totalRecipients": {
						"type": "integer"
					},
					"deliveredCount": {
						"type": "integer"
					},
					"openedCount": {
						"type": "integer"
					},
					"clickedCount": {
						"type": "integer"
					},
					"bouncedCount": {
						"type": "integer"
					},
					"deferredCount": {
						"type": "integer",
						"description": "Get only: messages still being retried."
					},
					"heldCount": {
						"type": "integer",
						"description": "Get only: messages held until the account is approved to email external recipients; not part of totalRecipients until then."
					},
					"abTestEnabled": {
						"type": "boolean"
					},
					"winnerVariantId": {
						"type": ["integer", "null"]
					},
					"testSampleSize": {
						"type": ["integer", "null"]
					},
					"testDurationMinutes": {
						"type": ["integer", "null"]
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"BroadcastVariant": {
				"type": "object",
				"required": ["id", "name", "subject", "weight"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"broadcastId": {
						"type": "integer"
					},
					"name": {
						"type": "string"
					},
					"subject": {
						"type": "string"
					},
					"htmlBody": {
						"type": ["string", "null"]
					},
					"textBody": {
						"type": ["string", "null"]
					},
					"weight": {
						"type": "integer"
					},
					"recipientCount": {
						"type": "integer"
					},
					"deliveredCount": {
						"type": "integer"
					},
					"openedCount": {
						"type": "integer"
					},
					"clickedCount": {
						"type": "integer"
					},
					"bouncedCount": {
						"type": "integer"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"BroadcastVariantStats": {
				"type": "object",
				"required": ["variants"],
				"properties": {
					"variants": {
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"id": {
									"type": "integer"
								},
								"name": {
									"type": "string"
								},
								"subject": {
									"type": "string"
								},
								"weight": {
									"type": "integer"
								},
								"recipientCount": {
									"type": "integer"
								},
								"deliveredCount": {
									"type": "integer"
								},
								"openedCount": {
									"type": "integer"
								},
								"clickedCount": {
									"type": "integer"
								},
								"bouncedCount": {
									"type": "integer"
								},
								"openRate": {
									"type": "number"
								},
								"clickRate": {
									"type": "number"
								}
							}
						}
					},
					"winnerVariantId": {
						"type": ["integer", "null"]
					}
				}
			},
			"BroadcastPerformance": {
				"type": "object",
				"properties": {
					"id": {
						"type": "string",
						"description": "Broadcast public id."
					},
					"subject": {
						"type": "string"
					},
					"status": {
						"type": "string"
					},
					"sent_at": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"total_recipients": {
						"type": "integer"
					},
					"delivered": {
						"type": "integer"
					},
					"opened": {
						"type": "integer"
					},
					"clicked": {
						"type": "integer"
					},
					"bounced": {
						"type": "integer"
					},
					"open_rate": {
						"type": "number"
					},
					"click_rate": {
						"type": "number"
					}
				}
			},
			"NonResponders": {
				"type": "object",
				"required": ["broadcast", "count", "contacts"],
				"properties": {
					"broadcast": {
						"type": "object",
						"properties": {
							"id": {
								"type": "string"
							},
							"subject": {
								"type": "string"
							}
						}
					},
					"count": {
						"type": "integer"
					},
					"contacts": {
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"id": {
									"type": "string",
									"description": "Contact public id."
								},
								"email": {
									"type": "string"
								},
								"first_name": {
									"type": ["string", "null"]
								},
								"last_name": {
									"type": ["string", "null"]
								}
							}
						}
					}
				}
			},
			"Webhook": {
				"type": "object",
				"required": ["id", "url", "events", "active"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"url": {
						"type": "string"
					},
					"events": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"signingSecret": {
						"type": "string",
						"description": "Masked. The full secret is returned only by create and rotate-secret."
					},
					"active": {
						"type": "boolean"
					},
					"consecutiveFailures": {
						"type": "integer"
					},
					"disabledAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"disabledReason": {
						"type": ["string", "null"]
					},
					"secretRotatedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"previousSecretExpiresAt": {
						"type": ["string", "null"],
						"format": "date-time",
						"description": "End of the rotation grace window, if one is open."
					},
					"lastDeliveryAt": {
						"type": ["string", "null"],
						"format": "date-time",
						"description": "List only."
					},
					"lastDeliveryStatus": {
						"type": ["integer", "null"],
						"description": "List only: HTTP status of the latest delivery."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"WebhookWithSecret": {
				"type": "object",
				"required": ["webhook", "signingSecret"],
				"properties": {
					"webhook": {
						"$ref": "#/components/schemas/Webhook"
					},
					"signingSecret": {
						"type": "string",
						"description": "Plaintext signing secret — shown once. Verify `X-PostStack-Signature` with it."
					}
				}
			},
			"WebhookDelivery": {
				"type": "object",
				"required": ["id", "webhookId", "eventType", "attempts", "createdAt"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"webhookId": {
						"type": "integer"
					},
					"eventType": {
						"type": "string"
					},
					"payload": {
						"type": "object"
					},
					"statusCode": {
						"type": ["integer", "null"]
					},
					"responseBody": {
						"type": ["string", "null"]
					},
					"attempts": {
						"type": "integer"
					},
					"nextRetryAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"deliveredAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"Suppression": {
				"type": "object",
				"required": ["id", "email", "reason", "createdAt"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"email": {
						"type": "string"
					},
					"reason": {
						"type": "string",
						"enum": [
							"hard_bounce",
							"complaint",
							"manual",
							"unsubscribe",
							"repeated_soft_bounce"
						]
					},
					"revalidateAfter": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"Brand": {
				"type": "object",
				"required": ["id", "publicId", "name"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`brd_…` id."
					},
					"teamId": {
						"type": "integer"
					},
					"name": {
						"type": "string"
					},
					"sendingPaused": {
						"type": "boolean",
						"description": "Paused by the bounce/complaint guard: the brand’s domains send nothing until an operator lifts it."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"SubscriptionTopic": {
				"type": "object",
				"required": ["id", "publicId", "name"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`top_…` id."
					},
					"name": {
						"type": "string"
					},
					"description": {
						"type": ["string", "null"]
					},
					"subscriberCount": {
						"type": "integer",
						"description": "List only."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"ContactSubscription": {
				"type": "object",
				"required": ["id", "contactId", "topicId", "subscribed"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"contactId": {
						"type": "integer"
					},
					"topicId": {
						"type": "integer"
					},
					"subscribed": {
						"type": "boolean",
						"description": "`false` records an explicit opt-out."
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					},
					"topic": {
						"$ref": "#/components/schemas/SubscriptionTopic"
					}
				}
			},
			"Mailbox": {
				"type": "object",
				"description": "An IMAP/POP3 mailbox. The password hash is never returned.",
				"required": ["id", "publicId", "emailAddress", "status"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`mb_…` id."
					},
					"domainId": {
						"type": "integer"
					},
					"emailAddress": {
						"type": "string"
					},
					"displayName": {
						"type": ["string", "null"]
					},
					"assignedUserId": {
						"type": ["integer", "null"]
					},
					"quotaBytes": {
						"type": ["integer", "null"]
					},
					"usedBytes": {
						"type": ["integer", "null"]
					},
					"status": {
						"type": "string",
						"enum": ["active", "suspended", "deleted"]
					},
					"webhookEnabled": {
						"type": "boolean"
					},
					"forwardTo": {
						"type": ["string", "null"]
					},
					"forwardMode": {
						"type": "string",
						"enum": ["relay", "wrapped"]
					},
					"forwardKeepCopy": {
						"type": "boolean"
					},
					"sentCount": {
						"type": "integer"
					},
					"lastLoginAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					},
					"domain": {
						"type": "object",
						"description": "List only.",
						"properties": {
							"id": {
								"type": "integer"
							},
							"name": {
								"type": "string"
							}
						}
					}
				}
			},
			"MailboxAlias": {
				"type": "object",
				"required": ["id", "aliasAddress", "destinationMailboxId"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"domainId": {
						"type": "integer"
					},
					"aliasAddress": {
						"type": "string"
					},
					"destinationMailboxId": {
						"type": "integer"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"MailboxFilterRule": {
				"type": "object",
				"required": ["id", "position", "field", "operator", "value", "action"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string"
					},
					"mailboxId": {
						"type": "integer"
					},
					"position": {
						"type": "integer",
						"description": "Evaluation order, 0-based."
					},
					"name": {
						"type": ["string", "null"]
					},
					"enabled": {
						"type": "boolean"
					},
					"field": {
						"type": "string",
						"enum": ["from", "to", "cc", "subject", "any_recipient"]
					},
					"operator": {
						"type": "string",
						"enum": ["contains", "not_contains", "is", "is_not"]
					},
					"value": {
						"type": "string"
					},
					"action": {
						"type": "string",
						"enum": ["fileinto", "addflag", "discard", "stop"]
					},
					"actionArg": {
						"type": ["string", "null"]
					},
					"options": {
						"type": ["object", "null"]
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"InboundEmail": {
				"type": "object",
				"required": ["id", "fromAddress", "toAddress", "createdAt"],
				"properties": {
					"id": {
						"type": "integer",
						"description": "Numeric id (inbound ids are not prefixed)."
					},
					"domainId": {
						"type": "integer"
					},
					"fromAddress": {
						"type": "string"
					},
					"fromName": {
						"type": ["string", "null"]
					},
					"toAddress": {
						"type": "string"
					},
					"toAddresses": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"ccAddresses": {
						"type": ["array", "null"],
						"items": {
							"type": "string"
						}
					},
					"messageId": {
						"type": ["string", "null"]
					},
					"subject": {
						"type": ["string", "null"]
					},
					"htmlBody": {
						"type": ["string", "null"]
					},
					"textBody": {
						"type": ["string", "null"]
					},
					"headers": {
						"type": ["object", "null"]
					},
					"mailboxHash": {
						"type": ["string", "null"],
						"description": "The `+tag` part of the recipient address."
					},
					"spamScore": {
						"type": ["number", "null"]
					},
					"spamVerdict": {
						"type": ["string", "null"]
					},
					"strippedReply": {
						"type": ["string", "null"],
						"description": "Reply text with quoted history removed."
					},
					"replyCount": {
						"type": "integer",
						"description": "How many emails have been sent in reply to it. List rows only."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"InboundReplySummary": {
				"type": "object",
				"required": ["id", "subject", "toAddresses", "status", "testMode", "createdAt"],
				"properties": {
					"id": {
						"type": "string",
						"description": "Public id of the reply (`em_…`)."
					},
					"subject": {
						"type": "string"
					},
					"toAddresses": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"status": {
						"type": "string"
					},
					"testMode": {
						"type": "boolean"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"ConversationEntry": {
				"type": "object",
				"required": ["kind", "id", "fromAddress", "createdAt"],
				"properties": {
					"kind": {
						"type": "string",
						"enum": ["inbound", "outbound"]
					},
					"id": {
						"oneOf": [
							{
								"type": "integer",
								"description": "Inbound email id."
							},
							{
								"type": "string",
								"description": "Outbound email id (`em_…`)."
							}
						]
					},
					"fromAddress": {
						"type": "string"
					},
					"fromName": {
						"type": ["string", "null"],
						"description": "Inbound only."
					},
					"toAddress": {
						"type": "string",
						"description": "Inbound only: the address it was delivered to."
					},
					"toAddresses": {
						"type": "array",
						"items": {
							"type": "string"
						},
						"description": "Outbound only."
					},
					"subject": {
						"type": ["string", "null"]
					},
					"status": {
						"type": "string",
						"description": "Outbound only."
					},
					"messageId": {
						"type": ["string", "null"]
					},
					"current": {
						"type": "boolean",
						"description": "Outbound only: the email the conversation was requested for."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"EmailConversation": {
				"type": "object",
				"required": ["messageId", "inReplyTo", "references", "repliesTo", "timeline"],
				"properties": {
					"messageId": {
						"type": "string",
						"description": "The Message-ID this email went out with."
					},
					"inReplyTo": {
						"type": ["string", "null"]
					},
					"references": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"repliesTo": {
						"oneOf": [
							{
								"$ref": "#/components/schemas/ConversationEntry"
							},
							{
								"type": "null"
							}
						]
					},
					"timeline": {
						"type": "array",
						"items": {
							"$ref": "#/components/schemas/ConversationEntry"
						},
						"description": "Both directions, oldest first; includes the email itself."
					}
				}
			},
			"InboundAttachment": {
				"type": "object",
				"required": ["id", "filename", "contentType", "size"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"inboundEmailId": {
						"type": "integer"
					},
					"filename": {
						"type": "string"
					},
					"contentType": {
						"type": "string"
					},
					"size": {
						"type": "integer",
						"description": "Bytes."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"InboundReplyDraft": {
				"type": "object",
				"properties": {
					"inbound": {
						"type": "object",
						"properties": {
							"id": {
								"type": "integer"
							},
							"from": {
								"type": "string"
							},
							"to": {
								"type": "string"
							},
							"subject": {
								"type": ["string", "null"]
							},
							"received_at": {
								"type": "string"
							}
						}
					},
					"suggested_from": {
						"type": "string"
					},
					"suggested_subject": {
						"type": "string"
					},
					"salutation": {
						"type": "string"
					},
					"body_placeholder": {
						"type": "string"
					},
					"quoted_html": {
						"type": "string"
					},
					"quoted_text": {
						"type": "string"
					},
					"threading": {
						"type": "object",
						"properties": {
							"in_reply_to": {
								"type": ["string", "null"]
							},
							"references": {
								"type": ["string", "null"]
							}
						}
					},
					"suggested_html": {
						"type": "string"
					},
					"suggested_text": {
						"type": "string"
					},
					"signs_automatically": {
						"type": "boolean"
					}
				}
			},
			"Workflow": {
				"type": "object",
				"required": ["id", "publicId", "name", "triggerType", "status"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`wf_…` id."
					},
					"name": {
						"type": "string"
					},
					"triggerType": {
						"type": "string",
						"enum": ["contact.created", "contact.subscribed", "custom", "manual"]
					},
					"triggerConfig": {
						"type": ["object", "null"],
						"description": "For `custom`, `eventName` holds the event that enrols contacts."
					},
					"status": {
						"type": "string",
						"enum": ["draft", "active", "paused"]
					},
					"runsCount": {
						"type": "integer",
						"description": "Get only."
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"WorkflowGraph": {
				"type": "object",
				"required": ["nodes", "edges"],
				"properties": {
					"nodes": {
						"type": "array",
						"items": {
							"type": "object",
							"required": ["public_id", "type", "config"],
							"properties": {
								"public_id": {
									"type": "string"
								},
								"type": {
									"type": "string",
									"enum": [
										"trigger",
										"send_email",
										"wait",
										"condition",
										"webhook"
									]
								},
								"config": {
									"type": "object"
								},
								"canvas_x": {
									"type": "number"
								},
								"canvas_y": {
									"type": "number"
								}
							}
						}
					},
					"edges": {
						"type": "array",
						"items": {
							"type": "object",
							"required": ["from_public_id", "to_public_id"],
							"properties": {
								"from_public_id": {
									"type": "string"
								},
								"to_public_id": {
									"type": "string"
								},
								"branch": {
									"type": ["string", "null"],
									"enum": ["match", "no_match"]
								}
							}
						}
					}
				}
			},
			"SignupForm": {
				"type": "object",
				"required": ["id", "publicId", "name", "fields", "active"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"publicId": {
						"type": "string",
						"description": "`sf_…` id."
					},
					"name": {
						"type": "string"
					},
					"segmentId": {
						"type": ["integer", "null"]
					},
					"topicId": {
						"type": ["integer", "null"]
					},
					"fields": {
						"type": "array",
						"items": {
							"type": "object"
						}
					},
					"styling": {
						"type": ["object", "null"]
					},
					"successMessage": {
						"type": ["string", "null"]
					},
					"redirectUrl": {
						"type": ["string", "null"]
					},
					"humanCheckSiteKey": {
						"type": ["string", "null"],
						"description": "Public sitekey of the form's HostStack Human Check, or null when off."
					},
					"humanCheckEnabled": {
						"type": "boolean",
						"description": "Whether submissions must pass Human Check. The secret is write-only and never returned."
					},
					"active": {
						"type": "boolean"
					},
					"doubleOptIn": {
						"type": "boolean",
						"description": "Whether a submission must be confirmed by email before the address is subscribed."
					},
					"confirmationFrom": {
						"type": ["string", "null"],
						"description": "Sender of the confirmation email; null = noreply@ the first verified domain."
					},
					"brandId": {
						"type": ["integer", "null"],
						"description": "The brand the form belongs to; null for the team’s own."
					},
					"submissionCount": {
						"type": "integer"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"EmailValidation": {
				"type": "object",
				"required": ["email", "result", "checks", "risk"],
				"properties": {
					"email": {
						"type": "string"
					},
					"result": {
						"type": "string",
						"enum": ["deliverable", "undeliverable", "risky", "unknown"]
					},
					"checks": {
						"type": "object",
						"required": ["syntax", "mx", "disposable", "role", "free"],
						"properties": {
							"syntax": {
								"type": "boolean"
							},
							"mx": {
								"type": "boolean"
							},
							"disposable": {
								"type": "boolean"
							},
							"role": {
								"type": "boolean"
							},
							"free": {
								"type": "boolean"
							}
						}
					},
					"risk": {
						"type": "string",
						"enum": ["low", "medium", "high"]
					}
				}
			},
			"NotificationChannel": {
				"type": "object",
				"required": ["publicId", "type", "name", "events", "active"],
				"properties": {
					"publicId": {
						"type": "string",
						"description": "`nc_…` id."
					},
					"type": {
						"type": "string",
						"enum": ["slack", "discord", "telegram", "web_push"]
					},
					"name": {
						"type": "string"
					},
					"domainId": {
						"type": ["integer", "null"]
					},
					"mailboxId": {
						"type": ["integer", "null"]
					},
					"events": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"active": {
						"type": "boolean"
					},
					"configSummary": {
						"type": "object",
						"description": "Masked view of the channel config — secrets are never returned."
					},
					"consecutiveFailures": {
						"type": "integer"
					},
					"disabledAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"disabledReason": {
						"type": ["string", "null"]
					},
					"lastUsedAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					},
					"updatedAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"NotificationDelivery": {
				"type": "object",
				"required": ["id", "eventType", "createdAt"],
				"properties": {
					"id": {
						"type": "integer"
					},
					"channelId": {
						"type": "integer"
					},
					"eventType": {
						"type": "string"
					},
					"payload": {
						"type": "object"
					},
					"statusCode": {
						"type": ["integer", "null"]
					},
					"responseBody": {
						"type": ["string", "null"]
					},
					"attempts": {
						"type": "integer"
					},
					"nextRetryAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"deliveredAt": {
						"type": ["string", "null"],
						"format": "date-time"
					},
					"createdAt": {
						"type": "string",
						"format": "date-time"
					}
				}
			},
			"Region": {
				"type": "object",
				"required": ["code", "name", "status", "isDefault"],
				"properties": {
					"code": {
						"type": "string"
					},
					"name": {
						"type": "string"
					},
					"location": {
						"type": ["string", "null"]
					},
					"apiUrl": {
						"type": ["string", "null"]
					},
					"status": {
						"type": "string",
						"enum": ["active", "draining", "disabled"]
					},
					"isDefault": {
						"type": "boolean"
					}
				}
			},
			"SendEmailInput": {
				"type": "object",
				"properties": {
					"from": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"to": {
						"minItems": 1,
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"cc": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"bcc": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"reply_to": {
						"type": "string",
						"maxLength": 320,
						"format": "email"
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string"
					},
					"text": {
						"type": "string"
					},
					"headers": {
						"type": "object",
						"additionalProperties": {
							"type": "string",
							"maxLength": 1024
						}
					},
					"tags": {
						"maxItems": 10,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 64
						}
					},
					"attachments": {
						"maxItems": 10,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"filename": {
									"type": "string",
									"minLength": 1
								},
								"content": {
									"type": "string",
									"minLength": 1,
									"maxLength": 25000000
								},
								"content_type": {
									"type": "string"
								},
								"content_id": {
									"type": "string"
								}
							},
							"required": ["filename", "content"]
						}
					},
					"idempotency_key": {
						"type": "string",
						"maxLength": 64
					},
					"scheduled_at": {
						"anyOf": [
							{
								"type": "string",
								"format": "date-time",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
							},
							{
								"type": "string",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?:Z))$"
							}
						]
					},
					"template_id": {
						"type": "string"
					},
					"variables": {
						"type": "object",
						"additionalProperties": {
							"type": "string"
						}
					},
					"unsubscribe": {
						"type": "boolean"
					},
					"signature": {
						"type": "string",
						"enum": ["auto", "none"]
					},
					"tracking": {
						"type": "object",
						"properties": {
							"opens": {
								"type": "boolean"
							},
							"clicks": {
								"type": "boolean"
							}
						}
					},
					"idempotency_window_hours": {
						"type": "integer",
						"minimum": 1,
						"maximum": 72
					}
				},
				"required": ["from", "to"]
			},
			"BatchSendInput": {
				"type": "object",
				"properties": {
					"emails": {
						"minItems": 1,
						"maxItems": 100,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"from": {
									"type": "string",
									"minLength": 1,
									"maxLength": 998
								},
								"to": {
									"minItems": 1,
									"maxItems": 50,
									"type": "array",
									"items": {
										"type": "string",
										"maxLength": 320,
										"format": "email"
									}
								},
								"cc": {
									"maxItems": 50,
									"type": "array",
									"items": {
										"type": "string",
										"maxLength": 320,
										"format": "email"
									}
								},
								"bcc": {
									"maxItems": 50,
									"type": "array",
									"items": {
										"type": "string",
										"maxLength": 320,
										"format": "email"
									}
								},
								"reply_to": {
									"type": "string",
									"maxLength": 320,
									"format": "email"
								},
								"subject": {
									"type": "string",
									"minLength": 1,
									"maxLength": 998
								},
								"html": {
									"type": "string"
								},
								"text": {
									"type": "string"
								},
								"headers": {
									"type": "object",
									"additionalProperties": {
										"type": "string",
										"maxLength": 1024
									}
								},
								"tags": {
									"maxItems": 10,
									"type": "array",
									"items": {
										"type": "string",
										"maxLength": 64
									}
								},
								"attachments": {
									"maxItems": 10,
									"type": "array",
									"items": {
										"type": "object",
										"properties": {
											"filename": {
												"type": "string",
												"minLength": 1
											},
											"content": {
												"type": "string",
												"minLength": 1,
												"maxLength": 25000000
											},
											"content_type": {
												"type": "string"
											},
											"content_id": {
												"type": "string"
											}
										},
										"required": ["filename", "content"]
									}
								},
								"idempotency_key": {
									"type": "string",
									"maxLength": 64
								},
								"scheduled_at": {
									"anyOf": [
										{
											"type": "string",
											"format": "date-time",
											"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
										},
										{
											"type": "string",
											"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?:Z))$"
										}
									]
								},
								"template_id": {
									"type": "string"
								},
								"variables": {
									"type": "object",
									"additionalProperties": {
										"type": "string"
									}
								},
								"unsubscribe": {
									"type": "boolean"
								},
								"signature": {
									"type": "string",
									"enum": ["auto", "none"]
								},
								"tracking": {
									"type": "object",
									"properties": {
										"opens": {
											"type": "boolean"
										},
										"clicks": {
											"type": "boolean"
										}
									}
								},
								"idempotency_window_hours": {
									"type": "integer",
									"minimum": 1,
									"maximum": 72
								}
							},
							"required": ["from", "to"]
						}
					}
				},
				"required": ["emails"]
			},
			"CreateDomainInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 253
					},
					"region": {
						"type": "string",
						"enum": ["eu-west-1"]
					},
					"custom_return_path": {
						"type": "string"
					},
					"open_tracking": {
						"type": "boolean"
					},
					"click_tracking": {
						"type": "boolean"
					},
					"tls_mode": {
						"type": "string",
						"enum": ["opportunistic", "enforced"]
					}
				},
				"required": ["name"]
			},
			"UpdateDomainInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 1,
								"maxLength": 64
							},
							{
								"type": "null"
							}
						]
					},
					"open_tracking": {
						"type": "boolean"
					},
					"click_tracking": {
						"type": "boolean"
					},
					"tracking_domain": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 253
							},
							{
								"type": "null"
							}
						]
					},
					"tls_mode": {
						"type": "string",
						"enum": ["opportunistic", "enforced"]
					},
					"inbound_enabled": {
						"type": "boolean"
					},
					"catch_all": {
						"type": "boolean"
					},
					"catch_all_mailbox_id": {
						"anyOf": [
							{
								"type": "integer",
								"minimum": 1
							},
							{
								"type": "null"
							}
						]
					},
					"stream_preference": {
						"type": "string",
						"enum": ["any", "transactional", "marketing", "notification"]
					},
					"bimi_logo_url": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 2048,
								"format": "uri"
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"CreateApiKeyInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"permission": {
						"type": "string",
						"enum": ["full_access", "sending_access"]
					},
					"mode": {
						"default": "live",
						"type": "string",
						"enum": ["live", "test"]
					},
					"domain_id": {
						"type": "string"
					},
					"allow_full_access": {
						"default": false,
						"type": "boolean"
					}
				},
				"required": ["name", "permission"]
			},
			"CreateContactInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"email": {
						"type": "string",
						"format": "email"
					},
					"first_name": {
						"type": "string",
						"maxLength": 100
					},
					"last_name": {
						"type": "string",
						"maxLength": 100
					},
					"unsubscribed": {
						"type": "boolean"
					},
					"properties": {
						"type": "object",
						"additionalProperties": {}
					}
				},
				"required": ["email"]
			},
			"UpdateContactInput": {
				"type": "object",
				"properties": {
					"first_name": {
						"type": "string",
						"maxLength": 100
					},
					"last_name": {
						"type": "string",
						"maxLength": 100
					},
					"unsubscribed": {
						"type": "boolean"
					},
					"properties": {
						"type": "object",
						"additionalProperties": {}
					}
				}
			},
			"ImportContactsInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"contacts": {
						"minItems": 1,
						"maxItems": 10000,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"email": {
									"type": "string",
									"format": "email"
								},
								"first_name": {
									"type": "string",
									"maxLength": 100
								},
								"last_name": {
									"type": "string",
									"maxLength": 100
								},
								"properties": {
									"type": "object",
									"additionalProperties": {
										"type": "string",
										"maxLength": 4096
									}
								}
							},
							"required": ["email"]
						}
					}
				},
				"required": ["contacts"]
			},
			"CreateContactPropertyInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"label": {
						"type": "string",
						"minLength": 1,
						"maxLength": 200
					},
					"type": {
						"type": "string",
						"enum": ["text", "number", "boolean", "date", "select"]
					},
					"options": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"required": {
						"type": "boolean"
					}
				},
				"required": ["name", "label"]
			},
			"UpdateContactPropertyInput": {
				"type": "object",
				"properties": {
					"label": {
						"type": "string",
						"minLength": 1,
						"maxLength": 200
					},
					"options": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"required": {
						"type": "boolean"
					}
				}
			},
			"CreateSegmentInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"rules": {
						"anyOf": [
							{
								"type": "object",
								"properties": {
									"operator": {
										"type": "string",
										"enum": ["and", "or"]
									},
									"conditions": {
										"minItems": 1,
										"maxItems": 50,
										"type": "array",
										"items": {
											"type": "object",
											"properties": {
												"field": {
													"type": "string",
													"minLength": 1,
													"maxLength": 200
												},
												"comparator": {
													"type": "string",
													"enum": [
														"equals",
														"not_equals",
														"contains",
														"starts_with",
														"ends_with",
														"greater_than",
														"less_than",
														"greater_than_or_equal",
														"less_than_or_equal",
														"before",
														"after",
														"in_last_days",
														"is_set",
														"is_not_set"
													]
												},
												"value": {
													"default": "",
													"type": "string",
													"maxLength": 500
												},
												"windowDays": {
													"type": "integer",
													"minimum": 1,
													"maximum": 365
												}
											},
											"required": ["field", "comparator"]
										}
									}
								},
								"required": ["operator", "conditions"]
							},
							{
								"type": "null"
							}
						]
					}
				},
				"required": ["name"]
			},
			"UpdateSegmentInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"rules": {
						"anyOf": [
							{
								"type": "object",
								"properties": {
									"operator": {
										"type": "string",
										"enum": ["and", "or"]
									},
									"conditions": {
										"minItems": 1,
										"maxItems": 50,
										"type": "array",
										"items": {
											"type": "object",
											"properties": {
												"field": {
													"type": "string",
													"minLength": 1,
													"maxLength": 200
												},
												"comparator": {
													"type": "string",
													"enum": [
														"equals",
														"not_equals",
														"contains",
														"starts_with",
														"ends_with",
														"greater_than",
														"less_than",
														"greater_than_or_equal",
														"less_than_or_equal",
														"before",
														"after",
														"in_last_days",
														"is_set",
														"is_not_set"
													]
												},
												"value": {
													"default": "",
													"type": "string",
													"maxLength": 500
												},
												"windowDays": {
													"type": "integer",
													"minimum": 1,
													"maximum": 365
												}
											},
											"required": ["field", "comparator"]
										}
									}
								},
								"required": ["operator", "conditions"]
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"PreviewSegmentRulesInput": {
				"type": "object",
				"properties": {
					"rules": {
						"type": "object",
						"properties": {
							"operator": {
								"type": "string",
								"enum": ["and", "or"]
							},
							"conditions": {
								"minItems": 1,
								"maxItems": 50,
								"type": "array",
								"items": {
									"type": "object",
									"properties": {
										"field": {
											"type": "string",
											"minLength": 1,
											"maxLength": 200
										},
										"comparator": {
											"type": "string",
											"enum": [
												"equals",
												"not_equals",
												"contains",
												"starts_with",
												"ends_with",
												"greater_than",
												"less_than",
												"greater_than_or_equal",
												"less_than_or_equal",
												"before",
												"after",
												"in_last_days",
												"is_set",
												"is_not_set"
											]
										},
										"value": {
											"default": "",
											"type": "string",
											"maxLength": 500
										},
										"windowDays": {
											"type": "integer",
											"minimum": 1,
											"maximum": 365
										}
									},
									"required": ["field", "comparator"]
								}
							}
						},
						"required": ["operator", "conditions"]
					}
				},
				"required": ["rules"]
			},
			"AddContactsToSegmentInput": {
				"type": "object",
				"properties": {
					"contact_ids": {
						"minItems": 1,
						"maxItems": 1000,
						"type": "array",
						"items": {
							"type": "string",
							"minLength": 1
						}
					}
				},
				"required": ["contact_ids"]
			},
			"CreateBroadcastInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"segment_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"topic_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"from": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string"
					},
					"text": {
						"type": "string"
					},
					"reply_to": {
						"type": "string",
						"maxLength": 320,
						"format": "email"
					},
					"name": {
						"type": "string",
						"maxLength": 100
					},
					"scheduled_at": {
						"anyOf": [
							{
								"type": "string",
								"format": "date-time",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
							},
							{
								"type": "string",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?:Z))$"
							}
						]
					},
					"ab_test": {
						"type": "object",
						"properties": {
							"variants": {
								"minItems": 2,
								"maxItems": 5,
								"type": "array",
								"items": {
									"type": "object",
									"properties": {
										"name": {
											"type": "string",
											"minLength": 1,
											"maxLength": 10
										},
										"subject": {
											"type": "string",
											"minLength": 1,
											"maxLength": 998
										},
										"html": {
											"type": "string"
										},
										"text": {
											"type": "string"
										},
										"weight": {
											"type": "integer",
											"minimum": 1,
											"maximum": 100
										}
									},
									"required": ["name", "subject", "weight"]
								}
							},
							"test_sample_size": {
								"default": 20,
								"type": "integer",
								"minimum": 5,
								"maximum": 50
							},
							"test_duration_minutes": {
								"default": 120,
								"type": "integer",
								"minimum": 30,
								"maximum": 1440
							}
						},
						"required": ["variants"]
					}
				},
				"required": ["segment_id", "from", "subject"]
			},
			"UpdateBroadcastInput": {
				"type": "object",
				"properties": {
					"segment_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"topic_id": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 1,
								"maxLength": 64
							},
							{
								"type": "null"
							}
						]
					},
					"from": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string"
					},
					"text": {
						"type": "string"
					},
					"reply_to": {
						"type": "string",
						"maxLength": 320,
						"format": "email"
					},
					"name": {
						"type": "string",
						"maxLength": 100
					},
					"scheduled_at": {
						"anyOf": [
							{
								"type": "string",
								"format": "date-time",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
							},
							{
								"type": "string",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?:Z))$"
							}
						]
					},
					"ab_test": {
						"type": "object",
						"properties": {
							"variants": {
								"minItems": 2,
								"maxItems": 5,
								"type": "array",
								"items": {
									"type": "object",
									"properties": {
										"name": {
											"type": "string",
											"minLength": 1,
											"maxLength": 10
										},
										"subject": {
											"type": "string",
											"minLength": 1,
											"maxLength": 998
										},
										"html": {
											"type": "string"
										},
										"text": {
											"type": "string"
										},
										"weight": {
											"type": "integer",
											"minimum": 1,
											"maximum": 100
										}
									},
									"required": ["name", "subject", "weight"]
								}
							},
							"test_sample_size": {
								"default": 20,
								"type": "integer",
								"minimum": 5,
								"maximum": 50
							},
							"test_duration_minutes": {
								"default": 120,
								"type": "integer",
								"minimum": 30,
								"maximum": 1440
							}
						},
						"required": ["variants"]
					}
				}
			},
			"TestBroadcastInput": {
				"type": "object",
				"properties": {
					"email": {
						"type": "string",
						"format": "email"
					}
				},
				"required": ["email"]
			},
			"ResendBroadcastInput": {
				"type": "object",
				"properties": {
					"target": {
						"type": "string",
						"enum": ["non_openers", "non_clickers"]
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					}
				}
			},
			"CreateTemplateInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string",
						"minLength": 1
					},
					"text": {
						"type": "string"
					},
					"variables": {
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 64
						}
					},
					"builder_type": {
						"type": "string",
						"enum": ["html", "visual"]
					},
					"builder_blocks": {
						"anyOf": [
							{
								"type": "object",
								"properties": {
									"blocks": {
										"type": "array",
										"items": {}
									},
									"backgroundColor": {
										"type": "string"
									},
									"contentBackgroundColor": {
										"type": "string"
									},
									"contentWidth": {
										"type": "number"
									}
								},
								"required": ["blocks"],
								"additionalProperties": {}
							},
							{
								"type": "null"
							}
						]
					}
				},
				"required": ["name", "subject", "html"]
			},
			"UpdateTemplateInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string",
						"minLength": 1
					},
					"text": {
						"type": "string"
					},
					"variables": {
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 64
						}
					},
					"builder_type": {
						"type": "string",
						"enum": ["html", "visual"]
					},
					"builder_blocks": {
						"anyOf": [
							{
								"type": "object",
								"properties": {
									"blocks": {
										"type": "array",
										"items": {}
									},
									"backgroundColor": {
										"type": "string"
									},
									"contentBackgroundColor": {
										"type": "string"
									},
									"contentWidth": {
										"type": "number"
									}
								},
								"required": ["blocks"],
								"additionalProperties": {}
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"CreateWebhookInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"url": {
						"type": "string",
						"format": "uri"
					},
					"events": {
						"minItems": 1,
						"type": "array",
						"items": {
							"type": "string",
							"enum": [
								"email.sent",
								"email.delivered",
								"email.bounced",
								"email.soft_bounced",
								"email.opened",
								"email.clicked",
								"email.complained",
								"email.unsubscribed",
								"email.failed",
								"email.inbound",
								"email.delivery_delayed",
								"email.scheduled",
								"email.suppressed",
								"contact.created",
								"contact.updated",
								"contact.deleted",
								"contact.unsubscribed",
								"domain.created",
								"domain.updated",
								"domain.deleted",
								"domain.verified",
								"domain.failed",
								"domain.dns_drift",
								"domain.dkim_rotation_started",
								"domain.dkim_rotation_activated",
								"domain.dkim_rotation_completed"
							]
						}
					}
				},
				"required": ["url", "events"]
			},
			"UpdateWebhookInput": {
				"type": "object",
				"properties": {
					"url": {
						"type": "string",
						"format": "uri"
					},
					"events": {
						"minItems": 1,
						"type": "array",
						"items": {
							"type": "string",
							"enum": [
								"email.sent",
								"email.delivered",
								"email.bounced",
								"email.soft_bounced",
								"email.opened",
								"email.clicked",
								"email.complained",
								"email.unsubscribed",
								"email.failed",
								"email.inbound",
								"email.delivery_delayed",
								"email.scheduled",
								"email.suppressed",
								"contact.created",
								"contact.updated",
								"contact.deleted",
								"contact.unsubscribed",
								"domain.created",
								"domain.updated",
								"domain.deleted",
								"domain.verified",
								"domain.failed",
								"domain.dns_drift",
								"domain.dkim_rotation_started",
								"domain.dkim_rotation_activated",
								"domain.dkim_rotation_completed"
							]
						}
					},
					"enabled": {
						"type": "boolean"
					}
				}
			},
			"RotateWebhookSecretInput": {
				"type": "object",
				"properties": {
					"graceHours": {
						"type": "integer",
						"minimum": 0,
						"maximum": 168
					}
				}
			},
			"BatchReplayWebhookDeliveriesInput": {
				"type": "object",
				"properties": {
					"withinMinutes": {
						"type": "integer",
						"minimum": 1,
						"maximum": 43200
					},
					"eventType": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"limit": {
						"type": "integer",
						"minimum": 1,
						"maximum": 1000
					}
				}
			},
			"CreateSubscriptionTopicInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"description": {
						"type": "string",
						"maxLength": 500
					}
				},
				"required": ["name"]
			},
			"UpdateSubscriptionTopicInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"description": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 500
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"CreateBrandInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					}
				},
				"required": ["name"]
			},
			"UpdateBrandInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					}
				}
			},
			"SubscribeToTopicInput": {
				"type": "object",
				"properties": {
					"topic_id": {
						"type": "string",
						"minLength": 1
					}
				},
				"required": ["topic_id"]
			},
			"CreateMailboxInput": {
				"type": "object",
				"properties": {
					"domainId": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 1
							},
							{
								"type": "integer",
								"minimum": 1
							}
						]
					},
					"localPart": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64,
						"pattern": "^[a-zA-Z0-9._%+-]+$"
					},
					"password": {
						"type": "string",
						"minLength": 8
					},
					"displayName": {
						"type": "string",
						"maxLength": 255
					},
					"quotaBytes": {
						"type": "integer",
						"minimum": 1073741824,
						"maximum": 53687091200
					},
					"webhookEnabled": {
						"type": "boolean"
					}
				},
				"required": ["domainId", "localPart", "password"]
			},
			"UpdateMailboxInput": {
				"type": "object",
				"properties": {
					"assignedUserId": {
						"anyOf": [
							{
								"type": "integer",
								"minimum": 1
							},
							{
								"type": "null"
							}
						]
					},
					"displayName": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 255
							},
							{
								"type": "null"
							}
						]
					},
					"quotaBytes": {
						"type": "integer",
						"minimum": 1073741824,
						"maximum": 53687091200
					},
					"status": {
						"type": "string",
						"enum": ["active", "suspended"]
					},
					"webhookEnabled": {
						"type": "boolean"
					},
					"forwardTo": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 1024
							},
							{
								"type": "null"
							}
						]
					},
					"forwardMode": {
						"type": "string",
						"enum": ["relay", "wrapped"]
					},
					"forwardKeepCopy": {
						"type": "boolean"
					},
					"signatureHtml": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 8192
							},
							{
								"type": "null"
							}
						]
					},
					"signatureText": {
						"anyOf": [
							{
								"type": "string",
								"maxLength": 2048
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"ChangeMailboxPasswordInput": {
				"type": "object",
				"properties": {
					"password": {
						"type": "string",
						"minLength": 8
					}
				},
				"required": ["password"]
			},
			"CreateMailboxAliasInput": {
				"type": "object",
				"properties": {
					"domainId": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 1
							},
							{
								"type": "integer",
								"minimum": 1
							}
						]
					},
					"localPart": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64,
						"pattern": "^[a-zA-Z0-9._%+-]+$"
					},
					"destinationMailboxId": {
						"type": "string",
						"minLength": 1
					}
				},
				"required": ["domainId", "localPart", "destinationMailboxId"]
			},
			"ReplaceMailboxFiltersInput": {
				"type": "object",
				"properties": {
					"rules": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"name": {
									"type": "string",
									"minLength": 1,
									"maxLength": 100
								},
								"field": {
									"type": "string",
									"enum": ["from", "to", "cc", "subject", "any_recipient"]
								},
								"operator": {
									"type": "string",
									"enum": ["contains", "not_contains", "is", "is_not"]
								},
								"value": {
									"type": "string",
									"minLength": 1,
									"maxLength": 500
								},
								"action": {
									"type": "string",
									"enum": ["fileinto", "addflag", "discard", "stop"]
								},
								"actionArg": {
									"anyOf": [
										{
											"type": "string",
											"maxLength": 200
										},
										{
											"type": "null"
										}
									]
								},
								"enabled": {
									"type": "boolean"
								}
							},
							"required": ["name", "field", "operator", "value", "action"]
						}
					}
				},
				"required": ["rules"]
			},
			"ReplyInboundInput": {
				"type": "object",
				"properties": {
					"from": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string"
					},
					"text": {
						"type": "string"
					},
					"cc": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"bcc": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"quote_original": {
						"type": "boolean"
					}
				},
				"required": ["from"]
			},
			"ForwardInboundInput": {
				"type": "object",
				"properties": {
					"from": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"to": {
						"minItems": 1,
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"cc": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"bcc": {
						"maxItems": 50,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"message": {
						"type": "string"
					}
				},
				"required": ["from", "to"]
			},
			"CreateWorkflowInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 200
					},
					"trigger_type": {
						"type": "string",
						"enum": ["contact.created", "contact.subscribed", "custom", "manual"]
					},
					"trigger_config": {
						"type": "object",
						"additionalProperties": {}
					}
				},
				"required": ["name", "trigger_type"]
			},
			"UpdateWorkflowInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 200
					},
					"trigger_type": {
						"type": "string",
						"enum": ["contact.created", "contact.subscribed", "custom", "manual"]
					},
					"trigger_config": {
						"anyOf": [
							{
								"type": "object",
								"additionalProperties": {}
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"PutWorkflowGraphInput": {
				"type": "object",
				"properties": {
					"nodes": {
						"maxItems": 500,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"public_id": {
									"type": "string",
									"minLength": 1,
									"maxLength": 64
								},
								"type": {
									"type": "string",
									"enum": [
										"trigger",
										"send_email",
										"wait",
										"condition",
										"webhook"
									]
								},
								"config": {
									"type": "object",
									"additionalProperties": {}
								},
								"canvas_x": {
									"type": "number"
								},
								"canvas_y": {
									"type": "number"
								}
							},
							"required": ["public_id", "type", "config", "canvas_x", "canvas_y"]
						}
					},
					"edges": {
						"maxItems": 1000,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"from_public_id": {
									"type": "string",
									"minLength": 1,
									"maxLength": 64
								},
								"to_public_id": {
									"type": "string",
									"minLength": 1,
									"maxLength": 64
								},
								"branch": {
									"anyOf": [
										{
											"type": "string",
											"enum": ["match", "no_match"]
										},
										{
											"type": "null"
										}
									]
								}
							},
							"required": ["from_public_id", "to_public_id"]
						}
					}
				},
				"required": ["nodes", "edges"]
			},
			"TriggerWorkflowInput": {
				"type": "object",
				"properties": {
					"contact_id": {
						"type": "string",
						"minLength": 1
					}
				},
				"required": ["contact_id"]
			},
			"WorkflowEventInput": {
				"type": "object",
				"properties": {
					"event": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"contact_id": {
						"type": "string",
						"minLength": 1
					},
					"email": {
						"type": "string",
						"format": "email"
					}
				},
				"required": ["event"]
			},
			"CreateSignupFormInput": {
				"type": "object",
				"properties": {
					"brand_id": {
						"type": "string",
						"minLength": 1,
						"maxLength": 64
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"segment_id": {
						"type": "string",
						"minLength": 1
					},
					"topic_id": {
						"type": "string",
						"minLength": 1
					},
					"fields": {
						"minItems": 1,
						"maxItems": 10,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"name": {
									"type": "string",
									"minLength": 1,
									"maxLength": 50
								},
								"type": {
									"type": "string",
									"enum": ["email", "text", "select"]
								},
								"required": {
									"type": "boolean"
								},
								"label": {
									"type": "string",
									"minLength": 1,
									"maxLength": 100
								},
								"placeholder": {
									"type": "string",
									"maxLength": 200
								},
								"options": {
									"type": "array",
									"items": {
										"type": "string"
									}
								}
							},
							"required": ["name", "type", "required", "label"]
						}
					},
					"success_message": {
						"type": "string",
						"maxLength": 500
					},
					"redirect_url": {
						"type": "string",
						"format": "uri"
					},
					"human_check": {
						"type": "object",
						"properties": {
							"site_key": {
								"type": "string",
								"minLength": 10,
								"maxLength": 200
							},
							"secret": {
								"type": "string",
								"minLength": 10,
								"maxLength": 500
							}
						},
						"required": ["site_key", "secret"]
					},
					"double_opt_in": {
						"type": "boolean"
					},
					"confirmation_from": {
						"type": "string",
						"minLength": 3,
						"maxLength": 320
					}
				},
				"required": ["name", "fields"]
			},
			"UpdateSignupFormInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 100
					},
					"segment_id": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 1
							},
							{
								"type": "null"
							}
						]
					},
					"topic_id": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 1
							},
							{
								"type": "null"
							}
						]
					},
					"fields": {
						"minItems": 1,
						"maxItems": 10,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"name": {
									"type": "string",
									"minLength": 1,
									"maxLength": 50
								},
								"type": {
									"type": "string",
									"enum": ["email", "text", "select"]
								},
								"required": {
									"type": "boolean"
								},
								"label": {
									"type": "string",
									"minLength": 1,
									"maxLength": 100
								},
								"placeholder": {
									"type": "string",
									"maxLength": 200
								},
								"options": {
									"type": "array",
									"items": {
										"type": "string"
									}
								}
							},
							"required": ["name", "type", "required", "label"]
						}
					},
					"success_message": {
						"type": "string",
						"maxLength": 500
					},
					"redirect_url": {
						"anyOf": [
							{
								"type": "string",
								"format": "uri"
							},
							{
								"type": "null"
							}
						]
					},
					"active": {
						"type": "boolean"
					},
					"human_check": {
						"anyOf": [
							{
								"type": "object",
								"properties": {
									"site_key": {
										"type": "string",
										"minLength": 10,
										"maxLength": 200
									},
									"secret": {
										"type": "string",
										"minLength": 10,
										"maxLength": 500
									}
								},
								"required": ["site_key", "secret"]
							},
							{
								"type": "null"
							}
						]
					},
					"double_opt_in": {
						"type": "boolean"
					},
					"confirmation_from": {
						"anyOf": [
							{
								"type": "string",
								"minLength": 3,
								"maxLength": 320
							},
							{
								"type": "null"
							}
						]
					}
				}
			},
			"SubmitSignupFormInput": {
				"type": "object",
				"properties": {
					"email": {
						"type": "string",
						"format": "email"
					},
					"first_name": {
						"type": "string",
						"maxLength": 100
					},
					"last_name": {
						"type": "string",
						"maxLength": 100
					}
				},
				"required": ["email"],
				"additionalProperties": true
			},
			"ValidateEmailInput": {
				"type": "object",
				"properties": {
					"email": {
						"type": "string",
						"maxLength": 320,
						"format": "email"
					}
				},
				"required": ["email"]
			},
			"ValidateEmailBatchInput": {
				"type": "object",
				"properties": {
					"emails": {
						"minItems": 1,
						"maxItems": 100,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					}
				},
				"required": ["emails"]
			},
			"CreateNotificationChannelInput": {
				"oneOf": [
					{
						"type": "object",
						"properties": {
							"type": {
								"type": "string",
								"const": "slack"
							},
							"name": {
								"type": "string",
								"minLength": 1,
								"maxLength": 200
							},
							"domainId": {
								"type": "integer",
								"minimum": 1
							},
							"mailboxId": {
								"type": "integer",
								"minimum": 1
							},
							"events": {
								"minItems": 1,
								"type": "array",
								"items": {
									"type": "string"
								}
							},
							"config": {
								"type": "object",
								"properties": {
									"webhookUrl": {
										"type": "string",
										"format": "uri"
									}
								},
								"required": ["webhookUrl"]
							}
						},
						"required": ["type", "name", "events", "config"]
					},
					{
						"type": "object",
						"properties": {
							"type": {
								"type": "string",
								"const": "discord"
							},
							"name": {
								"type": "string",
								"minLength": 1,
								"maxLength": 200
							},
							"domainId": {
								"type": "integer",
								"minimum": 1
							},
							"mailboxId": {
								"type": "integer",
								"minimum": 1
							},
							"events": {
								"minItems": 1,
								"type": "array",
								"items": {
									"type": "string"
								}
							},
							"config": {
								"type": "object",
								"properties": {
									"webhookUrl": {
										"type": "string",
										"format": "uri"
									}
								},
								"required": ["webhookUrl"]
							}
						},
						"required": ["type", "name", "events", "config"]
					},
					{
						"type": "object",
						"properties": {
							"type": {
								"type": "string",
								"const": "telegram"
							},
							"name": {
								"type": "string",
								"minLength": 1,
								"maxLength": 200
							},
							"domainId": {
								"type": "integer",
								"minimum": 1
							},
							"mailboxId": {
								"type": "integer",
								"minimum": 1
							},
							"events": {
								"minItems": 1,
								"type": "array",
								"items": {
									"type": "string"
								}
							},
							"config": {
								"type": "object",
								"properties": {
									"botToken": {
										"type": "string",
										"minLength": 20,
										"maxLength": 200
									},
									"chatId": {
										"type": "string",
										"minLength": 1,
										"maxLength": 64
									}
								},
								"required": ["botToken", "chatId"]
							}
						},
						"required": ["type", "name", "events", "config"]
					}
				]
			},
			"UpdateNotificationChannelInput": {
				"type": "object",
				"properties": {
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 200
					},
					"events": {
						"minItems": 1,
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"domainId": {
						"anyOf": [
							{
								"type": "integer",
								"minimum": 1
							},
							{
								"type": "null"
							}
						]
					},
					"mailboxId": {
						"anyOf": [
							{
								"type": "integer",
								"minimum": 1
							},
							{
								"type": "null"
							}
						]
					},
					"enabled": {
						"type": "boolean"
					},
					"config": {
						"type": "object",
						"additionalProperties": {
							"type": "string"
						}
					}
				}
			},
			"RescheduleEmailInput": {
				"type": "object",
				"properties": {
					"scheduled_at": {
						"anyOf": [
							{
								"type": "string",
								"format": "date-time",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
							},
							{
								"type": "string",
								"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?:Z))$"
							}
						]
					}
				},
				"required": ["scheduled_at"]
			},
			"EmailPreviewInput": {
				"type": "object",
				"properties": {
					"from": {
						"type": "string",
						"minLength": 1
					},
					"to": {
						"minItems": 1,
						"maxItems": 5,
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"subject": {
						"type": "string"
					},
					"html": {
						"type": "string"
					},
					"text": {
						"type": "string"
					},
					"template_id": {
						"type": "string"
					},
					"variables": {
						"type": "object",
						"additionalProperties": {
							"type": "string"
						}
					}
				},
				"required": ["from", "to"]
			},
			"SpamPreviewInput": {
				"type": "object",
				"properties": {
					"from": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"to": {
						"minItems": 1,
						"maxItems": 5,
						"type": "array",
						"items": {
							"type": "string",
							"maxLength": 320,
							"format": "email"
						}
					},
					"subject": {
						"type": "string",
						"minLength": 1,
						"maxLength": 998
					},
					"html": {
						"type": "string"
					},
					"text": {
						"type": "string"
					}
				},
				"required": ["from", "to", "subject"]
			},
			"AssignIpInput": {
				"type": "object",
				"properties": {
					"ipAddressId": {
						"type": "integer",
						"minimum": 1
					}
				},
				"required": ["ipAddressId"]
			},
			"AddSuppressionInput": {
				"type": "object",
				"properties": {
					"email": {
						"type": "string",
						"format": "email"
					},
					"reason": {
						"type": "string",
						"enum": ["hard_bounce", "complaint", "unsubscribe", "manual"]
					}
				},
				"required": ["email", "reason"]
			},
			"ImportSuppressionsInput": {
				"type": "object",
				"properties": {
					"entries": {
						"minItems": 1,
						"maxItems": 10000,
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"email": {
									"type": "string",
									"minLength": 1
								},
								"reason": {
									"default": "manual",
									"type": "string",
									"enum": ["hard_bounce", "complaint", "unsubscribe", "manual"]
								}
							},
							"required": ["email"]
						}
					}
				},
				"required": ["entries"]
			},
			"RenderTemplateInput": {
				"type": "object",
				"properties": {
					"variables": {
						"type": "object",
						"additionalProperties": {
							"type": "string"
						}
					}
				}
			},
			"DraftReplyInput": {
				"type": "object",
				"properties": {
					"tone": {
						"type": "string",
						"enum": ["formal", "friendly", "casual"]
					}
				}
			}
		}
	}
}
