{
  "openapi": "3.0.3",
  "info": {
    "title": "Email API",
    "version": "1.0.0",
    "description": "Customer support inbox backend \u2014 conversations, messages, recipients, attachments. Cognito-authenticated callers."
  },
  "servers": [
    {
      "url": "https://api.puglieseweb.com/email/v1",
      "description": "Production"
    }
  ],
  "paths": {
    "/attachments/presign": {
      "post": {
        "tags": [
          "Attachments"
        ],
        "summary": "Get a presigned PUT URL for uploading an attachment",
        "operationId": "generate_upload_url_attachments_presign_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PresignRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PresignResponse"
                }
              }
            }
          }
        }
      }
    },
    "/attachments/{proxy}": {
      "get": {
        "tags": [
          "Attachments"
        ],
        "summary": "Redirect to a presigned download URL for an attachment",
        "operationId": "generate_download_url_attachments__proxy__get",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Proxy"
            },
            "name": "proxy",
            "in": "path"
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DownloadRedirect"
                }
              }
            }
          }
        }
      }
    },
    "/conversations": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "summary": "List conversations",
        "operationId": "list_conversations_conversations_get",
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationsListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Conversations"
        ],
        "summary": "Create a conversation and send an email",
        "operationId": "create_conversation_conversations_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateConversationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "summary": "Get a conversation",
        "operationId": "get_conversation_conversations__id__get",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Id"
            },
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Conversations"
        ],
        "summary": "Update conversation status or read state",
        "operationId": "update_conversation_conversations__id__patch",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Id"
            },
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateConversationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/messages": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "summary": "List messages in a conversation",
        "operationId": "list_messages_conversations__id__messages_get",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Id"
            },
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagesResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Conversations"
        ],
        "summary": "Send a reply in a conversation",
        "operationId": "send_reply_conversations__id__messages_post",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Id"
            },
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendReplyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{slug}/recipients": {
      "get": {
        "tags": [
          "Recipients"
        ],
        "summary": "List recipients for a project",
        "operationId": "list_recipients_projects__slug__recipients_get",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            },
            "name": "slug",
            "in": "path"
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecipientsResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Recipients"
        ],
        "summary": "Add a recipient to a project",
        "operationId": "add_recipient_projects__slug__recipients_post",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            },
            "name": "slug",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddRecipientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Recipient"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{slug}/recipients/{email}": {
      "delete": {
        "tags": [
          "Recipients"
        ],
        "summary": "Remove a recipient from a project",
        "operationId": "remove_recipient_projects__slug__recipients__email__delete",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            },
            "name": "slug",
            "in": "path"
          },
          {
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email"
            },
            "name": "email",
            "in": "path"
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Conversation": {
        "properties": {
          "conversationId": {
            "type": "string",
            "title": "Conversationid"
          },
          "subject": {
            "type": "string",
            "title": "Subject",
            "default": ""
          },
          "project": {
            "type": "string",
            "title": "Project",
            "default": ""
          },
          "status": {
            "type": "string",
            "title": "Status",
            "default": "open"
          },
          "fromAddress": {
            "type": "string",
            "title": "Fromaddress",
            "default": ""
          },
          "externalContact": {
            "type": "string",
            "title": "Externalcontact",
            "default": ""
          },
          "lastMessageAt": {
            "type": "string",
            "title": "Lastmessageat",
            "default": ""
          },
          "lastMessagePreview": {
            "type": "string",
            "title": "Lastmessagepreview",
            "default": ""
          },
          "messageCount": {
            "type": "integer",
            "title": "Messagecount",
            "default": 0
          },
          "unread": {
            "type": "boolean",
            "title": "Unread",
            "default": false
          },
          "createdAt": {
            "type": "string",
            "title": "Createdat",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "conversationId"
        ],
        "title": "Conversation"
      },
      "ConversationsListResponse": {
        "properties": {
          "conversations": {
            "items": {
              "$ref": "#/components/schemas/Conversation"
            },
            "type": "array",
            "title": "Conversations"
          },
          "nextToken": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nexttoken"
          }
        },
        "type": "object",
        "required": [
          "conversations"
        ],
        "title": "ConversationsListResponse"
      },
      "CreateConversationRequest": {
        "properties": {
          "to": {
            "type": "string",
            "title": "To",
            "description": "Recipient email address"
          },
          "fromAddress": {
            "type": "string",
            "title": "Fromaddress"
          },
          "subject": {
            "type": "string",
            "title": "Subject"
          },
          "project": {
            "type": "string",
            "title": "Project"
          },
          "bodyHtml": {
            "type": "string",
            "title": "Bodyhtml",
            "default": ""
          },
          "bodyText": {
            "type": "string",
            "title": "Bodytext",
            "default": ""
          },
          "attachments": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Attachments"
          }
        },
        "type": "object",
        "required": [
          "to",
          "fromAddress",
          "subject",
          "project"
        ],
        "title": "CreateConversationRequest"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "UpdateConversationRequest": {
        "properties": {
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "unread": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Unread"
          }
        },
        "type": "object",
        "title": "UpdateConversationRequest"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "ResponseValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "ResponseValidationError"
      },
      "Message": {
        "properties": {
          "messageId": {
            "type": "string",
            "title": "Messageid"
          },
          "conversationId": {
            "type": "string",
            "title": "Conversationid"
          },
          "direction": {
            "type": "string",
            "title": "Direction"
          },
          "from": {
            "type": "string",
            "title": "From",
            "default": ""
          },
          "to": {
            "type": "string",
            "title": "To",
            "default": ""
          },
          "cc": {
            "type": "string",
            "title": "Cc",
            "default": ""
          },
          "subject": {
            "type": "string",
            "title": "Subject",
            "default": ""
          },
          "bodyHtml": {
            "type": "string",
            "title": "Bodyhtml",
            "default": ""
          },
          "bodyText": {
            "type": "string",
            "title": "Bodytext",
            "default": ""
          },
          "attachments": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Attachments"
          },
          "timestamp": {
            "type": "string",
            "title": "Timestamp",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "messageId",
          "conversationId",
          "direction"
        ],
        "title": "Message"
      },
      "MessagesResponse": {
        "properties": {
          "messages": {
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "type": "array",
            "title": "Messages"
          }
        },
        "type": "object",
        "required": [
          "messages"
        ],
        "title": "MessagesResponse"
      },
      "SendReplyRequest": {
        "properties": {
          "bodyHtml": {
            "type": "string",
            "title": "Bodyhtml",
            "default": ""
          },
          "bodyText": {
            "type": "string",
            "title": "Bodytext",
            "default": ""
          },
          "attachments": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Attachments"
          }
        },
        "type": "object",
        "title": "SendReplyRequest"
      },
      "AddRecipientRequest": {
        "properties": {
          "email": {
            "type": "string",
            "minLength": 1,
            "title": "Email"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "email"
        ],
        "title": "AddRecipientRequest"
      },
      "DeleteResponse": {
        "properties": {
          "deleted": {
            "type": "boolean",
            "title": "Deleted",
            "default": true
          }
        },
        "type": "object",
        "title": "DeleteResponse"
      },
      "Recipient": {
        "properties": {
          "email": {
            "type": "string",
            "title": "Email"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "default": ""
          },
          "project": {
            "type": "string",
            "title": "Project"
          }
        },
        "type": "object",
        "required": [
          "email",
          "project"
        ],
        "title": "Recipient"
      },
      "RecipientsResponse": {
        "properties": {
          "recipients": {
            "items": {
              "$ref": "#/components/schemas/Recipient"
            },
            "type": "array",
            "title": "Recipients"
          }
        },
        "type": "object",
        "required": [
          "recipients"
        ],
        "title": "RecipientsResponse"
      },
      "DownloadRedirect": {
        "properties": {
          "location": {
            "type": "string",
            "title": "Location",
            "description": "Presigned S3 GET URL (sent via the Location header on a 302 response)"
          }
        },
        "type": "object",
        "required": [
          "location"
        ],
        "title": "DownloadRedirect",
        "description": "Documented as JSON for the OpenAPI schema, but the runtime returns a 302\nredirect. Consumers should follow the `Location` header."
      },
      "PresignRequest": {
        "properties": {
          "filename": {
            "type": "string",
            "maxLength": 500,
            "title": "Filename",
            "default": "attachment"
          },
          "contentType": {
            "type": "string",
            "maxLength": 200,
            "title": "Contenttype",
            "default": "application/octet-stream"
          }
        },
        "type": "object",
        "title": "PresignRequest"
      },
      "PresignResponse": {
        "properties": {
          "uploadUrl": {
            "type": "string",
            "title": "Uploadurl"
          },
          "s3Key": {
            "type": "string",
            "title": "S3Key"
          }
        },
        "type": "object",
        "required": [
          "uploadUrl",
          "s3Key"
        ],
        "title": "PresignResponse"
      }
    }
  }
}