{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/crevio-co/json-schema/crevio-co-email-sequence-schema.json",
  "title": "EmailSequence",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/crevio-co-openapi.json#/components/schemas/EmailSequence",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "sequence"
      ]
    },
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "active",
        "paused"
      ]
    },
    "trigger": {
      "type": "object",
      "properties": {
        "event": {
          "type": "string",
          "enum": [
            "manual",
            "lead.created",
            "customer.tag_added",
            "order.paid"
          ],
          "description": "What enrolls people. `manual` enrolls only through `POST /sequences/{sequence_id}/enrollments`."
        },
        "tag_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "`customer.tag_added` only: the tag (`tag_...`) that enrolls. Form signups apply their tags after double opt-in, so a form's tag is the newsletter trigger."
        },
        "product_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "`order.paid` only: enroll buyers of these products (`prod_...`). Empty means any product."
        }
      },
      "required": [
        "event",
        "tag_id",
        "product_ids"
      ]
    },
    "exit": {
      "type": "object",
      "properties": {
        "on_purchase": {
          "type": "string",
          "enum": [
            "none",
            "any",
            "products"
          ],
          "description": "Stop when the person pays for an order placed after enrolling: `any` order, only orders containing `product_ids`, or `none`."
        },
        "product_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Products (`prod_...`) that count when `on_purchase` is `products`."
        },
        "tag_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Stop when the person gets any of these tags (`tag_...`)."
        },
        "on_reply": {
          "type": "boolean",
          "description": "Stop when the person replies. Replies are only seen when they reach a Crevio inbox, so with this on and no `reply_to`, replies go to the account's inbox."
        }
      },
      "required": [
        "on_purchase",
        "product_ids",
        "tag_ids",
        "on_reply"
      ]
    },
    "send_days": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "sun",
          "mon",
          "tue",
          "wed",
          "thu",
          "fri",
          "sat"
        ]
      },
      "description": "Weekdays a step may go out, in the business's time zone. A step due on another day waits for the next allowed day at the same local time."
    },
    "from": {
      "type": [
        "string",
        "null"
      ]
    },
    "reply_to": {
      "type": [
        "string",
        "null"
      ]
    },
    "styled": {
      "type": "boolean"
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/EmailSequenceStep"
      },
      "description": "Live steps in send order."
    },
    "metadata": {
      "type": "object"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "object",
    "id",
    "name",
    "status",
    "trigger",
    "exit",
    "send_days",
    "from",
    "reply_to",
    "styled",
    "steps",
    "metadata",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "EmailSequenceStep": {
      "type": "object",
      "properties": {
        "object": {
          "type": "string",
          "enum": [
            "sequence_step"
          ]
        },
        "id": {
          "type": "string"
        },
        "sequence": {
          "type": "string"
        },
        "position": {
          "type": "integer"
        },
        "subject": {
          "type": "string"
        },
        "preview_text": {
          "type": [
            "string",
            "null"
          ]
        },
        "body": {
          "type": "string"
        },
        "delay": {
          "type": "object",
          "properties": {
            "amount": {
              "type": "integer",
              "minimum": 0,
              "description": "How many `unit`s to wait. `0` sends right away."
            },
            "unit": {
              "type": "string",
              "enum": [
                "minutes",
                "hours",
                "days",
                "weeks"
              ]
            }
          },
          "required": [
            "amount",
            "unit"
          ],
          "description": "Wait after the previous step's send (after enrolling, for the first step)."
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "object",
        "id",
        "sequence",
        "position",
        "subject",
        "preview_text",
        "body",
        "delay",
        "created_at",
        "updated_at"
      ]
    }
  }
}