{
  "openapi": "3.1.0",
  "info": {
    "title": "Rewire Brand Libraries",
    "version": "1.0.0",
    "description": "Save and organize work in private brand inboxes on Hostinger."
  },
  "servers": [
    {
      "url": "https://libraries.rewireapps.in"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/brands": {
      "get": {
        "operationId": "listBrandLibraries",
        "summary": "List the brand libraries available to this key",
        "x-openai-isConsequential": false,
        "responses": {
          "200": {
            "description": "Accessible brands",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/v1/brands/{brand}/items": {
      "get": {
        "operationId": "listBrandItems",
        "summary": "Search a brand inbox by title, folder, type, or status",
        "x-openai-isConsequential": false,
        "responses": {
          "200": {
            "description": "Matching item summaries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "rewire",
                "innovative-india",
                "jayded",
                "askjay"
              ]
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "idea",
                "content",
                "automation",
                "file"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "inbox",
                "in-progress",
                "done",
                "archived"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ]
      },
      "post": {
        "operationId": "saveBrandItem",
        "summary": "Save an idea, content draft, automation brief, or file reference to a brand inbox",
        "x-openai-isConsequential": true,
        "responses": {
          "200": {
            "description": "Existing item for the same request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Submission"
                }
              }
            }
          },
          "201": {
            "description": "Item saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Submission"
                }
              }
            }
          },
          "409": {
            "description": "Request ID conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "rewire",
                "innovative-india",
                "jayded",
                "askjay"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "request_id",
                  "kind",
                  "title"
                ],
                "properties": {
                  "request_id": {
                    "type": "string",
                    "description": "A unique ID such as a UUID. Reuse it only to retry the same submission."
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "idea",
                      "content",
                      "automation",
                      "file"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 240
                  },
                  "body": {
                    "type": "string",
                    "description": "The selected idea, draft, or brief as plain text or Markdown.",
                    "maxLength": 24000
                  },
                  "folder": {
                    "type": "string",
                    "maxLength": 180
                  },
                  "source_url": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/brands/{brand}/items/{id}": {
      "get": {
        "operationId": "getBrandItem",
        "summary": "Read one item in a brand inbox",
        "x-openai-isConsequential": false,
        "responses": {
          "200": {
            "description": "Item details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxItem"
                }
              }
            }
          },
          "404": {
            "description": "Item unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "rewire",
                "innovative-india",
                "jayded",
                "askjay"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "patch": {
        "operationId": "updateBrandItem",
        "summary": "Edit, move, or change the status of a brand inbox item",
        "x-openai-isConsequential": true,
        "responses": {
          "200": {
            "description": "Item updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxItem"
                }
              }
            }
          },
          "409": {
            "description": "Revision conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "rewire",
                "innovative-india",
                "jayded",
                "askjay"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "revision"
                ],
                "properties": {
                  "revision": {
                    "type": "integer",
                    "description": "The current revision from getBrandItem."
                  },
                  "title": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  },
                  "folder": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "inbox",
                      "in-progress",
                      "done",
                      "archived"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "InboxItem": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "brand": { "type": "string" },
          "kind": { "type": "string" },
          "title": { "type": "string" },
          "body": { "type": "string" },
          "folder": { "type": "string" },
          "state": { "type": "string" },
          "revision": { "type": "integer" },
          "receipt_url": { "type": "string", "format": "uri", "description": "Private app link to the saved item." }
        }
      },
      "Submission": {
        "type": "object",
        "properties": {
          "created": { "type": "boolean" },
          "item": { "$ref": "#/components/schemas/InboxItem" }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
