{
  "openapi": "3.1.0",
  "info": {
    "title": "Avelto API",
    "version": "0.1.0",
    "description": "The email API for developers who want it to just work. Authenticate with `Authorization: Bearer <api key>`. Errors use `{ \"error\": { \"code\", \"message\" } }`. Docs: https://staging.avelto.dev/docs"
  },
  "servers": [
    {
      "url": "https://api-staging.avelto.dev"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Emails",
      "description": "Send, fetch, list and cancel emails."
    },
    {
      "name": "Templates",
      "description": "Stored subjects and bodies with {{variables}}, with a version history."
    },
    {
      "name": "Domains",
      "description": "Sending domains and their DNS records."
    },
    {
      "name": "Suppressions",
      "description": "Addresses that will not be sent to."
    },
    {
      "name": "Webhooks",
      "description": "Endpoints, deliveries and retries."
    },
    {
      "name": "Account",
      "description": "What the key can do and what the account has set up."
    },
    {
      "name": "Data rights",
      "description": "Export everything held for the account, and erase a recipient."
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key: `av_live_…` sends real mail, `av_test_…` runs the same pipeline without delivering."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "validation_error",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "rate_limited",
                  "internal_error",
                  "sandbox_recipient_not_allowed",
                  "domain_not_verified",
                  "recipient_suppressed",
                  "not_scheduled",
                  "plan_limit",
                  "account_paused",
                  "account_suspended"
                ]
              },
              "message": {
                "type": "string"
              },
              "details": {}
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ],
        "description": "Error envelope. Codes: validation_error, unauthorized, forbidden, not_found, conflict, rate_limited, internal_error, sandbox_recipient_not_allowed, domain_not_verified, recipient_suppressed, not_scheduled, plan_limit, account_paused, account_suspended."
      },
      "SendEmailRequest": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "minLength": 3,
            "maxLength": 320
          },
          "to": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 3,
                "maxLength": 320
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 320
                },
                "minItems": 1
              }
            ]
          },
          "cc": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 3,
                "maxLength": 320
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 320
                },
                "minItems": 1
              }
            ]
          },
          "bcc": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 3,
                "maxLength": 320
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 320
                },
                "minItems": 1
              }
            ]
          },
          "reply_to": {
            "type": "string",
            "minLength": 3,
            "maxLength": 320
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 998
          },
          "html": {
            "type": "string",
            "maxLength": 5000000
          },
          "text": {
            "type": "string",
            "maxLength": 5000000
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 1000
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-zA-Z0-9_\\-:.]+$"
            },
            "maxItems": 10
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 255
                },
                "content": {
                  "type": "string",
                  "minLength": 1
                },
                "url": {
                  "type": "string",
                  "maxLength": 2000,
                  "format": "uri"
                },
                "content_type": {
                  "type": "string",
                  "maxLength": 255,
                  "pattern": "^[\\w.+-]+\\/[\\w.+-]+(?:\\s*;\\s*[\\w.+-]+=[^;\\x00-\\x1f\\x7f]*)*$"
                }
              },
              "required": [
                "filename"
              ]
            },
            "maxItems": 10
          },
          "template_id": {
            "type": "string",
            "format": "uuid"
          },
          "template_slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "variables": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 10000
                },
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "scheduled_at": {
            "type": "string",
            "format": "date-time"
          },
          "unsubscribe_url": {
            "type": "string",
            "maxLength": 2000,
            "format": "uri"
          }
        },
        "required": [
          "from",
          "to"
        ]
      },
      "SendEmailResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "id"
        ]
      },
      "Email": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "subject": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "scheduled",
              "sent",
              "delivered",
              "bounced",
              "complained",
              "failed",
              "cancelled"
            ]
          },
          "scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "match": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "field": {
                "type": "string",
                "enum": [
                  "recipient",
                  "subject",
                  "message_id",
                  "email_id"
                ]
              },
              "value": {
                "type": "string"
              }
            },
            "required": [
              "field",
              "value"
            ]
          },
          "html": {
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "unsubscribe_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "idempotency_key": {
            "type": [
              "string",
              "null"
            ]
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 255
                },
                "content_type": {
                  "type": "string",
                  "maxLength": 255,
                  "pattern": "^[\\w.+-]+\\/[\\w.+-]+(?:\\s*;\\s*[\\w.+-]+=[^;\\x00-\\x1f\\x7f]*)*$"
                },
                "size": {
                  "type": "integer"
                }
              },
              "required": [
                "filename",
                "size"
              ]
            }
          },
          "domain_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "ses_message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "email.queued",
                    "email.scheduled",
                    "email.sent",
                    "email.delivered",
                    "email.delivery_delayed",
                    "email.bounced",
                    "email.complained",
                    "email.rejected",
                    "email.failed",
                    "email.cancelled"
                  ]
                },
                "payload": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "occurred_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "type",
                "payload",
                "occurred_at"
              ]
            }
          }
        },
        "required": [
          "id",
          "mode",
          "from",
          "to",
          "cc",
          "bcc",
          "reply_to",
          "subject",
          "tags",
          "status",
          "scheduled_at",
          "created_at",
          "updated_at",
          "html",
          "text",
          "headers",
          "unsubscribe_url",
          "idempotency_key",
          "attachments",
          "domain_id",
          "ses_message_id",
          "error",
          "events"
        ]
      },
      "ListEmailsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "mode": {
                  "type": "string",
                  "enum": [
                    "live",
                    "test"
                  ]
                },
                "from": {
                  "type": "string"
                },
                "to": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "cc": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "bcc": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "reply_to": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "subject": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "queued",
                    "scheduled",
                    "sent",
                    "delivered",
                    "bounced",
                    "complained",
                    "failed",
                    "cancelled"
                  ]
                },
                "scheduled_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "updated_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "match": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "field": {
                      "type": "string",
                      "enum": [
                        "recipient",
                        "subject",
                        "message_id",
                        "email_id"
                      ]
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "field",
                    "value"
                  ]
                }
              },
              "required": [
                "id",
                "mode",
                "from",
                "to",
                "cc",
                "bcc",
                "reply_to",
                "subject",
                "tags",
                "status",
                "scheduled_at",
                "created_at",
                "updated_at"
              ]
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "CancelEmailResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "cancelled"
            ]
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "BatchSendRequest": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "from": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 320
                },
                "to": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 320
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 320
                      },
                      "minItems": 1
                    }
                  ]
                },
                "cc": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 320
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 320
                      },
                      "minItems": 1
                    }
                  ]
                },
                "bcc": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 320
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 320
                      },
                      "minItems": 1
                    }
                  ]
                },
                "reply_to": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 320
                },
                "subject": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 998
                },
                "html": {
                  "type": "string",
                  "maxLength": 5000000
                },
                "text": {
                  "type": "string",
                  "maxLength": 5000000
                },
                "headers": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "pattern": "^[a-zA-Z0-9_\\-:.]+$"
                  },
                  "maxItems": 10
                },
                "attachments": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "filename": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255
                      },
                      "content": {
                        "type": "string",
                        "minLength": 1
                      },
                      "url": {
                        "type": "string",
                        "maxLength": 2000,
                        "format": "uri"
                      },
                      "content_type": {
                        "type": "string",
                        "maxLength": 255,
                        "pattern": "^[\\w.+-]+\\/[\\w.+-]+(?:\\s*;\\s*[\\w.+-]+=[^;\\x00-\\x1f\\x7f]*)*$"
                      }
                    },
                    "required": [
                      "filename"
                    ]
                  },
                  "maxItems": 10
                },
                "template_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "template_slug": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "variables": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 10000
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "scheduled_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "unsubscribe_url": {
                  "type": "string",
                  "maxLength": 2000,
                  "format": "uri"
                }
              },
              "required": [
                "from",
                "to"
              ]
            },
            "minItems": 1,
            "maxItems": 100
          }
        },
        "required": [
          "messages"
        ]
      },
      "BatchSendResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "index": {
                      "type": "integer"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "ok",
                    "index",
                    "id"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "index": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "validation_error",
                            "unauthorized",
                            "forbidden",
                            "not_found",
                            "conflict",
                            "rate_limited",
                            "internal_error",
                            "sandbox_recipient_not_allowed",
                            "domain_not_verified",
                            "recipient_suppressed",
                            "not_scheduled",
                            "plan_limit",
                            "account_paused",
                            "account_suspended"
                          ]
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "ok",
                    "index",
                    "error"
                  ]
                }
              ]
            }
          },
          "accepted": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "accepted",
          "failed"
        ]
      },
      "Template": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "html": {
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "variables": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "version": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "slug",
          "subject",
          "html",
          "text",
          "variables",
          "version",
          "created_at",
          "updated_at"
        ]
      },
      "TemplateVersion": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "html": {
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "version",
          "name",
          "subject",
          "html",
          "text",
          "created_by",
          "created_at"
        ]
      },
      "ListTemplatesResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                },
                "subject": {
                  "type": "string"
                },
                "html": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "text": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "variables": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "version": {
                  "type": "integer"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "updated_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "name",
                "slug",
                "subject",
                "html",
                "text",
                "variables",
                "version",
                "created_at",
                "updated_at"
              ]
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "CreateTemplateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "html": {
            "type": "string",
            "maxLength": 5000000
          },
          "text": {
            "type": "string",
            "maxLength": 5000000
          },
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          }
        },
        "required": [
          "name",
          "subject"
        ]
      },
      "UpdateTemplateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "html": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 5000000
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 5000000
          }
        }
      },
      "RestoreTemplateRequest": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "version"
        ]
      },
      "CreateDomainRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^(?=.{1,253}$)(?!-)([a-z0-9-]{1,63}(?<!-)\\.)+[a-z]{2,63}$"
          }
        },
        "required": [
          "name"
        ]
      },
      "Domain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "verified",
              "failed"
            ]
          },
          "dns_records": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "CNAME",
                    "TXT",
                    "MX"
                  ]
                },
                "name": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "purpose": {
                  "type": "string",
                  "enum": [
                    "dkim",
                    "spf",
                    "dmarc"
                  ]
                }
              },
              "required": [
                "type",
                "name",
                "value",
                "purpose"
              ]
            }
          },
          "health": {
            "type": "string",
            "enum": [
              "unknown",
              "healthy",
              "action_needed"
            ]
          },
          "health_changed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "dns_checks": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "CNAME",
                    "TXT",
                    "MX"
                  ]
                },
                "name": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "purpose": {
                  "type": "string",
                  "enum": [
                    "dkim",
                    "spf",
                    "dmarc"
                  ]
                },
                "id": {
                  "type": "string"
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "found",
                    "missing",
                    "mismatch"
                  ]
                },
                "found": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "type",
                "name",
                "value",
                "purpose",
                "id",
                "state",
                "found"
              ]
            }
          },
          "dns_checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "region",
          "status",
          "dns_records",
          "health",
          "health_changed_at",
          "dns_checks",
          "dns_checked_at",
          "created_at"
        ]
      },
      "ListDomainsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "region": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "verified",
                    "failed"
                  ]
                },
                "dns_records": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "CNAME",
                          "TXT",
                          "MX"
                        ]
                      },
                      "name": {
                        "type": "string"
                      },
                      "value": {
                        "type": "string"
                      },
                      "purpose": {
                        "type": "string",
                        "enum": [
                          "dkim",
                          "spf",
                          "dmarc"
                        ]
                      }
                    },
                    "required": [
                      "type",
                      "name",
                      "value",
                      "purpose"
                    ]
                  }
                },
                "health": {
                  "type": "string",
                  "enum": [
                    "unknown",
                    "healthy",
                    "action_needed"
                  ]
                },
                "health_changed_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                },
                "dns_checks": {
                  "type": [
                    "array",
                    "null"
                  ],
                  "items": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "CNAME",
                          "TXT",
                          "MX"
                        ]
                      },
                      "name": {
                        "type": "string"
                      },
                      "value": {
                        "type": "string"
                      },
                      "purpose": {
                        "type": "string",
                        "enum": [
                          "dkim",
                          "spf",
                          "dmarc"
                        ]
                      },
                      "id": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string",
                        "enum": [
                          "found",
                          "missing",
                          "mismatch"
                        ]
                      },
                      "found": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "type",
                      "name",
                      "value",
                      "purpose",
                      "id",
                      "state",
                      "found"
                    ]
                  }
                },
                "dns_checked_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "name",
                "region",
                "status",
                "dns_records",
                "health",
                "health_changed_at",
                "dns_checks",
                "dns_checked_at",
                "created_at"
              ]
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "Suppression": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": "string",
            "enum": [
              "bounce",
              "complaint",
              "manual"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "email_address",
          "reason",
          "created_at"
        ]
      },
      "CreateSuppressionRequest": {
        "type": "object",
        "properties": {
          "email_address": {
            "type": "string",
            "format": "email"
          }
        },
        "required": [
          "email_address"
        ]
      },
      "ListSuppressionsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "email_address": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "reason": {
                  "type": "string",
                  "enum": [
                    "bounce",
                    "complaint",
                    "manual"
                  ]
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "email_address",
                "reason",
                "created_at"
              ]
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "CreateWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048,
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email.queued",
                "email.scheduled",
                "email.sent",
                "email.delivered",
                "email.delivery_delayed",
                "email.bounced",
                "email.complained",
                "email.rejected",
                "email.failed",
                "email.cancelled"
              ]
            },
            "minItems": 1,
            "default": [
              "email.sent",
              "email.delivered",
              "email.delivery_delayed",
              "email.bounced",
              "email.complained",
              "email.rejected",
              "email.failed",
              "email.cancelled"
            ]
          }
        },
        "required": [
          "url"
        ]
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email.queued",
                "email.scheduled",
                "email.sent",
                "email.delivered",
                "email.delivery_delayed",
                "email.bounced",
                "email.complained",
                "email.rejected",
                "email.failed",
                "email.cancelled"
              ]
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "enabled",
          "created_at"
        ]
      },
      "WebhookEndpointWithSecret": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email.queued",
                "email.scheduled",
                "email.sent",
                "email.delivered",
                "email.delivery_delayed",
                "email.bounced",
                "email.complained",
                "email.rejected",
                "email.failed",
                "email.cancelled"
              ]
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "secret": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "enabled",
          "created_at",
          "secret"
        ]
      },
      "ListWebhooksResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "url": {
                  "type": "string"
                },
                "events": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "email.queued",
                      "email.scheduled",
                      "email.sent",
                      "email.delivered",
                      "email.delivery_delayed",
                      "email.bounced",
                      "email.complained",
                      "email.rejected",
                      "email.failed",
                      "email.cancelled"
                    ]
                  }
                },
                "enabled": {
                  "type": "boolean"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "url",
                "events",
                "enabled",
                "created_at"
              ]
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "endpoint_id": {
            "type": "string",
            "format": "uuid"
          },
          "email_event_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "event_type": {
            "type": "string",
            "enum": [
              "email.queued",
              "email.scheduled",
              "email.sent",
              "email.delivered",
              "email.delivery_delayed",
              "email.bounced",
              "email.complained",
              "email.rejected",
              "email.failed",
              "email.cancelled"
            ]
          },
          "email_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivered",
              "failed"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "response_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "is_test": {
            "type": "boolean"
          },
          "replay_of": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "endpoint_id",
          "email_event_id",
          "event_type",
          "email_id",
          "status",
          "attempts",
          "last_error",
          "response_code",
          "duration_ms",
          "is_test",
          "replay_of",
          "created_at"
        ]
      },
      "ListWebhookDeliveriesResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "endpoint_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "email_event_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid"
                },
                "event_type": {
                  "type": "string",
                  "enum": [
                    "email.queued",
                    "email.scheduled",
                    "email.sent",
                    "email.delivered",
                    "email.delivery_delayed",
                    "email.bounced",
                    "email.complained",
                    "email.rejected",
                    "email.failed",
                    "email.cancelled"
                  ]
                },
                "email_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "delivered",
                    "failed"
                  ]
                },
                "attempts": {
                  "type": "integer"
                },
                "last_error": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "response_code": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "duration_ms": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "is_test": {
                  "type": "boolean"
                },
                "replay_of": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "endpoint_id",
                "email_event_id",
                "event_type",
                "email_id",
                "status",
                "attempts",
                "last_error",
                "response_code",
                "duration_ms",
                "is_test",
                "replay_of",
                "created_at"
              ]
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "AccountSummary": {
        "type": "object",
        "properties": {
          "account": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "plan": {
                "type": "string",
                "enum": [
                  "free",
                  "pro",
                  "growth",
                  "enterprise"
                ]
              },
              "plan_step": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "name",
              "plan",
              "plan_step"
            ]
          },
          "key": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "mode",
              "scopes"
            ]
          },
          "sandbox": {
            "type": "object",
            "properties": {
              "domain": {
                "type": "string"
              },
              "recipients": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "simulator": {
                "type": "object",
                "properties": {
                  "delivered": {
                    "type": "string"
                  },
                  "bounced": {
                    "type": "string"
                  },
                  "complained": {
                    "type": "string"
                  }
                },
                "required": [
                  "delivered",
                  "bounced",
                  "complained"
                ]
              }
            },
            "required": [
              "domain",
              "recipients",
              "simulator"
            ]
          },
          "domains": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "verified",
                    "failed"
                  ]
                }
              },
              "required": [
                "id",
                "name",
                "status"
              ]
            }
          },
          "webhooks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "url": {
                  "type": "string"
                },
                "enabled": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "url",
                "enabled"
              ]
            }
          },
          "templates": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "slug": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "slug",
                "name"
              ]
            }
          },
          "docs_url": {
            "type": "string"
          }
        },
        "required": [
          "account",
          "key",
          "sandbox",
          "domains",
          "webhooks",
          "templates",
          "docs_url"
        ]
      },
      "WebhookPayload": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "email.queued",
              "email.scheduled",
              "email.sent",
              "email.delivered",
              "email.delivery_delayed",
              "email.bounced",
              "email.complained",
              "email.rejected",
              "email.failed",
              "email.cancelled"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "properties": {
              "email_id": {
                "type": "string",
                "format": "uuid"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              "from": {
                "type": "string"
              },
              "to": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "subject": {
                "type": "string"
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "status": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": {}
              }
            },
            "required": [
              "email_id",
              "mode",
              "from",
              "to",
              "subject",
              "tags",
              "status",
              "details"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "description": "Body POSTed to your webhook endpoints, signed with the Avelto-Signature header."
      },
      "EraseRecipientRequest": {
        "type": "object",
        "properties": {
          "email_address": {
            "type": "string",
            "format": "email"
          }
        },
        "required": [
          "email_address"
        ]
      },
      "EraseRecipientResponse": {
        "type": "object",
        "properties": {
          "recipient_hash": {
            "type": "string"
          },
          "emails_redacted": {
            "type": "integer"
          },
          "emails_deleted": {
            "type": "integer"
          },
          "events_redacted": {
            "type": "integer"
          },
          "suppressed": {
            "type": "boolean"
          }
        },
        "required": [
          "recipient_hash",
          "emails_redacted",
          "emails_deleted",
          "events_redacted",
          "suppressed"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/v1/emails": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Send an email",
        "description": "Queues an email. Returns 201 with the id, or 200 with the existing id when the Idempotency-Key was seen before. Sandbox senders only deliver to the account owner or the simulator addresses; other senders must be a verified domain. See https://staging.avelto.dev/docs/send-email.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "maxLength": 255,
              "description": "Replays the same email id for repeated requests."
            },
            "required": false,
            "name": "Idempotency-Key",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmailRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed from the Idempotency-Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendEmailResponse"
                }
              }
            }
          },
          "201": {
            "description": "Accepted and queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendEmailResponse"
                }
              }
            }
          },
          "400": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "sandbox_recipient_not_allowed, domain_not_verified, account_paused or account_suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "recipient_suppressed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "plan_limit or rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Emails"
        ],
        "summary": "List emails",
        "description": "Newest first, cursor-paginated. mode defaults to the API key's mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "scheduled",
                "sent",
                "delivered",
                "bounced",
                "complained",
                "failed",
                "cancelled"
              ]
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-zA-Z0-9_\\-:.]+$"
            },
            "required": false,
            "name": "tag",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "live",
                "test"
              ]
            },
            "required": false,
            "name": "mode",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "required": false,
            "name": "q",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of emails",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEmailsResponse"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/{id}": {
      "get": {
        "tags": [
          "Emails"
        ],
        "summary": "Get an email with its events",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Email"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/{id}/cancel": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Cancel a scheduled email",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelEmailResponse"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "not_scheduled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/batch": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Send up to 100 emails",
        "description": "Each message is validated, limited and queued exactly as a single send is; results[i] lines up with messages[i]. 200 when every message was accepted, 422 when none was, 207 when mixed. See https://staging.avelto.dev/docs/send-email.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "maxLength": 200,
              "description": "Makes the whole batch replayable; a retry returns the same ids."
            },
            "required": false,
            "name": "Idempotency-Key",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchSendRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Every message accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchSendResponse"
                }
              }
            }
          },
          "207": {
            "description": "Some accepted, some refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchSendResponse"
                }
              }
            }
          },
          "400": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "No message was accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchSendResponse"
                }
              }
            }
          },
          "429": {
            "description": "plan_limit or rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Create a template",
        "description": "A reusable subject and body with {{variables}} in them. Needs the templates:manage scope. See https://staging.avelto.dev/docs/templates.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            }
          },
          "400": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "conflict: that slug is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "List templates",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Most recently edited first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListTemplatesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates/{id}": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Get a template",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Templates"
        ],
        "summary": "Update a template",
        "description": "Only the fields you pass change. null clears a body part. Every save keeps a version.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            }
          },
          "400": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "conflict: that slug is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Delete a template",
        "description": "Emails already sent keep the text they were sent with.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates/{id}/versions": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "List versions",
        "description": "Newest first. Every save is kept.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TemplateVersion"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates/{id}/restore": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Restore a version",
        "description": "Writes the old version forward as a new one, so the history stays append-only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RestoreTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Restored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Add a sending domain",
        "description": "Returns the DNS records to publish. Poll GET /v1/domains/{id} until status is verified.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDomainRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Domain added, pending verification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "403": {
            "description": "plan_limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "conflict: already added, on this account or another",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "List domains",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Domains",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListDomainsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}": {
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "Get a domain (re-checks verification)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The domain with its current status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Domains"
        ],
        "summary": "Delete a domain",
        "description": "Needs a live key: a test key gets 403 forbidden.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "403": {
            "description": "forbidden: test key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/suppressions": {
      "get": {
        "tags": [
          "Suppressions"
        ],
        "summary": "List suppressed addresses",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of suppressions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListSuppressionsResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Suppressions"
        ],
        "summary": "Suppress an address manually",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSuppressionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Suppressed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Suppression"
                }
              }
            }
          },
          "409": {
            "description": "conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/suppressions/{email}": {
      "delete": {
        "tags": [
          "Suppressions"
        ],
        "summary": "Remove an address from the suppression list",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "email",
              "description": "URL-encoded email address"
            },
            "required": true,
            "name": "email",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create a webhook endpoint",
        "description": "The signing secret is returned once. Endpoint URLs must be https in production and may not point at private networks. Events: https://staging.avelto.dev/docs/webhooks/events.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Endpoint with its secret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointWithSecret"
                }
              }
            }
          },
          "400": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook endpoints",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoints",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListWebhooksResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/{id}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Get a webhook endpoint",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook endpoint",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/{id}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List deliveries for an endpoint",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Resource id",
              "example": "9c1f4a52-6f6e-4b8f-9b8e-2e1a5c7d3f10"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListWebhookDeliveriesResponse"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/{id}/deliveries/{deliveryId}/retry": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Retry a delivery",
        "description": "Re-enqueues the existing delivery. Its attempt count keeps climbing; no new delivery is created.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "deliveryId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Re-enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Describe the account and what is set up",
        "description": "The key's mode and scopes, the sandbox domain with every address a sandbox send may reach, and the account's domains, webhook endpoints and templates. Read this first when integrating: it says what exists and what the next step is.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The account summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSummary"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/export": {
      "get": {
        "tags": [
          "Data rights"
        ],
        "summary": "Export everything held for the account",
        "description": "One JSON document: account, users, keys, domains, emails with bodies, events, suppressions and webhooks. Answers a data subject access request. Needs a live key and the account:manage scope.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The full export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        }
      }
    },
    "/v1/recipients/erase": {
      "post": {
        "tags": [
          "Data rights"
        ],
        "summary": "Erase a recipient",
        "description": "Removes the address from emails, events and stored bodies, keeping only a hashed suppression entry so the address is never sent to again. Needs a live key and the account:manage scope.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EraseRecipientRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What was erased",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EraseRecipientResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {}
}