{
	"components": {
		"schemas": {
			"AiLabelRule": {
				"description": "An AI label and the natural-language condition that applies it. Auto-draft and auto-reply are configured here.",
				"properties": {
					"autoDraftEnabled": {
						"type": "boolean"
					},
					"autoReplyConfidenceThreshold": {
						"maximum": 100,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyDelayMinutes": {
						"maximum": 15,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyEnabled": {
						"description": "When true, Maylee sends replies on your behalf. Setting it requires `allowOutboundSend` on the key.",
						"type": "boolean"
					},
					"autoReplyNotifyOnSend": {
						"type": "boolean"
					},
					"condition": {
						"description": "Natural-language condition, up to 500 characters.",
						"type": "string"
					},
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"hideFromInbox": {
						"description": "When true, emails that receive this label leave the main inbox. They stay in INBOX, listable with `GET /emails?filtered=only`, and remain visible in any view whose criteria match them.",
						"type": "boolean"
					},
					"id": {
						"type": "string"
					},
					"label": {
						"$ref": "#/components/schemas/LabelRef"
					},
					"updatedAt": {
						"format": "date-time",
						"type": "string"
					}
				},
				"required": [
					"id",
					"label",
					"condition",
					"autoDraftEnabled",
					"autoReplyEnabled",
					"autoReplyConfidenceThreshold",
					"autoReplyDelayMinutes",
					"autoReplyNotifyOnSend",
					"hideFromInbox",
					"createdAt",
					"updatedAt"
				],
				"type": "object"
			},
			"Attachment": {
				"description": "Storage keys are never exposed; download goes through the dedicated endpoint.",
				"properties": {
					"filename": {
						"type": "string"
					},
					"mimeType": {
						"type": "string"
					},
					"size": {
						"type": "integer"
					}
				},
				"required": [
					"filename",
					"size",
					"mimeType"
				],
				"type": "object"
			},
			"AutoForwardRule": {
				"description": "Forwards matching incoming emails to an address. Managing rules requires `allowOutboundSend` on the key.",
				"properties": {
					"conditionField": {
						"enum": [
							"label",
							"sender_contains",
							"sender_equals",
							"subject_contains",
							"subject_equals"
						],
						"type": "string"
					},
					"conditionValue": {
						"description": "A label name when `conditionField` is `label`, otherwise the text to match, case-insensitively.",
						"type": "string"
					},
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"forwardTo": {
						"format": "email",
						"type": "string"
					},
					"id": {
						"type": "string"
					},
					"isActive": {
						"type": "boolean"
					},
					"mode": {
						"description": "`normal` forwards with the usual `Fwd:` subject and quoted body. `invisible` sends the original as is, with `Reply-To` set to the original sender.",
						"enum": [
							"normal",
							"invisible"
						],
						"type": "string"
					},
					"updatedAt": {
						"format": "date-time",
						"type": "string"
					}
				},
				"required": [
					"id",
					"conditionField",
					"conditionValue",
					"forwardTo",
					"mode",
					"isActive",
					"createdAt",
					"updatedAt"
				],
				"type": "object"
			},
			"BackfillAccepted": {
				"properties": {
					"jobs": {
						"description": "Number of background jobs queued, one per mailbox.",
						"type": "integer"
					},
					"mailboxIds": {
						"items": {
							"type": "string"
						},
						"type": "array"
					}
				},
				"required": [
					"jobs",
					"mailboxIds"
				],
				"type": "object"
			},
			"BackfillRequest": {
				"additionalProperties": false,
				"properties": {
					"limit": {
						"default": 200,
						"description": "Number of most recent INBOX emails to classify, per mailbox.",
						"maximum": 500,
						"minimum": 1,
						"type": "integer"
					},
					"mailboxId": {
						"description": "Only this mailbox. Default: every active mailbox.",
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"BulkDeleteResult": {
				"description": "Outcome of `delete` (move to trash).",
				"properties": {
					"deletedIds": {
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"noTrashIds": {
						"description": "In a mailbox without a trash folder: not moved.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"skippedIds": {
						"description": "Unknown, of another workspace, already deleted or already in the trash.",
						"items": {
							"type": "string"
						},
						"type": "array"
					}
				},
				"required": [
					"deletedIds",
					"skippedIds",
					"noTrashIds"
				],
				"type": "object"
			},
			"BulkLabelResult": {
				"description": "Outcome of `applyLabel` and `removeLabel`.",
				"properties": {
					"emailIds": {
						"description": "Ids of the workspace that were processed, deduplicated.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"labelId": {
						"type": "string"
					},
					"skippedIds": {
						"description": "Unknown ids, or ids of another workspace. Never an error.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"updatedCount": {
						"description": "Labels actually added or removed. An email that already had (or did not have) the label is not counted.",
						"type": "integer"
					}
				},
				"required": [
					"labelId",
					"emailIds",
					"skippedIds",
					"updatedCount"
				],
				"type": "object"
			},
			"BulkMarkReadResult": {
				"description": "Outcome of `markRead`.",
				"properties": {
					"isRead": {
						"type": "boolean"
					},
					"skippedIds": {
						"description": "Unknown ids, or ids of another workspace. Never an error.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"unchangedIds": {
						"description": "Already in the requested state.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"updatedIds": {
						"items": {
							"type": "string"
						},
						"type": "array"
					}
				},
				"required": [
					"updatedIds",
					"unchangedIds",
					"skippedIds"
				],
				"type": "object"
			},
			"CreateAiLabelRule": {
				"additionalProperties": false,
				"properties": {
					"autoDraftEnabled": {
						"description": "Auto-draft: Maylee prepares a reply draft for matching emails, for a person to review. Requires a subscription (`402 PLAN_REQUIRED` otherwise).",
						"type": "boolean"
					},
					"autoReplyConfidenceThreshold": {
						"description": "The reply is sent only when Maylee's confidence reaches this value (0 to 100); otherwise it stays in Drafts for review.",
						"maximum": 100,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyDelayMinutes": {
						"description": "Minutes to wait before sending (0 to 15), so that the user can cancel.",
						"maximum": 15,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyEnabled": {
						"description": "Auto-reply: Maylee sends the draft prepared by auto-draft without review, so it only works together with `autoDraftEnabled`. Requires a subscription and the Send emails permission on the key.",
						"type": "boolean"
					},
					"autoReplyNotifyOnSend": {
						"description": "Stored with the rule. It has no effect today.",
						"type": "boolean"
					},
					"color": {
						"description": "Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color.",
						"type": "string"
					},
					"condition": {
						"description": "Plain-language condition that Maylee checks on every new incoming email, for example \"Invoices, receipts or payment reminders from suppliers\".",
						"maxLength": 500,
						"minLength": 1,
						"type": "string"
					},
					"hideFromInbox": {
						"description": "Emails that receive this label leave the main inbox. They stay in INBOX, listable with `GET /emails?filtered=only`.",
						"type": "boolean"
					},
					"name": {
						"description": "Name of the AI label, unique among all labels of the workspace (manual and AI).",
						"maxLength": 50,
						"minLength": 1,
						"type": "string"
					}
				},
				"required": [
					"name",
					"color",
					"condition"
				],
				"type": "object"
			},
			"CreateApiKey": {
				"additionalProperties": false,
				"properties": {
					"allowOutboundSend": {
						"default": false,
						"type": "boolean"
					},
					"expiresAt": {
						"format": "date-time",
						"type": "string"
					},
					"name": {
						"maxLength": 80,
						"minLength": 1,
						"type": "string"
					},
					"scopes": {
						"items": {
							"enum": [
								"read",
								"write"
							],
							"type": "string"
						},
						"minItems": 1,
						"type": "array"
					}
				},
				"required": [
					"name",
					"scopes"
				],
				"type": "object"
			},
			"CreateAutoForwardRule": {
				"additionalProperties": false,
				"properties": {
					"conditionField": {
						"default": "label",
						"description": "What to match: `label` (an AI label), `sender_contains`, `sender_equals`, `subject_contains` or `subject_equals`.",
						"enum": [
							"label",
							"sender_contains",
							"sender_equals",
							"subject_contains",
							"subject_equals"
						],
						"type": "string"
					},
					"conditionValue": {
						"description": "The name of an AI label when `conditionField` is `label` (rules run when an email arrives, right after AI labeling, so a manual label never triggers them); otherwise the text to match, case-insensitively.",
						"maxLength": 255,
						"minLength": 1,
						"type": "string"
					},
					"forwardTo": {
						"description": "Destination address.",
						"format": "email",
						"maxLength": 255,
						"type": "string"
					},
					"isActive": {
						"default": true,
						"description": "An inactive rule is kept but forwards nothing.",
						"type": "boolean"
					},
					"mode": {
						"default": "normal",
						"description": "`normal` forwards with the usual `Fwd:` subject and quoted body. `invisible` passes the email on unchanged, with `Reply-To` set to the original sender.",
						"enum": [
							"normal",
							"invisible"
						],
						"type": "string"
					}
				},
				"required": [
					"conditionValue",
					"forwardTo"
				],
				"type": "object"
			},
			"CreateDraft": {
				"additionalProperties": false,
				"properties": {
					"bcc": {
						"description": "Each entry is `{ \"email\", \"name\" }`, `name` optional.",
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"body": {
						"additionalProperties": false,
						"description": "`{ \"html\" }`, `{ \"text\" }` or both. `text` feeds the preview snippet.",
						"properties": {
							"html": {
								"type": "string"
							},
							"text": {
								"type": "string"
							}
						},
						"type": "object"
					},
					"cc": {
						"description": "Each entry is `{ \"email\", \"name\" }`, `name` optional.",
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"inReplyTo": {
						"description": "`messageId` of the email you answer, to reply in the same conversation.",
						"maxLength": 998,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"mailboxId": {
						"description": "The mailbox the draft belongs to, and will be sent from. From `GET /mailboxes`.",
						"minLength": 1,
						"type": "string"
					},
					"references": {
						"description": "The answered email's `references` followed by its `messageId`, in that order.",
						"items": {
							"maxLength": 998,
							"pattern": "^[^\\r\\n]*$",
							"type": "string"
						},
						"type": "array"
					},
					"signature": {
						"description": "`default` (or omitted): the signature the user would get in the app for the sending address. `none`: no signature. Otherwise the id of a signature from `GET /signatures` (`SIGNATURE_NOT_FOUND` if it does not exist).",
						"maxLength": 128,
						"minLength": 1,
						"type": "string"
					},
					"subject": {
						"default": "",
						"description": "Defaults to an empty subject. No line breaks.",
						"maxLength": 2000,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"to": {
						"default": [],
						"description": "Optional: the user can add recipients in the app before sending. Each entry is `{ \"email\", \"name\" }`, `name` optional.",
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					}
				},
				"required": [
					"mailboxId",
					"body"
				],
				"type": "object"
			},
			"CreateInboxFilter": {
				"additionalProperties": false,
				"properties": {
					"type": {
						"description": "`sender`: exact address, case-insensitive. `domain`: sender domain such as `acme.com`. `subject`: text contained in the subject, case-insensitive. `label`: id of a label (manual or AI) carried by the email.",
						"enum": [
							"sender",
							"domain",
							"subject",
							"label"
						],
						"type": "string"
					},
					"value": {
						"description": "Address (stored lowercase), domain (stored lowercase, a leading `@` is dropped), subject text, or label id, depending on `type`.",
						"maxLength": 255,
						"minLength": 1,
						"type": "string"
					}
				},
				"required": [
					"type",
					"value"
				],
				"type": "object"
			},
			"CreateLabel": {
				"additionalProperties": false,
				"properties": {
					"color": {
						"description": "Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color.",
						"maxLength": 30,
						"minLength": 1,
						"type": "string"
					},
					"name": {
						"description": "Unique among all labels of the workspace, manual and AI.",
						"maxLength": 50,
						"minLength": 1,
						"type": "string"
					}
				},
				"required": [
					"name",
					"color"
				],
				"type": "object"
			},
			"CreateView": {
				"properties": {
					"filters": {
						"description": "Filter tree in the public DSL, or `{}` for no filter.",
						"oneOf": [
							{
								"$ref": "#/components/schemas/FilterNode"
							},
							{
								"additionalProperties": false,
								"type": "object"
							}
						]
					},
					"icon": {
						"description": "An emoji. No markup.",
						"maxLength": 32,
						"type": [
							"string",
							"null"
						]
					},
					"name": {
						"maxLength": 100,
						"minLength": 1,
						"type": "string"
					}
				},
				"required": [
					"name"
				],
				"type": "object"
			},
			"Email": {
				"description": "One email or draft with its metadata, without its body (see `GET /emails/{emailId}/body`). Maylee labels are not included: they are the `tags` of list items.",
				"properties": {
					"attachments": {
						"description": "Metadata only.",
						"items": {
							"$ref": "#/components/schemas/Attachment"
						},
						"type": "array"
					},
					"bcc": {
						"description": "Present here, absent from list items.",
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"cc": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"date": {
						"format": "date-time",
						"type": "string"
					},
					"folderId": {
						"description": "Folder the email lives in.",
						"type": "string"
					},
					"from": {
						"$ref": "#/components/schemas/EmailAddress"
					},
					"hasAttachments": {
						"type": "boolean"
					},
					"id": {
						"description": "Maylee id of the email.",
						"type": "string"
					},
					"inReplyTo": {
						"description": "RFC `In-Reply-To` header.",
						"type": [
							"string",
							"null"
						]
					},
					"isAutoForward": {
						"description": "Sent automatically by an auto-forward rule.",
						"type": "boolean"
					},
					"isAutoReply": {
						"description": "Sent automatically by Maylee's auto-reply.",
						"type": "boolean"
					},
					"isDraft": {
						"type": "boolean"
					},
					"isRead": {
						"type": "boolean"
					},
					"isStarred": {
						"type": "boolean"
					},
					"labels": {
						"description": "Labels as known by the provider (for example Gmail's `INBOX` or `IMPORTANT`), not Maylee labels.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"mailboxId": {
						"description": "Mailbox the email lives in.",
						"type": "string"
					},
					"messageId": {
						"description": "RFC `Message-ID` header. Needed to reply in the thread.",
						"type": "string"
					},
					"references": {
						"description": "RFC `References` header.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"scheduledSendAt": {
						"description": "For a scheduled draft: when it will be sent. `null` otherwise.",
						"format": "date-time",
						"type": [
							"string",
							"null"
						]
					},
					"scheduledStatus": {
						"description": "For a scheduled draft: its sending state. `null` otherwise.",
						"type": [
							"string",
							"null"
						]
					},
					"snippet": {
						"description": "Short text preview.",
						"type": "string"
					},
					"subject": {
						"type": "string"
					},
					"threadId": {
						"description": "Provider conversation id, when the provider has one.",
						"type": [
							"string",
							"null"
						]
					},
					"to": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"waitingForReply": {
						"description": "On an email you sent: Maylee estimates that it still expects an answer.",
						"type": "boolean"
					}
				},
				"type": "object"
			},
			"EmailAddress": {
				"properties": {
					"email": {
						"format": "email",
						"type": "string"
					},
					"name": {
						"type": [
							"string",
							"null"
						]
					}
				},
				"required": [
					"email"
				],
				"type": "object"
			},
			"EmailBody": {
				"properties": {
					"emailId": {
						"type": "string"
					},
					"html": {
						"description": "HTML body of the requested email. May be absent.",
						"type": "string"
					},
					"text": {
						"description": "Plain-text body of the requested email. May be absent.",
						"type": "string"
					},
					"thread": {
						"description": "Every message of the conversation, oldest first, including messages you sent and any draft in progress. Bounded to the mailbox the email lives in.",
						"items": {
							"$ref": "#/components/schemas/ThreadMessage"
						},
						"type": "array"
					}
				},
				"required": [
					"emailId",
					"thread"
				],
				"type": "object"
			},
			"EmailListItem": {
				"description": "Email as returned in list responses. Never includes storage keys or internal AI fields.",
				"properties": {
					"attachments": {
						"description": "Metadata only.",
						"items": {
							"$ref": "#/components/schemas/Attachment"
						},
						"type": "array"
					},
					"cc": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"date": {
						"format": "date-time",
						"type": "string"
					},
					"folderId": {
						"description": "Folder the email lives in.",
						"type": "string"
					},
					"from": {
						"$ref": "#/components/schemas/EmailAddress"
					},
					"hasAttachments": {
						"type": "boolean"
					},
					"id": {
						"description": "Maylee id of the email.",
						"type": "string"
					},
					"inReplyTo": {
						"description": "RFC `In-Reply-To` header.",
						"type": [
							"string",
							"null"
						]
					},
					"isDraft": {
						"type": "boolean"
					},
					"isRead": {
						"type": "boolean"
					},
					"isStarred": {
						"type": "boolean"
					},
					"mailboxId": {
						"description": "Mailbox the email lives in.",
						"type": "string"
					},
					"messageId": {
						"description": "RFC `Message-ID` header. Needed to reply in the thread.",
						"type": "string"
					},
					"references": {
						"description": "RFC `References` header.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"snippet": {
						"description": "Short text preview.",
						"type": "string"
					},
					"subject": {
						"type": "string"
					},
					"tags": {
						"description": "Maylee labels applied to the email, manual and AI.",
						"items": {
							"$ref": "#/components/schemas/LabelRef"
						},
						"type": "array"
					},
					"threadId": {
						"description": "Provider conversation id, when the provider has one.",
						"type": [
							"string",
							"null"
						]
					},
					"to": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"waitingForReply": {
						"description": "On an email you sent: Maylee estimates that it still expects an answer.",
						"type": "boolean"
					}
				},
				"type": "object"
			},
			"Error": {
				"properties": {
					"code": {
						"description": "Machine-readable error code. Branch on this, never on `error`.",
						"type": "string"
					},
					"details": {
						"additionalProperties": true,
						"type": "object"
					},
					"error": {
						"description": "Human-readable message.",
						"type": "string"
					}
				},
				"required": [
					"code",
					"error"
				],
				"type": "object"
			},
			"FilterNode": {
				"description": "A condition, or a group of nodes combined with `_and` / `_or`. See the Filters page for fields, operators and bounds.",
				"oneOf": [
					{
						"properties": {
							"id": {
								"description": "Client-side node id.",
								"type": "string"
							},
							"label": {
								"description": "The field to filter on.",
								"enum": [
									"mailbox",
									"label",
									"ai_label",
									"keyword_subject",
									"sender_address",
									"sender_domain",
									"date",
									"read_status",
									"has_attachment"
								],
								"type": "string"
							},
							"type": {
								"description": "The operator, valid for the field.",
								"enum": [
									"is",
									"is_not",
									"contains",
									"not_contains",
									"equals",
									"before",
									"after",
									"between",
									"is_true",
									"is_false"
								],
								"type": "string"
							},
							"value": {
								"type": "string"
							}
						},
						"required": [
							"id",
							"label",
							"type",
							"value"
						],
						"type": "object"
					},
					{
						"properties": {
							"_and": {
								"items": {
									"$ref": "#/components/schemas/FilterNode"
								},
								"type": "array"
							},
							"_or": {
								"items": {
									"$ref": "#/components/schemas/FilterNode"
								},
								"type": "array"
							},
							"id": {
								"type": "string"
							}
						},
						"required": [
							"id"
						],
						"type": "object"
					}
				]
			},
			"ForwardLog": {
				"description": "One forwarding attempt of a rule.",
				"properties": {
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"destination": {
						"format": "email",
						"type": "string"
					},
					"email": {
						"properties": {
							"date": {
								"format": "date-time",
								"type": "string"
							},
							"from": {
								"$ref": "#/components/schemas/EmailAddress"
							},
							"id": {
								"type": "string"
							},
							"subject": {
								"type": "string"
							}
						},
						"required": [
							"id",
							"subject",
							"from",
							"date"
						],
						"type": "object"
					},
					"emailId": {
						"type": "string"
					},
					"error": {
						"type": [
							"string",
							"null"
						]
					},
					"forwardedMessageId": {
						"type": [
							"string",
							"null"
						]
					},
					"id": {
						"type": "string"
					},
					"mode": {
						"enum": [
							"normal",
							"invisible"
						],
						"type": "string"
					},
					"status": {
						"enum": [
							"sent",
							"failed"
						],
						"type": "string"
					}
				},
				"required": [
					"id",
					"emailId",
					"destination",
					"mode",
					"status",
					"error",
					"forwardedMessageId",
					"createdAt",
					"email"
				],
				"type": "object"
			},
			"InboxFilter": {
				"description": "Hides matching emails from the main inbox without moving them. Evaluated when listing, so it applies to past emails too and is undone by deleting the filter.",
				"properties": {
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"id": {
						"type": "string"
					},
					"label": {
						"description": "The targeted label when `type` is `label`, null otherwise.",
						"oneOf": [
							{
								"$ref": "#/components/schemas/LabelRef"
							},
							{
								"type": "null"
							}
						]
					},
					"type": {
						"description": "`sender`: exact address, case-insensitive. `domain`: sender domain such as `acme.com`. `subject`: text contained in the subject. `label`: id of a label (manual or AI) carried by the email.",
						"enum": [
							"sender",
							"domain",
							"subject",
							"label"
						],
						"type": "string"
					},
					"updatedAt": {
						"format": "date-time",
						"type": "string"
					},
					"value": {
						"type": "string"
					}
				},
				"required": [
					"id",
					"type",
					"value",
					"label",
					"createdAt",
					"updatedAt"
				],
				"type": "object"
			},
			"Label": {
				"properties": {
					"color": {
						"description": "Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color.",
						"type": "string"
					},
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"id": {
						"type": "string"
					},
					"isAiLabel": {
						"description": "True when the label is applied by the AI pipeline rather than a human. AI labels are managed through `/ai-label-rules`.",
						"type": "boolean"
					},
					"name": {
						"type": "string"
					}
				},
				"required": [
					"id",
					"name",
					"color",
					"isAiLabel",
					"createdAt"
				],
				"type": "object"
			},
			"LabelRef": {
				"description": "A label as it appears on an email or on a rule.",
				"properties": {
					"color": {
						"description": "Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color.",
						"type": "string"
					},
					"id": {
						"type": "string"
					},
					"isAiLabel": {
						"type": "boolean"
					},
					"name": {
						"type": "string"
					}
				},
				"required": [
					"id",
					"name",
					"color",
					"isAiLabel"
				],
				"type": "object"
			},
			"Mailbox": {
				"description": "Credentials and OAuth tokens are never exposed.",
				"properties": {
					"backwardSyncComplete": {
						"type": "boolean"
					},
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"email": {
						"format": "email",
						"type": "string"
					},
					"id": {
						"type": "string"
					},
					"isActive": {
						"type": "boolean"
					},
					"lastSyncAt": {
						"type": [
							"string",
							"null"
						]
					},
					"name": {
						"type": [
							"string",
							"null"
						]
					},
					"picture": {
						"type": [
							"string",
							"null"
						]
					},
					"provider": {
						"type": "string"
					},
					"syncError": {
						"type": [
							"string",
							"null"
						]
					}
				},
				"type": "object"
			},
			"SendEmail": {
				"additionalProperties": false,
				"properties": {
					"bcc": {
						"description": "Each entry is `{ \"email\", \"name\" }`, `name` optional.",
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"body": {
						"additionalProperties": false,
						"description": "`{ \"html\" }`, `{ \"text\" }` or both.",
						"properties": {
							"html": {
								"type": "string"
							},
							"text": {
								"type": "string"
							}
						},
						"type": "object"
					},
					"cc": {
						"description": "Each entry is `{ \"email\", \"name\" }`, `name` optional.",
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"from": {
						"additionalProperties": false,
						"description": "Optional send-as alias. It must be a verified alias of the mailbox; otherwise the send is refused (`INVALID_SENDER_ALIAS`) rather than rewritten by the provider.",
						"properties": {
							"email": {
								"format": "email",
								"type": "string"
							},
							"name": {
								"type": "string"
							}
						},
						"required": [
							"email"
						],
						"type": "object"
					},
					"inReplyTo": {
						"description": "`messageId` of the email you answer, to reply in the same conversation.",
						"maxLength": 998,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"mailboxId": {
						"description": "The sending mailbox, from `GET /mailboxes`.",
						"minLength": 1,
						"type": "string"
					},
					"references": {
						"description": "The answered email's `references` followed by its `messageId`, in that order.",
						"items": {
							"maxLength": 998,
							"pattern": "^[^\\r\\n]*$",
							"type": "string"
						},
						"type": "array"
					},
					"signature": {
						"description": "`default` (or omitted): the signature the user would get in the app for the sending address. `none`: no signature. Otherwise the id of a signature from `GET /signatures` (`SIGNATURE_NOT_FOUND` if it does not exist).",
						"maxLength": 128,
						"minLength": 1,
						"type": "string"
					},
					"subject": {
						"default": "",
						"description": "Defaults to an empty subject. No line breaks.",
						"maxLength": 2000,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"to": {
						"description": "At least one recipient. Each entry is `{ \"email\", \"name\" }`, `name` optional.",
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"minItems": 1,
						"type": "array"
					}
				},
				"required": [
					"mailboxId",
					"to",
					"body"
				],
				"type": "object"
			},
			"SendResult": {
				"properties": {
					"messageId": {
						"description": "RFC `Message-ID` of the email that was sent.",
						"type": "string"
					},
					"threadId": {
						"description": "Provider conversation id, when the provider exposes one.",
						"type": [
							"string",
							"null"
						]
					}
				},
				"required": [
					"messageId",
					"threadId"
				],
				"type": "object"
			},
			"Signature": {
				"description": "The content is never returned: the server assembles the body at send time, so a caller only ever names a signature. `mailboxId` and `aliasEmail` both null means it is available from any address.",
				"properties": {
					"aliasEmail": {
						"type": [
							"string",
							"null"
						]
					},
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"id": {
						"type": "string"
					},
					"isDefault": {
						"description": "The one applied when a send does not ask for another.",
						"type": "boolean"
					},
					"mailboxId": {
						"type": [
							"string",
							"null"
						]
					},
					"name": {
						"type": "string"
					},
					"position": {
						"type": "integer"
					},
					"updatedAt": {
						"format": "date-time",
						"type": "string"
					}
				},
				"required": [
					"id",
					"name",
					"isDefault",
					"position"
				],
				"type": "object"
			},
			"ThreadMessage": {
				"description": "One message of a conversation, with its body. Only the fields listed here are part of the contract.",
				"properties": {
					"bccAddresses": {
						"description": "Only on messages you sent and on drafts. May be absent.",
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"ccAddresses": {
						"description": "May be absent.",
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"date": {
						"format": "date-time",
						"type": "string"
					},
					"fromAddress": {
						"type": "string"
					},
					"fromName": {
						"description": "May be absent.",
						"type": "string"
					},
					"html": {
						"description": "HTML body. May be absent.",
						"type": "string"
					},
					"id": {
						"description": "Maylee id. Use it with `GET /emails/{emailId}` for the full metadata.",
						"type": "string"
					},
					"isAutoForward": {
						"description": "Present only when `true`.",
						"type": "boolean"
					},
					"isAutoReply": {
						"description": "Present only when `true`.",
						"type": "boolean"
					},
					"isDraft": {
						"description": "A draft in progress in this conversation. Present only when `true`.",
						"type": "boolean"
					},
					"isMe": {
						"description": "`true` when the message was sent from the mailbox itself.",
						"type": "boolean"
					},
					"mailboxId": {
						"type": "string"
					},
					"messageId": {
						"description": "RFC `Message-ID` header.",
						"type": "string"
					},
					"references": {
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"subject": {
						"type": "string"
					},
					"text": {
						"description": "Plain-text body. May be absent.",
						"type": "string"
					},
					"toAddresses": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					}
				},
				"required": [
					"id",
					"messageId",
					"fromAddress",
					"toAddresses",
					"date",
					"subject",
					"isMe"
				],
				"type": "object"
			},
			"UpdateAiLabelRule": {
				"additionalProperties": false,
				"properties": {
					"autoDraftEnabled": {
						"description": "Auto-draft: Maylee prepares a reply draft for matching emails, for a person to review. Requires a subscription (`402 PLAN_REQUIRED` otherwise).",
						"type": "boolean"
					},
					"autoReplyConfidenceThreshold": {
						"description": "The reply is sent only when Maylee's confidence reaches this value (0 to 100); otherwise it stays in Drafts for review.",
						"maximum": 100,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyDelayMinutes": {
						"description": "Minutes to wait before sending (0 to 15), so that the user can cancel.",
						"maximum": 15,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyEnabled": {
						"description": "Auto-reply: Maylee sends the draft prepared by auto-draft without review, so it only works together with `autoDraftEnabled`. Requires a subscription and the Send emails permission on the key.",
						"type": "boolean"
					},
					"autoReplyNotifyOnSend": {
						"description": "Stored with the rule. It has no effect today.",
						"type": "boolean"
					},
					"color": {
						"description": "Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color.",
						"type": "string"
					},
					"condition": {
						"description": "Plain-language condition that Maylee checks on every new incoming email, for example \"Invoices, receipts or payment reminders from suppliers\".",
						"maxLength": 500,
						"type": "string"
					},
					"hideFromInbox": {
						"description": "Emails that receive this label leave the main inbox. They stay in INBOX, listable with `GET /emails?filtered=only`.",
						"type": "boolean"
					},
					"name": {
						"description": "Name of the AI label, unique among all labels of the workspace (manual and AI).",
						"maxLength": 50,
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"UpdateApiKey": {
				"additionalProperties": false,
				"properties": {
					"allowOutboundSend": {
						"type": "boolean"
					},
					"name": {
						"maxLength": 80,
						"minLength": 1,
						"type": "string"
					},
					"scopes": {
						"items": {
							"enum": [
								"read",
								"write"
							],
							"type": "string"
						},
						"minItems": 1,
						"type": "array"
					}
				},
				"type": "object"
			},
			"UpdateAutoForwardRule": {
				"additionalProperties": false,
				"properties": {
					"conditionField": {
						"description": "What to match: `label` (an AI label), `sender_contains`, `sender_equals`, `subject_contains` or `subject_equals`.",
						"enum": [
							"label",
							"sender_contains",
							"sender_equals",
							"subject_contains",
							"subject_equals"
						],
						"type": "string"
					},
					"conditionValue": {
						"description": "The name of an AI label when `conditionField` is `label` (rules run when an email arrives, right after AI labeling, so a manual label never triggers them); otherwise the text to match, case-insensitively.",
						"maxLength": 255,
						"type": "string"
					},
					"forwardTo": {
						"anyOf": [
							{
								"format": "email",
								"maxLength": 255,
								"type": "string"
							},
							{
								"enum": [
									""
								],
								"type": "string"
							}
						],
						"description": "Destination address."
					},
					"isActive": {
						"description": "An inactive rule is kept but forwards nothing.",
						"type": "boolean"
					},
					"mode": {
						"description": "`normal` forwards with the usual `Fwd:` subject and quoted body. `invisible` passes the email on unchanged, with `Reply-To` set to the original sender.",
						"enum": [
							"normal",
							"invisible"
						],
						"type": "string"
					}
				},
				"type": "object"
			},
			"UpdateInboxFilter": {
				"additionalProperties": false,
				"properties": {
					"type": {
						"description": "`sender`: exact address, case-insensitive. `domain`: sender domain such as `acme.com`. `subject`: text contained in the subject, case-insensitive. `label`: id of a label (manual or AI) carried by the email.",
						"enum": [
							"sender",
							"domain",
							"subject",
							"label"
						],
						"type": "string"
					},
					"value": {
						"description": "Address (stored lowercase), domain (stored lowercase, a leading `@` is dropped), subject text, or label id, depending on `type`.",
						"maxLength": 255,
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"UpdateLabel": {
				"additionalProperties": false,
				"properties": {
					"color": {
						"description": "Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color.",
						"maxLength": 30,
						"minLength": 1,
						"type": "string"
					},
					"name": {
						"description": "Unique among all labels of the workspace, manual and AI.",
						"maxLength": 50,
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"UpdateView": {
				"description": "At least one field is required.",
				"properties": {
					"filters": {
						"description": "Filter tree in the public DSL, or `{}` for no filter.",
						"oneOf": [
							{
								"$ref": "#/components/schemas/FilterNode"
							},
							{
								"additionalProperties": false,
								"type": "object"
							}
						]
					},
					"icon": {
						"maxLength": 32,
						"type": [
							"string",
							"null"
						]
					},
					"name": {
						"maxLength": 100,
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"View": {
				"properties": {
					"createdAt": {
						"format": "date-time",
						"type": "string"
					},
					"filters": {
						"description": "Filter tree in the public DSL, or `{}` for no filter.",
						"oneOf": [
							{
								"$ref": "#/components/schemas/FilterNode"
							},
							{
								"additionalProperties": false,
								"type": "object"
							}
						]
					},
					"icon": {
						"type": [
							"string",
							"null"
						]
					},
					"id": {
						"type": "string"
					},
					"mailboxIds": {
						"description": "Mailboxes the view is restricted to. Empty means all.",
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"name": {
						"type": "string"
					}
				},
				"required": [
					"id",
					"name",
					"icon",
					"filters",
					"mailboxIds",
					"createdAt"
				],
				"type": "object"
			}
		},
		"securitySchemes": {
			"apiKey": {
				"description": "Send your key as `Authorization: Bearer mk_…`. Session cookies are never accepted on this surface.",
				"scheme": "bearer",
				"type": "http"
			}
		}
	},
	"externalDocs": {
		"description": "Guides, API reference and MCP server documentation",
		"url": "https://docs.maylee.app"
	},
	"info": {
		"description": "Programmatic access to a Maylee workspace: read, classify, and send email.\n\nEvery endpoint is scoped to the workspace that owns the API key. No path\ncarries a workspace identifier, so a key can only ever reach its own data.\n\nQuery complexity is bounded: filter trees are capped at 5 levels\nand 50 conditions, values at 500 characters,\nand every read is cancelled server-side after 10000ms.",
		"title": "Maylee API",
		"version": "1.0.0"
	},
	"openapi": "3.1.0",
	"paths": {
		"/ai-label-rules": {
			"get": {
				"operationId": "listAiLabelRules",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"autoDraftEnabled": true,
											"autoReplyConfidenceThreshold": 85,
											"autoReplyDelayMinutes": 0,
											"autoReplyEnabled": false,
											"autoReplyNotifyOnSend": true,
											"condition": "The sender asks about pricing, a quote or a demo of our product.",
											"createdAt": "2026-06-03T08:00:00.000Z",
											"hideFromInbox": false,
											"id": "cmrl1a2b3c4d5e6f7g8h9i0j",
											"label": {
												"color": "Blue",
												"id": "cmtgai1b2c3d4e5f6g7h8i9j",
												"isAiLabel": true,
												"name": "Sales"
											},
											"updatedAt": "2026-08-20T16:40:00.000Z"
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/AiLabelRule"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Rules with their label."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List AI label rules",
				"tags": [
					"AI label rules"
				],
				"x-scope": "read"
			},
			"post": {
				"description": "Creates the AI label and the natural-language condition that applies it, in one call.\n\nSetting `autoReplyEnabled: true` lets Maylee send replies on your behalf: it requires `allowOutboundSend` on the key, like sending an email does.",
				"operationId": "createAiLabelRule",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"color": "Green",
								"condition": "The email is an invoice, a receipt or a payment confirmation from a supplier.",
								"hideFromInbox": true,
								"name": "Invoices"
							},
							"schema": {
								"$ref": "#/components/schemas/CreateAiLabelRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"rule": {
										"autoDraftEnabled": true,
										"autoReplyConfidenceThreshold": 85,
										"autoReplyDelayMinutes": 0,
										"autoReplyEnabled": false,
										"autoReplyNotifyOnSend": true,
										"condition": "The sender asks about pricing, a quote or a demo of our product.",
										"createdAt": "2026-06-03T08:00:00.000Z",
										"hideFromInbox": false,
										"id": "cmrl1a2b3c4d5e6f7g8h9i0j",
										"label": {
											"color": "Blue",
											"id": "cmtgai1b2c3d4e5f6g7h8i9j",
											"isAiLabel": true,
											"name": "Sales"
										},
										"updatedAt": "2026-08-20T16:40:00.000Z"
									}
								},
								"schema": {
									"properties": {
										"rule": {
											"$ref": "#/components/schemas/AiLabelRule"
										}
									},
									"required": [
										"rule"
									],
									"type": "object"
								}
							}
						},
						"description": "Created."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`DUPLICATE_RULE`: an AI label with this name already exists."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Create an AI label rule",
				"tags": [
					"AI label rules"
				],
				"x-requires": "allowOutboundSend when autoReplyEnabled is true",
				"x-scope": "write"
			}
		},
		"/ai-label-rules/{ruleId}": {
			"delete": {
				"description": "Deletes the rule and its label, and removes the label from every email that carried it.",
				"operationId": "deleteAiLabelRule",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Deleted."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Delete an AI label rule",
				"tags": [
					"AI label rules"
				],
				"x-scope": "write"
			},
			"get": {
				"operationId": "getAiLabelRule",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"rule": {
										"autoDraftEnabled": true,
										"autoReplyConfidenceThreshold": 85,
										"autoReplyDelayMinutes": 0,
										"autoReplyEnabled": false,
										"autoReplyNotifyOnSend": true,
										"condition": "The sender asks about pricing, a quote or a demo of our product.",
										"createdAt": "2026-06-03T08:00:00.000Z",
										"hideFromInbox": false,
										"id": "cmrl1a2b3c4d5e6f7g8h9i0j",
										"label": {
											"color": "Blue",
											"id": "cmtgai1b2c3d4e5f6g7h8i9j",
											"isAiLabel": true,
											"name": "Sales"
										},
										"updatedAt": "2026-08-20T16:40:00.000Z"
									}
								},
								"schema": {
									"properties": {
										"rule": {
											"$ref": "#/components/schemas/AiLabelRule"
										}
									},
									"required": [
										"rule"
									],
									"type": "object"
								}
							}
						},
						"description": "The rule."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get an AI label rule",
				"tags": [
					"AI label rules"
				],
				"x-scope": "read"
			},
			"patch": {
				"description": "Renames the label, changes the condition, or configures auto-draft and auto-reply. Setting `autoReplyEnabled: true` requires `allowOutboundSend` on the key.",
				"operationId": "updateAiLabelRule",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"autoDraftEnabled": true
							},
							"schema": {
								"$ref": "#/components/schemas/UpdateAiLabelRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"rule": {
										"autoDraftEnabled": true,
										"autoReplyConfidenceThreshold": 85,
										"autoReplyDelayMinutes": 0,
										"autoReplyEnabled": false,
										"autoReplyNotifyOnSend": true,
										"condition": "The sender asks about pricing, a quote or a demo of our product.",
										"createdAt": "2026-06-03T08:00:00.000Z",
										"hideFromInbox": false,
										"id": "cmrl1a2b3c4d5e6f7g8h9i0j",
										"label": {
											"color": "Blue",
											"id": "cmtgai1b2c3d4e5f6g7h8i9j",
											"isAiLabel": true,
											"name": "Sales"
										},
										"updatedAt": "2026-08-20T16:40:00.000Z"
									}
								},
								"schema": {
									"properties": {
										"rule": {
											"$ref": "#/components/schemas/AiLabelRule"
										}
									},
									"required": [
										"rule"
									],
									"type": "object"
								}
							}
						},
						"description": "The updated rule."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid or empty payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`DUPLICATE_RULE`: an AI label with this name already exists."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Update an AI label rule",
				"tags": [
					"AI label rules"
				],
				"x-requires": "allowOutboundSend when autoReplyEnabled is true",
				"x-scope": "write"
			}
		},
		"/ai-label-rules/backfill": {
			"post": {
				"description": "Rules only apply to emails synchronized after their creation. This queues one background job per active mailbox (or the given one) that classifies the `limit` most recent INBOX emails with every rule of the workspace.\n\nLabels land asynchronously: they appear in the `tags` of each email once it is classified. A backfill applies labels and nothing else: no auto-forward, auto-draft or auto-reply is triggered. Each classified email costs one model call.",
				"operationId": "classifyExistingEmails",
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"limit": 200
							},
							"schema": {
								"$ref": "#/components/schemas/BackfillRequest"
							}
						}
					},
					"required": false
				},
				"responses": {
					"202": {
						"content": {
							"application/json": {
								"example": {
									"jobs": 1,
									"mailboxIds": [
										"cmbx1a2b3c4d5e6f7g8h9i0j"
									]
								},
								"schema": {
									"$ref": "#/components/schemas/BackfillAccepted"
								}
							}
						},
						"description": "Jobs queued."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload, or the workspace has no AI label rule."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`MAILBOX_NOT_FOUND`: the mailbox is not in this workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Classify existing emails with the AI label rules",
				"tags": [
					"AI label rules"
				],
				"x-scope": "write"
			}
		},
		"/auto-forward-rules": {
			"get": {
				"operationId": "listAutoForwardRules",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"conditionField": "label",
											"conditionValue": "Invoices",
											"createdAt": "2026-08-01T09:00:00.000Z",
											"forwardTo": "accounting@your-company.com",
											"id": "cmaf1a2b3c4d5e6f7g8h9i0j",
											"isActive": true,
											"mode": "normal",
											"updatedAt": "2026-08-01T09:00:00.000Z"
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/AutoForwardRule"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Rules."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List auto-forward rules",
				"tags": [
					"Auto-forward rules"
				],
				"x-scope": "read"
			},
			"post": {
				"description": "Forwards every incoming email matching the condition to `forwardTo`.\n\nA rule makes email leave the workspace: creating, changing or deleting one requires `allowOutboundSend` on the key, like sending does. A key with `write` alone gets `403 OUTBOUND_SEND_NOT_ALLOWED`.",
				"operationId": "createAutoForwardRule",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"conditionField": "label",
								"conditionValue": "Invoices",
								"forwardTo": "accounting@your-company.com",
								"mode": "normal"
							},
							"schema": {
								"$ref": "#/components/schemas/CreateAutoForwardRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"rule": {
										"conditionField": "label",
										"conditionValue": "Invoices",
										"createdAt": "2026-08-01T09:00:00.000Z",
										"forwardTo": "accounting@your-company.com",
										"id": "cmaf1a2b3c4d5e6f7g8h9i0j",
										"isActive": true,
										"mode": "normal",
										"updatedAt": "2026-08-01T09:00:00.000Z"
									}
								},
								"schema": {
									"properties": {
										"rule": {
											"$ref": "#/components/schemas/AutoForwardRule"
										}
									},
									"required": [
										"rule"
									],
									"type": "object"
								}
							}
						},
						"description": "Created."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload: `forwardTo` must be an email address, `conditionValue` must not be empty."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Create an auto-forward rule",
				"tags": [
					"Auto-forward rules"
				],
				"x-requires": "allowOutboundSend",
				"x-scope": "write"
			}
		},
		"/auto-forward-rules/{ruleId}": {
			"delete": {
				"description": "Requires `allowOutboundSend` on the key.",
				"operationId": "deleteAutoForwardRule",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Deleted."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Delete an auto-forward rule",
				"tags": [
					"Auto-forward rules"
				],
				"x-requires": "allowOutboundSend",
				"x-scope": "write"
			},
			"get": {
				"operationId": "getAutoForwardRule",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"rule": {
										"conditionField": "label",
										"conditionValue": "Invoices",
										"createdAt": "2026-08-01T09:00:00.000Z",
										"forwardTo": "accounting@your-company.com",
										"id": "cmaf1a2b3c4d5e6f7g8h9i0j",
										"isActive": true,
										"mode": "normal",
										"updatedAt": "2026-08-01T09:00:00.000Z"
									}
								},
								"schema": {
									"properties": {
										"rule": {
											"$ref": "#/components/schemas/AutoForwardRule"
										}
									},
									"required": [
										"rule"
									],
									"type": "object"
								}
							}
						},
						"description": "The rule."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get an auto-forward rule",
				"tags": [
					"Auto-forward rules"
				],
				"x-scope": "read"
			},
			"patch": {
				"description": "Requires `allowOutboundSend` on the key. At least one field is required; `forwardTo` and `conditionValue` cannot be emptied.",
				"operationId": "updateAutoForwardRule",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"isActive": false
							},
							"schema": {
								"$ref": "#/components/schemas/UpdateAutoForwardRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"rule": {
										"conditionField": "label",
										"conditionValue": "Invoices",
										"createdAt": "2026-08-01T09:00:00.000Z",
										"forwardTo": "accounting@your-company.com",
										"id": "cmaf1a2b3c4d5e6f7g8h9i0j",
										"isActive": true,
										"mode": "normal",
										"updatedAt": "2026-08-01T09:00:00.000Z"
									}
								},
								"schema": {
									"properties": {
										"rule": {
											"$ref": "#/components/schemas/AutoForwardRule"
										}
									},
									"required": [
										"rule"
									],
									"type": "object"
								}
							}
						},
						"description": "The updated rule."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid or empty payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Update an auto-forward rule",
				"tags": [
					"Auto-forward rules"
				],
				"x-requires": "allowOutboundSend",
				"x-scope": "write"
			}
		},
		"/auto-forward-rules/{ruleId}/logs": {
			"get": {
				"description": "The 50 most recent attempts, newest first, with the email that triggered each one. In-flight attempts are not listed.",
				"operationId": "listAutoForwardRuleLogs",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"createdAt": "2026-08-26T08:15:12.000Z",
											"destination": "accounting@your-company.com",
											"email": {
												"date": "2026-08-26T08:15:02.000Z",
												"from": {
													"email": "billing@supplier.example",
													"name": "Supplier Billing"
												},
												"id": "cmemy2b3c4d5e6f7g8h9i0j1",
												"subject": "Invoice #2026-0142"
											},
											"emailId": "cmemy2b3c4d5e6f7g8h9i0j1",
											"error": null,
											"forwardedMessageId": "<20260826081512.4d5e6f@your-company.com>",
											"id": "cmfw1a2b3c4d5e6f7g8h9i0j",
											"mode": "normal",
											"status": "sent"
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/ForwardLog"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Attempts."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List the forwarding attempts of a rule",
				"tags": [
					"Auto-forward rules"
				],
				"x-scope": "read"
			}
		},
		"/drafts": {
			"get": {
				"description": "The most recent drafts of the workspace, up to `limit`. Not paginated.",
				"operationId": "listDrafts",
				"parameters": [
					{
						"description": "Page size. Values above 200 are clamped.",
						"in": "query",
						"name": "limit",
						"schema": {
							"default": 50,
							"maximum": 200,
							"minimum": 1,
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"attachments": [],
											"bcc": [],
											"cc": [],
											"date": "2026-08-25T14:05:40.000Z",
											"folderId": "cmfd9z8y7x6w5v4u3t2s1r0q",
											"from": {
												"email": "contact@your-company.com",
												"name": null
											},
											"hasAttachments": false,
											"id": "cmdr1a2b3c4d5e6f7g8h9i0j",
											"inReplyTo": "<CAF3k9x1@mail.example.com>",
											"isAutoForward": false,
											"isAutoReply": false,
											"isDraft": true,
											"isRead": true,
											"isStarred": false,
											"labels": [
												"\\Draft"
											],
											"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
											"messageId": "draft-5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13@local",
											"references": [
												"<CAF3k9x1@mail.example.com>"
											],
											"scheduledSendAt": null,
											"scheduledStatus": null,
											"snippet": "Hello Jane, here is the quote you asked for.",
											"subject": "Re: Quote request",
											"threadId": "18c2f5a9e7b1d3c4",
											"to": [
												{
													"email": "client@acme.com",
													"name": "Jane Client"
												}
											],
											"waitingForReply": false
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/Email"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "The workspace drafts."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List drafts",
				"tags": [
					"Drafts"
				],
				"x-scope": "read"
			},
			"post": {
				"description": "Creates a draft in one of the workspace mailboxes without sending it. The draft shows up\nimmediately in the Maylee app, where a person reviews it, edits it and sends it: this is\nthe way to prepare an email from an integration or an agent while keeping a human in the loop.\n\nNothing leaves the workspace, so the `write` scope is enough: `allowOutboundSend` is not\nrequired. Attachments cannot be added through the API.",
				"operationId": "createDraft",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"body": {
									"text": "Hello Jane, here is the quote you asked for."
								},
								"inReplyTo": "<CAF3k9x1@mail.example.com>",
								"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
								"references": [
									"<CAF3k9x1@mail.example.com>"
								],
								"subject": "Re: Quote request",
								"to": [
									{
										"email": "client@acme.com",
										"name": "Jane Client"
									}
								]
							},
							"schema": {
								"$ref": "#/components/schemas/CreateDraft"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"draft": {
										"attachments": [],
										"bcc": [],
										"cc": [],
										"date": "2026-08-25T14:05:40.000Z",
										"folderId": "cmfd9z8y7x6w5v4u3t2s1r0q",
										"from": {
											"email": "contact@your-company.com",
											"name": null
										},
										"hasAttachments": false,
										"id": "cmdr1a2b3c4d5e6f7g8h9i0j",
										"inReplyTo": "<CAF3k9x1@mail.example.com>",
										"isAutoForward": false,
										"isAutoReply": false,
										"isDraft": true,
										"isRead": true,
										"isStarred": false,
										"labels": [
											"\\Draft"
										],
										"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
										"messageId": "draft-5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13@local",
										"references": [
											"<CAF3k9x1@mail.example.com>"
										],
										"scheduledSendAt": null,
										"scheduledStatus": null,
										"snippet": "Hello Jane, here is the quote you asked for.",
										"subject": "Re: Quote request",
										"threadId": "18c2f5a9e7b1d3c4",
										"to": [
											{
												"email": "client@acme.com",
												"name": "Jane Client"
											}
										],
										"waitingForReply": false
									}
								},
								"schema": {
									"properties": {
										"draft": {
											"$ref": "#/components/schemas/Email"
										}
									},
									"required": [
										"draft"
									],
									"type": "object"
								}
							}
						},
						"description": "Created. `draft` is the same object `GET /drafts/{draftId}` returns."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Mailbox not found. Call `GET /mailboxes` for valid ids."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Idempotency key reused with a different body, or original call still in flight."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Create a draft",
				"tags": [
					"Drafts"
				],
				"x-scope": "write"
			}
		},
		"/drafts/{draftId}": {
			"get": {
				"operationId": "getDraft",
				"parameters": [
					{
						"in": "path",
						"name": "draftId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"draft": {
										"attachments": [],
										"bcc": [],
										"cc": [],
										"date": "2026-08-25T14:05:40.000Z",
										"folderId": "cmfd9z8y7x6w5v4u3t2s1r0q",
										"from": {
											"email": "contact@your-company.com",
											"name": null
										},
										"hasAttachments": false,
										"id": "cmdr1a2b3c4d5e6f7g8h9i0j",
										"inReplyTo": "<CAF3k9x1@mail.example.com>",
										"isAutoForward": false,
										"isAutoReply": false,
										"isDraft": true,
										"isRead": true,
										"isStarred": false,
										"labels": [
											"\\Draft"
										],
										"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
										"messageId": "draft-5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13@local",
										"references": [
											"<CAF3k9x1@mail.example.com>"
										],
										"scheduledSendAt": null,
										"scheduledStatus": null,
										"snippet": "Hello Jane, here is the quote you asked for.",
										"subject": "Re: Quote request",
										"threadId": "18c2f5a9e7b1d3c4",
										"to": [
											{
												"email": "client@acme.com",
												"name": "Jane Client"
											}
										],
										"waitingForReply": false
									}
								},
								"schema": {
									"properties": {
										"draft": {
											"$ref": "#/components/schemas/Email"
										}
									},
									"required": [
										"draft"
									],
									"type": "object"
								}
							}
						},
						"description": "The draft."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found in this workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get a draft",
				"tags": [
					"Drafts"
				],
				"x-scope": "read"
			}
		},
		"/drafts/send": {
			"post": {
				"description": "The only irreversible action in this API: it leaves the system and reaches a third party.\n\nRequires the `write` scope AND `allowOutboundSend` enabled on the key: the scope alone is\ndeliberately not enough. Always send an `Idempotency-Key`: a retry after a network timeout\nwould otherwise deliver the message twice.",
				"operationId": "sendEmail",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"body": {
									"text": "Hello Jane, here is the quote you asked for."
								},
								"inReplyTo": "<CAF3k9x1@mail.example.com>",
								"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
								"references": [
									"<CAF3k9x1@mail.example.com>"
								],
								"subject": "Re: Quote request",
								"to": [
									{
										"email": "client@acme.com",
										"name": "Jane Client"
									}
								]
							},
							"schema": {
								"$ref": "#/components/schemas/SendEmail"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"messageId": "<20260825140233.1a2b3c@your-company.com>",
									"threadId": "18c2f5a9e7b1d3c4"
								},
								"schema": {
									"$ref": "#/components/schemas/SendResult"
								}
							}
						},
						"description": "Sent. Returns the message id."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload, or sender alias not verified for the mailbox."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Mailbox not found. Call `GET /mailboxes` for valid ids."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Idempotency key reused with a different body, or original call still in flight."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Send an email",
				"tags": [
					"Drafts"
				],
				"x-requires": "allowOutboundSend",
				"x-scope": "write"
			}
		},
		"/emails": {
			"get": {
				"description": "Use this to browse a mailbox or a saved view. For keyword lookup use `/emails/search` instead.",
				"operationId": "listEmails",
				"parameters": [
					{
						"in": "query",
						"name": "mailboxId",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "Restrict to one folder. Omitted, all folders are considered.",
						"in": "query",
						"name": "folderType",
						"schema": {
							"enum": [
								"INBOX",
								"SENT",
								"DRAFTS",
								"SPAM",
								"TRASH"
							],
							"type": "string"
						}
					},
					{
						"description": "Apply a saved view. Get ids from `GET /views`.",
						"in": "query",
						"name": "viewId",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "`only` lists the INBOX emails hidden by inbox filters and by `hideFromInbox` AI labels (the app's \"Filtered emails\"). The plain INBOX listing never returns them; views are never affected.",
						"in": "query",
						"name": "filtered",
						"schema": {
							"enum": [
								"only"
							],
							"type": "string"
						}
					},
					{
						"description": "JSON-encoded filter tree. Max 5 levels, 50 conditions, 500-character values.",
						"in": "query",
						"name": "filters",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "Optional keyword filter. Terms shorter than 2 characters are ignored.",
						"in": "query",
						"name": "search",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "Opaque cursor from a previous response `nextCursor`. Format is `ISO_DATE|ID` and is not part of the contract.",
						"in": "query",
						"name": "cursor",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "Page size. Values above 200 are clamped.",
						"in": "query",
						"name": "limit",
						"schema": {
							"default": 50,
							"maximum": 200,
							"minimum": 1,
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"hasMore": true,
									"items": [
										{
											"attachments": [
												{
													"filename": "brief.pdf",
													"mimeType": "application/pdf",
													"size": 48213
												}
											],
											"cc": [],
											"date": "2026-08-25T13:47:02.000Z",
											"folderId": "cmfd1a2b3c4d5e6f7g8h9i0j",
											"from": {
												"email": "client@acme.com",
												"name": "Jane Client"
											},
											"hasAttachments": true,
											"id": "cmemx1a2b3c4d5e6f7g8h9i0",
											"inReplyTo": null,
											"isDraft": false,
											"isRead": false,
											"isStarred": false,
											"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
											"messageId": "<CAF3k9x1@mail.example.com>",
											"references": [],
											"snippet": "Hello, could you send us a quote for the annual plan?",
											"subject": "Quote request",
											"tags": [
												{
													"color": "Blue",
													"id": "cmtgai1b2c3d4e5f6g7h8i9j",
													"isAiLabel": true,
													"name": "Sales"
												}
											],
											"threadId": "18c2f5a9e7b1d3c4",
											"to": [
												{
													"email": "contact@your-company.com",
													"name": null
												}
											],
											"waitingForReply": false
										}
									],
									"nextCursor": "2026-08-25T13:47:02.000Z|cmemx1a2b3c4d5e6f7g8h9i0"
								},
								"schema": {
									"properties": {
										"hasMore": {
											"type": "boolean"
										},
										"items": {
											"items": {
												"$ref": "#/components/schemas/EmailListItem"
											},
											"type": "array"
										},
										"nextCursor": {
											"description": "Pass back as `?cursor=` to fetch the next page. `null` on the last page.",
											"type": [
												"string",
												"null"
											]
										}
									},
									"required": [
										"items",
										"nextCursor",
										"hasMore"
									],
									"type": "object"
								}
							}
						},
						"description": "A page of emails."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid filter tree, or a bound was exceeded."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"408": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Query exceeded the server time limit."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List emails",
				"tags": [
					"Emails"
				],
				"x-scope": "read"
			}
		},
		"/emails/{emailId}": {
			"delete": {
				"description": "Never a permanent delete: the message stays recoverable from trash.",
				"operationId": "trashEmail",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Moved to trash, or already there: replaying a deletion is not an error."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`NO_TRASH_FOLDER`: the mailbox has no trash folder, so the move cannot be applied."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Move an email to trash",
				"tags": [
					"Emails"
				],
				"x-scope": "write"
			},
			"get": {
				"description": "Metadata of one email, without its body. It carries what a reply in the same thread needs: `mailboxId`, `messageId`, `references` and `from`.",
				"operationId": "getEmail",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"email": {
										"attachments": [
											{
												"filename": "brief.pdf",
												"mimeType": "application/pdf",
												"size": 48213
											}
										],
										"bcc": [],
										"cc": [],
										"date": "2026-08-25T13:47:02.000Z",
										"folderId": "cmfd1a2b3c4d5e6f7g8h9i0j",
										"from": {
											"email": "client@acme.com",
											"name": "Jane Client"
										},
										"hasAttachments": true,
										"id": "cmemx1a2b3c4d5e6f7g8h9i0",
										"inReplyTo": null,
										"isAutoForward": false,
										"isAutoReply": false,
										"isDraft": false,
										"isRead": false,
										"isStarred": false,
										"labels": [
											"INBOX",
											"IMPORTANT"
										],
										"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
										"messageId": "<CAF3k9x1@mail.example.com>",
										"references": [],
										"scheduledSendAt": null,
										"scheduledStatus": null,
										"snippet": "Hello, could you send us a quote for the annual plan?",
										"subject": "Quote request",
										"threadId": "18c2f5a9e7b1d3c4",
										"to": [
											{
												"email": "contact@your-company.com",
												"name": null
											}
										],
										"waitingForReply": false
									}
								},
								"schema": {
									"properties": {
										"email": {
											"$ref": "#/components/schemas/Email"
										}
									},
									"required": [
										"email"
									],
									"type": "object"
								}
							}
						},
						"description": "The email metadata."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get an email",
				"tags": [
					"Emails"
				],
				"x-scope": "read"
			},
			"patch": {
				"description": "Provide at least one of `isRead` or `isStarred`. A body with neither is rejected rather than silently ignored.",
				"operationId": "updateEmail",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"isRead": true
							},
							"schema": {
								"properties": {
									"isRead": {
										"type": "boolean"
									},
									"isStarred": {
										"type": "boolean"
									}
								},
								"type": "object"
							}
						}
					}
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"email": {
										"attachments": [
											{
												"filename": "brief.pdf",
												"mimeType": "application/pdf",
												"size": 48213
											}
										],
										"bcc": [],
										"cc": [],
										"date": "2026-08-25T13:47:02.000Z",
										"folderId": "cmfd1a2b3c4d5e6f7g8h9i0j",
										"from": {
											"email": "client@acme.com",
											"name": "Jane Client"
										},
										"hasAttachments": true,
										"id": "cmemx1a2b3c4d5e6f7g8h9i0",
										"inReplyTo": null,
										"isAutoForward": false,
										"isAutoReply": false,
										"isDraft": false,
										"isRead": false,
										"isStarred": false,
										"labels": [
											"INBOX",
											"IMPORTANT"
										],
										"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
										"messageId": "<CAF3k9x1@mail.example.com>",
										"references": [],
										"scheduledSendAt": null,
										"scheduledStatus": null,
										"snippet": "Hello, could you send us a quote for the annual plan?",
										"subject": "Quote request",
										"threadId": "18c2f5a9e7b1d3c4",
										"to": [
											{
												"email": "contact@your-company.com",
												"name": null
											}
										],
										"waitingForReply": false
									}
								},
								"schema": {
									"properties": {
										"email": {
											"$ref": "#/components/schemas/Email"
										}
									},
									"required": [
										"email"
									],
									"type": "object"
								}
							}
						},
						"description": "The updated email."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Neither field provided."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Update read or starred state",
				"tags": [
					"Emails"
				],
				"x-scope": "write"
			}
		},
		"/emails/{emailId}/body": {
			"get": {
				"description": "Returns the rendered body plus every message of the conversation, oldest first.",
				"operationId": "getEmailBody",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"emailId": "cmemx1a2b3c4d5e6f7g8h9i0",
									"html": "<p>Hello, could you send us a quote for the annual plan?</p>",
									"text": "Hello, could you send us a quote for the annual plan?",
									"thread": [
										{
											"date": "2026-08-25T13:47:02.000Z",
											"fromAddress": "client@acme.com",
											"fromName": "Jane Client",
											"html": "<p>Hello, could you send us a quote for the annual plan?</p>",
											"id": "cmemx1a2b3c4d5e6f7g8h9i0",
											"isMe": false,
											"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
											"messageId": "<CAF3k9x1@mail.example.com>",
											"references": [],
											"subject": "Quote request",
											"text": "Hello, could you send us a quote for the annual plan?",
											"toAddresses": [
												{
													"email": "contact@your-company.com"
												}
											]
										}
									]
								},
								"schema": {
									"$ref": "#/components/schemas/EmailBody"
								}
							}
						},
						"description": "Body and thread."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found in this workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get an email body and its thread",
				"tags": [
					"Emails"
				],
				"x-scope": "read"
			}
		},
		"/emails/{emailId}/labels/{labelId}": {
			"delete": {
				"description": "Idempotent: removing a label the email does not have is not an error.",
				"operationId": "removeLabelFromEmail",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					},
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Removed."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`EMAIL_NOT_FOUND`: unknown email, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Remove a label from an email",
				"tags": [
					"Emails"
				],
				"x-scope": "write"
			},
			"post": {
				"description": "Idempotent: applying a label the email already has returns the current labels without firing `label.applied` again.",
				"operationId": "applyLabelToEmail",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					},
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"labels": [
										{
											"color": "Blue",
											"id": "cmtgai1b2c3d4e5f6g7h8i9j",
											"isAiLabel": true,
											"name": "Sales"
										},
										{
											"color": "Green",
											"id": "cmtg1a2b3c4d5e6f7g8h9i0j",
											"isAiLabel": false,
											"name": "Quotes"
										}
									]
								},
								"schema": {
									"properties": {
										"labels": {
											"items": {
												"$ref": "#/components/schemas/LabelRef"
											},
											"type": "array"
										}
									},
									"required": [
										"labels"
									],
									"type": "object"
								}
							}
						},
						"description": "Every label now on the email."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`EMAIL_NOT_FOUND` or `LABEL_NOT_FOUND`: unknown id, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Apply a label to an email",
				"tags": [
					"Emails"
				],
				"x-scope": "write"
			}
		},
		"/emails/bulk": {
			"post": {
				"description": "Counts against the quota once per email processed, not once per request. Supports `Idempotency-Key`.",
				"operationId": "bulkUpdateEmails",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"action": "markRead",
								"emailIds": [
									"cmemx1a2b3c4d5e6f7g8h9i0"
								],
								"isRead": true
							},
							"schema": {
								"properties": {
									"action": {
										"enum": [
											"markRead",
											"delete",
											"applyLabel",
											"removeLabel"
										],
										"type": "string"
									},
									"emailIds": {
										"items": {
											"type": "string"
										},
										"maxItems": 500,
										"type": "array"
									},
									"isRead": {
										"description": "Required when action is `markRead`.",
										"type": "boolean"
									},
									"labelId": {
										"description": "Required when action is `applyLabel` or `removeLabel`.",
										"type": "string"
									}
								},
								"required": [
									"action",
									"emailIds"
								],
								"type": "object"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"isRead": true,
									"skippedIds": [],
									"unchangedIds": [],
									"updatedIds": [
										"cmemx1a2b3c4d5e6f7g8h9i0"
									]
								},
								"schema": {
									"oneOf": [
										{
											"$ref": "#/components/schemas/BulkMarkReadResult"
										},
										{
											"$ref": "#/components/schemas/BulkDeleteResult"
										},
										{
											"$ref": "#/components/schemas/BulkLabelResult"
										}
									]
								}
							}
						},
						"description": "Per-id outcome, shaped by the action. Partial failures do not fail the batch."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Empty array, more than 500 ids, unknown action, or a missing `isRead` / `labelId`."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`LABEL_NOT_FOUND`: the label is unknown or belongs to another workspace."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Idempotency key reused with a different body, or original call still in flight."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Bulk mark-read, delete, apply or remove a label",
				"tags": [
					"Emails"
				],
				"x-scope": "write"
			}
		},
		"/emails/search": {
			"get": {
				"description": "Use this when looking for a keyword. Unlike `?search=` on the list, a term shorter than 2 characters is rejected rather than ignored.",
				"operationId": "searchEmails",
				"parameters": [
					{
						"in": "query",
						"name": "q",
						"required": true,
						"schema": {
							"maxLength": 200,
							"minLength": 2,
							"type": "string"
						}
					},
					{
						"in": "query",
						"name": "mailboxId",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "Restrict to one folder. Omitted, all folders are considered.",
						"in": "query",
						"name": "folderType",
						"schema": {
							"enum": [
								"INBOX",
								"SENT",
								"DRAFTS",
								"SPAM",
								"TRASH"
							],
							"type": "string"
						}
					},
					{
						"description": "Opaque cursor from a previous response `nextCursor`. Format is `ISO_DATE|ID` and is not part of the contract.",
						"in": "query",
						"name": "cursor",
						"schema": {
							"type": "string"
						}
					},
					{
						"description": "Page size. Values above 200 are clamped.",
						"in": "query",
						"name": "limit",
						"schema": {
							"default": 50,
							"maximum": 200,
							"minimum": 1,
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"hasMore": true,
									"items": [
										{
											"attachments": [
												{
													"filename": "brief.pdf",
													"mimeType": "application/pdf",
													"size": 48213
												}
											],
											"cc": [],
											"date": "2026-08-25T13:47:02.000Z",
											"folderId": "cmfd1a2b3c4d5e6f7g8h9i0j",
											"from": {
												"email": "client@acme.com",
												"name": "Jane Client"
											},
											"hasAttachments": true,
											"id": "cmemx1a2b3c4d5e6f7g8h9i0",
											"inReplyTo": null,
											"isDraft": false,
											"isRead": false,
											"isStarred": false,
											"mailboxId": "cmbx1a2b3c4d5e6f7g8h9i0j",
											"messageId": "<CAF3k9x1@mail.example.com>",
											"references": [],
											"snippet": "Hello, could you send us a quote for the annual plan?",
											"subject": "Quote request",
											"tags": [
												{
													"color": "Blue",
													"id": "cmtgai1b2c3d4e5f6g7h8i9j",
													"isAiLabel": true,
													"name": "Sales"
												}
											],
											"threadId": "18c2f5a9e7b1d3c4",
											"to": [
												{
													"email": "contact@your-company.com",
													"name": null
												}
											],
											"waitingForReply": false
										}
									],
									"nextCursor": "2026-08-25T13:47:02.000Z|cmemx1a2b3c4d5e6f7g8h9i0"
								},
								"schema": {
									"properties": {
										"hasMore": {
											"type": "boolean"
										},
										"items": {
											"items": {
												"$ref": "#/components/schemas/EmailListItem"
											},
											"type": "array"
										},
										"nextCursor": {
											"description": "Pass back as `?cursor=` to fetch the next page. `null` on the last page.",
											"type": [
												"string",
												"null"
											]
										}
									},
									"required": [
										"items",
										"nextCursor",
										"hasMore"
									],
									"type": "object"
								}
							}
						},
						"description": "A page of matching emails."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, too short or too long query."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Full-text search",
				"tags": [
					"Emails"
				],
				"x-scope": "read"
			}
		},
		"/filters": {
			"get": {
				"operationId": "listInboxFilters",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"createdAt": "2026-07-15T08:30:00.000Z",
											"id": "cmfl1a2b3c4d5e6f7g8h9i0j",
											"label": null,
											"type": "domain",
											"updatedAt": "2026-07-15T08:30:00.000Z",
											"value": "newsletter.example.com"
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/InboxFilter"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Filters of the workspace."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List inbox filters",
				"tags": [
					"Inbox filters"
				],
				"x-scope": "read"
			},
			"post": {
				"description": "Hides matching emails from the main inbox without moving them: they stay in INBOX, are listed by `GET /emails?filtered=only`, and remain visible in any view whose criteria match them.\n\nAddresses and domains are stored lowercase; a leading `@` on a domain is dropped. A `label` filter must reference a label of the workspace.",
				"operationId": "createInboxFilter",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"type": "domain",
								"value": "newsletter.example.com"
							},
							"schema": {
								"$ref": "#/components/schemas/CreateInboxFilter"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"filter": {
										"createdAt": "2026-07-15T08:30:00.000Z",
										"id": "cmfl1a2b3c4d5e6f7g8h9i0j",
										"label": null,
										"type": "domain",
										"updatedAt": "2026-07-15T08:30:00.000Z",
										"value": "newsletter.example.com"
									}
								},
								"schema": {
									"properties": {
										"filter": {
											"$ref": "#/components/schemas/InboxFilter"
										}
									},
									"required": [
										"filter"
									],
									"type": "object"
								}
							}
						},
						"description": "Created."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`LABEL_NOT_FOUND`: the label of a `label` filter is not in this workspace."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`DUPLICATE_FILTER`: a filter with this type and value already exists."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Create an inbox filter",
				"tags": [
					"Inbox filters"
				],
				"x-scope": "write"
			}
		},
		"/filters/{filterId}": {
			"delete": {
				"description": "The emails it hid reappear in the main inbox immediately.",
				"operationId": "deleteInboxFilter",
				"parameters": [
					{
						"in": "path",
						"name": "filterId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Deleted."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Delete an inbox filter",
				"tags": [
					"Inbox filters"
				],
				"x-scope": "write"
			},
			"get": {
				"operationId": "getInboxFilter",
				"parameters": [
					{
						"in": "path",
						"name": "filterId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"filter": {
										"createdAt": "2026-07-15T08:30:00.000Z",
										"id": "cmfl1a2b3c4d5e6f7g8h9i0j",
										"label": null,
										"type": "domain",
										"updatedAt": "2026-07-15T08:30:00.000Z",
										"value": "newsletter.example.com"
									}
								},
								"schema": {
									"properties": {
										"filter": {
											"$ref": "#/components/schemas/InboxFilter"
										}
									},
									"required": [
										"filter"
									],
									"type": "object"
								}
							}
						},
						"description": "The filter."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get an inbox filter",
				"tags": [
					"Inbox filters"
				],
				"x-scope": "read"
			},
			"patch": {
				"description": "Changes `type` and/or `value`. The resulting filter is validated as a whole, so a new `type` needs a compatible `value`.",
				"operationId": "updateInboxFilter",
				"parameters": [
					{
						"in": "path",
						"name": "filterId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"value": "news.example.com"
							},
							"schema": {
								"$ref": "#/components/schemas/UpdateInboxFilter"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"filter": {
										"createdAt": "2026-07-15T08:30:00.000Z",
										"id": "cmfl1a2b3c4d5e6f7g8h9i0j",
										"label": null,
										"type": "domain",
										"updatedAt": "2026-07-15T08:30:00.000Z",
										"value": "newsletter.example.com"
									}
								},
								"schema": {
									"properties": {
										"filter": {
											"$ref": "#/components/schemas/InboxFilter"
										}
									},
									"required": [
										"filter"
									],
									"type": "object"
								}
							}
						},
						"description": "The updated filter."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid or empty payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`DUPLICATE_FILTER`: a filter with this type and value already exists."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Update an inbox filter",
				"tags": [
					"Inbox filters"
				],
				"x-scope": "write"
			}
		},
		"/labels": {
			"get": {
				"description": "Every label of the workspace, AI labels included. Use the ids in filters and on `POST /emails/{emailId}/labels/{labelId}`.",
				"operationId": "listLabels",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"color": "Green",
											"createdAt": "2026-06-02T09:20:00.000Z",
											"id": "cmtg1a2b3c4d5e6f7g8h9i0j",
											"isAiLabel": false,
											"name": "Quotes"
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/Label"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Labels, AI-applied ones included."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List labels",
				"tags": [
					"Labels"
				],
				"x-scope": "read"
			},
			"post": {
				"description": "Creates a manual label. For a label applied automatically by the AI, create a rule on `/ai-label-rules` instead.",
				"operationId": "createLabel",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"color": "Green",
								"name": "Quotes"
							},
							"schema": {
								"$ref": "#/components/schemas/CreateLabel"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"label": {
										"color": "Green",
										"createdAt": "2026-06-02T09:20:00.000Z",
										"id": "cmtg1a2b3c4d5e6f7g8h9i0j",
										"isAiLabel": false,
										"name": "Quotes"
									}
								},
								"schema": {
									"properties": {
										"label": {
											"$ref": "#/components/schemas/Label"
										}
									},
									"required": [
										"label"
									],
									"type": "object"
								}
							}
						},
						"description": "Created."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`DUPLICATE_TAG_NAME`: a label with this name already exists."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Create a label",
				"tags": [
					"Labels"
				],
				"x-scope": "write"
			}
		},
		"/labels/{labelId}": {
			"delete": {
				"description": "Removes the label from every email that carries it. Manual labels only: delete an AI label through its rule.",
				"operationId": "deleteLabel",
				"parameters": [
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Deleted."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`INVALID_TAG`: the label is an AI label."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Delete a label",
				"tags": [
					"Labels"
				],
				"x-scope": "write"
			},
			"get": {
				"operationId": "getLabel",
				"parameters": [
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"label": {
										"color": "Green",
										"createdAt": "2026-06-02T09:20:00.000Z",
										"id": "cmtg1a2b3c4d5e6f7g8h9i0j",
										"isAiLabel": false,
										"name": "Quotes"
									}
								},
								"schema": {
									"properties": {
										"label": {
											"$ref": "#/components/schemas/Label"
										}
									},
									"required": [
										"label"
									],
									"type": "object"
								}
							}
						},
						"description": "The label."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get a label",
				"tags": [
					"Labels"
				],
				"x-scope": "read"
			},
			"patch": {
				"description": "Manual labels only: an AI label is renamed through its rule on `/ai-label-rules`.",
				"operationId": "updateLabel",
				"parameters": [
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"color": "Orange"
							},
							"schema": {
								"$ref": "#/components/schemas/UpdateLabel"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"label": {
										"color": "Green",
										"createdAt": "2026-06-02T09:20:00.000Z",
										"id": "cmtg1a2b3c4d5e6f7g8h9i0j",
										"isAiLabel": false,
										"name": "Quotes"
									}
								},
								"schema": {
									"properties": {
										"label": {
											"$ref": "#/components/schemas/Label"
										}
									},
									"required": [
										"label"
									],
									"type": "object"
								}
							}
						},
						"description": "The updated label."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid or empty payload, or `INVALID_TAG` when the label is an AI label."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"409": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "`DUPLICATE_TAG_NAME`: a label with this name already exists."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Rename or recolor a label",
				"tags": [
					"Labels"
				],
				"x-scope": "write"
			}
		},
		"/mailboxes": {
			"get": {
				"description": "Call this to resolve the `mailboxId` every send and most filters need.",
				"operationId": "listMailboxes",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"backwardSyncComplete": true,
											"createdAt": "2026-06-02T09:14:31.000Z",
											"email": "contact@your-company.com",
											"id": "cmbx1a2b3c4d5e6f7g8h9i0j",
											"isActive": true,
											"lastSyncAt": "2026-08-25T14:02:11.000Z",
											"name": "Contact",
											"picture": null,
											"provider": "GOOGLE",
											"syncError": null
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/Mailbox"
											},
											"type": "array"
										}
									},
									"type": "object"
								}
							}
						},
						"description": "Connected mailboxes."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List connected mailboxes",
				"tags": [
					"Mailboxes"
				],
				"x-scope": "read"
			}
		},
		"/signatures": {
			"get": {
				"description": "Call this to turn a signature name into the id that `signature` takes on a send or a draft.",
				"operationId": "listSignatures",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/Signature"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Signatures of the workspace."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List signatures",
				"tags": [
					"Signatures"
				],
				"x-scope": "read"
			}
		},
		"/views": {
			"get": {
				"description": "Apply one with `?viewId=` on `GET /emails`. `filters` is the view definition, in the same DSL as `?filters=`.",
				"operationId": "listViews",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"items": [
										{
											"createdAt": "2026-07-01T10:00:00.000Z",
											"filters": {
												"_and": [
													{
														"id": "c1",
														"label": "ai_label",
														"type": "contains",
														"value": "cmtgai1b2c3d4e5f6g7h8i9j"
													},
													{
														"id": "c2",
														"label": "read_status",
														"type": "is_false",
														"value": ""
													}
												],
												"id": "g1"
											},
											"icon": "🎯",
											"id": "cmvw1a2b3c4d5e6f7g8h9i0j",
											"mailboxIds": [],
											"name": "Leads to answer"
										}
									]
								},
								"schema": {
									"properties": {
										"items": {
											"items": {
												"$ref": "#/components/schemas/View"
											},
											"type": "array"
										}
									},
									"required": [
										"items"
									],
									"type": "object"
								}
							}
						},
						"description": "Saved views."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "List saved views",
				"tags": [
					"Views"
				],
				"x-scope": "read"
			},
			"post": {
				"description": "Saves a filter tree under a name. The tree is bounded like `?filters=`: 5 levels, 50 conditions, 500-character values.",
				"operationId": "createView",
				"parameters": [
					{
						"description": "A unique value per operation, such as a UUID. Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"example": "5f0c2b1e-8a7d-4f3e-9c61-2d4b7a9e0f13",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"filters": {
									"_and": [
										{
											"id": "c1",
											"label": "ai_label",
											"type": "contains",
											"value": "cmtgai1b2c3d4e5f6g7h8i9j"
										},
										{
											"id": "c2",
											"label": "read_status",
											"type": "is_false",
											"value": ""
										}
									],
									"id": "g1"
								},
								"icon": "🎯",
								"name": "Leads to answer"
							},
							"schema": {
								"$ref": "#/components/schemas/CreateView"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"example": {
									"view": {
										"createdAt": "2026-07-01T10:00:00.000Z",
										"filters": {
											"_and": [
												{
													"id": "c1",
													"label": "ai_label",
													"type": "contains",
													"value": "cmtgai1b2c3d4e5f6g7h8i9j"
												},
												{
													"id": "c2",
													"label": "read_status",
													"type": "is_false",
													"value": ""
												}
											],
											"id": "g1"
										},
										"icon": "🎯",
										"id": "cmvw1a2b3c4d5e6f7g8h9i0j",
										"mailboxIds": [],
										"name": "Leads to answer"
									}
								},
								"schema": {
									"properties": {
										"view": {
											"$ref": "#/components/schemas/View"
										}
									},
									"required": [
										"view"
									],
									"type": "object"
								}
							}
						},
						"description": "Created."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid payload, invalid filter tree, or a bound was exceeded."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Create a view",
				"tags": [
					"Views"
				],
				"x-scope": "write"
			}
		},
		"/views/{viewId}": {
			"delete": {
				"operationId": "deleteView",
				"parameters": [
					{
						"in": "path",
						"name": "viewId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Deleted."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Delete a view",
				"tags": [
					"Views"
				],
				"x-scope": "write"
			},
			"get": {
				"operationId": "getView",
				"parameters": [
					{
						"in": "path",
						"name": "viewId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"view": {
										"createdAt": "2026-07-01T10:00:00.000Z",
										"filters": {
											"_and": [
												{
													"id": "c1",
													"label": "ai_label",
													"type": "contains",
													"value": "cmtgai1b2c3d4e5f6g7h8i9j"
												},
												{
													"id": "c2",
													"label": "read_status",
													"type": "is_false",
													"value": ""
												}
											],
											"id": "g1"
										},
										"icon": "🎯",
										"id": "cmvw1a2b3c4d5e6f7g8h9i0j",
										"mailboxIds": [],
										"name": "Leads to answer"
									}
								},
								"schema": {
									"properties": {
										"view": {
											"$ref": "#/components/schemas/View"
										}
									},
									"required": [
										"view"
									],
									"type": "object"
								}
							}
						},
						"description": "The view."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Get a view",
				"tags": [
					"Views"
				],
				"x-scope": "read"
			},
			"patch": {
				"description": "`filters` replaces the whole tree. At least one field is required.",
				"operationId": "updateView",
				"parameters": [
					{
						"in": "path",
						"name": "viewId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"example": {
								"name": "Hot leads"
							},
							"schema": {
								"$ref": "#/components/schemas/UpdateView"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"example": {
									"view": {
										"createdAt": "2026-07-01T10:00:00.000Z",
										"filters": {
											"_and": [
												{
													"id": "c1",
													"label": "ai_label",
													"type": "contains",
													"value": "cmtgai1b2c3d4e5f6g7h8i9j"
												},
												{
													"id": "c2",
													"label": "read_status",
													"type": "is_false",
													"value": ""
												}
											],
											"id": "g1"
										},
										"icon": "🎯",
										"id": "cmvw1a2b3c4d5e6f7g8h9i0j",
										"mailboxIds": [],
										"name": "Leads to answer"
									}
								},
								"schema": {
									"properties": {
										"view": {
											"$ref": "#/components/schemas/View"
										}
									},
									"required": [
										"view"
									],
									"type": "object"
								}
							}
						},
						"description": "The updated view."
					},
					"400": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Invalid or empty payload, invalid filter tree, or a bound was exceeded."
					},
					"401": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Missing, malformed, revoked or expired API key."
					},
					"403": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Key lacks the required scope, or outbound sending is not enabled on it."
					},
					"404": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Not found, or belongs to another workspace."
					},
					"429": {
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						},
						"description": "Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted."
					}
				},
				"summary": "Update a view",
				"tags": [
					"Views"
				],
				"x-scope": "write"
			}
		}
	},
	"security": [
		{
			"apiKey": []
		}
	],
	"servers": [
		{
			"description": "Production",
			"url": "https://api.maylee.app/api/v1"
		},
		{
			"description": "Same origin",
			"url": "/api/v1"
		}
	],
	"tags": [
		{
			"description": "List, search and read the emails of every connected mailbox, mark them read or starred, label them, and move them to the trash. Bodies are fetched on demand, and nothing is ever deleted permanently.",
			"name": "Emails"
		},
		{
			"description": "Create drafts that a person reviews and sends from the Maylee app, or send an email immediately.",
			"name": "Drafts"
		},
		{
			"description": "Connected mailboxes, read-only: connecting one goes through OAuth or credentials in the Maylee app, never through a key.",
			"name": "Mailboxes"
		},
		{
			"description": "Signatures of the workspace, read-only: they are written in the Maylee app. Use an id as `signature` on a send or a draft; without it, Maylee signs like the app would.",
			"name": "Signatures"
		},
		{
			"description": "Manual labels are created here and applied by people, or by you through the API. AI labels show up in the same list with `isAiLabel: true`; they are renamed or deleted through their AI label rule.",
			"name": "Labels"
		},
		{
			"description": "An AI label plus a condition written in plain language. Maylee reads each incoming email and applies the label when the condition holds. A rule can also prepare replies (auto-draft) and send them (auto-reply).",
			"name": "AI label rules"
		},
		{
			"description": "Saved filter trees, shown in the Maylee sidebar. Apply one with `?viewId=` on `GET /emails`.",
			"name": "Views"
		},
		{
			"description": "Hide matching emails from the main inbox without moving them. Filters are evaluated when listing, so they apply to past emails too.",
			"name": "Inbox filters"
		},
		{
			"description": "Forward every incoming email that matches a condition to another address. Managing rules requires the Send emails permission on the key.",
			"name": "Auto-forward rules"
		}
	],
	"x-apiKeyScopes": [
		"read",
		"write"
	],
	"x-webhookEvents": [
		"email.received",
		"email.updated",
		"email.deleted",
		"draft.sent",
		"label.applied",
		"mailbox.sync_failed"
	]
}
