Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

225 KB
Raw Blame
{
  "openapi": "3.1.0",
  "info": {
    "title": "email_service",
    "description": "",
    "termsOfService": "https://macro.com/terms",
    "license": {
      "name": ""
    },
    "version": "0.1.0"
  },
  "paths": {
    "/email/attachments/{id}": {
      "get": {
        "tags": ["Attachments"],
        "summary": "Get an attachment by ID.",
        "operationId": "get_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Attachment ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAttachmentResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/attachments/{id}/document_id": {
      "get": {
        "tags": ["Attachments"],
        "summary": "Get the Macro document id for an email attachment, uploading it if it doesn't already exist.",
        "operationId": "get_attachment_document_id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Attachment ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAttachmentDocumentIDResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/backfill/gmail": {
      "get": {
        "tags": ["Init"],
        "summary": "List all backfill jobs for the authenticated user, across every link they\nown. Scoped by the user's fusionauth id from the request context rather than\na single resolved link.",
        "operationId": "list_backfill_gmail",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListBackfillJobsResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Init"],
        "summary": "Cancel a backfill job.",
        "operationId": "cancel_backfill_gmail",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelBackfillParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/backfill/gmail/active": {
      "get": {
        "tags": ["Init"],
        "summary": "Get any active backfill job for the user.",
        "operationId": "get_backfill_gmail_active",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetActiveBackfillJobResponse"
                }
              }
            }
          },
          "204": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/backfill/gmail/{id}": {
      "get": {
        "tags": ["Init"],
        "summary": "Get a backfill job.",
        "operationId": "get_backfill_gmail",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Job ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetBackfillJobResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/calendar-events/{event_id}/forward": {
      "post": {
        "tags": ["email"],
        "summary": "Email one of the viewer's events to people the organizer's guest list\ndoes not name, from the inbox that holds the viewer's copy, with the\nusual undo delay, carrying the copy's join link. When the copy is Google's\nprivate copy of an invitation from an organizer outside Google, it is a\nreal invitation (`METHOD:REQUEST`) naming the recipients, who answer it to\nthe organizer, who gets the email too. Otherwise it is the event's file\n(`METHOD:PUBLISH`, no attendees): recipients can add the event to their\nown calendar, are not added to the guest list, and the organizer is not\ntold.",
        "operationId": "forward_calendar_event",
        "parameters": [
          {
            "name": "event_id",
            "in": "path",
            "description": "The viewer's copy of the event",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ForwardCalendarEventRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "The email is queued to send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForwardCalendarEventResponse"
                }
              }
            }
          },
          "400": {
            "description": "No, too many, or invalid recipients",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForwardCalendarEventError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "The inbox holding the copy cannot send for the viewer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForwardCalendarEventError"
                }
              }
            }
          },
          "404": {
            "description": "No such event on one of the viewer's own inboxes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForwardCalendarEventError"
                }
              }
            }
          },
          "502": {
            "description": "The email could not be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForwardCalendarEventError"
                }
              }
            }
          }
        }
      }
    },
    "/email/contacts": {
      "get": {
        "tags": ["Contacts"],
        "summary": "List all contacts belonging to the user, grouped by link.",
        "operationId": "list_contacts",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListContactsResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/contacts/block": {
      "post": {
        "tags": ["Contacts"],
        "summary": "Durably block a sender in the selected inbox.",
        "operationId": "block_sender",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlockSenderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": ""
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/contacts/blocked": {
      "get": {
        "tags": ["Contacts"],
        "summary": "List all blocked senders for the authenticated user.",
        "operationId": "list_blocked_senders",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListBlockedResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/contacts/unblock": {
      "post": {
        "tags": ["Contacts"],
        "summary": "Durably remove Macro-managed sender blocking in the selected inbox.",
        "operationId": "unblock_sender",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnblockSenderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": ""
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/draft-transfers/{id}/recover": {
      "post": {
        "tags": ["Drafts"],
        "operationId": "recover_draft_transfer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferRecoveryResponse"
                }
              }
            }
          },
          "403": {
            "description": ""
          },
          "500": {
            "description": ""
          }
        }
      }
    },
    "/email/drafts": {
      "post": {
        "tags": ["Drafts"],
        "summary": "Create a draft.",
        "operationId": "create_draft",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDraftRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDraftResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/scheduled": {
      "get": {
        "tags": ["Draft Scheduling"],
        "summary": "List scheduled drafts.",
        "operationId": "get_scheduled_messages",
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "description": "The number of scheduled messages to skip.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "The maximum number of scheduled messages to return.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetScheduledResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/scheduled/{id}": {
      "put": {
        "tags": ["Draft Scheduling"],
        "summary": "Schedule or update a scheduled draft.",
        "operationId": "upsert_scheduled_message",
        "parameters": [
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the draft message to schedule",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertScheduledRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertScheduledResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/scheduled/{message_id}": {
      "delete": {
        "tags": ["Draft Scheduling"],
        "summary": "Remove the scheduled send from a draft, including immediate-send undo.",
        "operationId": "delete_scheduled_draft",
        "parameters": [
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "The ID of the draft",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Scheduled send deleted successfully"
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}": {
      "delete": {
        "tags": ["Drafts"],
        "summary": "Delete a draft.",
        "operationId": "delete_draft",
        "parameters": [
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Draft ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/attachments": {
      "post": {
        "tags": ["Drafts"],
        "summary": "Add an attachment to a draft.",
        "operationId": "add_draft_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the draft to add the attachment to.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddDraftAttachmentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddDraftAttachmentResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/attachments/{attachment_id}": {
      "delete": {
        "tags": ["Drafts"],
        "summary": "Remove an attachment from a draft.",
        "operationId": "remove_draft_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the draft to remove the attachment from.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "attachment_id",
            "in": "path",
            "description": "The ID of the attachment to remove.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/attachments/{attachment_id}/complete": {
      "post": {
        "tags": ["Drafts"],
        "summary": "Confirm an uploaded attachment before it becomes part of a sendable draft.",
        "operationId": "complete_draft_attachment",
        "parameters": [
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "attachment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          },
          "400": {
            "description": ""
          },
          "403": {
            "description": ""
          },
          "404": {
            "description": ""
          },
          "409": {
            "description": ""
          },
          "500": {
            "description": ""
          }
        }
      }
    },
    "/email/drafts/{id}/forwarded-attachments": {
      "post": {
        "tags": ["Drafts"],
        "summary": "Add a forwarded attachment to a draft.",
        "operationId": "add_forwarded_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the draft to add the forwarded attachment to.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddForwardedAttachmentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddForwardedAttachmentResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/forwarded-attachments/{attachment_id}": {
      "delete": {
        "tags": ["Drafts"],
        "summary": "Remove a forwarded attachment from a draft.",
        "operationId": "remove_forwarded_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the draft to remove the forwarded attachment from.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "attachment_id",
            "in": "path",
            "description": "The ID of the forwarded attachment to remove.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "draft_generation",
            "in": "query",
            "description": "Generation from the last loaded draft. Legacy clients use zero.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/operation": {
      "get": {
        "tags": ["Drafts"],
        "summary": "The same provider-neutral state returned on fully hydrated email messages.",
        "operationId": "message_operation_status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Message ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageOperationResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/resolve": {
      "post": {
        "tags": ["Drafts"],
        "summary": "Resolve an observed draft conflict or uncertain provider operation.",
        "operationId": "resolve_message_operation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Message ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResolveMessageOperationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": ""
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/drafts/{id}/transfer": {
      "post": {
        "tags": ["Drafts"],
        "operationId": "transfer_draft",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferDraftRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferDraftResponse"
                }
              }
            }
          },
          "403": {
            "description": ""
          },
          "404": {
            "description": ""
          },
          "409": {
            "description": ""
          },
          "500": {
            "description": ""
          }
        }
      }
    },
    "/email/filters": {
      "get": {
        "tags": ["Email Filters"],
        "summary": "List all email filters for the current user.",
        "operationId": "list_email_filters",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEmailFiltersResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": ["Email Filters"],
        "summary": "Create or update an email filter.",
        "operationId": "upsert_email_filter",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertEmailFilterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertEmailFilterResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/filters/{id}": {
      "delete": {
        "tags": ["Email Filters"],
        "summary": "Delete an email filter by ID.",
        "operationId": "delete_email_filter",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Filter ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/init": {
      "post": {
        "tags": ["Init"],
        "summary": "Initialize email functionality for the user. Populates initial threads and enables inbox syncing.",
        "operationId": "init_user",
        "parameters": [
          {
            "name": "link_id",
            "in": "query",
            "description": "**OPTIONAL**. The in_progress_user_link id from a /link/gmail flow.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "force_share",
            "in": "query",
            "description": "**OPTIONAL**. Confirms promoting a mailbox already connected by another user into a shared inbox.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitErrorCodeResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SharedInboxConflictResponse"
                }
              }
            }
          },
          "429": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/labels": {
      "get": {
        "tags": ["Labels"],
        "summary": "List all labels for the user's email link.",
        "operationId": "list_labels",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListLabelsResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Labels"],
        "summary": "Create a label.",
        "operationId": "create_label",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLabelRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateLabelResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/labels/{id}": {
      "delete": {
        "tags": ["Labels"],
        "summary": "Delete a label.",
        "operationId": "delete_label",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Label ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/links": {
      "get": {
        "tags": ["Links"],
        "summary": "List all links belonging to the user.",
        "operationId": "list_links",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListLinksResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/links/health-check": {
      "post": {
        "tags": ["Links"],
        "summary": "Probes the live auth state of each of the caller's inboxes (owned and delegated)\nagainst the auth service and records the result on each link. A grant that died\nwhile the caller was inactive is detected here within minutes instead of waiting on\nthe daily refresh sweep; the side effects (clearing or setting the reauth flag, and\nthe one-time reauth fan-out) are handled by the email service token source.",
        "description": "Probes are durably queued and the response returns immediately to stay off the\nload path; each persisted flag is picked up by the next links read. Probes are\nthrottled per link in Redis so frequent calls — and many sharers of a shared inbox —\ncollapse to one refresh per window.",
        "operationId": "health_check_links",
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/links/{link_id}": {
      "delete": {
        "tags": ["Links"],
        "summary": "Removes a linked inbox.",
        "description": "For an inbox the caller owns this enqueues a full cascade teardown\n(`LinkManagerMessage::DeleteLink`). For an inbox reached via delegation it\nonly drops the `macro_user_links` edge, leaving the owner's data intact.",
        "operationId": "delete_link",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "description": "Inbox link ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/links/{link_id}/calendar": {
      "delete": {
        "tags": ["Links"],
        "summary": "Turns calendar off for a connected inbox.",
        "description": "Removes the inbox's calendar data, drops the calendar scopes from its\nrecorded Google grant, and closes its push channels, so the inbox reads as\ncalendar-less until the user runs the calendar consent flow again. Gmail\nsync is untouched.\n\nOnly the inbox's owner may do this: a delegate can see the owner's calendar\nbut must not be able to delete the owner's data.",
        "operationId": "disable_link_calendar",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "description": "Inbox link ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/links/{link_id}/resync": {
      "post": {
        "tags": ["Links"],
        "summary": "Re-syncs a linked inbox by enqueuing a fresh backfill.",
        "description": "Idempotent: if a backfill is already `Init`/`InProgress` for the inbox this is\na no-op and returns that job.",
        "operationId": "resync_link",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "description": "Inbox link ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResyncResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/messages": {
      "post": {
        "tags": ["Messages"],
        "summary": "Send a message.",
        "operationId": "send_message",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMessageResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "An agent's program asked to send; it must go through a review or a confirmed send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/messages/batch": {
      "post": {
        "tags": ["Messages"],
        "operationId": "get_messages_batch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ParsedMessage"
                  }
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/messages/labels": {
      "patch": {
        "tags": ["Messages"],
        "summary": "Add or remove a label from a batch of messages",
        "operationId": "add_remove_label",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateLabelBatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateLabelBatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/messages/{id}": {
      "get": {
        "tags": ["Messages"],
        "operationId": "get_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Message ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ParsedMessage"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/messages/{id}/eml": {
      "get": {
        "tags": ["Messages"],
        "summary": "Download a message's original source as an `.eml` file.",
        "operationId": "get_message_eml",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Message ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "message/rfc822": {
                "schema": {
                  "$ref": "#/components/schemas/EmlFile"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/settings": {
      "patch": {
        "tags": ["Settings"],
        "summary": "Patch user settings.",
        "operationId": "patch_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchSettingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatchSettingsResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnresolvedSignatureImagesError"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/settings/operations": {
      "get": {
        "tags": ["Settings"],
        "summary": "Accepted label and sender-policy changes awaiting provider confirmation.",
        "operationId": "mailbox_settings_operations",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MailboxSettingsOperation"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/email/sync": {
      "delete": {
        "tags": ["Sync"],
        "summary": "Disables inbox syncing for the selected inbox.",
        "description": "The inbox is the caller's primary, or the one named by `X-Email-Link-Id`,\nwhich may be an inbox the caller only reaches through delegation. Removal\ntherefore follows the same policy as `DELETE /email/links/{link_id}`: an\nowner's inbox is torn down, while a delegate only loses their\n`macro_user_links` edge and the owner's data stays intact.",
        "operationId": "disable_sync",
        "parameters": [
          {
            "name": "X-Email-Link-Id",
            "in": "header",
            "description": "Inbox link ID to act on instead of the caller's primary inbox; may name a delegated inbox.",
            "required": false,
            "schema": {
              "type": ["string", "null"],
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/archived": {
      "patch": {
        "tags": ["Threads"],
        "summary": "Change the archived status of up to 100 threads, sending one provider\nwrite per inbox. A thread that can't change is reported, not fatal.",
        "operationId": "archive_threads",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ArchiveThreadsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArchiveThreadsResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/previews/cursor/{view}": {
      "get": {
        "tags": ["Previews"],
        "summary": "Get paginated thread previews with cursor-based pagination.",
        "operationId": "previews_inbox_cursor",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Limit for pagination. Default is 20. Max is 500.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "sort_method",
            "in": "query",
            "description": "Sort method. Options are viewed_at, created_at, updated_at, viewed_updated. Defaults to viewed_updated.",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/ApiSortMethod"
            }
          },
          {
            "name": "view",
            "in": "path",
            "description": "View type. Supported values: inbox, sent, drafts, starred, all, important, other, user:<label>",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Cursor value. Base64 encoded timestamp and item id, separated by |.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiPaginatedThreadCursor"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{id}/archived": {
      "patch": {
        "tags": ["Threads"],
        "summary": "Change the archived status of a thread.",
        "operationId": "archive_thread",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ArchiveThreadRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{id}/labels": {
      "patch": {
        "tags": ["Threads"],
        "summary": "Add or remove a label from all messages in a thread.",
        "operationId": "add_remove_thread_label",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Thread ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateThreadLabelRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateThreadLabelsResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{id}/messages": {
      "get": {
        "tags": ["Threads"],
        "operationId": "get_thread_messages_handler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Thread ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "since",
            "in": "query",
            "description": "Filter messages after this date",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Limit number of messages returned",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ParsedMessage"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{id}/operations": {
      "get": {
        "tags": ["Threads"],
        "summary": "Fetch the latest organization action outcomes without provider-specific status strings.",
        "operationId": "thread_operations",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Thread ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MailboxOperation"
                  }
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{id}/seen": {
      "post": {
        "tags": ["Threads"],
        "summary": "Called by FE when the user has seen a thread.",
        "operationId": "thread_seen",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Thread ID.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{id}/state": {
      "patch": {
        "tags": ["Threads"],
        "summary": "Set mailbox state without client-side provider label lookup.",
        "operationId": "update_thread_state",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Thread ID",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateThreadStateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": ""
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{thread_id}": {
      "get": {
        "tags": ["Threads"],
        "summary": "Get a thread with paginated messages.",
        "operationId": "get_thread",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Thread ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset for message pagination. Default is 0.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Limit for message pagination. Default is 5, max 100.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetThreadResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{thread_id}/calendar-invitations": {
      "get": {
        "tags": ["email"],
        "operationId": "get_thread_calendar_invitations",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Authorized email thread",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "$ref": "#/components/schemas/InvitationResolution"
                  },
                  "propertyNames": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "401": {
            "description": ""
          },
          "403": {
            "description": ""
          }
        }
      }
    },
    "/email/threads/{thread_id}/messages/{message_id}/calendar-invitations/{invitation_id}/copy": {
      "post": {
        "tags": ["email"],
        "summary": "Add a shared event saved from one of the thread's messages to one of the\nviewer's Google calendars, the way Add to calendar adds a channel-shared\nevent: a snapshot under the meeting's iCalendar UID and organizer, with the\nviewer as its only guest and no join link. Nobody is notified. Only a\npublished event file (`METHOD:PUBLISH`) can be added; an invitation is\nanswered from the calendar it reached.",
        "operationId": "copy_thread_calendar_invitation",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Authorized email thread",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message carrying the event",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "invitation_id",
            "in": "path",
            "description": "Saved event within the message",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CopyCalendarEventRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The copy on the viewer's calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarEvent"
                }
              }
            }
          },
          "400": {
            "description": "The saved event cannot be added, or the calendar is not a Google calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarMutationApiError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Calendar is read-only or needs reauthorization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarMutationApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such saved event in the thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarMutationApiError"
                }
              }
            }
          },
          "409": {
            "description": "Already on the viewer's calendar, no writable calendar, or the provider refused the copy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarMutationApiError"
                }
              }
            }
          },
          "503": {
            "description": "Transient provider failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarMutationApiError"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{thread_id}/project": {
      "patch": {
        "tags": ["Threads"],
        "summary": "Update the project assignment for a thread.",
        "operationId": "update_thread_project",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Thread ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateThreadProjectRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateThreadProjectResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/email/threads/{thread_id}/read-receipts": {
      "get": {
        "tags": ["email"],
        "operationId": "get_thread_read_receipts",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Authorized email thread",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadReadReceipts"
                }
              }
            }
          },
          "401": {
            "description": ""
          },
          "403": {
            "description": ""
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": ["Health"],
        "summary": "Health check",
        "operationId": "health_handler",
        "responses": {
          "200": {
            "description": "Health",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          }
        }
      }
    },
    "/opens/{token}": {
      "get": {
        "tags": ["email"],
        "summary": "Every request gets the same uncacheable pixel so the response reveals nothing\nabout the token, and each open reaches the server.",
        "operationId": "get_read_receipt_pixel",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "Opaque pixel token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transparent pixel, for any token",
            "content": {
              "image/gif": {}
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AccessLevel": {
        "type": "string",
        "description": "Ordered from least to most access top -> bottom",
        "enum": ["view", "comment", "edit", "owner"]
      },
      "AddDraftAttachmentRequest": {
        "type": "object",
        "description": "The request passed to send a message",
        "required": ["file_name", "sha", "size"],
        "properties": {
          "file_name": {
            "type": "string",
            "description": "The name of the file being uploaded."
          },
          "sha": {
            "type": "string",
            "description": "The SHA256 hash of the file being uploaded."
          },
          "size": {
            "type": "integer",
            "format": "int32",
            "description": "The size of the file in bytes."
          },
          "upload_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Stable client upload identifier. Retry the same file with the same ID."
          }
        }
      },
      "AddDraftAttachmentResponse": {
        "type": "object",
        "required": ["attachment_id", "upload_url", "content_type"],
        "properties": {
          "attachment_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the attachment in the database."
          },
          "content_type": {
            "type": "string",
            "description": "The MIME type of the attachment."
          },
          "upload_url": {
            "type": "string",
            "description": "The URL to upload the attachment to."
          }
        }
      },
      "AddForwardedAttachmentRequest": {
        "type": "object",
        "required": ["attachment_id"],
        "properties": {
          "attachment_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the original attachment to forward."
          }
        }
      },
      "AddForwardedAttachmentResponse": {
        "type": "object",
        "required": ["attachment_id"],
        "properties": {
          "attachment_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the original attachment."
          },
          "filename": {
            "type": ["string", "null"],
            "description": "Original file name of the attachment."
          },
          "mime_type": {
            "type": ["string", "null"],
            "description": "MIME type of the attachment."
          },
          "size_bytes": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "File size in bytes."
          }
        }
      },
      "ApiAttachment": {
        "type": "object",
        "required": ["id", "messageId", "createdAt"],
        "properties": {
          "contentId": {
            "type": ["string", "null"]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "filename": {
            "type": ["string", "null"]
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "messageId": {
            "type": "string",
            "format": "uuid"
          },
          "mimeType": {
            "type": ["string", "null"]
          },
          "providerAttachmentId": {
            "type": ["string", "null"]
          },
          "sizeBytes": {
            "type": ["integer", "null"],
            "format": "int64"
          }
        }
      },
      "ApiAttachmentDraft": {
        "type": "object",
        "description": "API representation of a draft attachment on a message.",
        "required": [
          "id",
          "draft_id",
          "file_name",
          "content_type",
          "sha",
          "size",
          "s3_key",
          "upload_pending",
          "is_inline"
        ],
        "properties": {
          "content_id": {
            "type": ["string", "null"]
          },
          "content_type": {
            "type": "string"
          },
          "draft_id": {
            "type": "string",
            "format": "uuid"
          },
          "file_name": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "is_inline": {
            "type": "boolean"
          },
          "s3_key": {
            "type": "string"
          },
          "sha": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "format": "int32"
          },
          "upload_pending": {
            "type": "boolean"
          }
        }
      },
      "ApiAttachmentForwarded": {
        "type": "object",
        "description": "API representation of a forwarded attachment on a message.",
        "required": ["attachment_id", "draft_id", "message_provider_id"],
        "properties": {
          "attachment_id": {
            "type": "string",
            "format": "uuid"
          },
          "draft_id": {
            "type": "string",
            "format": "uuid"
          },
          "filename": {
            "type": ["string", "null"]
          },
          "message_provider_id": {
            "type": "string"
          },
          "mime_type": {
            "type": ["string", "null"]
          },
          "provider_attachment_id": {
            "type": ["string", "null"]
          },
          "size_bytes": {
            "type": ["integer", "null"],
            "format": "int64"
          }
        }
      },
      "ApiContact": {
        "type": "object",
        "required": ["id", "linkId"],
        "properties": {
          "emailAddress": {
            "type": ["string", "null"]
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "linkId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": ["string", "null"]
          },
          "sfsPhotoUrl": {
            "type": ["string", "null"]
          }
        }
      },
      "ApiContactInfo": {
        "type": "object",
        "description": "API representation of a contact (sender or recipient).",
        "required": ["email"],
        "properties": {
          "email": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "photo_url": {
            "type": ["string", "null"]
          }
        }
      },
      "ApiDraftContactInfo": {
        "type": "object",
        "description": "Contact info for draft request/response (backward-compatible with MessageToSend shape).",
        "required": ["email"],
        "properties": {
          "email": {
            "type": "string",
            "description": "Email address."
          },
          "name": {
            "type": ["string", "null"],
            "description": "Display name."
          },
          "photo_url": {
            "type": ["string", "null"],
            "description": "Profile photo URL."
          }
        }
      },
      "ApiDraftInput": {
        "type": "object",
        "description": "The draft input matching the current `MessageToSend` JSON shape for backward compat.",
        "required": ["subject"],
        "properties": {
          "bcc": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ApiDraftContactInfo"
            },
            "description": "Bcc recipients."
          },
          "body_html": {
            "type": ["string", "null"],
            "description": "HTML body (base64 URL_SAFE_NO_PAD encoded). Sanitized before storage."
          },
          "body_macro": {
            "type": ["string", "null"],
            "description": "Macro body format."
          },
          "body_text": {
            "type": ["string", "null"],
            "description": "Plain text body."
          },
          "cc": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ApiDraftContactInfo"
            },
            "description": "Cc recipients."
          },
          "db_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Existing message DB ID (for updating an existing draft)."
          },
          "draft_generation": {
            "type": "integer",
            "format": "int32",
            "description": "Generation from the last loaded draft; legacy clients begin at zero."
          },
          "headers_json": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Value",
                "description": "Headers JSON."
              }
            ]
          },
          "include_signature": {
            "type": ["boolean", "null"],
            "description": "Per-message override for whether to include the signature on send:\n`Some(false)` to exclude (user dismissed it). Omit to use the inbox's\ndefault policy. Ignored for drafts."
          },
          "provider_id": {
            "type": ["string", "null"],
            "description": "Provider message ID."
          },
          "provider_thread_id": {
            "type": ["string", "null"],
            "description": "Provider thread ID."
          },
          "replying_to_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "ID of the message this draft is replying to."
          },
          "subject": {
            "type": "string",
            "description": "Subject line."
          },
          "thread_db_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Thread DB ID."
          },
          "to": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ApiDraftContactInfo"
            },
            "description": "To recipients."
          }
        }
      },
      "ApiDraftOutput": {
        "type": "object",
        "description": "The draft output matching the current `MessageToSend` JSON shape for backward compat.",
        "required": ["draft_generation", "link_id", "subject"],
        "properties": {
          "bcc": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ApiDraftContactInfo"
            },
            "description": "Bcc recipients."
          },
          "body_html": {
            "type": ["string", "null"],
            "description": "HTML body (decoded)."
          },
          "body_macro": {
            "type": ["string", "null"],
            "description": "Macro body."
          },
          "body_text": {
            "type": ["string", "null"],
            "description": "Plain text body."
          },
          "cc": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ApiDraftContactInfo"
            },
            "description": "Cc recipients."
          },
          "db_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Message DB ID."
          },
          "draft_generation": {
            "type": "integer",
            "format": "int32",
            "description": "Generation required for subsequent edits."
          },
          "headers_json": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Value",
                "description": "Headers JSON."
              }
            ]
          },
          "link_id": {
            "type": "string",
            "format": "uuid",
            "description": "Link ID."
          },
          "provider_id": {
            "type": ["string", "null"],
            "description": "Provider message ID."
          },
          "provider_thread_id": {
            "type": ["string", "null"],
            "description": "Provider thread ID."
          },
          "replying_to_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "ID of the message this draft is replying to."
          },
          "send_time": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Send time."
          },
          "subject": {
            "type": "string",
            "description": "Subject line."
          },
          "thread_db_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Thread DB ID."
          },
          "to": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ApiDraftContactInfo"
            },
            "description": "To recipients."
          }
        }
      },
      "ApiEmailFilter": {
        "type": "object",
        "description": "A single email filter in API responses.",
        "required": ["id", "is_important", "created_at"],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "email_address": {
            "type": ["string", "null"]
          },
          "email_domain": {
            "type": ["string", "null"]
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "is_important": {
            "type": "boolean"
          }
        }
      },
      "ApiLabel": {
        "type": "object",
        "required": [
          "id",
          "linkId",
          "providerLabelId",
          "name",
          "createdAt",
          "messageListVisibility",
          "labelListVisibility",
          "type"
        ],
        "properties": {
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "labelListVisibility": {
            "$ref": "#/components/schemas/ApiLabelListVisibility"
          },
          "linkId": {
            "type": "string",
            "format": "uuid"
          },
          "messageListVisibility": {
            "$ref": "#/components/schemas/ApiMessageListVisibility"
          },
          "name": {
            "type": "string"
          },
          "providerLabelId": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/ApiLabelType"
          }
        }
      },
      "ApiLabelListVisibility": {
        "type": "string",
        "enum": ["LabelShow", "LabelShowIfUnread", "LabelHide"]
      },
      "ApiLabelType": {
        "type": "string",
        "enum": ["System", "User"]
      },
      "ApiMessage": {
        "type": "object",
        "description": "API representation of a fully assembled email message.",
        "required": [
          "draft_generation",
          "db_id",
          "thread_db_id",
          "link_id",
          "is_read",
          "is_starred",
          "is_sent",
          "is_draft",
          "has_attachments",
          "to",
          "cc",
          "bcc",
          "labels",
          "attachments",
          "attachments_draft",
          "attachments_forwarded",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiMessageAttachment"
            }
          },
          "attachments_draft": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiAttachmentDraft"
            }
          },
          "attachments_forwarded": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiAttachmentForwarded"
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiContactInfo"
            }
          },
          "body_html_sanitized": {
            "type": ["string", "null"]
          },
          "body_macro": {
            "type": ["string", "null"]
          },
          "body_replyless": {
            "type": ["string", "null"]
          },
          "body_text": {
            "type": ["string", "null"]
          },
          "calendar_invitations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalendarInvitation"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiContactInfo"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "draft_generation": {
            "type": "integer",
            "format": "int32",
            "description": "Draft edit generation; changes at send and cancellation boundaries."
          },
          "from": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiContactInfo"
              }
            ]
          },
          "global_id": {
            "type": ["string", "null"]
          },
          "has_attachments": {
            "type": "boolean"
          },
          "headers_json": {},
          "internal_date_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "is_draft": {
            "type": "boolean"
          },
          "is_read": {
            "type": "boolean"
          },
          "is_sent": {
            "type": "boolean"
          },
          "is_starred": {
            "type": "boolean"
          },
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiMessageLabel"
            }
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "operation_status": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiMessageOperation"
              }
            ]
          },
          "provider_history_id": {
            "type": ["string", "null"]
          },
          "provider_id": {
            "type": ["string", "null"]
          },
          "provider_thread_id": {
            "type": ["string", "null"]
          },
          "replying_to_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "scheduled_send_status": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ScheduledSendStatus",
                "description": "Delivery state, including failures and unresolved provider outcomes."
              }
            ]
          },
          "scheduled_send_time": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "sent_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "size_estimate": {
            "type": ["integer", "null"],
            "format": "int64"
          },
          "snippet": {
            "type": ["string", "null"]
          },
          "subject": {
            "type": ["string", "null"]
          },
          "thread_db_id": {
            "type": "string",
            "format": "uuid"
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiContactInfo"
            }
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiMessageAttachment": {
        "type": "object",
        "description": "API representation of a provider attachment on a message.",
        "required": ["db_id"],
        "properties": {
          "content_id": {
            "type": ["string", "null"]
          },
          "data_url": {
            "type": ["string", "null"]
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "filename": {
            "type": ["string", "null"]
          },
          "mime_type": {
            "type": ["string", "null"]
          },
          "provider_id": {
            "type": ["string", "null"]
          },
          "reference_url": {
            "type": ["string", "null"]
          },
          "sfs_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "size_bytes": {
            "type": ["integer", "null"],
            "format": "int64"
          }
        }
      },
      "ApiMessageLabel": {
        "type": "object",
        "description": "API representation of a label on a message.",
        "required": ["link_id", "provider_label_id", "created_at"],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "label_list_visibility": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiLabelListVisibility"
              }
            ]
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "message_list_visibility": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiMessageListVisibility"
              }
            ]
          },
          "name": {
            "type": ["string", "null"]
          },
          "provider_label_id": {
            "type": "string"
          },
          "type_": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiLabelType"
              }
            ]
          }
        }
      },
      "ApiMessageListVisibility": {
        "type": "string",
        "enum": ["Show", "Hide"]
      },
      "ApiMessageOperation": {
        "type": "object",
        "description": "Versions are opaque decimal strings so clients never truncate an i64.",
        "required": ["state", "revision"],
        "properties": {
          "issue": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiMessageOperationIssue"
              }
            ]
          },
          "remote_version": {
            "type": ["string", "null"]
          },
          "revision": {
            "type": "string"
          },
          "state": {
            "$ref": "#/components/schemas/ApiMessageOperationState"
          }
        }
      },
      "ApiMessageOperationIssue": {
        "type": "string",
        "description": "Provider-neutral state exposed to clients.",
        "enum": [
          "ACCEPTING_REMOTE",
          "DRAFT_CONFLICT",
          "CREATION_UNKNOWN",
          "ATTACHMENT_UNKNOWN",
          "SEND_UNKNOWN",
          "SEND_REJECTED",
          "ACCESS_REVOKED",
          "INVALID_CONTENT",
          "MOVE_PENDING",
          "MOVE_CONFLICT",
          "MOVE_SOURCE_SENT",
          "MOVE_REAUTHORIZATION",
          "MOVE_ORIGINAL_REMAINS"
        ]
      },
      "ApiMessageOperationState": {
        "type": "string",
        "description": "Provider-neutral state exposed to clients.",
        "enum": [
          "PENDING",
          "SYNCHRONIZED",
          "CONFLICT",
          "UNCERTAIN",
          "SUBMITTING",
          "CONFIRMING",
          "SENT",
          "DELETED",
          "CANCELLED",
          "FAILED"
        ]
      },
      "ApiMessageResolutionAction": {
        "type": "string",
        "description": "A deliberate resolution of a particular observed operation version.",
        "enum": [
          "keep_local",
          "use_provider",
          "recheck",
          "retry_send",
          "keep_original"
        ]
      },
      "ApiPaginatedThreadCursor": {
        "type": "object",
        "required": ["items"],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiThreadPreviewCursor"
            }
          },
          "next_cursor": {
            "type": ["string", "null"]
          }
        }
      },
      "ApiSortMethod": {
        "type": "string",
        "description": "common types of sorts based on timestamps",
        "enum": ["viewed_at", "updated_at", "created_at", "viewed_updated"]
      },
      "ApiThread": {
        "type": "object",
        "description": "API representation of a fully assembled email thread.",
        "required": [
          "db_id",
          "link_id",
          "inbox_visible",
          "is_read",
          "has_received_mail",
          "access_level",
          "created_at",
          "updated_at",
          "messages"
        ],
        "properties": {
          "access_level": {
            "$ref": "#/components/schemas/AccessLevel"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "has_received_mail": {
            "type": "boolean",
            "description": "Whether any message was received rather than drafted or sent. Only\nthreads with received mail can return to the inbox."
          },
          "inbox_visible": {
            "type": "boolean"
          },
          "is_read": {
            "type": "boolean"
          },
          "latest_inbound_message_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "latest_non_spam_message_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "latest_outbound_message_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiMessage"
            }
          },
          "project_id": {
            "type": ["string", "null"]
          },
          "provider_id": {
            "type": ["string", "null"]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiThreadPreviewCursor": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiThreadPreviewCursorInner"
          },
          {
            "type": "object",
            "required": ["attachments", "contacts", "labels"],
            "properties": {
              "attachments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ApiAttachment"
                }
              },
              "contacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ApiContact"
                }
              },
              "frecencyScore": {
                "type": ["number", "null"],
                "format": "double"
              },
              "labels": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ApiLabel"
                }
              }
            }
          }
        ]
      },
      "ApiThreadPreviewCursorInner": {
        "type": "object",
        "required": [
          "id",
          "ownerId",
          "inboxVisible",
          "isRead",
          "isDraft",
          "isImportant",
          "sortTs",
          "createdAt",
          "updatedAt",
          "linkId"
        ],
        "properties": {
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "inboxVisible": {
            "type": "boolean"
          },
          "isDraft": {
            "type": "boolean"
          },
          "isImportant": {
            "type": "boolean"
          },
          "isRead": {
            "type": "boolean"
          },
          "linkId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": ["string", "null"]
          },
          "ownerId": {
            "type": "string"
          },
          "providerId": {
            "type": ["string", "null"]
          },
          "senderEmail": {
            "type": ["string", "null"]
          },
          "senderName": {
            "type": ["string", "null"]
          },
          "senderPhotoUrl": {
            "type": ["string", "null"]
          },
          "snippet": {
            "type": ["string", "null"]
          },
          "sortTs": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "viewedAt": {
            "type": ["string", "null"],
            "format": "date-time"
          }
        }
      },
      "ArchiveThreadRequest": {
        "type": "object",
        "required": ["value"],
        "properties": {
          "value": {
            "type": "boolean"
          }
        }
      },
      "ArchiveThreadsRequest": {
        "type": "object",
        "required": ["thread_ids", "value"],
        "properties": {
          "thread_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "value": {
            "type": "boolean"
          }
        }
      },
      "ArchiveThreadsResponse": {
        "type": "object",
        "required": ["updated_thread_ids", "failed_thread_ids"],
        "properties": {
          "failed_thread_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Threads left unchanged because they could not be updated."
          },
          "updated_thread_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Threads whose archived status now matches the request."
          }
        }
      },
      "Attachment": {
        "type": "object",
        "description": "Attachments of a message, as sent to us by the provider.",
        "required": ["db_id"],
        "properties": {
          "content_id": {
            "type": ["string", "null"]
          },
          "data_url": {
            "type": ["string", "null"]
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "filename": {
            "type": ["string", "null"]
          },
          "mime_type": {
            "type": ["string", "null"]
          },
          "provider_id": {
            "type": ["string", "null"]
          },
          "reference_url": {
            "type": ["string", "null"],
            "description": "Cloud reference: open this provider page instead of downloading bytes."
          },
          "sfs_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "size_bytes": {
            "type": ["integer", "null"],
            "format": "int64"
          }
        }
      },
      "AttachmentDraft": {
        "type": "object",
        "required": [
          "id",
          "draft_id",
          "file_name",
          "content_type",
          "sha",
          "size",
          "s3_key"
        ],
        "properties": {
          "content_id": {
            "type": ["string", "null"],
            "description": "Original Content-ID retained when transferring a provider attachment."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type of the attachment (e.g., \"application/pdf\", \"image/png\")."
          },
          "draft_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the draft message this attachment belongs to."
          },
          "file_name": {
            "type": "string",
            "description": "Original file name of the attachment."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the attachment."
          },
          "is_inline": {
            "type": "boolean",
            "description": "Whether the attachment is referenced inline by the message body."
          },
          "s3_key": {
            "type": "string",
            "description": "S3 object key where the attachment content is stored."
          },
          "sha": {
            "type": "string",
            "description": "SHA-256 hash of the file content for integrity verification."
          },
          "size": {
            "type": "integer",
            "format": "int32",
            "description": "File size in bytes."
          },
          "upload_pending": {
            "type": "boolean",
            "description": "Bytes have not yet been verified; sending must wait for completion."
          }
        }
      },
      "AttachmentForwarded": {
        "type": "object",
        "description": "A forwarded attachment linking a draft to an original message's attachment.\nData is fetched from Gmail at send time rather than stored in S3.",
        "required": ["attachment_id", "draft_id", "message_provider_id"],
        "properties": {
          "attachment_id": {
            "type": "string",
            "format": "uuid",
            "description": "The UUID of the original attachment in email_attachments."
          },
          "draft_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the draft message this forwarded attachment belongs to."
          },
          "filename": {
            "type": ["string", "null"],
            "description": "Original file name of the attachment."
          },
          "message_provider_id": {
            "type": "string",
            "description": "The Gmail message ID of the original message containing the attachment."
          },
          "mime_type": {
            "type": ["string", "null"],
            "description": "MIME type of the attachment."
          },
          "provider_attachment_id": {
            "type": ["string", "null"],
            "description": "The Gmail attachment ID for fetching data from Gmail API."
          },
          "size_bytes": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "File size in bytes."
          }
        }
      },
      "AttendeeResponseStatus": {
        "type": "string",
        "description": "RSVP state for an attendee.",
        "enum": ["needs_action", "accepted", "declined", "tentative"]
      },
      "BackfillJob": {
        "type": "object",
        "required": [
          "id",
          "fusionauth_user_id",
          "total_threads",
          "status",
          "threads_retrieved_count",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "fusionauth_user_id": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "link_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/BackfillJobStatus"
          },
          "threads_requested_limit": {
            "type": ["integer", "null"],
            "format": "int32"
          },
          "threads_retrieved_count": {
            "type": "integer",
            "format": "int32"
          },
          "total_threads": {
            "type": "integer",
            "format": "int32"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BackfillJobStatus": {
        "type": "string",
        "enum": ["Init", "InProgress", "Complete", "Cancelled", "Failed"]
      },
      "BackfillStatus": {
        "type": "string",
        "description": "Progress/terminal state of a backfill job for [`RefreshEmailEvent::Backfill`].",
        "enum": ["progress", "complete", "failed"]
      },
      "BlockSenderRequest": {
        "type": "object",
        "description": "Request to block a sender.",
        "required": ["email_address"],
        "properties": {
          "email_address": {
            "type": "string",
            "description": "The email address of the sender to block."
          }
        }
      },
      "CalendarAttendee": {
        "type": "object",
        "description": "An attendee on a calendar event.",
        "required": [
          "email",
          "responseStatus",
          "isOrganizer",
          "isOptional",
          "isSelf"
        ],
        "properties": {
          "comment": {
            "type": ["string", "null"],
            "description": "Optional attendee comment."
          },
          "displayName": {
            "type": ["string", "null"],
            "description": "Provider display name."
          },
          "email": {
            "type": "string",
            "description": "Normalized email address."
          },
          "isOptional": {
            "type": "boolean",
            "description": "Whether attendance is optional."
          },
          "isOrganizer": {
            "type": "boolean",
            "description": "Whether this attendee is the organizer."
          },
          "isSelf": {
            "type": "boolean",
            "description": "Whether this attendee is one of the viewing requester's inboxes."
          },
          "responseStatus": {
            "$ref": "#/components/schemas/AttendeeResponseStatus",
            "description": "RSVP state."
          }
        }
      },
      "CalendarEvent": {
        "type": "object",
        "description": "A stable, first-class Macro calendar event entity.\n\nContent fields hold the canonical source's values: the account's primary\ncalendar copy when one is synced, else the freshest remaining copy.",
        "required": [
          "id",
          "ownerId",
          "icalUid",
          "title",
          "status",
          "visibility",
          "transparency",
          "time",
          "recurrenceLines",
          "sequence",
          "isReadOnly",
          "attendees",
          "guestPolicy",
          "isSnapshot",
          "viewerCan",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "attendees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalendarAttendee"
            },
            "description": "Attendees, keyed by email during persistence."
          },
          "calendarId": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Calendar the canonical source belongs to, when known. Absent only in\nprojections stored before calendars were attributed."
          },
          "conferenceProvider": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ConferenceProvider",
                "description": "Which conferencing system backs `conference_url`. `None` whenever no\nconference is attached."
              }
            ]
          },
          "conferenceUrl": {
            "type": ["string", "null"],
            "description": "Direct join URL when known."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Entity creation time."
          },
          "creatorEmail": {
            "type": ["string", "null"],
            "description": "Provider-reported creator email. Distinct from the organizer when\nsomeone writes onto a calendar they do not own. Omitted from stored\nprojections when unknown so events ingested before this field still\ncompare equal."
          },
          "creatorName": {
            "type": ["string", "null"],
            "description": "Provider-reported creator display name."
          },
          "description": {
            "type": ["string", "null"],
            "description": "Optional event body."
          },
          "eventType": {
            "$ref": "#/components/schemas/EventType",
            "description": "Provider event type. Skipped when it is the regular type so\nprojections stored before event types were modeled still compare\nequal."
          },
          "guestPolicy": {
            "$ref": "#/components/schemas/GuestPolicy",
            "description": "What the organizer lets guests do: the canonical copy's values, or\nGoogle's defaults for an event synced before the policy was modeled."
          },
          "icalUid": {
            "type": "string",
            "description": "RFC 5545 UID used to reconcile provider and email sources."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Macro entity identifier."
          },
          "isReadOnly": {
            "type": "boolean",
            "description": "Whether the canonical source's calendar prohibits editing it."
          },
          "isSnapshot": {
            "type": "boolean",
            "description": "Whether this is a snapshot of a meeting shared with the owner, which\nMacro added to their calendar as a private copy: the meeting's changes\nnever reach it, and nothing done to it reaches the meeting."
          },
          "location": {
            "type": ["string", "null"],
            "description": "Optional physical or virtual location label."
          },
          "organizerEmail": {
            "type": ["string", "null"],
            "description": "Organizer email."
          },
          "organizerName": {
            "type": ["string", "null"],
            "description": "Organizer display name."
          },
          "ownerId": {
            "type": "string",
            "description": "Macro user who owns this event entity."
          },
          "recurrenceLines": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Raw RFC 5545 recurrence properties (`RRULE`, `RDATE`, `EXDATE`)."
          },
          "reminders": {
            "$ref": "#/components/schemas/EventReminders",
            "description": "Per-user reminder configuration. Skipped when it is the provider\ndefault so projections stored before reminders were modeled still\ncompare equal."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Provider/iCalendar sequence number.",
            "minimum": 0
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalendarEventSourceContent"
            },
            "description": "Content of every active copy of this event, canonical first: the\nprimary calendar's copy, then the freshest. A client picks the copy\nwhose calendar it is showing and falls back to the first. Populated\nonly on the read path, so stored projections omit it."
          },
          "status": {
            "$ref": "#/components/schemas/EventStatus",
            "description": "Event status."
          },
          "time": {
            "$ref": "#/components/schemas/EventTime",
            "description": "Timed or all-day shape."
          },
          "title": {
            "type": "string",
            "description": "Display title."
          },
          "transparency": {
            "$ref": "#/components/schemas/EventTransparency",
            "description": "Availability behavior."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Entity update time."
          },
          "viewerCan": {
            "$ref": "#/components/schemas/ViewerCapabilities",
            "description": "What the viewing requester may do with the event. Resolved only on\nthe read path, alongside each attendee's `is_self`; nothing when no\nviewer is known. Source projections never store it."
          },
          "visibility": {
            "$ref": "#/components/schemas/EventVisibility",
            "description": "Event visibility."
          }
        }
      },
      "CalendarEventSourceContent": {
        "type": "object",
        "description": "The content one provider copy of an event carries.\n\nGoogle keeps these fields per calendar copy: a shared calendar's copy of a\nmember's event can have its own title, type, reminders, and access role.\nThe entity holds its canonical source's values. Every other copy's values\nare read from here so a client can show the copy that belongs to the\ncalendar being viewed.",
        "required": [
          "calendarId",
          "title",
          "eventType",
          "visibility",
          "transparency",
          "isReadOnly",
          "reminders"
        ],
        "properties": {
          "calendarId": {
            "type": "string",
            "format": "uuid",
            "description": "Calendar this copy lives on."
          },
          "creatorEmail": {
            "type": ["string", "null"],
            "description": "Provider-reported creator email."
          },
          "creatorName": {
            "type": ["string", "null"],
            "description": "Provider-reported creator display name."
          },
          "description": {
            "type": ["string", "null"],
            "description": "Optional event body."
          },
          "eventType": {
            "$ref": "#/components/schemas/EventType",
            "description": "Provider event type."
          },
          "isReadOnly": {
            "type": "boolean",
            "description": "Whether the calendar's access role prohibits editing this copy."
          },
          "location": {
            "type": ["string", "null"],
            "description": "Optional physical or virtual location label."
          },
          "reminders": {
            "$ref": "#/components/schemas/EventReminders",
            "description": "Reminder configuration of this copy."
          },
          "title": {
            "type": "string",
            "description": "Display title."
          },
          "transparency": {
            "$ref": "#/components/schemas/EventTransparency",
            "description": "Availability behavior."
          },
          "visibility": {
            "$ref": "#/components/schemas/EventVisibility",
            "description": "Event visibility."
          }
        }
      },
      "CalendarInvitation": {
        "type": "object",
        "description": "Display snapshot of one meaningful VEVENT, owned by the email domain.",
        "required": ["id", "uid", "method", "sequence", "attendees"],
        "properties": {
          "attendees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvitationParticipant"
            },
            "description": "Historical attendee identities and participation metadata."
          },
          "comment": {
            "type": ["string", "null"],
            "description": "Reply or counter-proposal comment."
          },
          "conference_url": {
            "type": ["string", "null"],
            "description": "Validated HTTP(S) conferencing URL; never fetched during rendering."
          },
          "description": {
            "type": ["string", "null"],
            "description": "Plaintext description, retaining passwords and dial-in instructions."
          },
          "dtstamp": {
            "type": ["string", "null"],
            "description": "Scheduling timestamp in its original spelling."
          },
          "end": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/InvitationDateTime",
                "description": "Exclusive typed end, derived from DURATION when DTEND is absent."
              }
            ]
          },
          "id": {
            "type": "string",
            "description": "Content-derived component identity, stable across repeated extraction."
          },
          "last_modified": {
            "type": ["string", "null"],
            "description": "Last modification timestamp in its original spelling."
          },
          "location": {
            "type": ["string", "null"],
            "description": "Plaintext event location."
          },
          "method": {
            "$ref": "#/components/schemas/InvitationMethod",
            "description": "Original scheduling method."
          },
          "organizer": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/InvitationParticipant",
                "description": "Organizer identity from the scheduling component."
              }
            ]
          },
          "recurrence": {
            "type": ["array", "null"],
            "items": {
              "type": "string"
            },
            "description": "Raw `RRULE`, `RDATE` and `EXDATE` lines, empty for a single event.\n`None` on snapshots saved before recurrence was recorded, where a\nseries cannot be told apart from a single event."
          },
          "recurrence_id": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/InvitationDateTime",
                "description": "Original occurrence start, even when the instance moved."
              }
            ]
          },
          "recurrence_id_raw": {
            "type": ["string", "null"],
            "description": "Original recurrence identifier spelling and parameters."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Scheduling revision, distinct from delivery order.",
            "minimum": 0
          },
          "start": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/InvitationDateTime",
                "description": "Original typed start, if supplied."
              }
            ]
          },
          "status": {
            "type": ["string", "null"],
            "description": "Original event status."
          },
          "title": {
            "type": ["string", "null"],
            "description": "Event summary."
          },
          "uid": {
            "type": "string",
            "description": "iCalendar UID; never a Google provider event ID."
          }
        }
      },
      "CalendarMutationApiError": {
        "type": "object",
        "description": "HTTP error body returned by calendar mutation endpoints.",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "$ref": "#/components/schemas/CalendarMutationErrorCode",
            "description": "Machine-readable failure category."
          },
          "message": {
            "type": "string",
            "description": "Human-readable failure description."
          }
        }
      },
      "CalendarMutationErrorCode": {
        "type": "string",
        "description": "Machine-readable failure category for calendar mutations.",
        "enum": [
          "not_found",
          "occurrence_not_found",
          "read_only",
          "no_writable_calendar",
          "not_attendee",
          "not_organizer",
          "guests_cannot_invite",
          "guest_list_hidden",
          "guests_cannot_modify",
          "already_on_calendar",
          "join_request_open",
          "copy_refused",
          "snapshot",
          "invalid_input",
          "reauth_required",
          "provider_rejected",
          "retryable",
          "persist_failed",
          "macro_call_failed",
          "copy_choice_required",
          "confirmation_required"
        ]
      },
      "CalendarOccurrence": {
        "type": "object",
        "description": "A materialized recurrence instance optimized for range queries.",
        "required": ["eventId", "occurrenceKey", "time", "isCancelled"],
        "properties": {
          "eventId": {
            "type": "string",
            "format": "uuid",
            "description": "Owning event entity."
          },
          "isCancelled": {
            "type": "boolean",
            "description": "Whether the instance was cancelled."
          },
          "occurrenceKey": {
            "type": "string",
            "description": "Stable key within the event."
          },
          "recurrenceId": {
            "type": ["string", "null"],
            "description": "Provider recurrence identifier, when applicable."
          },
          "time": {
            "$ref": "#/components/schemas/EventTime",
            "description": "Instance time."
          }
        }
      },
      "CancelBackfillParams": {
        "type": "object",
        "required": ["job_id"],
        "properties": {
          "job_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "ConferenceProvider": {
        "type": "string",
        "description": "The conferencing system backing an event's join URL.\n\nCalendars can create Google Meet or Microsoft Teams according to their\ncapabilities. Imported third-party conferences are labeled separately.\nOmitting a conference change preserves the current conference; explicit\nchanges still require provider and calendar capability validation.",
        "enum": ["microsoft_teams", "google_meet", "other"]
      },
      "Contact": {
        "type": "object",
        "required": ["id", "link_id"],
        "properties": {
          "email_address": {
            "type": ["string", "null"]
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": ["string", "null"]
          },
          "original_photo_url": {
            "type": ["string", "null"]
          },
          "sfs_photo_url": {
            "type": ["string", "null"]
          }
        }
      },
      "ContactInfo": {
        "type": "object",
        "required": ["email"],
        "properties": {
          "email": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "photo_url": {
            "type": ["string", "null"]
          }
        }
      },
      "ContactInfoLegacy": {
        "type": "object",
        "required": ["email", "email_address"],
        "properties": {
          "email": {
            "type": "string"
          },
          "email_address": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "photo_url": {
            "type": ["string", "null"]
          }
        }
      },
      "ContactInfoWithInteraction": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ContactInfoLegacy"
          },
          {
            "type": "object",
            "required": ["last_interaction"],
            "properties": {
              "last_interaction": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "CopyCalendarEventRequest": {
        "type": "object",
        "description": "Request body adding a shared event to the requester's calendar.",
        "properties": {
          "calendarId": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Google calendar to add the copy to; defaults to the requester's\nprimary inbox's primary calendar."
          }
        }
      },
      "CreateDraftRequest": {
        "type": "object",
        "description": "Request body for creating a draft.",
        "required": ["draft"],
        "properties": {
          "draft": {
            "$ref": "#/components/schemas/ApiDraftInput",
            "description": "The draft content."
          },
          "send_time": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Scheduled send time."
          }
        }
      },
      "CreateDraftResponse": {
        "type": "object",
        "description": "Response body for creating a draft.",
        "required": ["draft"],
        "properties": {
          "draft": {
            "$ref": "#/components/schemas/ApiDraftOutput",
            "description": "The created draft."
          }
        }
      },
      "CreateLabelRequest": {
        "type": "object",
        "required": ["label_name"],
        "properties": {
          "label_name": {
            "type": "string"
          }
        }
      },
      "CreateLabelResponse": {
        "type": "object",
        "description": "The response returned from the create label endpoint",
        "required": ["label"],
        "properties": {
          "label": {
            "$ref": "#/components/schemas/Label",
            "description": "Local label. Pending provider creation is reported by settings operations."
          }
        }
      },
      "EmlFile": {
        "type": "string",
        "format": "binary"
      },
      "EmptyResponse": {
        "type": "object",
        "description": "Empty response is required due to custom fetch forcing `response.json()`"
      },
      "ErrorResponse": {
        "type": "object",
        "description": "A plain old json error response for use with axum.\nyup, thats it.",
        "required": ["message"],
        "properties": {
          "message": {
            "type": "string",
            "description": "Message to explain failure"
          }
        }
      },
      "EventReminderOverride": {
        "type": "object",
        "description": "One reminder: how it alerts and how many minutes before the event start\n(before midnight in the calendar's zone for all-day events) it fires.",
        "required": ["method", "minutes"],
        "properties": {
          "method": {
            "type": "string",
            "description": "Provider method, stored verbatim; only `popup` fires Macro\nnotifications."
          },
          "minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes before the event start.",
            "minimum": 0
          }
        }
      },
      "EventReminders": {
        "type": "object",
        "description": "Per-user reminder configuration for an event, mirroring Google's model:\neither the calendar's default reminders apply, or the explicit overrides\nreplace them entirely.",
        "required": ["useDefault"],
        "properties": {
          "overrides": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventReminderOverride"
            },
            "description": "Explicit reminders replacing the defaults when `use_default` is off."
          },
          "useDefault": {
            "type": "boolean",
            "description": "Whether the calendar's default reminders apply."
          }
        }
      },
      "EventStatus": {
        "type": "string",
        "description": "Canonical event status.",
        "enum": ["confirmed", "tentative", "cancelled"]
      },
      "EventTime": {
        "oneOf": [
          {
            "type": "object",
            "description": "An event with absolute instants.",
            "required": ["startsAt", "endsAt", "kind"],
            "properties": {
              "endsAt": {
                "type": "string",
                "format": "date-time",
                "description": "Exclusive end instant; equal to the start for an imported point event."
              },
              "kind": {
                "type": "string",
                "enum": ["timed"]
              },
              "startsAt": {
                "type": "string",
                "format": "date-time",
                "description": "Inclusive start instant."
              },
              "timeZone": {
                "type": ["string", "null"],
                "description": "Original IANA time-zone identifier, when supplied."
              }
            }
          },
          {
            "type": "object",
            "description": "An all-day event using RFC 5545's exclusive end date.",
            "required": ["startDate", "endDate", "kind"],
            "properties": {
              "endDate": {
                "type": "string",
                "format": "date",
                "description": "Exclusive local end date."
              },
              "kind": {
                "type": "string",
                "enum": ["allDay"]
              },
              "startDate": {
                "type": "string",
                "format": "date",
                "description": "Inclusive local start date."
              }
            }
          }
        ],
        "description": "The mutually exclusive time shape of a calendar event.\n\nFields are renamed per variant rather than with `rename_all_fields`\nbecause utoipa only honors variant-level serde renames when it\nderives the OpenAPI schema."
      },
      "EventTransparency": {
        "type": "string",
        "description": "Whether an event blocks availability.",
        "enum": ["opaque", "transparent"]
      },
      "EventType": {
        "type": "string",
        "description": "Google's event type: ordinary meetings versus the status-style entries\n(working location, out of office, focus time, birthdays) Google renders\nand notifies differently. Immutable at the provider after creation.",
        "enum": [
          "default",
          "out_of_office",
          "focus_time",
          "working_location",
          "birthday",
          "from_gmail"
        ]
      },
      "EventVisibility": {
        "type": "string",
        "description": "Visibility of event details.",
        "enum": ["default", "public", "private", "confidential"]
      },
      "ForwardCalendarEventError": {
        "type": "object",
        "description": "A refused or failed forward.",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "$ref": "#/components/schemas/ForwardCalendarEventErrorCode",
            "description": "What went wrong."
          },
          "message": {
            "type": "string",
            "description": "A message fit to show the user."
          }
        }
      },
      "ForwardCalendarEventErrorCode": {
        "type": "string",
        "description": "Why a forward was not sent.",
        "enum": [
          "not_found",
          "invalid_recipients",
          "inbox_unavailable",
          "send_failed"
        ]
      },
      "ForwardCalendarEventRecipient": {
        "type": "object",
        "description": "One person a forwarded invitation goes to.",
        "required": ["email"],
        "properties": {
          "email": {
            "type": "string",
            "description": "Their email address."
          },
          "name": {
            "type": ["string", "null"],
            "description": "Their display name."
          }
        }
      },
      "ForwardCalendarEventRequest": {
        "type": "object",
        "description": "Who a forwarded invitation goes to, and what its email says.",
        "required": ["to"],
        "properties": {
          "bodyText": {
            "type": ["string", "null"],
            "description": "A plain-text summary of the event the email opens with; the title\nwhen absent. The email ends with a note saying what the recipient\ncan do with the forward."
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForwardCalendarEventRecipient"
            },
            "description": "The people it goes to, at most 50."
          }
        }
      },
      "ForwardCalendarEventResponse": {
        "type": "object",
        "description": "The email the forward queued.",
        "required": ["messageId", "threadId"],
        "properties": {
          "messageId": {
            "type": "string",
            "format": "uuid",
            "description": "The sent message."
          },
          "threadId": {
            "type": "string",
            "format": "uuid",
            "description": "Its thread."
          }
        }
      },
      "GetActiveBackfillJobResponse": {
        "type": "object",
        "description": "The response returned from the get backfill job endpoint",
        "required": ["job"],
        "properties": {
          "job": {
            "$ref": "#/components/schemas/BackfillJob"
          }
        }
      },
      "GetAttachmentDocumentIDResponse": {
        "type": "object",
        "description": "The response returned from the get attachment endpoint",
        "required": ["attachment_id", "document_id"],
        "properties": {
          "attachment_id": {
            "type": "string",
            "format": "uuid"
          },
          "document_id": {
            "type": "string"
          }
        }
      },
      "GetAttachmentResponse": {
        "type": "object",
        "description": "The response returned from the get attachment endpoint",
        "required": ["attachment"],
        "properties": {
          "attachment": {
            "$ref": "#/components/schemas/Attachment"
          }
        }
      },
      "GetBackfillJobResponse": {
        "type": "object",
        "description": "The response returned from the get backfill job endpoint",
        "required": ["job"],
        "properties": {
          "job": {
            "$ref": "#/components/schemas/BackfillJob"
          }
        }
      },
      "GetPreviewsCursorParams": {
        "type": "object",
        "description": "Parameters for getting thread previews with cursor-based pagination.",
        "properties": {
          "limit": {
            "type": ["integer", "null"],
            "format": "int32",
            "description": "Limit for pagination. Default is 20. Max is 500.",
            "minimum": 0
          },
          "sort_method": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiSortMethod",
                "description": "Sort method. Options are viewed_at, created_at, updated_at, viewed_updated. Defaults to viewed_updated."
              }
            ]
          }
        }
      },
      "GetScheduledResponse": {
        "type": "object",
        "required": ["messages"],
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      },
      "GetThreadResponse": {
        "type": "object",
        "description": "Response body for the get-thread endpoint.",
        "required": ["thread"],
        "properties": {
          "thread": {
            "$ref": "#/components/schemas/ApiThread"
          }
        }
      },
      "GuestPolicy": {
        "type": "object",
        "description": "The switches an organizer sets on an event to bound what its guests may\ndo. Google omits a switch from the payload while it holds its default.",
        "required": ["canModify", "canInviteOthers", "canSeeOtherGuests"],
        "properties": {
          "canInviteOthers": {
            "type": "boolean",
            "description": "Whether guests may invite others."
          },
          "canModify": {
            "type": "boolean",
            "description": "Whether guests may change the event, including its guest list."
          },
          "canSeeOtherGuests": {
            "type": "boolean",
            "description": "Whether guests may see the guest list."
          }
        }
      },
      "InitErrorCodeResponse": {
        "type": "object",
        "description": "Structured 400 body carrying a machine-readable code. Clients branch on\n`code` instead of parsing the human message.",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable machine-readable error code."
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation."
          }
        }
      },
      "InitResponse": {
        "type": "object",
        "required": ["link_id"],
        "properties": {
          "backfill_job_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Present when init enqueued a backfill job. Absent for cross-user delegation,\nwhere the child link's backfill already ran under its own macro_id; present for\nthe self-link bootstrap, where a fresh link is provisioned and backfilled."
          },
          "link_id": {
            "type": "string",
            "format": "uuid",
            "description": "The email_links row id for the now-accessible inbox. For cross-user delegation\nthis is the *existing* child link the caller now delegates over; for the\nself-link bootstrap and the data-source path it's a freshly upserted row."
          }
        }
      },
      "InvitationDateTime": {
        "oneOf": [
          {
            "type": "object",
            "description": "Calendar date. DTEND remains exclusive.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["date"]
              },
              "value": {
                "type": "string",
                "description": "ISO calendar date."
              }
            }
          },
          {
            "type": "object",
            "description": "Unambiguous instant with the original timezone retained.",
            "required": ["value", "time_zone", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["zoned"]
              },
              "time_zone": {
                "type": "string",
                "description": "IANA zone of the original TZID, or UTC."
              },
              "value": {
                "type": "string",
                "description": "RFC3339 instant."
              }
            }
          },
          {
            "type": "object",
            "description": "Floating, ambiguous, nonexistent, or unknown-zone wall time.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["unresolved"]
              },
              "time_zone": {
                "type": ["string", "null"],
                "description": "Original TZID if present."
              },
              "value": {
                "type": "string",
                "description": "ISO local wall time, without an offset."
              }
            }
          }
        ],
        "description": "Preserve date-only and unresolved times without manufacturing UTC instants."
      },
      "InvitationMethod": {
        "type": "string",
        "description": "Original scheduling method, including methods unsupported for actions.",
        "enum": ["request", "reply", "cancel", "counter", "publish", "unknown"]
      },
      "InvitationParticipant": {
        "type": "object",
        "description": "Scheduling participant; saved responses are historical, not current RSVP.",
        "required": ["email"],
        "properties": {
          "email": {
            "type": "string",
            "description": "Participant calendar address."
          },
          "name": {
            "type": ["string", "null"],
            "description": "Sender-supplied display name."
          },
          "participation_status": {
            "type": ["string", "null"],
            "description": "Original PARTSTAT, retaining extensions."
          }
        }
      },
      "InvitationResolution": {
        "oneOf": [
          {
            "type": "object",
            "description": "Viewer has no active owned or delegated Google-backed calendar.",
            "required": ["kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["disconnected"]
              }
            }
          },
          {
            "type": "object",
            "description": "An active calendar is still ingesting this event.",
            "required": ["kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["still_syncing"]
              }
            }
          },
          {
            "type": "object",
            "description": "A saved scheduling cancellation precedes removal from the synced projection.",
            "required": ["kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["cancelled"]
              }
            }
          },
          {
            "type": "object",
            "description": "Original occurrence identity cannot safely be interpreted.",
            "required": ["kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["unavailable"]
              }
            }
          },
          {
            "type": "object",
            "description": "No independently authorized matching copy has synced.",
            "required": ["kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["no_match"]
              }
            }
          },
          {
            "type": "object",
            "description": "More than one authorized account could respond; never guess.",
            "required": ["kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["ambiguous"]
              }
            }
          },
          {
            "type": "object",
            "description": "Current authorized event and explicit capabilities.",
            "required": [
              "event",
              "occurrence",
              "responding_email",
              "can_respond",
              "can_join",
              "is_stale",
              "kind"
            ],
            "properties": {
              "can_join": {
                "type": "boolean",
                "description": "Whether the conference link belongs to the reconciled scheduling target."
              },
              "can_respond": {
                "type": "boolean",
                "description": "Whether a response is currently allowed."
              },
              "event": {
                "$ref": "#/components/schemas/CalendarEvent",
                "description": "Current occurrence-specific content."
              },
              "is_stale": {
                "type": "boolean",
                "description": "Whether the provider projection trails the email revision."
              },
              "kind": {
                "type": "string",
                "enum": ["resolved"]
              },
              "occurrence": {
                "$ref": "#/components/schemas/CalendarOccurrence",
                "description": "Original occurrence identity and current time."
              },
              "responding_email": {
                "type": "string",
                "description": "Connected address that would respond."
              }
            }
          }
        ],
        "description": "Refreshable result, distinct from the immutable email contents."
      },
      "Label": {
        "type": "object",
        "required": ["link_id", "provider_label_id", "created_at"],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "label_list_visibility": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/LabelListVisibility"
              }
            ]
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "message_list_visibility": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/MessageListVisibility"
              }
            ]
          },
          "name": {
            "type": ["string", "null"]
          },
          "provider_label_id": {
            "type": "string"
          },
          "type_": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/LabelType"
              }
            ]
          }
        }
      },
      "LabelInfo": {
        "type": "object",
        "required": ["provider_id", "name"],
        "properties": {
          "name": {
            "type": "string"
          },
          "provider_id": {
            "type": "string"
          }
        }
      },
      "LabelListVisibility": {
        "type": "string",
        "enum": ["LabelShow", "LabelShowIfUnread", "LabelHide"]
      },
      "LabelType": {
        "type": "string",
        "enum": ["System", "User"]
      },
      "Link": {
        "type": "object",
        "required": [
          "id",
          "macro_id",
          "fusionauth_user_id",
          "email_address",
          "provider",
          "is_sync_active",
          "sync_status",
          "needs_reauth",
          "needs_calendar_permission",
          "calendar_disabled",
          "has_calendar_data",
          "settings",
          "is_primary",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "calendar_disabled": {
            "type": "boolean",
            "description": "Whether the user turned calendar off for this inbox, which also removed\nits calendar data. `needs_calendar_permission` is true either way, so\nthis is what separates \"never granted\" from \"deliberately off\" —\nunprompted calendar nags must stay quiet for the latter."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "email_address": {
            "type": "string"
          },
          "fusionauth_user_id": {
            "type": "string"
          },
          "has_calendar_data": {
            "type": "boolean",
            "description": "Whether Macro holds calendar data for this inbox. Drives the turn-off\ncontrol on its own, so removing that data never depends on the recorded\nscopes still matching the set Macro requests today — a set that changes\nas the integration narrows, stranding data behind a capability check\nthat no longer recognizes an older grant."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "is_primary": {
            "type": "boolean"
          },
          "is_sync_active": {
            "type": "boolean"
          },
          "macro_id": {
            "type": "string"
          },
          "needs_calendar_permission": {
            "type": "boolean",
            "description": "Whether the link's Google grant is missing the calendar scope. True for\ninboxes connected before the calendar capability existed (and for\ngrants where the user declined it); drives the per-inbox calendar\nupgrade prompt. Re-running the connect flow records the new grant."
          },
          "needs_reauth": {
            "type": "boolean",
            "description": "Whether the link's Google grant needs to be reconnected. Drives the\nper-inbox reconnect prompt independently of the sync-status badge."
          },
          "photo_url": {
            "type": ["string", "null"],
            "description": "The inbox's own profile photo (its self-contact's SFS photo), if synced."
          },
          "provider": {
            "$ref": "#/components/schemas/UserProvider"
          },
          "settings": {
            "$ref": "#/components/schemas/Settings"
          },
          "sync_status": {
            "$ref": "#/components/schemas/SyncStatus"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ListBackfillJobsResponse": {
        "type": "object",
        "description": "The response returned from the list backfill jobs endpoint",
        "required": ["jobs"],
        "properties": {
          "jobs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BackfillJob"
            }
          }
        }
      },
      "ListBlockedResponse": {
        "type": "object",
        "description": "Response containing list of blocked email addresses.",
        "required": ["blocked_emails"],
        "properties": {
          "blocked_emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of email addresses that are currently blocked."
          }
        }
      },
      "ListContactsResponse": {
        "type": "object",
        "required": ["contacts"],
        "properties": {
          "contacts": {
            "type": "object",
            "description": "the thread, with messages inside",
            "additionalProperties": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/ContactInfoWithInteraction"
              }
            },
            "propertyNames": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "ListEmailFiltersResponse": {
        "type": "object",
        "description": "Response body for listing email filters.",
        "required": ["filters"],
        "properties": {
          "filters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiEmailFilter"
            }
          }
        }
      },
      "ListLabelsResponse": {
        "type": "object",
        "description": "Response body for listing labels.",
        "required": ["labels"],
        "properties": {
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiLabel"
            }
          }
        }
      },
      "ListLinksResponse": {
        "type": "object",
        "description": "The response returned from the list links endpoint",
        "required": ["links"],
        "properties": {
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Link"
            },
            "description": "the thread, with messages inside"
          }
        }
      },
      "MailboxAction": {
        "oneOf": [
          {
            "type": "object",
            "description": "Mark correspondence read or unread.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["read"]
              },
              "value": {
                "type": "boolean",
                "description": "Mark correspondence read or unread."
              }
            }
          },
          {
            "type": "object",
            "description": "Set the follow-up star.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["flagged"]
              },
              "value": {
                "type": "boolean",
                "description": "Set the follow-up star."
              }
            }
          },
          {
            "type": "object",
            "description": "Archive inbox messages, or restore received correspondence to the inbox.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["archived"]
              },
              "value": {
                "type": "boolean",
                "description": "Archive inbox messages, or restore received correspondence to the inbox."
              }
            }
          },
          {
            "type": "object",
            "description": "Move to recoverable trash, or restore correspondence to Inbox (drafts to Drafts).",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["trashed"]
              },
              "value": {
                "type": "boolean",
                "description": "Move to recoverable trash, or restore correspondence to Inbox (drafts to Drafts)."
              }
            }
          },
          {
            "type": "object",
            "description": "Move to junk, or restore to the inbox.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["junk"]
              },
              "value": {
                "type": "boolean",
                "description": "Move to junk, or restore to the inbox."
              }
            }
          },
          {
            "type": "object",
            "description": "Add/remove a category while preserving other provider assignments.",
            "required": ["value", "kind"],
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["category"]
              },
              "value": {
                "type": "object",
                "description": "Add/remove a category while preserving other provider assignments.",
                "required": ["name", "present"],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "present": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        ],
        "description": "Desired organization state. Categories never stand in for folders or flags."
      },
      "MailboxOperation": {
        "type": "object",
        "description": "Durable outcome of an accepted organization action.",
        "required": ["id", "action", "state", "updated_at"],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/MailboxAction"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "state": {
            "$ref": "#/components/schemas/MailboxOperationState"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MailboxOperationState": {
        "type": "string",
        "enum": ["pending", "applied", "failed", "cancelled"]
      },
      "MailboxSettingsChange": {
        "type": "string",
        "enum": ["create_label", "delete_label", "sender_block"]
      },
      "MailboxSettingsOperation": {
        "type": "object",
        "description": "An accepted inbox configuration change awaiting provider confirmation.",
        "required": ["id", "kind", "resource", "enabled", "needs_attention"],
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "$ref": "#/components/schemas/MailboxSettingsChange"
          },
          "needs_attention": {
            "type": "boolean"
          },
          "resource": {
            "type": "string"
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "db_id",
          "thread_db_id",
          "link_id",
          "is_read",
          "is_starred",
          "is_sent",
          "is_draft",
          "has_attachments",
          "to",
          "cc",
          "bcc",
          "labels",
          "attachments",
          "attachments_draft",
          "attachments_forwarded",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            }
          },
          "attachments_draft": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttachmentDraft"
            },
            "description": "Uploaded file attachments for the message, if it is a draft"
          },
          "attachments_forwarded": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttachmentForwarded"
            },
            "description": "Forwarded attachments from original messages, if it is a draft"
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactInfo"
            }
          },
          "body_html_sanitized": {
            "type": ["string", "null"]
          },
          "body_macro": {
            "type": ["string", "null"]
          },
          "body_text": {
            "type": ["string", "null"]
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactInfo"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "from": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ContactInfo"
              }
            ]
          },
          "global_id": {
            "type": ["string", "null"],
            "description": "The globally unique Message-ID header value created by the sender to uniquely identify this email\nUsed for threading across all providers (In-Reply-To header, References header)"
          },
          "has_attachments": {
            "type": "boolean"
          },
          "headers_json": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Value"
              }
            ]
          },
          "internal_date_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "is_draft": {
            "type": "boolean"
          },
          "is_read": {
            "type": "boolean"
          },
          "is_sent": {
            "type": "boolean"
          },
          "is_starred": {
            "type": "boolean"
          },
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Label"
            }
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "provider_history_id": {
            "type": ["string", "null"]
          },
          "provider_id": {
            "type": ["string", "null"]
          },
          "provider_thread_id": {
            "type": ["string", "null"]
          },
          "replying_to_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "scheduled_send_time": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "sent_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "size_estimate": {
            "type": ["integer", "null"],
            "format": "int64"
          },
          "snippet": {
            "type": ["string", "null"]
          },
          "subject": {
            "type": ["string", "null"]
          },
          "thread_db_id": {
            "type": "string",
            "format": "uuid"
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactInfo"
            }
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MessageListVisibility": {
        "type": "string",
        "enum": ["Show", "Hide"]
      },
      "MessageOperationResponse": {
        "type": "object",
        "description": "Authorized polling response. Gmail has no asynchronous draft operation.",
        "properties": {
          "operation": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApiMessageOperation"
              }
            ]
          }
        }
      },
      "MessageReadReceipt": {
        "type": "object",
        "description": "Open state of one tracked, sent message.",
        "required": ["message_id", "open_count"],
        "properties": {
          "first_opened_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "First counted fetch."
          },
          "last_opened_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Latest counted fetch."
          },
          "message_id": {
            "type": "string",
            "format": "uuid",
            "description": "The tracked message."
          },
          "open_count": {
            "type": "integer",
            "format": "int32",
            "description": "Counted pixel fetches.",
            "minimum": 0
          }
        }
      },
      "ParsedMessage": {
        "type": "object",
        "required": [
          "db_id",
          "link_id",
          "thread_db_id",
          "to",
          "cc",
          "bcc",
          "labels"
        ],
        "properties": {
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactInfo"
            }
          },
          "body_parsed": {
            "type": ["string", "null"]
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactInfo"
            }
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "draft_generation": {
            "type": "integer",
            "format": "int32",
            "description": "Draft edit generation captured with this message snapshot."
          },
          "from": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ContactInfo"
              }
            ]
          },
          "internal_date_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LabelInfo"
            }
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "subject": {
            "type": ["string", "null"]
          },
          "thread_db_id": {
            "type": "string",
            "format": "uuid"
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactInfo"
            }
          }
        }
      },
      "PatchSettingsRequest": {
        "type": "object",
        "required": ["settings"],
        "properties": {
          "settings": {
            "$ref": "#/components/schemas/Settings"
          }
        }
      },
      "PatchSettingsResponse": {
        "type": "object",
        "required": ["settings"],
        "properties": {
          "settings": {
            "$ref": "#/components/schemas/Settings"
          }
        }
      },
      "PreviewView": {
        "oneOf": [
          {
            "type": "string",
            "enum": [
              "inbox",
              "sent",
              "drafts",
              "starred",
              "all",
              "spam",
              "trash",
              "important",
              "other"
            ]
          },
          {
            "type": "string",
            "format": "user:<label>"
          }
        ],
        "description": "View type. Supported values include standard labels and a custom user label user:<label>"
      },
      "PreviewViewStandardLabel": {
        "type": "string",
        "enum": [
          "inbox",
          "sent",
          "drafts",
          "starred",
          "all",
          "spam",
          "trash",
          "important",
          "other"
        ]
      },
      "RefreshEmailEvent": {
        "oneOf": [
          {
            "type": "object",
            "description": "Backfill progress for `link_id`; see [`BackfillStatus`].",
            "required": ["link_id", "status", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["backfill"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              },
              "status": {
                "$ref": "#/components/schemas/BackfillStatus"
              }
            }
          },
          {
            "type": "object",
            "description": "A message was inserted or updated for `link_id`.",
            "required": ["link_id", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["upsert_message"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "type": "object",
            "description": "Labels changed for `link_id`.",
            "required": ["link_id", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["update_labels"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "type": "object",
            "description": "A message was deleted for `link_id`.",
            "required": ["link_id", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["delete_message"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "type": "object",
            "description": "The inbox `link_id` was removed and its data torn down.",
            "required": ["link_id", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["link_removed"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "type": "object",
            "description": "The self-contact photo for `link_id` finished uploading to static\nfile storage, so the inbox's derived `photo_url` is now available.",
            "required": ["link_id", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["photo_synced"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "type": "object",
            "description": "Live backfill progress for `link_id`, for driving a progress indicator on\nthe frontend: `completed_threads` out of `total_threads`, plus `status`.\nCounts reflect the Redis progress counters; the priority pass may bump\nboth above the raw mailbox size, but in lockstep, so the ratio holds.\nAppended last so existing variants keep their generated TS names.",
            "required": [
              "link_id",
              "status",
              "completed_threads",
              "total_threads",
              "event"
            ],
            "properties": {
              "completed_threads": {
                "type": "integer",
                "format": "int32"
              },
              "event": {
                "type": "string",
                "enum": ["backfill_progress"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              },
              "status": {
                "$ref": "#/components/schemas/BackfillStatus"
              },
              "total_threads": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "type": "object",
            "description": "A Focus classification was stored for a thread in `link_id`, so its\nreaders read their Focus list again. `traceparent` is the W3C trace\ncontext of the classification, for that read to join. Coalesced by the\nsender; carries nothing about the mail.",
            "required": ["link_id", "event"],
            "properties": {
              "event": {
                "type": "string",
                "enum": ["focus_updated"]
              },
              "link_id": {
                "type": "string",
                "format": "uuid"
              },
              "traceparent": {
                "type": ["string", "null"]
              }
            }
          }
        ],
        "description": "Payload for the `refresh_email` connection gateway event: identifies the\ninbox that changed and the kind of change."
      },
      "ResolveMessageOperationRequest": {
        "type": "object",
        "description": "Stale versions fail without altering the current operation.",
        "required": ["revision", "action"],
        "properties": {
          "accept_duplicate_risk": {
            "type": "boolean"
          },
          "action": {
            "$ref": "#/components/schemas/ApiMessageResolutionAction"
          },
          "remote_version": {
            "type": ["string", "null"]
          },
          "revision": {
            "type": "string"
          }
        }
      },
      "ResyncResponse": {
        "type": "object",
        "description": "The response returned from the resync endpoint.",
        "required": ["backfill_job_id", "already_in_progress"],
        "properties": {
          "already_in_progress": {
            "type": "boolean",
            "description": "True when a backfill was already running and this call was a no-op."
          },
          "backfill_job_id": {
            "type": "string",
            "format": "uuid",
            "description": "Opaque ID of the backfill job or provider sync stream driving the resync.\nthe one already in progress."
          }
        }
      },
      "ScheduledSendStatus": {
        "type": "string",
        "description": "The user-visible delivery state of an unsent scheduled message.",
        "enum": ["pending", "sending", "failed", "unconfirmed"]
      },
      "SendMessageRequest": {
        "type": "object",
        "description": "Request body for sending a message (backward-compatible with `{ message: MessageToSend }`).",
        "required": ["message"],
        "properties": {
          "message": {
            "$ref": "#/components/schemas/ApiDraftInput",
            "description": "The message content."
          }
        }
      },
      "SendMessageResponse": {
        "type": "object",
        "description": "Response body for sending a message.",
        "required": ["message"],
        "properties": {
          "message": {
            "$ref": "#/components/schemas/ApiDraftOutput",
            "description": "The created message."
          }
        }
      },
      "Settings": {
        "type": "object",
        "properties": {
          "read_receipts_enabled": {
            "type": ["boolean", "null"],
            "description": "Whether messages sent from this inbox carry an open-tracking pixel."
          },
          "signature": {
            "type": ["string", "null"],
            "description": "The user's email signature content (HTML). On a patch, omit or send\n`null` to leave unchanged (both deserialize to `None`); pass an empty\nstring to clear it. The column cannot be set to SQL NULL via patch."
          },
          "signature_on_replies_forwards": {
            "type": ["boolean", "null"]
          }
        }
      },
      "SharedInboxConflictResponse": {
        "type": "object",
        "description": "Returned with a `409 Conflict` when a connect targets an external mailbox another\nmacro user has already connected. The client surfaces a confirmation; on confirm it\nretries `/email/init` with `force_share=true` to promote the mailbox to a shared inbox.",
        "required": [
          "email_address",
          "existing_owner_email",
          "existing_link_id"
        ],
        "properties": {
          "email_address": {
            "type": "string",
            "description": "The mailbox address that is already connected."
          },
          "existing_link_id": {
            "type": "string",
            "format": "uuid",
            "description": "The existing link that would be shared if the caller confirms."
          },
          "existing_owner_email": {
            "type": "string",
            "description": "The email of the macro user who first connected the mailbox."
          }
        }
      },
      "SyncStatus": {
        "type": "string",
        "description": "Coarse sync state for an inbox, used to render a one-line hint in the\nmulti-inbox settings list. Derived from the link's `is_sync_active` flag, its\nreauth health, and its most recent backfill job.",
        "enum": ["SYNCING", "UP_TO_DATE", "ERROR", "NEEDS_REAUTH", "INACTIVE"]
      },
      "Thread": {
        "type": "object",
        "required": [
          "db_id",
          "link_id",
          "inbox_visible",
          "is_read",
          "created_at",
          "updated_at",
          "messages"
        ],
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "db_id": {
            "type": "string",
            "format": "uuid"
          },
          "inbox_visible": {
            "type": "boolean"
          },
          "is_read": {
            "type": "boolean"
          },
          "latest_inbound_message_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "latest_non_spam_message_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "latest_outbound_message_ts": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "link_id": {
            "type": "string",
            "format": "uuid"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "provider_id": {
            "type": ["string", "null"]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ThreadList": {
        "type": "object",
        "required": ["threads"],
        "properties": {
          "next_page_token": {
            "type": ["string", "null"]
          },
          "threads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ThreadSummary"
            }
          }
        }
      },
      "ThreadPreviewCursor": {
        "type": "object",
        "description": "thread summary returned in preview cursor endpoint",
        "required": [
          "id",
          "ownerId",
          "inboxVisible",
          "isRead",
          "isDraft",
          "isImportant",
          "attachments",
          "participants",
          "sortTs",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "inboxVisible": {
            "type": "boolean"
          },
          "isDraft": {
            "type": "boolean"
          },
          "isImportant": {
            "type": "boolean"
          },
          "isRead": {
            "type": "boolean"
          },
          "name": {
            "type": ["string", "null"]
          },
          "ownerId": {
            "type": "string"
          },
          "participants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Contact"
            }
          },
          "providerId": {
            "type": ["string", "null"]
          },
          "senderEmail": {
            "type": ["string", "null"]
          },
          "senderName": {
            "type": ["string", "null"]
          },
          "senderPhotoUrl": {
            "type": ["string", "null"]
          },
          "snippet": {
            "type": ["string", "null"]
          },
          "sortTs": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "viewedAt": {
            "type": ["string", "null"],
            "format": "date-time"
          }
        }
      },
      "ThreadReadReceipts": {
        "type": "object",
        "description": "Open state of the caller's tracked, sent messages in one thread.",
        "required": ["receipts"],
        "properties": {
          "receipts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageReadReceipt"
            }
          }
        }
      },
      "ThreadStateField": {
        "type": "string",
        "description": "Semantic mailbox facts, independent of folder/category names.",
        "enum": ["read", "starred", "trashed", "junk"]
      },
      "ThreadSummary": {
        "type": "object",
        "required": ["provider_id"],
        "properties": {
          "provider_id": {
            "type": "string"
          }
        }
      },
      "TransferDraftRequest": {
        "type": "object",
        "description": "Reuse the same operation ID when retrying after a lost response.",
        "required": ["operation_id", "destination_link_id"],
        "properties": {
          "destination_link_id": {
            "type": "string",
            "format": "uuid"
          },
          "draft_generation": {
            "type": "integer",
            "format": "int32",
            "description": "Generation captured with the source draft."
          },
          "operation_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "TransferDraftResponse": {
        "type": "object",
        "description": "A new identity prevents delayed writes from mutating the moved copy.",
        "required": [
          "message_id",
          "thread_id",
          "source_id",
          "source_thread_id",
          "attachments"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiAttachmentDraft"
            }
          },
          "message_id": {
            "type": "string",
            "format": "uuid"
          },
          "source_id": {
            "type": "string",
            "format": "uuid"
          },
          "source_thread_id": {
            "type": "string",
            "format": "uuid"
          },
          "thread_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "TransferRecoveryResponse": {
        "type": "object",
        "description": "A null result confirms that the move cannot commit, even if its request was delayed.",
        "properties": {
          "committed": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TransferDraftResponse"
              }
            ]
          }
        }
      },
      "UnblockSenderRequest": {
        "type": "object",
        "description": "Request to unblock a sender.",
        "required": ["email_address"],
        "properties": {
          "email_address": {
            "type": "string",
            "description": "The email address of the sender to unblock."
          }
        }
      },
      "UnresolvedSignatureImagesError": {
        "type": "object",
        "description": "Body returned with a 422 when signature images can't be loaded.",
        "required": ["unresolved_image_count"],
        "properties": {
          "unresolved_image_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "UpdateLabelBatchRequest": {
        "type": "object",
        "required": ["message_ids", "label_id", "value"],
        "properties": {
          "label_id": {
            "type": "string",
            "format": "uuid"
          },
          "message_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "value": {
            "type": "boolean"
          }
        }
      },
      "UpdateLabelBatchResponse": {
        "type": "object",
        "required": ["successful_ids", "failed_ids", "missing_ids"],
        "properties": {
          "failed_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "missing_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "successful_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "UpdateThreadLabelRequest": {
        "type": "object",
        "description": "Request body for updating a thread's labels.",
        "required": ["label_id", "value"],
        "properties": {
          "label_id": {
            "type": "string",
            "format": "uuid"
          },
          "value": {
            "type": "boolean"
          }
        }
      },
      "UpdateThreadLabelsResponse": {
        "type": "object",
        "description": "Response body for updating a thread's labels.",
        "required": ["successful_ids", "failed_ids"],
        "properties": {
          "failed_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "successful_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "UpdateThreadProjectRequest": {
        "type": "object",
        "description": "Request body for updating a thread's project.",
        "properties": {
          "projectId": {
            "type": ["string", "null"],
            "description": "The project ID to assign to the thread, or null to remove from project."
          }
        }
      },
      "UpdateThreadProjectResponse": {
        "type": "object",
        "description": "Response body for updating a thread's project.",
        "properties": {
          "oldProjectId": {
            "type": ["string", "null"],
            "description": "The previous project ID of the thread."
          }
        }
      },
      "UpdateThreadStateRequest": {
        "type": "object",
        "description": "Desired state for every applicable message in an authorized thread.",
        "required": ["field", "value"],
        "properties": {
          "field": {
            "$ref": "#/components/schemas/ThreadStateField"
          },
          "value": {
            "type": "boolean"
          }
        }
      },
      "UpsertEmailFilterRequest": {
        "type": "object",
        "description": "Request body for creating or updating an email filter.",
        "required": ["is_important"],
        "properties": {
          "email_address": {
            "type": ["string", "null"],
            "description": "Exact email address to match. Mutually exclusive with `email_domain`."
          },
          "email_domain": {
            "type": ["string", "null"],
            "description": "Email domain to match. Mutually exclusive with `email_address`."
          },
          "is_important": {
            "type": "boolean",
            "description": "Whether matching senders should be considered important."
          }
        }
      },
      "UpsertEmailFilterResponse": {
        "type": "object",
        "description": "Response body for upsert email filter.",
        "required": ["filter"],
        "properties": {
          "filter": {
            "$ref": "#/components/schemas/ApiEmailFilter"
          }
        }
      },
      "UpsertScheduledRequest": {
        "type": "object",
        "required": ["send_time"],
        "properties": {
          "include_signature": {
            "type": ["boolean", "null"],
            "description": "Per-message signature override; absent uses the inbox's send defaults."
          },
          "send_time": {
            "type": "string",
            "format": "date-time",
            "description": "The time to send the message (ISO 8601 format)."
          },
          "user_confirmation": {
            "type": ["string", "null"],
            "description": "The user's own reply approving this send, quoted verbatim. Required\nfrom an agent's program, which is refused without it; ignored for a\nperson in the app, whose Send Later is their confirmation."
          }
        }
      },
      "UpsertScheduledResponse": {
        "type": "object",
        "required": ["message_id", "send_time"],
        "properties": {
          "message_id": {
            "type": "string",
            "format": "uuid"
          },
          "send_time": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UserProvider": {
        "type": "string",
        "enum": ["GMAIL", "OUTLOOK"]
      },
      "Value": {},
      "ViewerCapabilities": {
        "type": "object",
        "description": "What the viewing requester may do with an event.",
        "required": [
          "editDetails",
          "inviteGuests",
          "removeGuests",
          "setGuestPolicy",
          "rsvp",
          "organize"
        ],
        "properties": {
          "editDetails": {
            "type": "boolean",
            "description": "Change the event's details (title, time, description, conference)."
          },
          "inviteGuests": {
            "type": "boolean",
            "description": "Add guests."
          },
          "organize": {
            "type": "boolean",
            "description": "Act as the event's organizer: replace its whole guest list and manage\nits conferencing."
          },
          "removeGuests": {
            "type": "boolean",
            "description": "Remove guests."
          },
          "rsvp": {
            "type": "boolean",
            "description": "Answer the invitation."
          },
          "setGuestPolicy": {
            "type": "boolean",
            "description": "Change the event's guest policy, which only Google calendars have."
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Email Service",
      "description": "Macro Email Service"
    }
  ]
}