{
  "openapi": "3.1.0",
  "info": {
    "title": "Spiral of Cellular Light · Clinical Biophysics & Protocol API",
    "version": "1.0.0",
    "description": "Machine-readable API for Spiral of Cellular Light—an open-access systems biology, mitochondrial bioenergetics, and 28-day circadian protocol platform. Enables AI agents (Claude, ChatGPT, Gemini, MCP clients) to query daily compound schedules, molecular mechanisms, circadian calendars, authenticated longitudinal check-ins, and CERN/Zenodo monographs.",
    "contact": {
      "name": "Elura'Veth",
      "url": "https://spiraloflight.life"
    }
  },
  "servers": [
    {
      "url": "https://spiraloflight.vercel.app",
      "description": "Direct Agent API Gateway (Bypasses Cloudflare Browser Integrity Check / Error 1010 for Python & AI HTTP clients)"
    },
    {
      "url": "https://spiraloflight.life",
      "description": "Primary Sanctuary Domain"
    }
  ],
  "paths": {
    "/api/walk/day": {
      "get": {
        "operationId": "getWalkDay",
        "summary": "Get specific day protocol for the 28-day Walk",
        "description": "Returns the morning and evening ally checklists, doses, circadian focus, and guidance scrawl for any day (1 to 28) of the pilgrimage.",
        "parameters": [
          {
            "name": "day",
            "in": "query",
            "required": false,
            "description": "Day number between 1 and 28 (default: 1)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 28,
              "default": 1
            }
          },
          {
            "name": "spirals",
            "in": "query",
            "required": false,
            "description": "Comma-separated list of active spirals (e.g. waters,garden,flame,mind)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Day protocol data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "day": {
                      "type": "integer"
                    },
                    "dayCode": {
                      "type": "string"
                    },
                    "theme": {
                      "type": "string"
                    },
                    "orientation": {
                      "type": "object",
                      "description": "Quiet daily orientation scrawl: lead narrative, rotating foundation drip, and somatic anchor note",
                      "properties": {
                        "lead": {
                          "type": "string",
                          "description": "Prominent day-specific teaching (from Higher Flame or Cell Shedding)"
                        },
                        "drip": {
                          "type": "string",
                          "description": "Contemplative paragraph from foundation trees (Waters, Mind, Garden)"
                        },
                        "note": {
                          "type": "string",
                          "description": "Punchy somatic anchor or permission note"
                        },
                        "phaseFocus": {
                          "type": "string"
                        }
                      }
                    },
                    "circadianSchedule": {
                      "type": "object"
                    },
                    "guidance": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "guidanceNote": {
                      "type": "string"
                    },
                    "practice": {
                      "type": "object"
                    },
                    "chamberUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/calendar-events": {
      "get": {
        "operationId": "getCalendarEvents",
        "summary": "Get 56 circadian events for calendar synchronization",
        "description": "Returns an array of 56 circadian morning egress (7:30 AM) and evening restoration (9:00 PM) events across 28 days for synchronizing a user's Google Calendar, Apple Calendar, or Outlook.",
        "parameters": [
          {
            "name": "start",
            "in": "query",
            "required": false,
            "description": "Start date in YYYY-MM-DD format (default: today)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "spirals",
            "in": "query",
            "required": false,
            "description": "Comma-separated active spirals",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of calendar events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sanctuary": {
                      "type": "string"
                    },
                    "anchorDate": {
                      "type": "string"
                    },
                    "totalEvents": {
                      "type": "integer"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/calendar.ics": {
      "get": {
        "operationId": "getCalendarIcs",
        "summary": "Get RFC 5545 iCalendar (.ics) subscription feed",
        "description": "Returns a standard RFC 5545 .ics stream for 1-click WebCal subscription in Apple Calendar, Google Calendar, or Outlook.",
        "parameters": [
          {
            "name": "start",
            "in": "query",
            "required": false,
            "description": "Start date in YYYY-MM-DD format (default: today)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "iCalendar data stream",
            "content": {
              "text/calendar": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/apothecary/allies": {
      "get": {
        "operationId": "searchAllies",
        "summary": "Search and query supplement allies and doses",
        "description": "Searches the complete Apothecary registry for supplement doses, mechanisms, biological spiral affiliations, and circadian timing.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search keyword (e.g. magnesium, nac, glutathione)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tree",
            "in": "query",
            "required": false,
            "description": "Filter by spiral tree (waters, garden, flame, mind, shedding, mirror)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching supplement allies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalMatches": {
                      "type": "integer"
                    },
                    "allies": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/spirals/teachings": {
      "get": {
        "operationId": "getTeachings",
        "summary": "Query Gateway Chapters and Spiral Biophysics",
        "description": "Returns full monographs, biophysical mechanisms, and theses for Gateway chapters 1-6 or biological spirals (waters, garden, flame, mind, shedding, mirror).",
        "parameters": [
          {
            "name": "spiral",
            "in": "query",
            "required": false,
            "description": "Spiral identifier (waters, garden, flame, mind, shedding, mirror)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chapter",
            "in": "query",
            "required": false,
            "description": "Gateway chapter number between 1 and 6",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Biophysical teachings and cosmology",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/research/preprints": {
      "get": {
        "operationId": "getPreprints",
        "summary": "Get CERN & Zenodo peer-reviewed academic preprints",
        "description": "Returns citation metadata, DOIs, abstracts, and direct download links for the three open access biophysical papers.",
        "responses": {
          "200": {
            "description": "List of academic preprints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "repository": {
                      "type": "string"
                    },
                    "preprints": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/safety/cycling": {
      "get": {
        "operationId": "getSafetyAndCycling",
        "summary": "Get protocol safety guardrails and pulse-cycling rationale",
        "description": "Returns essential safety considerations, why senolytics (Cell Shedding) are pulsed for 14 days rather than daily, why earth chelation is 7 days, and contraindications.",
        "responses": {
          "200": {
            "description": "Safety guidelines and pulse-cycling rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/pilgrim/me": {
      "get": {
        "operationId": "getPilgrimStatus",
        "summary": "Get current seeker pilgrimage day, lit candles, and today's allies",
        "description": "Requires sovereign Pilgrim Agent Key via Bearer header or '?key=...'. Dynamically calculates today's day from the seeker's anchor start date, returns today's morning and evening allies with individual check/lit statuses, somatic practice, and reflection note.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "day",
            "in": "query",
            "required": false,
            "description": "Optionally query a specific day (1..28) instead of the current calculated day",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 28
            }
          },
          {
            "name": "key",
            "in": "query",
            "required": false,
            "description": "Alternative to Authorization header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authenticated seeker progression and today's protocol checklist",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid Pilgrim Agent Key"
          }
        }
      }
    },
    "/api/pilgrim/check": {
      "post": {
        "operationId": "setPilgrimCheck",
        "summary": "Light or unlight a supplement candle for a pilgrimage day",
        "description": "Marks an ally candle as taken or un-taken in the seeker's cloud vault. Updates the 28-day progression lattice in real time.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "day",
                  "allyId"
                ],
                "properties": {
                  "day": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 28,
                    "description": "Pilgrimage day (1 to 28)"
                  },
                  "allyId": {
                    "type": "string",
                    "description": "ID of ally (e.g. 'quercetin', 'magnesium_threonate')"
                  },
                  "lit": {
                    "type": "boolean",
                    "default": true,
                    "description": "True to mark candle as lit, false to unlight"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Candle status updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/pilgrim/reflection": {
      "post": {
        "operationId": "setPilgrimReflection",
        "summary": "Record or append a somatic reflection note for a pilgrimage day",
        "description": "Saves a personal reflection or journal note into the seeker's cloud heart container for any day.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "day",
                  "reflection"
                ],
                "properties": {
                  "day": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 28,
                    "description": "Pilgrimage day (1 to 28)"
                  },
                  "reflection": {
                    "type": "string",
                    "description": "Somatic, emotional, or biophysical reflection note"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reflection note recorded successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/pilgrim/checkin": {
      "post": {
        "operationId": "recordPilgrimCheckin",
        "summary": "Autonomous multi-ally check-in, candle lighting, and somatic feedback",
        "description": "Processes a natural conversational check-in: lights candles for taken allies, records skipped allies and reasons, logs reflection notes, and returns biophysical advisory feedback.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "day"
                ],
                "properties": {
                  "day": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 28,
                    "description": "Day number (1 to 28)"
                  },
                  "period": {
                    "type": "string",
                    "enum": [
                      "morning",
                      "afternoon",
                      "evening",
                      "night"
                    ],
                    "default": "morning"
                  },
                  "takenAllies": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "IDs of allies taken"
                  },
                  "skippedAllies": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "reason": {
                          "type": "string"
                        }
                      }
                    },
                    "description": "Allies intentionally skipped with somatic rationale"
                  },
                  "sensations": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Somatic sensations experienced (e.g. liver_heat, floating_head, flushing)"
                  },
                  "reflection": {
                    "type": "string",
                    "description": "Personal journal reflection note"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check-in processed, candles lit, and advisory returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/pilgrim/advisory": {
      "get": {
        "operationId": "getBiophysicalAdvisory",
        "summary": "Query biophysical mechanisms and somatic counter-actions",
        "description": "Returns non-equilibrium mechanisms, somatic physical counter-actions, and safe botanical substitutions for sensations or symptoms.",
        "parameters": [
          {
            "name": "symptom",
            "in": "query",
            "required": false,
            "description": "Symptom or sensation key (e.g. liver_heat, flushing, floating_head, day_3_boss_fight)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "day",
            "in": "query",
            "required": false,
            "description": "Filter sensations common to a specific pilgrimage day (1 to 7)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Biophysical mechanisms and somatic remedies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sol_sec_...",
        "description": "Sovereign Pilgrim Agent Key generated inside the Pilgrim Vault modal on https://spiraloflight.life."
      }
    }
  }
}