{
	"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,
						"maximum": 500,
						"minimum": 1,
						"type": "integer"
					},
					"mailboxId": {
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"CreateAiLabelRule": {
				"additionalProperties": false,
				"properties": {
					"autoDraftEnabled": {
						"type": "boolean"
					},
					"autoReplyConfidenceThreshold": {
						"maximum": 100,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyDelayMinutes": {
						"maximum": 15,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyEnabled": {
						"type": "boolean"
					},
					"autoReplyNotifyOnSend": {
						"type": "boolean"
					},
					"color": {
						"type": "string"
					},
					"condition": {
						"maxLength": 500,
						"minLength": 1,
						"type": "string"
					},
					"hideFromInbox": {
						"type": "boolean"
					},
					"name": {
						"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",
						"enum": [
							"label",
							"sender_contains",
							"sender_equals",
							"subject_contains",
							"subject_equals"
						],
						"type": "string"
					},
					"conditionValue": {
						"maxLength": 255,
						"minLength": 1,
						"type": "string"
					},
					"forwardTo": {
						"format": "email",
						"maxLength": 255,
						"type": "string"
					},
					"isActive": {
						"default": true,
						"type": "boolean"
					},
					"mode": {
						"default": "normal",
						"enum": [
							"normal",
							"invisible"
						],
						"type": "string"
					}
				},
				"required": [
					"conditionValue",
					"forwardTo"
				],
				"type": "object"
			},
			"CreateDraft": {
				"additionalProperties": false,
				"properties": {
					"bcc": {
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"body": {
						"additionalProperties": false,
						"properties": {
							"html": {
								"type": "string"
							},
							"text": {
								"type": "string"
							}
						},
						"type": "object"
					},
					"cc": {
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"inReplyTo": {
						"maxLength": 998,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"mailboxId": {
						"minLength": 1,
						"type": "string"
					},
					"references": {
						"items": {
							"maxLength": 998,
							"pattern": "^[^\\r\\n]*$",
							"type": "string"
						},
						"type": "array"
					},
					"signature": {
						"maxLength": 128,
						"minLength": 1,
						"type": "string"
					},
					"subject": {
						"default": "",
						"maxLength": 2000,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"to": {
						"default": [],
						"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": {
						"enum": [
							"sender",
							"domain",
							"subject",
							"label"
						],
						"type": "string"
					},
					"value": {
						"maxLength": 255,
						"minLength": 1,
						"type": "string"
					}
				},
				"required": [
					"type",
					"value"
				],
				"type": "object"
			},
			"CreateLabel": {
				"additionalProperties": false,
				"properties": {
					"color": {
						"maxLength": 30,
						"minLength": 1,
						"type": "string"
					},
					"name": {
						"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"
			},
			"EmailAddress": {
				"properties": {
					"email": {
						"format": "email",
						"type": "string"
					},
					"name": {
						"type": [
							"string",
							"null"
						]
					}
				},
				"required": [
					"email"
				],
				"type": "object"
			},
			"EmailListItem": {
				"description": "Email as returned in list responses. Never includes storage keys or internal AI fields.",
				"properties": {
					"attachments": {
						"items": {
							"$ref": "#/components/schemas/Attachment"
						},
						"type": "array"
					},
					"cc": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"date": {
						"format": "date-time",
						"type": "string"
					},
					"folderId": {
						"type": "string"
					},
					"from": {
						"$ref": "#/components/schemas/EmailAddress"
					},
					"hasAttachments": {
						"type": "boolean"
					},
					"id": {
						"type": "string"
					},
					"inReplyTo": {
						"type": [
							"string",
							"null"
						]
					},
					"isDraft": {
						"type": "boolean"
					},
					"isRead": {
						"type": "boolean"
					},
					"isStarred": {
						"type": "boolean"
					},
					"mailboxId": {
						"type": "string"
					},
					"messageId": {
						"type": "string"
					},
					"references": {
						"items": {
							"type": "string"
						},
						"type": "array"
					},
					"snippet": {
						"type": "string"
					},
					"subject": {
						"type": "string"
					},
					"tags": {
						"items": {
							"type": "object"
						},
						"type": "array"
					},
					"threadId": {
						"type": [
							"string",
							"null"
						]
					},
					"to": {
						"items": {
							"$ref": "#/components/schemas/EmailAddress"
						},
						"type": "array"
					},
					"waitingForReply": {
						"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": {
						"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": {
						"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": {
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"body": {
						"additionalProperties": false,
						"properties": {
							"html": {
								"type": "string"
							},
							"text": {
								"type": "string"
							}
						},
						"type": "object"
					},
					"cc": {
						"items": {
							"additionalProperties": false,
							"properties": {
								"email": {
									"format": "email",
									"type": "string"
								},
								"name": {
									"type": "string"
								}
							},
							"required": [
								"email"
							],
							"type": "object"
						},
						"type": "array"
					},
					"from": {
						"additionalProperties": false,
						"properties": {
							"email": {
								"format": "email",
								"type": "string"
							},
							"name": {
								"type": "string"
							}
						},
						"required": [
							"email"
						],
						"type": "object"
					},
					"inReplyTo": {
						"maxLength": 998,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"mailboxId": {
						"minLength": 1,
						"type": "string"
					},
					"references": {
						"items": {
							"maxLength": 998,
							"pattern": "^[^\\r\\n]*$",
							"type": "string"
						},
						"type": "array"
					},
					"signature": {
						"maxLength": 128,
						"minLength": 1,
						"type": "string"
					},
					"subject": {
						"default": "",
						"maxLength": 2000,
						"pattern": "^[^\\r\\n]*$",
						"type": "string"
					},
					"to": {
						"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"
			},
			"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"
			},
			"UpdateAiLabelRule": {
				"additionalProperties": false,
				"properties": {
					"autoDraftEnabled": {
						"type": "boolean"
					},
					"autoReplyConfidenceThreshold": {
						"maximum": 100,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyDelayMinutes": {
						"maximum": 15,
						"minimum": 0,
						"type": "integer"
					},
					"autoReplyEnabled": {
						"type": "boolean"
					},
					"autoReplyNotifyOnSend": {
						"type": "boolean"
					},
					"color": {
						"type": "string"
					},
					"condition": {
						"maxLength": 500,
						"type": "string"
					},
					"hideFromInbox": {
						"type": "boolean"
					},
					"name": {
						"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": {
						"enum": [
							"label",
							"sender_contains",
							"sender_equals",
							"subject_contains",
							"subject_equals"
						],
						"type": "string"
					},
					"conditionValue": {
						"maxLength": 255,
						"type": "string"
					},
					"forwardTo": {
						"anyOf": [
							{
								"format": "email",
								"maxLength": 255,
								"type": "string"
							},
							{
								"enum": [
									""
								],
								"type": "string"
							}
						]
					},
					"isActive": {
						"type": "boolean"
					},
					"mode": {
						"enum": [
							"normal",
							"invisible"
						],
						"type": "string"
					}
				},
				"type": "object"
			},
			"UpdateInboxFilter": {
				"additionalProperties": false,
				"properties": {
					"type": {
						"enum": [
							"sender",
							"domain",
							"subject",
							"label"
						],
						"type": "string"
					},
					"value": {
						"maxLength": 255,
						"minLength": 1,
						"type": "string"
					}
				},
				"type": "object"
			},
			"UpdateLabel": {
				"additionalProperties": false,
				"properties": {
					"color": {
						"maxLength": 30,
						"minLength": 1,
						"type": "string"
					},
					"name": {
						"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"
			}
		}
	},
	"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": {
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateAiLabelRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"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",
				"x-scope": "write"
			},
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateAiLabelRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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: watch the `label.applied` webhook event. A backfill applies labels and nothing else: no auto-forward, auto-draft or auto-reply is triggered. Each classified email costs one model call.",
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/BackfillRequest"
							}
						}
					},
					"required": false
				},
				"responses": {
					"202": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "write"
			}
		},
		"/auto-forward-rules": {
			"get": {
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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`.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateAutoForwardRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"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",
				"x-requires": "allowOutboundSend",
				"x-scope": "write"
			}
		},
		"/auto-forward-rules/{ruleId}": {
			"delete": {
				"description": "Requires `allowOutboundSend` on the key.",
				"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",
				"x-requires": "allowOutboundSend",
				"x-scope": "write"
			},
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "read"
			},
			"patch": {
				"description": "Requires `allowOutboundSend` on the key. At least one field is required; `forwardTo` and `conditionValue` cannot be emptied.",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateAutoForwardRule"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"parameters": [
					{
						"in": "path",
						"name": "ruleId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "read"
			}
		},
		"/drafts": {
			"get": {
				"parameters": [
					{
						"description": "Page size. Values above 200 are clamped.",
						"in": "query",
						"name": "limit",
						"schema": {
							"default": 50,
							"maximum": 200,
							"minimum": 1,
							"type": "integer"
						}
					}
				],
				"responses": {
					"200": {
						"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",
				"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.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateDraft"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"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",
				"x-scope": "write"
			}
		},
		"/drafts/{draftId}": {
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "draftId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"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",
				"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.",
				"parameters": [
					{
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/SendEmail"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"description": "Sent. Returns the provider 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."
					},
					"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",
				"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.",
				"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": {
								"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",
				"x-scope": "read"
			}
		},
		"/emails/{emailId}": {
			"delete": {
				"description": "Never a permanent delete — the message stays recoverable from trash.",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"204": {
						"description": "Moved to trash."
					},
					"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": "Move an email to trash",
				"x-scope": "write"
			},
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"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",
				"x-scope": "read"
			},
			"patch": {
				"description": "Provide at least one of `isRead` or `isStarred`. A body with neither is rejected rather than silently ignored.",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"properties": {
									"isRead": {
										"type": "boolean"
									},
									"isStarred": {
										"type": "boolean"
									}
								},
								"type": "object"
							}
						}
					}
				},
				"responses": {
					"200": {
						"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."
					},
					"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",
				"x-scope": "write"
			}
		},
		"/emails/{emailId}/body": {
			"get": {
				"description": "Returns the rendered body plus every message of the conversation, oldest first.",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"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",
				"x-scope": "read"
			}
		},
		"/emails/{emailId}/labels/{labelId}": {
			"delete": {
				"description": "Idempotent: removing a label the email does not have is not an error.",
				"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",
				"x-scope": "write"
			},
			"post": {
				"description": "Idempotent: applying a label the email already has returns the current labels without firing `label.applied` again.",
				"parameters": [
					{
						"in": "path",
						"name": "emailId",
						"required": true,
						"schema": {
							"type": "string"
						}
					},
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "write"
			}
		},
		"/emails/bulk": {
			"post": {
				"description": "Counts against the quota once per email processed, not once per request. Supports `Idempotency-Key`.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"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": {
						"description": "Per-id outcome. 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",
				"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.",
				"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": {
								"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",
				"x-scope": "read"
			}
		},
		"/filters": {
			"get": {
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateInboxFilter"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "write"
			}
		},
		"/filters/{filterId}": {
			"delete": {
				"description": "The emails it hid reappear in the main inbox immediately.",
				"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",
				"x-scope": "write"
			},
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "filterId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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`.",
				"parameters": [
					{
						"in": "path",
						"name": "filterId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateInboxFilter"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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}`.",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateLabel"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"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",
				"x-scope": "write"
			},
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "read"
			},
			"patch": {
				"description": "Manual labels only: an AI label is renamed through its rule on `/ai-label-rules`.",
				"parameters": [
					{
						"in": "path",
						"name": "labelId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateLabel"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "write"
			}
		},
		"/mailboxes": {
			"get": {
				"description": "Call this to resolve the `mailboxId` every send and most filters need.",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"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",
				"x-scope": "read"
			}
		},
		"/views": {
			"get": {
				"description": "Apply one with `?viewId=` on `GET /emails`. `filters` is the view definition, in the same DSL as `?filters=`.",
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"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.",
				"parameters": [
					{
						"description": "Replays the stored response for 24h. Reusing a key with a different body returns 409.",
						"in": "header",
						"name": "Idempotency-Key",
						"schema": {
							"maxLength": 255,
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/CreateView"
							}
						}
					},
					"required": true
				},
				"responses": {
					"201": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "write"
			}
		},
		"/views/{viewId}": {
			"delete": {
				"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",
				"x-scope": "write"
			},
			"get": {
				"parameters": [
					{
						"in": "path",
						"name": "viewId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "read"
			},
			"patch": {
				"description": "`filters` replaces the whole tree. At least one field is required.",
				"parameters": [
					{
						"in": "path",
						"name": "viewId",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/UpdateView"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"content": {
							"application/json": {
								"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",
				"x-scope": "write"
			}
		}
	},
	"security": [
		{
			"apiKey": []
		}
	],
	"servers": [
		{
			"description": "Production",
			"url": "https://api.maylee.app/api/v1"
		},
		{
			"description": "Same origin",
			"url": "/api/v1"
		}
	],
	"x-apiKeyScopes": [
		"read",
		"write"
	],
	"x-webhookEvents": [
		"email.received",
		"email.updated",
		"email.deleted",
		"draft.sent",
		"label.applied",
		"mailbox.sync_failed"
	]
}
