{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sendfire.ai/record-schema/1.0.0/brand-record.schema.json",
  "$comment": "Copyright (c) 2026 Sendfire Email Inc. Licensed under the MIT License; see LICENSE-MIT.md beside this file.",
  "title": "Sendfire Brand record",
  "description": "One Brand's record from Sendfire: its Brand Brief with revision history, Brand Memory with sources, Suggestions and their decisions, Campaigns with their Briefs, copy and Retros, Tests, Reports, Flow Retros and review history. Version 1.0.0. See README.md beside this file for the glossary and change log.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "schemaVersion", "exportedAt", "brand", "brandBrief", "memories", "suggestions", "campaigns", "tests", "reports", "flows", "reviews"],
  "properties": {
    "format": { "const": "sendfire.brand-record" },
    "schemaVersion": { "const": "1.0.0" },
    "exportedAt": { "$ref": "#/$defs/timestamp" },
    "brand": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "status", "industry", "timezone", "reportingCurrency", "createdAt"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "name": { "type": "string" },
        "status": { "enum": ["active", "inactive"] },
        "industry": { "$ref": "#/$defs/text" },
        "timezone": { "$ref": "#/$defs/text", "description": "IANA time zone the Brand measures its days in." },
        "reportingCurrency": { "$ref": "#/$defs/text", "description": "ISO 4217 code of the Brand's amounts." },
        "createdAt": { "$ref": "#/$defs/timestamp" }
      }
    },
    "brandBrief": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sections"],
      "properties": {
        "sections": { "type": "array", "items": { "$ref": "#/$defs/briefSection" } }
      }
    },
    "memories": { "type": "array", "items": { "$ref": "#/$defs/memory" } },
    "suggestions": { "type": "array", "items": { "$ref": "#/$defs/suggestion" } },
    "campaigns": { "type": "array", "items": { "$ref": "#/$defs/campaign" } },
    "tests": { "type": "array", "items": { "$ref": "#/$defs/test" } },
    "reports": { "type": "array", "items": { "$ref": "#/$defs/report" } },
    "flows": { "type": "array", "items": { "$ref": "#/$defs/flow" } },
    "reviews": { "type": "array", "items": { "$ref": "#/$defs/review" } }
  },
  "$defs": {
    "id": { "type": "string", "minLength": 1, "description": "Opaque record id. It joins records inside one export and means nothing outside it." },
    "text": { "type": ["string", "null"] },
    "timestamp": { "type": "string", "format": "date-time" },
    "optionalTimestamp": { "type": ["string", "null"], "format": "date-time" },
    "day": { "type": "string", "format": "date" },
    "optionalDay": { "type": ["string", "null"], "format": "date" },
    "number": { "type": ["number", "null"] },
    "authoredBy": {
      "enum": ["sendfire", "marketer", "agent"],
      "description": "Who wrote the record: Sendfire's AI, the Marketer, or an agent the Marketer brought (pasted by the Marketer or connected through MCP)."
    },
    "briefSection": {
      "type": "object",
      "additionalProperties": false,
      "required": ["section", "title", "content", "revisions"],
      "properties": {
        "section": { "enum": ["identity", "voice", "audience", "offers", "constraints", "goals"] },
        "title": { "type": "string" },
        "content": { "$ref": "#/$defs/text", "description": "The current text: the newest revision, or null when nothing is written." },
        "revisions": {
          "type": "array",
          "description": "Every revision, oldest first.",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["revision", "content", "source", "authoredBy", "createdAt", "sourceMemoryIds"],
            "properties": {
              "revision": { "type": "integer", "minimum": 1 },
              "content": { "type": "string" },
              "source": { "enum": ["marketer_edit", "accepted_suggestion", "imported"] },
              "authoredBy": { "$ref": "#/$defs/authoredBy" },
              "createdAt": { "$ref": "#/$defs/timestamp" },
              "sourceMemoryIds": { "type": "array", "items": { "$ref": "#/$defs/id" } }
            }
          }
        }
      }
    },
    "persona": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "who", "buysAndWhy", "respondsTo", "objections", "relationshipStage", "primary"],
      "properties": {
        "name": { "type": "string" },
        "who": { "type": "string" },
        "buysAndWhy": { "type": "string" },
        "respondsTo": { "type": "string" },
        "objections": { "type": "string" },
        "relationshipStage": { "type": "string", "description": "never_bought, bought_once, repeat or lapsed." },
        "primary": { "type": "boolean" }
      }
    },
    "memory": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "kind", "label", "content", "persona", "status", "validFrom", "validUntil", "supersedes", "authoredBy", "createdAt", "supersededAt", "sources"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "kind": { "enum": ["learning", "example", "persona"] },
        "label": { "$ref": "#/$defs/text" },
        "content": { "type": "string" },
        "persona": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/persona" }] },
        "status": { "enum": ["active", "superseded"] },
        "validFrom": { "$ref": "#/$defs/optionalTimestamp" },
        "validUntil": { "$ref": "#/$defs/optionalTimestamp" },
        "supersedes": { "type": ["string", "null"], "description": "Id of the memory this one replaced." },
        "authoredBy": { "$ref": "#/$defs/authoredBy" },
        "createdAt": { "$ref": "#/$defs/timestamp" },
        "supersededAt": { "$ref": "#/$defs/optionalTimestamp" },
        "sources": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["kind", "label", "observedAt", "freshness"],
            "properties": {
              "kind": { "enum": ["campaign", "campaign_evidence", "marketer", "test", "flow_retro", "generation_feedback", "connected_agent", "imported"] },
              "label": { "$ref": "#/$defs/text" },
              "observedAt": { "$ref": "#/$defs/optionalTimestamp" },
              "freshness": { "$ref": "#/$defs/text", "description": "The evidence label when the source was read: ready, thin, stale, missing, partial, sync_failed or incomplete_window." }
            }
          }
        }
      }
    },
    "suggestion": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "status", "change", "memoryKind", "targetMemoryId", "targetBriefSection", "proposedContent", "rationale", "question", "from", "campaignId", "testId", "flowId", "createdAt", "decision"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "status": { "enum": ["waiting", "accepted", "dismissed", "set_aside"] },
        "change": { "enum": ["new", "reinforce", "revise"] },
        "memoryKind": { "enum": ["learning", "example", "persona"] },
        "targetMemoryId": { "type": ["string", "null"] },
        "targetBriefSection": { "type": ["string", "null"] },
        "proposedContent": { "type": "string" },
        "rationale": { "$ref": "#/$defs/text" },
        "question": { "$ref": "#/$defs/text" },
        "from": { "enum": ["retro", "test", "flow_retro", "brand_learning", "generation_feedback", "connected_agent", "imported"] },
        "campaignId": { "type": ["string", "null"] },
        "testId": { "type": ["string", "null"] },
        "flowId": { "type": ["string", "null"] },
        "createdAt": { "$ref": "#/$defs/timestamp" },
        "decision": {
          "oneOf": [
            { "type": "null" },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["outcome", "acceptedAs", "finalContent", "dismissalReason", "decidedBy", "decidedAt"],
              "properties": {
                "outcome": { "enum": ["accepted", "dismissed"] },
                "acceptedAs": { "enum": ["as_written", "edited", null] },
                "finalContent": { "$ref": "#/$defs/text" },
                "dismissalReason": { "$ref": "#/$defs/text" },
                "decidedBy": { "$ref": "#/$defs/authoredBy" },
                "decidedAt": { "$ref": "#/$defs/timestamp" }
              }
            }
          ]
        }
      }
    },
    "campaignBrief": {
      "type": "object",
      "additionalProperties": false,
      "required": ["goal", "offer", "audience", "keyMessage", "primaryCta", "concept", "referenceUrls", "context", "draftingIntent", "updatedAt"],
      "properties": {
        "goal": { "$ref": "#/$defs/text" },
        "offer": { "$ref": "#/$defs/text" },
        "audience": { "$ref": "#/$defs/text" },
        "keyMessage": { "$ref": "#/$defs/text" },
        "primaryCta": { "$ref": "#/$defs/text" },
        "concept": { "$ref": "#/$defs/text" },
        "referenceUrls": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["url", "label"],
            "properties": { "url": { "type": "string" }, "label": { "$ref": "#/$defs/text" } }
          }
        },
        "context": { "$ref": "#/$defs/text" },
        "draftingIntent": {
          "oneOf": [
            { "type": "null" },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["label", "setBy"],
              "properties": {
                "label": { "enum": ["Flash Sale", "Product Launch", "Newsletter", "VIP Early Access", "Win-back", "other", "not_disclosed"] },
                "setBy": { "$ref": "#/$defs/authoredBy" }
              }
            }
          ]
        },
        "updatedAt": { "$ref": "#/$defs/timestamp" }
      }
    },
    "campaign": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "klaviyoCampaignId", "name", "channel", "status", "archived", "sendDate", "createdAt", "asSent", "performance", "brief", "copy", "retros"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "klaviyoCampaignId": { "type": ["string", "null"], "description": "The campaign's id in the Brand's own Klaviyo account." },
        "name": { "type": "string" },
        "channel": { "$ref": "#/$defs/text" },
        "status": { "enum": ["Idea", "Backlog", "In Production", "Review", "Scheduled", "Sent", null] },
        "archived": { "type": "boolean" },
        "sendDate": { "$ref": "#/$defs/optionalTimestamp" },
        "createdAt": { "$ref": "#/$defs/timestamp" },
        "asSent": {
          "type": "object",
          "additionalProperties": false,
          "required": ["subject", "previewText"],
          "properties": { "subject": { "$ref": "#/$defs/text" }, "previewText": { "$ref": "#/$defs/text" } }
        },
        "performance": {
          "type": "object",
          "description": "Klaviyo's totals for the send as Sendfire last read them. Rates are fractions.",
          "additionalProperties": false,
          "required": ["recipients", "openRate", "clickRate", "revenue", "orders"],
          "properties": {
            "recipients": { "$ref": "#/$defs/number" },
            "openRate": { "$ref": "#/$defs/number" },
            "clickRate": { "$ref": "#/$defs/number" },
            "revenue": { "$ref": "#/$defs/number" },
            "orders": { "$ref": "#/$defs/number" }
          }
        },
        "brief": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/campaignBrief" }] },
        "copy": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["element", "content", "authoredBy", "agentClient", "updatedAt"],
            "properties": {
              "element": { "enum": ["subject", "preview_text", "from_name", "hero_headline", "hero_subhead", "body", "cta", "sms_body", "sms_link"] },
              "content": { "type": "string" },
              "authoredBy": { "$ref": "#/$defs/authoredBy" },
              "agentClient": { "$ref": "#/$defs/text", "description": "The connected agent's client name, when an agent wrote the element." },
              "updatedAt": { "$ref": "#/$defs/timestamp" }
            }
          }
        },
        "retros": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "markdown", "memoryDecision", "suggestionId", "evidence", "authoredBy", "createdAt"],
            "properties": {
              "id": { "$ref": "#/$defs/id" },
              "markdown": { "type": "string", "description": "The Retro as written, in Markdown." },
              "memoryDecision": { "enum": ["suggestion_raised", "no_change", "suggestion_set_aside"] },
              "suggestionId": { "type": ["string", "null"] },
              "evidence": { "$ref": "#/$defs/text" },
              "authoredBy": { "$ref": "#/$defs/authoredBy" },
              "createdAt": { "$ref": "#/$defs/timestamp" }
            }
          }
        }
      }
    },
    "test": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "hypothesis", "primaryKpi", "category", "control", "variant", "runsIn", "channel", "status", "decisionRule", "campaignIds", "createdAt", "completedAt", "conclusions"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "name": { "type": "string" },
        "hypothesis": { "$ref": "#/$defs/text" },
        "primaryKpi": { "$ref": "#/$defs/text" },
        "category": { "$ref": "#/$defs/text" },
        "control": { "$ref": "#/$defs/text" },
        "variant": { "$ref": "#/$defs/text" },
        "runsIn": { "enum": ["campaigns", "flow"] },
        "channel": { "type": "string" },
        "status": { "enum": ["open", "concluded"] },
        "decisionRule": {
          "oneOf": [
            { "type": "null" },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["ifVariantWins", "ifControlWins", "ifNoDifference"],
              "properties": {
                "ifVariantWins": { "type": "string" },
                "ifControlWins": { "type": "string" },
                "ifNoDifference": { "type": "string" }
              }
            }
          ]
        },
        "campaignIds": { "type": "array", "items": { "$ref": "#/$defs/id" } },
        "createdAt": { "$ref": "#/$defs/timestamp" },
        "completedAt": { "$ref": "#/$defs/optionalTimestamp" },
        "conclusions": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "outcome", "whatWeLearned", "whatWeWillDo", "decisionTaken", "concludedAt"],
            "properties": {
              "id": { "$ref": "#/$defs/id" },
              "outcome": { "enum": ["supports_control", "supports_variant", "no_meaningful_difference", "mixed", "inconclusive", "insufficient_evidence"] },
              "whatWeLearned": { "type": "string" },
              "whatWeWillDo": { "$ref": "#/$defs/text" },
              "decisionTaken": { "$ref": "#/$defs/text" },
              "concludedAt": { "$ref": "#/$defs/timestamp" }
            }
          }
        }
      }
    },
    "report": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "month", "periodStart", "periodEnd", "state", "reviewedAt", "note", "revision", "authoredBy", "updatedAt", "narrative"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "month": { "type": "string", "pattern": "^\\d{4}-\\d{2}$" },
        "periodStart": { "$ref": "#/$defs/day" },
        "periodEnd": { "$ref": "#/$defs/day" },
        "state": { "type": "string" },
        "reviewedAt": { "$ref": "#/$defs/optionalTimestamp" },
        "note": { "$ref": "#/$defs/text", "description": "The Marketer's note on the month." },
        "revision": { "type": ["integer", "null"] },
        "authoredBy": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/authoredBy" }] },
        "updatedAt": { "$ref": "#/$defs/optionalTimestamp" },
        "narrative": {
          "oneOf": [
            { "type": "null" },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["headline", "summary", "whatMattered", "whatWeLearned", "nextMonth", "flowWork"],
              "properties": {
                "headline": { "type": "string" },
                "summary": { "type": "string" },
                "whatMattered": { "type": "array", "items": { "type": "string" } },
                "whatWeLearned": { "type": "array", "items": { "type": "string" } },
                "nextMonth": { "type": "array", "items": { "type": "string" } },
                "flowWork": {
                  "oneOf": [
                    { "type": "null" },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": ["revisions", "retros"],
                      "properties": {
                        "revisions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": ["flowName", "step", "change", "reason", "liveOn"],
                            "properties": {
                              "flowName": { "type": "string" },
                              "step": { "type": "string" },
                              "change": { "type": "string" },
                              "reason": { "type": "string" },
                              "liveOn": { "$ref": "#/$defs/day" }
                            }
                          }
                        },
                        "retros": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": ["flowName", "period", "text"],
                            "properties": {
                              "flowName": { "type": "string" },
                              "period": { "type": "string" },
                              "text": { "type": "string" }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      }
    },
    "flow": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "klaviyoFlowId", "name", "flowRetros"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "klaviyoFlowId": { "type": ["string", "null"], "description": "The flow's id in the Brand's own Klaviyo account." },
        "name": { "type": "string" },
        "flowRetros": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "windowStart", "windowEnd", "markdown", "evidence", "authoredBy", "createdAt"],
            "properties": {
              "id": { "$ref": "#/$defs/id" },
              "windowStart": { "$ref": "#/$defs/optionalDay" },
              "windowEnd": { "$ref": "#/$defs/optionalDay" },
              "markdown": { "type": "string", "description": "The Flow Retro as written, in Markdown." },
              "evidence": { "$ref": "#/$defs/text" },
              "authoredBy": { "$ref": "#/$defs/authoredBy" },
              "createdAt": { "$ref": "#/$defs/timestamp" }
            }
          }
        }
      }
    },
    "review": {
      "type": "object",
      "additionalProperties": false,
      "required": ["subject", "versions", "events"],
      "properties": {
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "id"],
          "properties": {
            "kind": { "enum": ["campaign", "campaign_direction", "campaign_plan", "report", "test", "flow_retro", "flow_spec", "revision"] },
            "id": { "$ref": "#/$defs/id" }
          }
        },
        "versions": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["version", "publishedAt"],
            "properties": { "version": { "type": "integer", "minimum": 1 }, "publishedAt": { "$ref": "#/$defs/timestamp" } }
          }
        },
        "events": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["kind", "by", "body", "edited", "version", "at"],
            "properties": {
              "kind": { "enum": ["shared", "comment", "question", "reply", "approved", "changes_requested", "resolved", "marked_reviewed", "marked_approved", "approval_skipped"] },
              "by": { "enum": ["member", "marketer", "sendfire"], "description": "Members are not named in an export." },
              "body": { "$ref": "#/$defs/text" },
              "edited": { "type": "boolean" },
              "version": { "type": ["integer", "null"] },
              "at": { "$ref": "#/$defs/timestamp" }
            }
          }
        }
      }
    }
  }
}
