{
  "openapi": "3.0.3",
  "info": {
    "title": "1052 Mail Receive-only API",
    "version": "1.0.0",
    "description": "Single-owner API. Bearer key grants access to all mailboxes. No email sending, import or deletion routes. cloud-test denotes diagnostic injection, not SMTP delivery."
  },
  "servers": [
    {
      "url": "https://mail.1052.xin"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/domains": {
      "get": {
        "summary": "List supported receiving domains",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/v1/mailboxes": {
      "get": {
        "summary": "List existing receiving addresses",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "post": {
        "summary": "Create receiving address",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          },
          "201": {
            "description": "Mailbox created and enabled in cloud"
          },
          "202": {
            "description": "Mailbox saved, cloudPending=true; wait for synchronization"
          },
          "409": {
            "description": "Address already exists"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "prefix",
                  "domain"
                ],
                "properties": {
                  "prefix": {
                    "type": "string",
                    "example": "shopping"
                  },
                  "domain": {
                    "type": "string",
                    "example": "1052.xin"
                  },
                  "label": {
                    "type": "string",
                    "example": "购物通知"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{id}": {
      "patch": {
        "summary": "Enable/disable address or change label",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "label": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages": {
      "get": {
        "summary": "List received mail (40 per page)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "mailbox",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Mailbox UUID or email address; omit for all"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Search sender, subject and body"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Positive page number, starting at 1"
          },
          {
            "name": "unread",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "true to return unread messages only"
          }
        ]
      }
    },
    "/v1/messages/{id}": {
      "get": {
        "summary": "Read message body and attachment metadata",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Set read/starred flags",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "read": {
                    "type": "boolean"
                  },
                  "starred": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages/{id}/raw": {
      "get": {
        "summary": "Download original EML",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/attachments/{id}": {
      "get": {
        "summary": "Download attachment",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/status": {
      "get": {
        "summary": "Read statistics and last cloud sync status",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/v1/sync": {
      "post": {
        "summary": "Request immediate cloud synchronization",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    }
  }
}