{
  "openapi": "3.1.0",
  "info": {
    "title": "TrackInPublic API",
    "version": "1.0.0",
    "description": "Personal API of TrackInPublic, a public habit tracker. Every call is scoped to the account that owns the key. Check-ins and tasks always apply to today in the user's timezone: past days cannot be written (no backfill). Keys (tip_live_...) are created on the dashboard with a Pro plan. Docs: https://trackinpublic.app/integrations",
    "contact": {
      "name": "TrackInPublic support",
      "url": "https://trackinpublic.app/support",
      "email": "contact@trackinpublic.app"
    },
    "termsOfService": "https://trackinpublic.app/terms",
    "license": {
      "name": "TrackInPublic Terms of Service",
      "url": "https://trackinpublic.app/terms"
    },
    "x-providerName": "trackinpublic.app",
    "x-logo": {
      "url": "https://trackinpublic.app/icon-512.png",
      "altText": "TrackInPublic"
    },
    "x-privacy-policy": "https://trackinpublic.app/privacy"
  },
  "servers": [
    {
      "url": "https://trackinpublic.app/api/v1"
    }
  ],
  "externalDocs": {
    "description": "Setup recipes for ChatGPT, Claude, Grok and curl",
    "url": "https://trackinpublic.app/integrations"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Get my account",
        "description": "The authenticated user: name, handle (slug), timezone, plan and public page URL.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/today": {
      "get": {
        "operationId": "getToday",
        "summary": "Get today's list",
        "description": "Today's habits and one-off tasks with what is done, the streak of each habit, whether the user committed in public this morning, and the recap hour. Call this first to learn exact names and ids.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Today"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/today/commit": {
      "post": {
        "operationId": "commitToday",
        "summary": "Commit to today's list in public",
        "description": "Publishes today's day page. If the user turned auto-posting on, @trackinpublic posts the list and tags them. Idempotent. Only call when the user asks to commit.",
        "x-openai-isConsequential": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "committedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/habits": {
      "get": {
        "operationId": "listHabits",
        "summary": "List my habits",
        "description": "All habits with current streak, best streak, total check-ins, visibility, and whether each is checked today.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "habits": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Habit"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createHabit",
        "summary": "Create a habit",
        "description": "Creates a daily habit. Public by default. Names are unique per account (case-insensitive), 60 characters max.",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "e.g. Gym, Read 20 pages"
                  },
                  "isPublic": {
                    "type": "boolean",
                    "description": "false keeps it private (off the public page). Default true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "isPublic": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Habit limit of the plan reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A habit with that name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/habits/{id}": {
      "patch": {
        "operationId": "updateHabit",
        "summary": "Rename or show/hide a habit",
        "description": "Rename a habit and/or switch it between public and private. Its history is kept.",
        "x-openai-isConsequential": false,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The habit id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "isPublic": {
                    "type": "boolean",
                    "description": "false keeps it private (off the public page). Default true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "isPublic": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A habit with that name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteHabit",
        "summary": "Delete a habit and its history",
        "description": "Deletes the habit and every check-in it ever had. Cannot be undone. Only call after the user explicitly confirms.",
        "x-openai-isConsequential": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The habit id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/checkins": {
      "get": {
        "operationId": "listCheckins",
        "summary": "List my check-ins",
        "description": "Every check-in of the account as habitId + day (YYYY-MM-DD), plus today's date in the user's timezone.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "today": {
                      "type": "string",
                      "description": "YYYY-MM-DD in the user's timezone"
                    },
                    "checkins": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "habitId": {
                            "type": "string"
                          },
                          "day": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "checkIn",
        "summary": "Check a habit in for today",
        "description": "Marks a habit done for today in the user's timezone (checked false undoes today's check-in). Past days are never writable. Pass habitId, or habit with the exact name.",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "habitId": {
                    "type": "string",
                    "description": "Habit id (preferred)"
                  },
                  "habit": {
                    "type": "string",
                    "description": "Exact habit name, case-insensitive, if no id"
                  },
                  "checked": {
                    "type": "boolean",
                    "description": "false to undo today's check-in. Default true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "habitId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "day": {
                      "type": "string"
                    },
                    "checked": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tasks": {
      "get": {
        "operationId": "listTasks",
        "summary": "List today's tasks",
        "description": "The one-off tasks on today's list. Tasks belong to the day they were added; past days are closed.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tasks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Task"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "addTask",
        "summary": "Add a task to today",
        "description": "Adds a one-off task to today's list (20 a day at most). Public by default: it shows on the day page and in the recap.",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "isPublic": {
                    "type": "boolean",
                    "description": "false keeps it private (off the public page). Default true."
                  },
                  "projectId": {
                    "type": "string",
                    "description": "Optional project id to file the task under"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Daily task limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tasks/{id}": {
      "patch": {
        "operationId": "updateTask",
        "summary": "Tick or edit a task",
        "description": "Mark one of today's tasks done (done true) or not, rename it, or switch its visibility. Tasks from past days are closed (409).",
        "x-openai-isConsequential": false,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The task id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "done": {
                    "type": "boolean"
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "isPublic": {
                    "type": "boolean",
                    "description": "false keeps it private (off the public page). Default true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "That day is closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTask",
        "summary": "Remove a task from today",
        "description": "Removes one of today's tasks. Tasks from past days are closed (409).",
        "x-openai-isConsequential": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The task id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "That day is closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects": {
      "get": {
        "operationId": "listProjects",
        "summary": "List my projects",
        "description": "Projects group tasks on the profile, like repositories. Returns id, name, description and visibility.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "projects": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Project"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createProject",
        "summary": "Create a project",
        "description": "Creates a project (20 at most). Public by default.",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "isPublic": {
                    "type": "boolean",
                    "description": "false keeps it private (off the public page). Default true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Project limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{id}": {
      "patch": {
        "operationId": "updateProject",
        "summary": "Edit a project",
        "description": "Rename a project, change its description, or switch its visibility.",
        "x-openai-isConsequential": false,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The project id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "isPublic": {
                    "type": "boolean",
                    "description": "false keeps it private (off the public page). Default true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteProject",
        "summary": "Delete a project",
        "description": "Deletes a project. Its tasks stay, without a project.",
        "x-openai-isConsequential": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The project id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/profile": {
      "get": {
        "operationId": "getProfile",
        "summary": "Get my public profile",
        "description": "The profile as visitors see it: pinned cards, 53-week activity graph, this month, counts, plus links to the page and the year story image.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateProfile",
        "summary": "Edit my profile",
        "description": "Change display name, handle (changes the public URL), bio, location, pinned card ids, or whether private check-ins light the graph (names never shown).",
        "x-openai-isConsequential": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "handle": {
                    "type": "string",
                    "description": "New handle: the page moves to trackinpublic.app/<handle>"
                  },
                  "bio": {
                    "type": "string",
                    "maxLength": 160
                  },
                  "location": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "showPrivate": {
                    "type": "boolean"
                  },
                  "pinned": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 6,
                    "description": "Habit or project ids to pin, or \"private\" for the private-work card"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "slug": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Handle taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/me/social": {
      "get": {
        "operationId": "getSocial",
        "summary": "Get my social settings",
        "description": "Handles to be tagged on each network, favorite network, auto-post consent and recap hour.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Social"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateSocial",
        "summary": "Edit my social settings",
        "description": "Set handles, favorite network, recap hour (12-23) or auto-posting consent. Turning autoPost on lets @trackinpublic post the user's day and tag them: ask first.",
        "x-openai-isConsequential": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "x": {
                    "type": "string"
                  },
                  "instagram": {
                    "type": "string"
                  },
                  "threads": {
                    "type": "string"
                  },
                  "bluesky": {
                    "type": "string"
                  },
                  "linkedin": {
                    "type": "string"
                  },
                  "tiktok": {
                    "type": "string"
                  },
                  "favorite": {
                    "type": "string",
                    "enum": [
                      "",
                      "instagram",
                      "x",
                      "tiktok",
                      "threads",
                      "bluesky",
                      "linkedin"
                    ]
                  },
                  "autoPost": {
                    "type": "boolean"
                  },
                  "recapHour": {
                    "type": "integer",
                    "minimum": 12,
                    "maximum": 23
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Social"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/leaderboard": {
      "get": {
        "operationId": "getLeaderboard",
        "summary": "Public leaderboard",
        "description": "Public ranking of people by their longest live streak on public habits (top 100). No key needed.",
        "security": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LeaderboardRow"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Personal key tip_live_... from the dashboard (Pro). The X-API-Key header is accepted too. (OAuth 2.1 access tokens are for the MCP endpoint, https://trackinpublic.app/api/mcp, not for this REST API.)"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string",
            "description": "Handle: the page is trackinpublic.app/<slug>"
          },
          "tz": {
            "type": "string",
            "description": "IANA timezone, decides when a day closes"
          },
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "pro"
            ]
          },
          "billing": {
            "type": "object",
            "additionalProperties": true
          },
          "page": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Habit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isPublic": {
            "type": "boolean"
          },
          "streak": {
            "type": "integer",
            "description": "Current streak in days"
          },
          "best": {
            "type": "integer",
            "description": "Best streak in days"
          },
          "checkedToday": {
            "type": "boolean"
          },
          "totalCheckins": {
            "type": "integer"
          }
        }
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "isPublic": {
            "type": "boolean"
          },
          "done": {
            "type": "boolean"
          },
          "day": {
            "type": "string",
            "description": "YYYY-MM-DD"
          },
          "projectId": {
            "type": "string",
            "description": "Project id, or null"
          }
        }
      },
      "Project": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "isPublic": {
            "type": "boolean"
          }
        }
      },
      "TodayItem": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "habit",
              "task"
            ]
          },
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "isPublic": {
            "type": "boolean"
          },
          "done": {
            "type": "boolean"
          },
          "streak": {
            "type": "integer",
            "description": "Habits only"
          },
          "projectId": {
            "type": "string",
            "description": "Tasks only, or null"
          }
        }
      },
      "Today": {
        "type": "object",
        "properties": {
          "day": {
            "type": "string",
            "description": "YYYY-MM-DD in the user's timezone"
          },
          "dayNumber": {
            "type": "integer",
            "description": "Days since signup, signup day = 1"
          },
          "tz": {
            "type": "string"
          },
          "msToMidnight": {
            "type": "integer",
            "description": "Milliseconds until the day closes"
          },
          "committedAt": {
            "type": "string",
            "description": "When the user committed today, or null"
          },
          "recapHour": {
            "type": "integer"
          },
          "recapPublishedAt": {
            "type": "string",
            "description": "When the evening recap was published, or null"
          },
          "autoPost": {
            "type": "boolean"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TodayItem"
            }
          },
          "done": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Public page, day page and share card URLs"
          },
          "postingTo": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Networks where @trackinpublic will post this day"
          },
          "favorite": {
            "type": "string"
          }
        }
      },
      "Social": {
        "type": "object",
        "properties": {
          "x": {
            "type": "string"
          },
          "instagram": {
            "type": "string"
          },
          "threads": {
            "type": "string"
          },
          "bluesky": {
            "type": "string"
          },
          "linkedin": {
            "type": "string"
          },
          "tiktok": {
            "type": "string"
          },
          "favorite": {
            "type": "string"
          },
          "autoPost": {
            "type": "boolean"
          },
          "recapHour": {
            "type": "integer"
          }
        }
      },
      "LeaderboardRow": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "streak": {
            "type": "integer"
          },
          "best": {
            "type": "integer"
          },
          "totalCheckins": {
            "type": "integer"
          },
          "habitCount": {
            "type": "integer"
          },
          "checkedToday": {
            "type": "integer"
          },
          "topHabit": {
            "type": "string"
          }
        }
      }
    }
  }
}