{
  "openapi": "3.0.3",
  "info": {
    "title": "TaskInSync Public API",
    "version": "1.0.0",
    "description": "Scoped-key REST API for TaskInSync. Authenticate with an API key from the app (Settings → API keys) sent as the `x-api-key` header. Read scope covers GETs; write scope is required for POST/PATCH/DELETE. A GraphQL endpoint (`POST /api/graphql`, JWT auth) exposes the same data — see /developers."
  },
  "servers": [{ "url": "https://tasknest-production-8f56.up.railway.app/api/v1" }],
  "components": {
    "securitySchemes": {
      "ApiKey": { "type": "apiKey", "in": "header", "name": "x-api-key" }
    },
    "schemas": {
      "Task": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "status": { "type": "string", "example": "In Progress" },
          "priority": { "type": "string", "enum": ["Low", "Medium", "High", "Critical"] },
          "tags": { "type": "array", "items": { "type": "string" } },
          "dueDate": { "type": "string", "format": "date-time", "nullable": true },
          "storyPoints": { "type": "number" }
        }
      },
      "Project": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "type": { "type": "string", "enum": ["simple", "agile"] },
          "taskCount": { "type": "integer" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean", "example": false },
          "error": { "type": "object", "properties": { "message": { "type": "string" }, "code": { "type": "string" } } }
        }
      }
    }
  },
  "security": [{ "ApiKey": [] }],
  "paths": {
    "/projects": {
      "get": {
        "summary": "List your projects",
        "responses": { "200": { "description": "Array of projects", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Project" } } } } } }
      }
    },
    "/projects/{id}": {
      "get": {
        "summary": "Get one project",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Project" }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }
      }
    },
    "/projects/{id}/tasks": {
      "get": {
        "summary": "List a project's tasks",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Array of tasks", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } } } } } }
      },
      "post": {
        "summary": "Create a task (write scope)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["title"], "properties": { "title": { "type": "string" }, "priority": { "type": "string" }, "status": { "type": "string" }, "tags": { "type": "array", "items": { "type": "string" } }, "dueDate": { "type": "string", "format": "date-time" } } } } } },
        "responses": { "201": { "description": "Created task" }, "403": { "description": "Read-scope key on a write endpoint" } }
      }
    },
    "/projects/{id}/tasks/{taskId}": {
      "get": {
        "summary": "Get one task",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "taskId", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Task" }, "404": { "description": "Not found" } }
      },
      "patch": {
        "summary": "Update task fields (write scope)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "taskId", "in": "path", "required": true, "schema": { "type": "string" } }],
        "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } },
        "responses": { "200": { "description": "Updated task" } }
      },
      "delete": {
        "summary": "Delete a task (write scope)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "taskId", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Deleted" } }
      }
    },
    "/projects/{id}/tasks/{taskId}/status": {
      "patch": {
        "summary": "Move a task to a status (write scope — workflow rules apply)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "taskId", "in": "path", "required": true, "schema": { "type": "string" } }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["status"], "properties": { "status": { "type": "string", "example": "Completed" } } } } } },
        "responses": { "200": { "description": "Task with the new status" }, "409": { "description": "Blocked by workflow rules" } }
      }
    }
  }
}
