{
  "openapi": "3.1.0",
  "info": {
    "title": "Murit CMS Content API v1",
    "version": "1.0.0",
    "description": "Read-only multi-tenant Content API serving normalized posts, pre-rendered sanitized HTML, and sitemaps with zero build triggers. CMS operators must deploy the registered 20260909_122610_legacy_redirects database migration before using legacy URL fields; frontend clients do not run CMS migrations.",
    "contact": {
      "name": "Murit CMS Support",
      "url": "https://murit.space/docs"
    }
  },
  "servers": [
    {
      "url": "https://murit.space",
      "description": "Murit CMS Instance"
    }
  ],
  "paths": {
    "/api/content/v1/sites/{siteKey}": {
      "get": {
        "summary": "Get site metadata",
        "description": "Returns public configuration and metadata for a registered website.",
        "operationId": "getSiteMetadata",
        "parameters": [
          {
            "name": "siteKey",
            "in": "path",
            "required": true,
            "description": "The immutable public site key (e.g. site_...)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Site metadata returned successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "primaryURL": {
                          "type": "string"
                        },
                        "defaultLocale": {
                          "type": "string"
                        },
                        "siteKey": {
                          "type": "string"
                        },
                        "blogBasePath": {
                          "type": "string"
                        },
                        "timezone": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/content/v1/sites/{siteKey}/posts": {
      "get": {
        "summary": "List published posts",
        "description": "Returns a paginated list of published post summaries for the given website.",
        "operationId": "listPublishedPosts",
        "parameters": [
          {
            "name": "siteKey",
            "in": "path",
            "required": true,
            "description": "Public site key",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Number of posts to return (1-50, default 20)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor for pagination from previous response",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Filter posts by category slug",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Filter posts by tag slug",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Set to \"astro\" to return { posts: AstroPost[] } instead of the default paginated DTO envelope.",
            "schema": {
              "type": "string",
              "enum": [
                "default",
                "astro",
                "legacy"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of posts, or an AstroPost envelope when format=astro/legacy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PostSummary"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "nextCursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/content/v1/sites/{siteKey}/legacy-posts": {
      "get": {
        "summary": "List published posts in the Astro/legacy contract",
        "description": "Returns { posts: AstroPost[] }, the envelope expected by Astro SSG and legacy frontends.",
        "operationId": "listLegacyPosts",
        "parameters": [
          {
            "name": "siteKey",
            "in": "path",
            "required": true,
            "description": "Public site key",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Filter posts by category slug",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Filter posts by tag slug",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of posts in Astro-compatible contract",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "posts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AstroPost"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/content/v1/sites/{siteKey}/posts/{slug}": {
      "get": {
        "summary": "Get single published post",
        "description": "Retrieves full article details including sanitized lexical HTML, categories, and SEO metadata.",
        "operationId": "getPostBySlug",
        "parameters": [
          {
            "name": "siteKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The post URL slug",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Set to \"astro\" to return { post: AstroPost } instead of { data: PostDetail }.",
            "schema": {
              "type": "string",
              "enum": [
                "default",
                "astro",
                "legacy"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full post details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PostDetail"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/rjls-api/posts": {
      "get": {
        "summary": "Legacy compatibility alias for /legacy-posts",
        "description": "Backward-compatibility alias for the pre-migration RJLS frontend. Requires an explicit registered siteKey and returns only that website’s published posts.",
        "operationId": "getLegacyPostsAlias",
        "parameters": [
          {
            "name": "siteKey",
            "in": "query",
            "required": true,
            "description": "The registered public site key; there is no implicit fallback tenant.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Astro/legacy posts envelope",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "posts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AstroPost"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing siteKey query parameter"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/content/v1/sites/{siteKey}/sitemap": {
      "get": {
        "summary": "Retrieve sitemap index",
        "description": "Returns published article URLs and last-modified ISO timestamps for SEO sitemap generation.",
        "operationId": "getSitemapIndex",
        "parameters": [
          {
            "name": "siteKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sitemap list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SitemapItem"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "nextCursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/content/v1/sites/{siteKey}/preview": {
      "get": {
        "summary": "Redeem private draft preview",
        "description": "Access unpublished saved drafts using an ephemeral 5-minute cryptographic token.",
        "operationId": "previewDraft",
        "parameters": [
          {
            "name": "siteKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "query",
            "required": true,
            "description": "Cryptographic signed preview token",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Draft post content",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PostDetail"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired preview token"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "NotFound": {
        "description": "Website, post, or resource not found",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Media": {
        "type": "object",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "caption": {
            "type": [
              "string",
              "null"
            ]
          },
          "alt": {
            "type": [
              "string",
              "null"
            ]
          },
          "width": {
            "type": [
              "integer",
              "null"
            ]
          },
          "height": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "Taxonomy": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          }
        }
      },
      "PostSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "excerpt": {
            "type": "string"
          },
          "modifiedAt": {
            "type": "string",
            "format": "date-time"
          },
          "featuredMedia": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Media"
              },
              {
                "type": "null"
              }
            ]
          },
          "title": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Taxonomy"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Taxonomy"
            }
          },
          "seo": {
            "type": "object",
            "properties": {
              "title": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "canonicalURL": {
                "type": "string"
              },
              "keywords": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "socialImage": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Media"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      },
      "PostDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PostSummary"
          },
          {
            "type": "object",
            "properties": {
              "contentHtml": {
                "type": "string",
                "description": "Sanitized, pre-rendered lexical HTML ready for direct injection"
              }
            }
          }
        ]
      },
      "SitemapItem": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "lastModified": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AstroPost": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "excerpt": {
            "type": "string"
          },
          "image": {
            "type": [
              "string",
              "null"
            ]
          },
          "imageAlt": {
            "type": "string"
          },
          "imageWidth": {
            "type": [
              "number",
              "null"
            ]
          },
          "imageHeight": {
            "type": [
              "number",
              "null"
            ]
          },
          "seoImage": {
            "type": [
              "string",
              "null"
            ]
          },
          "seoImageWidth": {
            "type": [
              "number",
              "null"
            ]
          },
          "seoImageHeight": {
            "type": [
              "number",
              "null"
            ]
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "seoKeywords": {
            "type": [
              "string",
              "null"
            ]
          },
          "seoTitle": {
            "type": "string"
          },
          "seoDescription": {
            "type": "string"
          },
          "contentHtml": {
            "type": "string"
          },
          "contentMarkdown": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUpdatedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "redirectUrls": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "legacyUrl": {
            "type": "string"
          }
        }
      }
    }
  }
}