{
  "openapi": "3.1.0",
  "info": {
    "title": "SentFast API",
    "version": "1.0.0",
    "description": "Send transactional emails from templates stored in SentFast. Your backend sends a template id, a recipient and the values of the template variables.",
    "contact": {
      "name": "SentFast",
      "url": "https://sentfa.st/contact",
      "email": "hi@sentfa.st"
    }
  },
  "servers": [
    {
      "url": "https://sentfa.st"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/api/v1/email/send": {
      "post": {
        "operationId": "sendEmail",
        "summary": "Send a stored email template",
        "description": "Renders the template identified by `id`, replacing its {{variables}} with `params`, and delivers it to `to`. The key must belong to the same project as the template.",
        "externalDocs": {
          "url": "https://sentfa.st/docs/send-email"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmailRequest"
              },
              "examples": {
                "minimal": {
                  "summary": "Template with variables",
                  "value": {
                    "id": "em_a1b2c3d4",
                    "to": "customer@example.com",
                    "params": {
                      "user_name": "Alex"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The message was handed to the delivery provider and logged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendEmailResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON body, or `id` or `to` missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No template with that id in the project that owns the key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Monthly send limit of the plan reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The delivery provider rejected the message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The API is disabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Project API key. Prefix sf_live_ for production and sf_test_ for testing. Keep it server-side."
      }
    },
    "schemas": {
      "SendEmailRequest": {
        "type": "object",
        "required": [
          "id",
          "to"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Id of the email template, e.g. em_a1b2c3d4.",
            "examples": [
              "em_a1b2c3d4"
            ]
          },
          "to": {
            "type": "string",
            "format": "email",
            "description": "Recipient address."
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            },
            "description": "Addresses in copy."
          },
          "params": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Values for the {{variables}} of the template."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            }
          }
        }
      },
      "Attachment": {
        "type": "object",
        "required": [
          "filename"
        ],
        "description": "Provide the file either as a public URL or as base64.",
        "properties": {
          "filename": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Publicly reachable URL of the file."
          },
          "base64": {
            "type": "string",
            "description": "File contents encoded in base64."
          },
          "contentType": {
            "type": "string",
            "examples": [
              "application/pdf"
            ]
          }
        }
      },
      "SendEmailResponse": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}