{
  "openapi": "3.1.0",
  "info": {
    "title": "Intigly blog agent",
    "version": "1.0.0",
    "description": "Write blog posts to the Intigly CMS. Call getRules first. The server formats, links and validates."
  },
  "servers": [
    {
      "url": "https://intigly-blog-agent.pages.dev"
    }
  ],
  "paths": {
    "/v1/rules": {
      "get": {
        "operationId": "getRules",
        "summary": "Read the writing rules before writing a post",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/related": {
      "get": {
        "operationId": "findRelatedPosts",
        "summary": "Find existing posts to link to",
        "parameters": [
          {
            "name": "title",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tags",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/posts": {
      "get": {
        "operationId": "listPosts",
        "summary": "Search existing posts",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "operationId": "createPost",
        "summary": "Create a post (saved as draft unless status is published)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "category",
                  "excerpt",
                  "short_answer",
                  "sections",
                  "intigly_fits_md",
                  "faq",
                  "key_takeaways"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Post title. Search-intent phrased."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Optional. Lowercase-hyphen. Defaults to the title."
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "Design",
                      "Marketing",
                      "Branding",
                      "AI",
                      "Content",
                      "Web",
                      "Video"
                    ]
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "2 to 5 topic tags, e.g. 'Kerning Guides'."
                  },
                  "excerpt": {
                    "type": "string",
                    "description": "60 to 200 characters. Shown under the title and in search results."
                  },
                  "short_answer": {
                    "type": "string",
                    "description": "1 or 2 sentences that answer the title directly."
                  },
                  "sections": {
                    "type": "array",
                    "minItems": 4,
                    "description": "The article body: at least 4 sections.",
                    "items": {
                      "type": "object",
                      "required": [
                        "heading",
                        "body_md"
                      ],
                      "properties": {
                        "heading": {
                          "type": "string"
                        },
                        "body_md": {
                          "type": "string",
                          "description": "Plain markdown: paragraphs, **bold**, - bullets, [links](url), pipe tables. No headings, no HTML, no numbered lists."
                        }
                      }
                    }
                  },
                  "intigly_fits_md": {
                    "type": "string",
                    "description": "Short natural paragraph on how Intigly fits this topic. Must mention Intigly."
                  },
                  "faq": {
                    "type": "array",
                    "minItems": 3,
                    "maxItems": 8,
                    "items": {
                      "type": "object",
                      "required": [
                        "q",
                        "a"
                      ],
                      "properties": {
                        "q": {
                          "type": "string"
                        },
                        "a": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "key_takeaways": {
                    "type": "array",
                    "minItems": 3,
                    "items": {
                      "type": "string"
                    }
                  },
                  "cover_url": {
                    "type": "string",
                    "description": "Optional. Leave empty; covers are added separately."
                  },
                  "author": {
                    "type": "string",
                    "description": "Optional byline name. Defaults to the configured author."
                  },
                  "service": {
                    "type": "string",
                    "enum": [
                      "content-creation",
                      "launch-videos",
                      "creative-subscription"
                    ],
                    "description": "Optional. Which service card to show. Chosen from the topic if omitted."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "draft",
                      "published"
                    ],
                    "description": "Default draft. Use published only when the user asked to publish."
                  },
                  "allow_similar": {
                    "type": "boolean"
                  },
                  "meta_title": {
                    "type": "string"
                  },
                  "meta_desc": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "409": {
            "description": "Duplicate"
          },
          "422": {
            "description": "Rule violations, nothing saved"
          }
        }
      }
    },
    "/v1/posts/{slug}": {
      "get": {
        "operationId": "getPost",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "operationId": "updatePost",
        "summary": "Update fields, or resend sections/faq/etc to rebuild the post",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Post title. Search-intent phrased."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Optional. Lowercase-hyphen. Defaults to the title."
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "Design",
                      "Marketing",
                      "Branding",
                      "AI",
                      "Content",
                      "Web",
                      "Video"
                    ]
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "2 to 5 topic tags, e.g. 'Kerning Guides'."
                  },
                  "excerpt": {
                    "type": "string",
                    "description": "60 to 200 characters. Shown under the title and in search results."
                  },
                  "short_answer": {
                    "type": "string",
                    "description": "1 or 2 sentences that answer the title directly."
                  },
                  "sections": {
                    "type": "array",
                    "minItems": 4,
                    "description": "The article body: at least 4 sections.",
                    "items": {
                      "type": "object",
                      "required": [
                        "heading",
                        "body_md"
                      ],
                      "properties": {
                        "heading": {
                          "type": "string"
                        },
                        "body_md": {
                          "type": "string",
                          "description": "Plain markdown: paragraphs, **bold**, - bullets, [links](url), pipe tables. No headings, no HTML, no numbered lists."
                        }
                      }
                    }
                  },
                  "intigly_fits_md": {
                    "type": "string",
                    "description": "Short natural paragraph on how Intigly fits this topic. Must mention Intigly."
                  },
                  "faq": {
                    "type": "array",
                    "minItems": 3,
                    "maxItems": 8,
                    "items": {
                      "type": "object",
                      "required": [
                        "q",
                        "a"
                      ],
                      "properties": {
                        "q": {
                          "type": "string"
                        },
                        "a": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "key_takeaways": {
                    "type": "array",
                    "minItems": 3,
                    "items": {
                      "type": "string"
                    }
                  },
                  "cover_url": {
                    "type": "string",
                    "description": "Optional. Leave empty; covers are added separately."
                  },
                  "author": {
                    "type": "string",
                    "description": "Optional byline name. Defaults to the configured author."
                  },
                  "service": {
                    "type": "string",
                    "enum": [
                      "content-creation",
                      "launch-videos",
                      "creative-subscription"
                    ],
                    "description": "Optional. Which service card to show. Chosen from the topic if omitted."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "draft",
                      "published"
                    ],
                    "description": "Default draft. Use published only when the user asked to publish."
                  },
                  "allow_similar": {
                    "type": "boolean"
                  },
                  "meta_title": {
                    "type": "string"
                  },
                  "meta_desc": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/posts/{slug}/publish": {
      "post": {
        "operationId": "publishPost",
        "summary": "Publish a draft and add backlinks from related posts",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/posts/{slug}/unpublish": {
      "post": {
        "operationId": "unpublishPost",
        "summary": "Back to draft and remove the backlinks it added",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ]
}