{
  "openapi": "3.1.0",
  "info": {
    "title": "Promptary API",
    "version": "1.0.0",
    "description": "Fetch your AI prompts from any app, script, or automation tool via a stable REST endpoint. Every prompt in Promptary gets a unique ID that never changes — update the prompt in Promptary and every app that calls it gets the new version automatically.",
    "contact": {
      "email": "evkhv67@gmail.com",
      "url": "https://promptary.dev"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://promptary.dev/terms"
    }
  },
  "servers": [
    {
      "url": "https://promptary.dev/api/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/prompts/{id}": {
      "get": {
        "summary": "Get a prompt by ID",
        "description": "Fetch the assembled text of any prompt by its stable UUID. The prompt ID never changes. Update the prompt in Promptary and the next call to this endpoint returns the updated version automatically — no redeployment needed.",
        "operationId": "getPrompt",
        "tags": ["Prompts"],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The stable UUID of the prompt, visible in the Promptary app under the prompt's ID section.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "432cf304-77a4-44f6-9cdb-288d920dc8ca"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Prompt found and returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Prompt"
                },
                "example": {
                  "id": "432cf304-77a4-44f6-9cdb-288d920dc8ca",
                  "title": "YouTube Shorts Script",
                  "framework": "risen",
                  "text": "Role: You are a viral video scriptwriter...\nInstructions: Write a 60-second YouTube Shorts script...",
                  "topic_id": "8f3a1b2c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
                  "updated_at": "2026-06-25T09:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorUnauthorized"
                },
                "example": {
                  "error": "unauthorized"
                }
              }
            }
          },
          "404": {
            "description": "Prompt not found or not accessible with this API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorNotFound"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Prompt not found"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Maximum 60 requests per minute per API key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from your Promptary account. Create keys in the app under API Keys. Format: `Bearer pk_live_...`. Requires Developer or Team plan."
      }
    },
    "schemas": {
      "Prompt": {
        "type": "object",
        "required": ["id", "title", "framework", "text", "topic_id", "updated_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Stable unique identifier for this prompt. Never changes."
          },
          "title": {
            "type": "string",
            "description": "Human-readable title of the prompt.",
            "example": "YouTube Shorts Script"
          },
          "framework": {
            "type": "string",
            "description": "The prompt framework used.",
            "enum": ["crit","race","rtf","ape","risen","craft","costar","tag","care","image","video","freeform"],
            "example": "risen"
          },
          "text": {
            "type": "string",
            "description": "The fully assembled prompt text, ready to pass to any AI model."
          },
          "topic_id": {
            "type": "string",
            "format": "uuid",
            "description": "ID of the topic this prompt belongs to."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of the last update. Use this to detect changes."
          }
        }
      },
      "ErrorUnauthorized": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "example": "unauthorized"
          }
        }
      },
      "ErrorNotFound": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "not_found"
              },
              "message": {
                "type": "string",
                "example": "Prompt not found"
              }
            }
          }
        }
      }
    }
  }
}
