{
  "openapi": "3.1.0",
  "info": {
    "title": "Sendtern API",
    "version": "0.1.0",
    "description": "Transactional email and sender domain management. Use the URL of your self-hosted installation."
  },
  "servers": [
    {
      "url": "/",
      "description": "Current installation"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/emails": {
      "post": {
        "summary": "Queue an email",
        "x-sendtern-permission": "sending_access",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmail"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List emails",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 30
            }
          },
          {
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The UUID of the last email in the previous page. Use a cursor from the current workspace."
          },
          {
            "in": "query",
            "name": "q",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "sending",
                "captured",
                "sent",
                "delayed",
                "delivered",
                "bounced",
                "failed",
                "skipped",
                "uncertain"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Email"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The pagination cursor does not exist in this workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/emails/{id}": {
      "get": {
        "summary": "Retrieve email and timeline",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailDetail"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/domains": {
      "post": {
        "summary": "Add a domain",
        "x-sendtern-permission": "full_access",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 240,
                    "minLength": 1,
                    "format": "hostname",
                    "description": "Fully qualified sending domain, including a dot. IDNs are accepted in Unicode or punycode."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List domains",
        "x-sendtern-permission": "full_access",
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Domain"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/domains/{id}": {
      "get": {
        "summary": "Retrieve a domain",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Remove a domain",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "deleted": {
                      "const": true
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/domains/{id}/verify": {
      "post": {
        "summary": "Check DNS records",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys": {
      "post": {
        "summary": "Create an API key",
        "x-sendtern-permission": "full_access",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60,
                    "minLength": 1
                  },
                  "permission": {
                    "type": "string",
                    "enum": [
                      "sending_access",
                      "full_access"
                    ],
                    "default": "sending_access"
                  },
                  "domain": {
                    "type": "string",
                    "maxLength": 253,
                    "description": "Optionally restrict a sending_access key to one verified domain name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "token": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "token"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List API key metadata",
        "x-sendtern-permission": "full_access",
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys/{id}": {
      "delete": {
        "summary": "Revoke an API key",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked"
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/events": {
      "post": {
        "summary": "Trigger matching automations and resume waiting runs",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "event",
                  "email"
                ],
                "properties": {
                  "event": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9_.-]{1,63}$"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "data": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted event",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "runs",
                    "resumed"
                  ],
                  "properties": {
                    "runs": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid"
                      }
                    },
                    "resumed": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/emails/stats": {
      "get": {
        "summary": "Daily email activity and totals",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "query",
            "name": "days",
            "schema": {
              "type": "integer",
              "enum": [
                1,
                7,
                14,
                30,
                90
              ],
              "default": 7
            }
          }
        ],
        "responses": {
          "200": {
            "description": "UTC daily buckets and aggregate status counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "totals",
                    "series"
                  ],
                  "properties": {
                    "totals": {
                      "type": "object"
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/emails/batch": {
      "post": {
        "summary": "Queue up to 100 transactional emails in a batch",
        "x-sendtern-permission": "sending_access",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Retry the same request safely for 24 hours."
          },
          {
            "in": "header",
            "name": "X-Batch-Validation",
            "required": false,
            "schema": {
              "enum": [
                "strict",
                "permissive"
              ],
              "default": "strict"
            }
          }
        ],
        "description": "Strict mode rolls back the entire request on a failure. Permissive mode may skip invalid individual rows. Scheduled emails and attachments are not supported in batches.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ResendBatchEmailInput"
                },
                "minItems": 1,
                "maxItems": 100
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResendBatchResult"
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/test/emails": {
      "post": {
        "summary": "Capture an email in the test inbox",
        "description": "Captures the message for inspection without SMTP or live quota usage. The project can review the capture for up to seven days in Email Playground.",
        "x-sendtern-permission": "sending_access",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": { "type": "string", "minLength": 1, "maxLength": 256 }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  { "$ref": "#/components/schemas/ResendEmailInput" },
                  {
                    "required": ["from", "to", "subject"],
                    "anyOf": [{ "required": ["html"] }, { "required": ["text"] }],
                    "not": { "anyOf": [{ "required": ["template"] }, { "required": ["scheduled_at"] }] }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email captured",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "id": { "type": "string", "format": "uuid" } },
                  "required": ["id"]
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          }
        }
      }
    },
    "/resend/emails": {
      "post": {
        "summary": "Queue an email using Resend-compatible request fields",
        "x-sendtern-permission": "sending_access",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Retry the same request safely for 24 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResendEmailInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List emails using Resend-compatible responses",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ResendEmail"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "has_more",
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/emails/batch": {
      "post": {
        "summary": "Queue up to 100 transactional emails in a batch",
        "x-sendtern-permission": "sending_access",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Retry the same request safely for 24 hours."
          },
          {
            "in": "header",
            "name": "X-Batch-Validation",
            "required": false,
            "schema": {
              "enum": [
                "strict",
                "permissive"
              ],
              "default": "strict"
            }
          }
        ],
        "description": "Strict mode rolls back the entire request on a failure. Permissive mode may skip invalid individual rows. Scheduled emails and attachments are not supported in batches.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ResendBatchEmailInput"
                },
                "minItems": 1,
                "maxItems": 100
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResendBatchResult"
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/emails/{id}": {
      "get": {
        "summary": "Retrieve a Resend-compatible email object",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResendEmailDetail"
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Reschedule an email that has not reached its scheduled time",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scheduled_at": {
                    "type": "string",
                    "maxLength": 80,
                    "description": "Future ISO timestamp with timezone or “in N seconds/minutes/hours/days”, up to 30 days ahead."
                  }
                },
                "required": [
                  "scheduled_at"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "email"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "object",
                    "id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/emails/{id}/cancel": {
      "post": {
        "summary": "Cancel an email before its scheduled time",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "email"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "object",
                    "id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/domains": {
      "post": {
        "summary": "Create a sending domain",
        "x-sendtern-permission": "full_access",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "tls": {
                    "const": "opportunistic"
                  },
                  "open_tracking": {
                    "const": false
                  },
                  "click_tracking": {
                    "const": false
                  },
                  "capabilities": {
                    "type": "object",
                    "properties": {
                      "sending": {
                        "const": "enabled"
                      },
                      "receiving": {
                        "const": "disabled"
                      }
                    },
                    "required": [
                      "sending",
                      "receiving"
                    ]
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResendDomainDetail"
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List domains",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ResendDomain"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "has_more",
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/domains/{id}": {
      "get": {
        "summary": "Read domain information and DNS records",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/ResendDomainDetail"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "object": {
                          "const": "domain"
                        }
                      },
                      "required": [
                        "object"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Remove a sending domain",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "domain"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "deleted": {
                      "const": true
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/domains/{id}/verify": {
      "post": {
        "summary": "Check all Sendtern domain DNS records",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "domain"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "object",
                    "id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/api-keys": {
      "post": {
        "summary": "Create a Sendtern API key for the SDK",
        "x-sendtern-permission": "full_access",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "permission": {
                    "type": "string",
                    "enum": [
                      "sending_access",
                      "full_access"
                    ],
                    "default": "full_access"
                  },
                  "domain_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "api_key"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "token": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "token"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List API keys",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "has_more",
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/resend/api-keys/{id}": {
      "delete": {
        "summary": "Revoke the key",
        "x-sendtern-permission": "full_access",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "api_key"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "deleted": {
                      "const": true
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Sendtern API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Sendtern API key"
      }
    },
    "schemas": {
      "SendEmail": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "maxLength": 320,
            "minLength": 3
          },
          "to": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50,
                "minItems": 1
              }
            ]
          },
          "cc": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "bcc": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "reply_to": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "html": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200000
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100000
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "value": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                }
              },
              "required": [
                "name",
                "value"
              ]
            },
            "maxItems": 10
          },
          "template": {
            "type": "object",
            "description": "A published template in the workspace, identified by ID or alias.",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "variables": {
                "type": "object",
                "maxProperties": 50,
                "additionalProperties": {
                  "type": [
                    "string",
                    "number"
                  ]
                },
                "propertyNames": {
                  "pattern": "^[A-Za-z_][A-Za-z_0-9]{0,59}$"
                }
              }
            }
          }
        },
        "required": [
          "to"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "from",
              "subject",
              "text"
            ]
          },
          {
            "required": [
              "from",
              "subject",
              "html"
            ]
          },
          {
            "required": [
              "template"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "text"
                  ]
                },
                {
                  "required": [
                    "html"
                  ]
                }
              ]
            }
          }
        ]
      },
      "Email": {
        "type": "object",
        "properties": {
          "object": {
            "const": "email"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "reply_to": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "subject": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_event": {
            "type": "string",
            "enum": [
              "queued",
              "sending",
              "captured",
              "sent",
              "delayed",
              "delivered",
              "bounced",
              "failed",
              "skipped",
              "uncertain"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "value": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                }
              },
              "required": [
                "name",
                "value"
              ]
            }
          }
        },
        "required": [
          "object",
          "id",
          "from",
          "to",
          "cc",
          "bcc",
          "reply_to",
          "subject",
          "created_at",
          "updated_at",
          "last_event",
          "mode",
          "tags"
        ]
      },
      "EmailDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Email"
          },
          {
            "type": "object",
            "properties": {
              "text": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "html": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "error": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "detail": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "created_at",
                    "detail"
                  ]
                }
              }
            },
            "required": [
              "text",
              "html",
              "error",
              "events"
            ]
          }
        ]
      },
      "Domain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "verified"
            ]
          },
          "records": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "const": "TXT"
                },
                "name": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "pending",
                    "verified"
                  ]
                },
                "optional": {
                  "type": "boolean"
                }
              },
              "required": [
                "type",
                "name",
                "value",
                "status"
              ]
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "checked_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "status",
          "records",
          "created_at",
          "checked_at"
        ]
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "permission": {
            "type": "string",
            "enum": [
              "sending_access",
              "full_access"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The domain restriction, if any."
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "permission",
          "created_at",
          "last_used_at",
          "domain"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "statusCode": {
            "type": "integer"
          }
        },
        "required": [
          "name",
          "message",
          "statusCode"
        ]
      },
      "ResendBatchEmailInput": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "maxLength": 320,
            "minLength": 3
          },
          "to": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50,
                "minItems": 1
              }
            ]
          },
          "cc": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "bcc": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "reply_to": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "html": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200000
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100000
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "value": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                }
              },
              "required": [
                "name",
                "value"
              ]
            },
            "maxItems": 10
          },
          "template": {
            "type": "object",
            "description": "A published template in the workspace, identified by ID or alias.",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "variables": {
                "type": "object",
                "maxProperties": 50,
                "additionalProperties": {
                  "type": [
                    "string",
                    "number"
                  ]
                },
                "propertyNames": {
                  "pattern": "^[A-Za-z_][A-Za-z_0-9]{0,59}$"
                }
              }
            }
          },
          "headers": {
            "type": "object",
            "maxProperties": 20,
            "additionalProperties": {
              "type": "string",
              "maxLength": 2048
            },
            "description": "Safe custom headers such as X-Reference. Routing and provider security headers are reserved."
          }
        },
        "required": [
          "to"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "from",
              "subject",
              "text"
            ]
          },
          {
            "required": [
              "from",
              "subject",
              "html"
            ]
          },
          {
            "required": [
              "template"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "text"
                  ]
                },
                {
                  "required": [
                    "html"
                  ]
                }
              ]
            }
          }
        ]
      },
      "ResendEmailInput": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "maxLength": 320,
            "minLength": 3
          },
          "to": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50,
                "minItems": 1
              }
            ]
          },
          "cc": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "bcc": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "reply_to": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "maxItems": 50
              }
            ]
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "html": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200000
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100000
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "value": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                }
              },
              "required": [
                "name",
                "value"
              ]
            },
            "maxItems": 10
          },
          "template": {
            "type": "object",
            "description": "A published template in the workspace, identified by ID or alias.",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "variables": {
                "type": "object",
                "maxProperties": 50,
                "additionalProperties": {
                  "type": [
                    "string",
                    "number"
                  ]
                },
                "propertyNames": {
                  "pattern": "^[A-Za-z_][A-Za-z_0-9]{0,59}$"
                }
              }
            }
          },
          "headers": {
            "type": "object",
            "maxProperties": 20,
            "additionalProperties": {
              "type": "string",
              "maxLength": 2048
            },
            "description": "Safe custom headers such as X-Reference. Routing and provider security headers are reserved."
          },
          "scheduled_at": {
            "type": "string",
            "maxLength": 80,
            "description": "Future ISO timestamp with timezone or “in N seconds/minutes/hours/days”, up to 30 days ahead."
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 120
                },
                "content": {
                  "type": "string",
                  "contentEncoding": "base64"
                },
                "content_type": {
                  "type": "string"
                },
                "content_id": {
                  "type": "string"
                }
              },
              "required": [
                "filename",
                "content"
              ],
              "additionalProperties": false
            },
            "maxItems": 10,
            "description": "Inline base64 attachments. Maximum combined size 500 KiB decoded."
          }
        },
        "required": [
          "to"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "from",
              "subject",
              "text"
            ]
          },
          {
            "required": [
              "from",
              "subject",
              "html"
            ]
          },
          {
            "required": [
              "template"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "text"
                  ]
                },
                {
                  "required": [
                    "html"
                  ]
                }
              ]
            }
          }
        ]
      },
      "ResendEmail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cc": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "bcc": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "reply_to": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "subject": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_event": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "message_id",
          "from",
          "to",
          "cc",
          "bcc",
          "reply_to",
          "subject",
          "created_at",
          "scheduled_at",
          "last_event"
        ]
      },
      "ResendEmailDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ResendEmail"
          },
          {
            "type": "object",
            "properties": {
              "object": {
                "const": "email"
              },
              "html": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "text": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "object",
              "html",
              "text"
            ]
          }
        ]
      },
      "ResendDomain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "open_tracking": {
            "const": false
          },
          "click_tracking": {
            "const": false
          },
          "capabilities": {
            "type": "object",
            "properties": {
              "sending": {
                "const": "enabled"
              },
              "receiving": {
                "const": "disabled"
              }
            },
            "required": [
              "sending",
              "receiving"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "created_at",
          "status",
          "open_tracking",
          "click_tracking",
          "capabilities"
        ]
      },
      "ResendDomainRecord": {
        "type": "object",
        "properties": {
          "record": {
            "enum": [
              "Ownership",
              "DKIM",
              "SPF"
            ]
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "type": {
            "const": "TXT"
          },
          "status": {
            "type": "string"
          },
          "ttl": {
            "const": "Auto"
          }
        },
        "required": [
          "record",
          "name",
          "value",
          "type",
          "status",
          "ttl"
        ]
      },
      "ResendDomainDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ResendDomain"
          },
          {
            "type": "object",
            "properties": {
              "records": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ResendDomainRecord"
                }
              }
            },
            "required": [
              "records"
            ]
          }
        ]
      },
      "ResendBatchResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "id"
              ]
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "minimum": 0
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "index",
                "message"
              ]
            }
          }
        },
        "required": [
          "data"
        ]
      }
    }
  }
}
