{
  "openapi": "3.1.0",
  "info": {
    "title": "Planzer.io API",
    "version": "1.0.0",
    "description": "Read and create tasks in Planzer.io and get notified when tasks are created or completed. Used by the Zapier and Make integrations and available for your own scripts.\n\nAuthenticate with a personal API key: create one in Planzer under Settings → Integrations → API keys and send it as `Authorization: Bearer pk_…`. A key gives access to the tasks of the account that created it.\n\nErrors are returned as `{ \"error\": { \"status\": 400, \"message\": \"…\" } }`. Requests are limited to 120 per minute.",
    "contact": { "name": "Planzer.io support", "email": "support@planzer.io", "url": "https://planzer.io/contact" }
  },
  "servers": [ { "url": "https://api.planzer.io/v1" } ],
  "security": [ { "apiKey": [] } ],
  "tags": [
    { "name": "Account" },
    { "name": "Tasks" },
    { "name": "Projects and tags" },
    { "name": "Webhooks", "description": "Planzer POSTs `{ \"event\": \"task.created\", \"created_at\": \"…\", \"data\": <Task> }` as JSON to your https URL as soon as the event happens. Answer 410 Gone to unsubscribe. Webhooks created with a key are removed when the key is deleted." }
  ],
  "paths": {
    "/me": {
      "get": {
        "tags": [ "Account" ],
        "summary": "The account the API key belongs to",
        "operationId": "getMe",
        "responses": {
          "200": { "description": "The account", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Me" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/tasks": {
      "get": {
        "tags": [ "Tasks" ],
        "summary": "List tasks, newest first",
        "operationId": "listTasks",
        "parameters": [
          { "name": "status", "in": "query", "schema": { "type": "string", "enum": [ "open", "completed", "all" ], "default": "all" } },
          { "name": "sort", "in": "query", "description": "`created`: newest created first. `completed`: most recently completed first (completed tasks only).", "schema": { "type": "string", "enum": [ "created", "completed" ], "default": "created" } },
          { "name": "search", "in": "query", "description": "Only tasks whose title contains this text.", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 25 } }
        ],
        "responses": {
          "200": { "description": "Tasks", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } } } } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "post": {
        "tags": [ "Tasks" ],
        "summary": "Create a task",
        "operationId": "createTask",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewTask" } } } },
        "responses": {
          "201": { "description": "The created task", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "description": "The free plan's task limit is reached", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/tasks/{taskId}": {
      "get": {
        "tags": [ "Tasks" ],
        "summary": "Get a task",
        "operationId": "getTask",
        "parameters": [ { "$ref": "#/components/parameters/TaskId" } ],
        "responses": {
          "200": { "description": "The task", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/tasks/{taskId}/complete": {
      "post": {
        "tags": [ "Tasks" ],
        "summary": "Complete a task",
        "description": "Works like ticking the task off in the app: a running timer on it is stopped. Completing a completed task changes nothing.",
        "operationId": "completeTask",
        "parameters": [ { "$ref": "#/components/parameters/TaskId" } ],
        "responses": {
          "200": { "description": "The completed task", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/projects": {
      "get": {
        "tags": [ "Projects and tags" ],
        "summary": "List active projects",
        "operationId": "listProjects",
        "responses": {
          "200": { "description": "Projects", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Project" } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/tags": {
      "get": {
        "tags": [ "Projects and tags" ],
        "summary": "List tags",
        "operationId": "listTags",
        "responses": {
          "200": { "description": "Tags", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Tag" } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/webhooks": {
      "post": {
        "tags": [ "Webhooks" ],
        "summary": "Subscribe to an event",
        "description": "The target URL must be a public https address. Up to 50 webhooks per account.",
        "operationId": "createWebhook",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "required": [ "event", "target_url" ],
            "properties": {
              "event": { "type": "string", "enum": [ "task.created", "task.completed" ] },
              "target_url": { "type": "string", "format": "uri", "example": "https://hooks.example.com/planzer" }
            }
          } } }
        },
        "responses": {
          "201": { "description": "The webhook", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Webhook" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/webhooks/{webhookId}": {
      "delete": {
        "tags": [ "Webhooks" ],
        "summary": "Unsubscribe",
        "description": "Also answers 204 when the webhook is already gone.",
        "operationId": "deleteWebhook",
        "parameters": [ { "name": "webhookId", "in": "path", "required": true, "schema": { "type": "string" } } ],
        "responses": {
          "204": { "description": "Deleted" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    }
  },
  "webhooks": {
    "task.created": {
      "post": {
        "summary": "A task was created",
        "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WebhookEvent" } } } },
        "responses": { "200": { "description": "Received" }, "410": { "description": "Unsubscribe this webhook" } }
      }
    },
    "task.completed": {
      "post": {
        "summary": "A task was completed",
        "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WebhookEvent" } } } },
        "responses": { "200": { "description": "Received" }, "410": { "description": "Unsubscribe this webhook" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": { "type": "http", "scheme": "bearer", "bearerFormat": "pk_…", "description": "A personal API key from Settings → Integrations → API keys." }
    },
    "parameters": {
      "TaskId": { "name": "taskId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
    },
    "responses": {
      "BadRequest": { "description": "Invalid input", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Unauthorized": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "NotFound": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    },
    "schemas": {
      "Me": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "timezone": { "type": "string", "example": "Europe/Copenhagen" }
        }
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "title": { "type": "string" },
          "notes": { "type": "string" },
          "status": { "type": "string", "enum": [ "open", "completed" ] },
          "date": { "type": [ "string", "null" ], "format": "date", "description": "The day it's planned for; null = inbox." },
          "deadline": { "type": [ "string", "null" ], "format": "date" },
          "estimate_minutes": { "type": "integer" },
          "priority": { "type": "string", "enum": [ "none", "low", "medium", "high", "urgent" ] },
          "project": { "type": [ "object", "null" ], "properties": { "id": { "type": "string" }, "name": { "type": "string" } } },
          "tag": { "type": [ "object", "null" ], "properties": { "id": { "type": "string" }, "name": { "type": "string" } } },
          "source": { "type": "string", "description": "PLANZER, or the integration it was imported from." },
          "created_at": { "type": [ "string", "null" ], "format": "date-time" },
          "completed_at": { "type": [ "string", "null" ], "format": "date-time" },
          "url": { "type": "string", "format": "uri" }
        }
      },
      "NewTask": {
        "type": "object",
        "required": [ "title" ],
        "properties": {
          "title": { "type": "string", "maxLength": 255 },
          "notes": { "type": "string" },
          "date": { "type": "string", "description": "YYYY-MM-DD, or `today` (in the account's time zone). Leave out for the inbox." },
          "deadline": { "type": "string", "format": "date" },
          "estimate_minutes": { "type": "integer", "minimum": 0 },
          "priority": { "type": "string", "enum": [ "none", "low", "medium", "high", "urgent" ] },
          "project_id": { "type": "string" },
          "tag_id": { "type": "string" }
        }
      },
      "Project": {
        "type": "object",
        "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "color": { "type": [ "string", "null" ] }, "due_date": { "type": [ "string", "null" ], "format": "date" } }
      },
      "Tag": {
        "type": "object",
        "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "color": { "type": [ "string", "null" ] } }
      },
      "Webhook": {
        "type": "object",
        "properties": { "id": { "type": "string" }, "event": { "type": "string" }, "target_url": { "type": "string" } }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "event": { "type": "string", "enum": [ "task.created", "task.completed" ] },
          "created_at": { "type": "string", "format": "date-time" },
          "data": { "$ref": "#/components/schemas/Task" }
        }
      },
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "object", "properties": { "status": { "type": "integer" }, "message": { "type": "string" } } } }
      }
    }
  }
}
