{
  "openapi": "3.0.3",
  "info": {
    "title": "NiloyFlix API",
    "version": "5.7.0",
    "description": "Installation-wide API. Every enabled key can read every inbox on this installation — local domain inboxes, website inboxes and admin-connected Gmail / Outlook / Hotmail inboxes, including their + aliases (and Gmail dot variants). No per-key ownership, no rate limits, no customer open limits or subject filters. The message array uses the exact NiloyFlix format (id, subject, timestamp, date, datediff, content, sender_name, sender_email, attachments). Provider originals are read-only; deletion removes only the local copy. 40 MiB mailbox quota; attachments excluded."
  },
  "servers": [
    {
      "url": "https://yourdomain.com"
    }
  ],
  "paths": {
    "/api/domains/{apikey}": {
      "get": {
        "summary": "List configured domains",
        "parameters": [
          {
            "name": "apikey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Installation-wide secret key"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid or disabled key"
          },
          "404": {
            "description": "Not found"
          },
          "405": {
            "description": "Method not allowed"
          }
        }
      }
    },
    "/api/email/{email}/{apikey}": {
      "get": {
        "summary": "Validate or create an email address",
        "parameters": [
          {
            "name": "email",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "email"
          },
          {
            "name": "apikey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Installation-wide secret key"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "email": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid or disabled key"
          },
          "404": {
            "description": "Not found"
          },
          "405": {
            "description": "Method not allowed"
          }
        },
        "description": "Returns the address if the inbox exists (any inbox, connected inbox or connected alias). Otherwise creates a permanent inbox on an administrator-added domain."
      }
    },
    "/api/messages/{email}/{apikey}": {
      "get": {
        "summary": "Read any active inbox",
        "parameters": [
          {
            "name": "email",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "email"
          },
          {
            "name": "apikey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Installation-wide secret key"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Message"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid or disabled key"
          },
          "404": {
            "description": "Not found"
          },
          "405": {
            "description": "Method not allowed"
          },
          "502": {
            "description": "Provider request failed; retry or check connection"
          },
          "503": {
            "description": "Provider busy, sync in progress, or retry backoff; honor Retry-After"
          },
          "507": {
            "description": "Connected inbox local storage is full"
          }
        },
        "description": "Works for any email on this installation with any enabled key. For a connected inbox, an alias such as name+tag@gmail.com (or a Gmail dot variant) returns only mail sent to that alias. A connected inbox that needs reconnection still returns its cached mail (header X-NiloyFlix-Sync-Status: reconnect)."
      }
    },
    "/api/message/{message_id}/{apikey}": {
      "delete": {
        "summary": "Delete an individual message permanently",
        "parameters": [
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "message_id"
          },
          {
            "name": "apikey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Installation-wide secret key"
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid or disabled key"
          },
          "404": {
            "description": "Not found"
          },
          "405": {
            "description": "Method not allowed."
          },
          "200": {
            "description": "Message deleted and its storage released.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "deleted": true
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "Read one message by ID (any inbox)",
        "parameters": [
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "message_id"
          },
          {
            "name": "apikey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Installation-wide secret key"
          }
        ],
        "responses": {
          "200": {
            "description": "Message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "400": {
            "description": "Invalid message ID"
          },
          "401": {
            "description": "Invalid or disabled key"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Message": {
        "type": "object",
        "required": [
          "id",
          "subject",
          "timestamp",
          "date",
          "datediff",
          "content",
          "sender_name",
          "sender_email",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "64-character hexadecimal message ID"
          },
          "subject": {
            "type": "string"
          },
          "timestamp": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "datediff": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "sender_name": {
            "type": "string"
          },
          "sender_email": {
            "type": "string"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Always empty; attachments are not stored."
          }
        },
        "example": {
          "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "subject": "Welcome to NiloyFlix",
          "timestamp": "2026-10-18T10:00:00.000000Z",
          "date": "18 Oct 2026 10:00 AM",
          "datediff": "2 hours ago",
          "content": "<p>Your inbox is ready.</p>",
          "sender_name": "Example",
          "sender_email": "hello@example.com",
          "attachments": []
        }
      }
    }
  }
}
