{
  "openapi": "3.1.0",
  "info": {
    "title": "MailEnv Public API",
    "version": "1.0.0",
    "summary": "Managed REST API for sending transactional email through Amazon SES.",
    "description": "Send transactional email over HTTPS with API key authentication. MailEnv is a managed REST API wrapper for Amazon SES: domain authentication, bounce and complaint suppression, and sending limits are handled for every request. Human-readable docs: https://mailenv.com/api-docs/",
    "contact": {
      "name": "MailEnv",
      "url": "https://mailenv.com/contact.php",
      "email": "devops@miamiweblab.com"
    },
    "termsOfService": "https://mailenv.com/terms/"
  },
  "externalDocs": {
    "description": "API reference",
    "url": "https://mailenv.com/api-docs/"
  },
  "servers": [
    {
      "url": "https://pub-api.mailenv.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Mail",
      "description": "Send transactional email."
    }
  ],
  "paths": {
    "/api/v1/send-mail": {
      "post": {
        "tags": [
          "Mail"
        ],
        "operationId": "sendMail",
        "summary": "Send mail",
        "description": "Sends an email message using the provided parameters. All email addresses must be in a valid email format, and the API key must be active and not locked.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMailRequest"
              },
              "example": {
                "to": "recipient@example.com",
                "from": "sender@example.com",
                "subject": "Test Email",
                "message": "This is a test email message"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Mail request successful.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMailResponse"
                },
                "example": {
                  "result": {
                    "id": "550e8400-e29b-41d4-a716-446655440000"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request: missing required fields or invalid JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "result": "error",
                  "message": "Missing required fields: to, subject"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized: invalid API key or locked account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "result": "error",
                  "message": "Invalid API key"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden: invalid tokens or email volume expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "result": "error",
                  "message": "Invalid tokens or rate limit exceeded"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests: throttling limit reached."
          },
          "500": {
            "description": "Internal server error."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Your API key, sent as the raw value of the Authorization header."
      }
    },
    "schemas": {
      "SendMailRequest": {
        "type": "object",
        "required": [
          "to",
          "from",
          "subject",
          "message"
        ],
        "properties": {
          "to": {
            "type": "string",
            "format": "email",
            "description": "Recipient email address."
          },
          "from": {
            "type": "string",
            "format": "email",
            "description": "Sender email address."
          },
          "subject": {
            "type": "string",
            "description": "Email subject line."
          },
          "message": {
            "type": "string",
            "description": "Email message body."
          }
        }
      },
      "SendMailResponse": {
        "type": "object",
        "required": [
          "result"
        ],
        "properties": {
          "result": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "Unique identifier for the mail request."
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "result",
          "message"
        ],
        "properties": {
          "result": {
            "type": "string",
            "const": "error"
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message."
          }
        }
      }
    }
  }
}
