{
  "openapi": "3.0.3",
  "info": {
    "title": "Cockpilot API",
    "version": "1.9.0",
    "description": "Cockpilot (https://cockpilot.si) is a shared management tool for agencies and teams: tasks, projects, contacts and KPIs, driven from the app, the phone or an AI assistant. Every workspace has its own address, https://<team>.cockpilot.si, and serves this API under /api/ and the MCP server at /mcp.\n\nAuthentication: a personal token (ck_...) or an OAuth access token, in Authorization: Bearer. A read-only token is refused on every write (403 droits_insuffisants).\n\nIdentifiers, field names, enum values and error codes are in French (titre, echeance, a_faire...): they are stable machine names. Errors are JSON: { erreur, code, champ, recu, attendu, indice }, and a refused request changes nothing.\n\nFull reference: https://cockpilot.si/docs/. MCP server for AI assistants: https://mcp.cockpilot.si/mcp.",
    "termsOfService": "https://cockpilot.si/terms/",
    "contact": {
      "name": "Cockpilot support",
      "email": "contact@cockpilot.si",
      "url": "https://cockpilot.si/support/"
    },
    "license": {
      "name": "Proprietary: Cockpilot terms of service",
      "url": "https://cockpilot.si/terms/"
    },
    "x-logo": {
      "url": "https://cockpilot.si/icon-512.png",
      "altText": "Cockpilot"
    }
  },
  "externalDocs": {
    "description": "API and MCP reference",
    "url": "https://cockpilot.si/docs/"
  },
  "servers": [
    {
      "url": "https://{team}.cockpilot.si",
      "description": "Your Cockpilot workspace",
      "variables": {
        "team": {
          "default": "directory-review",
          "description": "Your workspace address, the part before .cockpilot.si."
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Discovery",
      "description": "Who is calling, the accepted values, and the health of the workspace."
    },
    {
      "name": "Read",
      "description": "The briefing, tasks, projects, contacts, KPIs, the activity log and the live change stream."
    },
    {
      "name": "Tasks",
      "description": "Create, update, complete, reopen, reorder and delete tasks."
    },
    {
      "name": "Projects",
      "description": "Create, update, reorder and delete projects (spaces)."
    },
    {
      "name": "Contacts",
      "description": "Create, update and delete contacts: clients, prospects, partners."
    },
    {
      "name": "Maintenance",
      "description": "Trash, restore, clean-up and import."
    },
    {
      "name": "MCP",
      "description": "The MCP server for AI assistants, on the same address."
    },
    {
      "name": "Pages, metrics and automations",
      "description": "Pages, metric series, totals, data sources and triggers."
    }
  ],
  "paths": {
    "/api/sante": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "Health check",
        "operationId": "getSante",
        "description": "Auth: None for the reduced answer; any identity for the full one. The only /api/ route that answers an unidentified caller (except while equipe.json is invalid: 503).\n\nAPI.md:180 still shows \"version\": 2 for the reduced answer; the code returns VERSION_SCHEMA, which is 3 (index.js:161, index.js:3119). revision is the cheapest change detector: poll it, then fetch GET /api/etat?depuis=... (API.md:1576-1581).\n\nExample: GET https://app.cockpilot.si/api/sante (no credentials) -> 200 {\"ok\":true,\"version\":3}",
        "responses": {
          "200": {
            "description": "Unidentified: { ok: true, version: 3 }. Identified: { ok, taches, projets, contacts (counts), revision (increments on every write), version (data format, 3), jour (YYYY-MM-DD), git: {...}, journal: { ok, lignesEcrites, lignesPerdues, dernierEchec }, bdd: {...} (database mode only), equipe: { exposition, hotes, ports: { local, serve }, personnes, jetons, jetonsOrphelins, jetonsInvalides? } and anomalies: { responsablesInconnus: [ { personne, taches } ] } (team mode), comptes: { comptes, avecDeuxFacteurs, invitations, sessions } (public exposure; numbers only) }.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "503 equipe_invalide (equipe.json invalid: all of Cockpit is paused)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/moi": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "Who is calling: person, rights, team",
        "operationId": "getMoi",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed. An unidentified caller receives the identity refusal itself (401 identite_requise...).\n\nExample: GET /api/moi with Authorization: Bearer <token of claude-robin> -> 200 { \"mode\": \"equipe\", \"personne\": { \"id\": \"robin\", ... }, \"via\": \"jeton:claude-robin\", ... }",
        "responses": {
          "200": {
            "description": "Team mode: { mode: \"equipe\", personne: { id, nom, initiale } | null, via, admin, droits, exposition }. via: \"jeton:<token id>\" (personal token), \"session\" (browser account), \"service\" (service token), \"local\", \"tailscale\". Solo mode: { mode: \"solo\", personne: null, via: \"solo\", admin: true, droits: \"ecriture\", exposition: null }.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "401 identite_requise (with connexion: \"/connexion\" in public exposure); 401 jeton_invalide; 401 jeton_orphelin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/vocabulaire": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "Accepted values for every field",
        "operationId": "getVocabulaire",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/vocabulaire -> 200 { \"statuts\": [\"a_faire\",\"en_cours\",\"en_attente\",\"fait\"], \"priorites\": [\"basse\",\"moyenne\",\"haute\",null], \"etatsProjet\": [\"actif\",\"veille\",\"termine\",\"archive\"], ... }",
        "responses": {
          "200": {
            "description": "The whole vocabulary, recited from the code: { statuts, priorites, etatsProjet, unitesRecurrence, champsTache, champsDuServeur, champsDeModification, champsProjet, champsDeModificationProjet, champsDuServeurProjet, typesContact, champsContact, champsDeModificationContact, champsDuServeurContact, filtresTaches, filtresContacts, trisContacts, relances, filtresJournal, actionsJournal, periodesKpi, filtresKpi, tris, couleurs, conventions: { ...French prose rules }, saisieRapide: { exemple, jetons: { ... } }, personnes?: [ { id, nom, initiale } ] (team mode) }. The &nom quick-add token is listed only in team mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/resume": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Daily briefing",
        "operationId": "getResume",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/resume?pour=moi (as Flo) -> 200 { \"jour\": \"2026-09-23\", \"revision\": 7, \"pour\": \"flo\", \"compte\": { \"ouvertes\": 1, ..., \"aAttribuer\": 3 }, \"maJournee\": [ { \"id\": \"5effad242245\", \"titre\": \"Payer OVH\", ..., \"focus\": true, \"responsable\": \"flo\" } ], ... }",
        "parameters": [
          {
            "name": "pour",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Whose briefing. Absent: all tasks (historic shape, no pour/aAttribuer keys). A person: only tasks whose responsable is that person, plus aAttribuer (everyone's unassigned, open, awake tasks). equipe: all tasks plus aAttribuer. In solo mode only equipe is accepted. Values: moi | <person id> | equipe."
          }
        ],
        "responses": {
          "200": {
            "description": "{ jour, revision, pour?, compte: { ouvertes, enRetard, echeanceAujourdhui, maJournee, enCours, enAttente, endormies, sansProjet, faitesAujourdhui, projetsActifs, aAttribuer? }, maJournee, enRetard, echeanceAujourdhui, enCours, enAttente, aAttribuer?, prochainesActions: [ { projet, projetId, tache: <compact task> | null } ] (active projects, by ordre), projetsSansProchaineAction: [ { id, nom } ], compteCommercial: { relances, relancesEnRetard, projetsEcheanceProche, projetsEnRetard }, relances: [compact contact] (follow-up date today or past, oldest first), projetsEcheanceProche: [compact project] (actif or veille, due within 7 days or overdue) }. Task lists are compact tasks sorted by ordre; sleeping tasks are excluded from enRetard, echeanceAujourdhui, maJournee, enCours.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (any parameter other than pour); 400 personne_inconnue (with choix); 400 personne_requise (pour=moi with the service token)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/taches": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "List and search tasks",
        "operationId": "getTaches",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nURL booleans accept 1, oui, vrai, true, on and 0, non, faux, false, off (index.js:1736-1741). In JSON bodies, booleans must be real true/false.\n\nExample: GET /api/taches?projet=boutique&ouvertes=oui&tri=echeance&forme=compacte ; GET /api/taches?en_retard=oui&forme=compacte ; GET /api/taches?q=facture&endormies=exclure",
        "parameters": [
          {
            "name": "projet",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One project (name matched ignoring case and accents) or tasks without project. Unknown name: 400 projet_introuvable with choix. Values: <id> | <name> | aucun | null."
          },
          {
            "name": "statut",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Status filter. Values: a_faire,en_cours,en_attente,fait (comma-separated)."
          },
          {
            "name": "priorite",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Priority filter. Values: basse,moyenne,haute,null (comma-separated)."
          },
          {
            "name": "ouvertes",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "oui: everything except fait."
          },
          {
            "name": "focus",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Starred (in the day) or not."
          },
          {
            "name": "en_retard",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Due date passed and not done."
          },
          {
            "name": "sans_echeance",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "No due date."
          },
          {
            "name": "echeance_avant",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Due on or before (inclusive); tasks without due date excluded."
          },
          {
            "name": "echeance_apres",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Due on or after (inclusive); tasks without due date excluded."
          },
          {
            "name": "endormies",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Sleeping tasks (reveil in the future, not en_attente) are included by default; exclure reproduces what the screen shows. Values: inclure (default) | exclure | seules."
          },
          {
            "name": "etiquette",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One tag (normalized before comparison)."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Free text in title, notes, tags and project name, accent-insensitive."
          },
          {
            "name": "depuis",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only tasks modified after it (maj > depuis)."
          },
          {
            "name": "responsable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Tasks of that person, or unassigned tasks. In solo mode only aucun. Values: moi | <person id> | aucun."
          },
          {
            "name": "tri",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Sort order. Values: ordre (default) | echeance | priorite | maj | cree | titre."
          },
          {
            "name": "limite",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "default": 200
            },
            "description": "1 to 1000."
          },
          {
            "name": "decalage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "default": 0
            },
            "description": "Offset."
          },
          {
            "name": "forme",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Compact tasks (9 fields, 10 in team mode with responsable) instead of full objects. Values: compacte."
          }
        ],
        "responses": {
          "200": {
            "description": "{ total, limite, decalage, tronquee, revision, taches: [task | compact task] }. tronquee says more results remain.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (unknown filter, unknown value, non-boolean, malformed date, unknown tri), with champ, recu, attendu; 400 projet_introuvable (with choix); 400 personne_inconnue (with choix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Create one or more tasks",
        "operationId": "postTaches",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: curl -X POST https://app.cockpilot.si/api/taches -H \"Authorization: Bearer ck_...\" -H \"Content-Type: application/json\" -d '{\"saisie\":\"Relancer le graphiste !haute\",\"echeance\":\"2026-12-01\",\"focus\":true,\"duree\":30,\"notes\":\"voir le devis\"}' -> 201 { \"titre\": \"Relancer le graphiste\", \"priorite\": \"haute\", \"echeance\": \"2026-12-01\", \"focus\": true, \"duree\": 30, \"notes\": \"voir le devis\", ... }   (body and asserted values from tests/ecritures.js:302-307)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "saisie": {
                    "type": "string",
                    "description": "Quick-add line (see quick_add_syntax). Optional if titre is given."
                  },
                  "strict": {
                    "type": "boolean",
                    "description": "true: an unknown @project is refused (400 projet_introuvable with choix) instead of being created.",
                    "default": false
                  },
                  "titre": {
                    "type": "string",
                    "description": "Title (required if saisie gives none)."
                  },
                  "projet": {
                    "type": "string",
                    "nullable": true,
                    "description": "Project by name or id (alternative to projetId). Unknown: 400 { erreur, choix } without code."
                  },
                  "projetId": {
                    "type": "string",
                    "nullable": true,
                    "description": "Project."
                  },
                  "statut": {
                    "description": "Status (default a_faire)."
                  },
                  "priorite": {
                    "description": "Priority."
                  },
                  "echeance": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Due date imposed from outside (an invoice, a follow-up): the only thing that makes a task overdue."
                  },
                  "reveil": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Wake date: before it, the task sleeps (hidden from day/week views, still visible on its project, never a next action), unless it is en_attente."
                  },
                  "focus": {
                    "type": "boolean",
                    "description": "\"I am doing it today\" (the star, \"ma journée\"). Reset to false for undone tasks at the first request of each new day. Team mode: only the responsable can star; starring an unassigned task assigns it to the actor (attribueeA); reassigning a starred task removes the star (focusRetire)."
                  },
                  "duree": {
                    "description": "Estimated duration in minutes (used by KPI workload)."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tags."
                  },
                  "attenteDe": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who we are waiting on."
                  },
                  "recurrence": {
                    "description": "Repetition. Completing the task creates the next occurrence immediately (same responsable, created by whoever completed it)."
                  },
                  "sousTaches": {
                    "description": "Subtasks (REST only)."
                  },
                  "ordre": {
                    "type": "number",
                    "description": "Manual order (lower first); the project's next action is its first actionable task by ordre."
                  },
                  "responsable": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who does the task. Absent at creation = the creator (null for the service token)."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Free notes. PATCH noteAjout (REST) or cockpit_noter (MCP) appends signed, dated lines."
                  },
                  "id": {
                    "type": "string",
                    "description": "Optional client-chosen id (1-40 chars [A-Za-z0-9_-]); if it exists, nothing is created and the existing task is returned with deja: true (safe replay)."
                  },
                  "client": {
                    "type": "string",
                    "description": "Optional client/tab identifier echoed as origine in /api/flux events."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Single: 201 <task> (+ projetCree: { id, nom } when an @name created a project); 200 { ...<existing task>, deja: true } on replay. Array: 201 { creees, taches, deja: [replayed ids] }, or 200 { creees: 0, taches: [], deja } when everything was a replay. Without responsable, the task goes to the creator (null for the service token or in solo mode).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 titre_vide; 400 conflit_saisie (champ, dansLaSaisie, dansLeChamp); 400 projet_introuvable (strict: jeton, choix); 400 parametre_invalide (bad value or unknown field; also impossible date read from the line, indice \"valeur lue dans la saisie rapide\"; strict not boolean; array element neither string nor object; more than 200 elements); 400 champ_de_service (cree, maj, faitLe, projetIdAvant, suivanteId, creePar, creeVia, majPar, faitPar); 400 id_invalide, 400 id_en_double, 400 liste_vide; 400 personne_inconnue (jeton, choix), 400 plusieurs_responsables, 400 personne_requise; 409 tache_d_un_autre (focus: true on a task assigned to someone else)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/taches/{id}": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Read a task",
        "operationId": "getTachesId",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/taches/5effad242245 -> 200 { \"id\": \"5effad242245\", \"titre\": \"Payer OVH\", ... }",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Task identifier ([A-Za-z0-9_-])."
          }
        ],
        "responses": {
          "200": {
            "description": "The full task object (see task_fields).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 { erreur: \"aucune tâche d'identifiant « <id> »\" } (no code field; distinct from 404 route_inconnue)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "Update a task",
        "operationId": "patchTachesId",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: PATCH /api/taches/<id> { \"priorite\": \"haute\", \"siMaj\": \"<outdated maj>\" } -> 409 { \"erreur\": \"cette tâche a été modifiée depuis que vous l'avez lue\", \"code\": \"conflit\", \"champ\": \"siMaj\", \"recu\": \"<outdated maj>\", \"par\": \"<majPar>\", \"actuelle\": { ...the task as it is now... }, \"indice\": \"rien n'a été écrit. Relisez la tâche dans actuelle, puis renvoyez votre modification avec son maj dans siMaj\" }   (strings from index.js:3571-3581; flow exercised by tests/mcp.js:361-363)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "titre": {
                    "type": "string",
                    "description": "Title."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Free notes. PATCH noteAjout (REST) or cockpit_noter (MCP) appends signed, dated lines."
                  },
                  "projetId": {
                    "type": "string",
                    "nullable": true,
                    "description": "Project."
                  },
                  "projet": {
                    "description": "Given fields replace the old ones (sousTaches and tags are replaced whole). statut fait sets faitLe/faitPar; leaving fait clears them."
                  },
                  "statut": {
                    "description": "Status (default a_faire)."
                  },
                  "priorite": {
                    "description": "Priority."
                  },
                  "echeance": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Due date imposed from outside (an invoice, a follow-up): the only thing that makes a task overdue."
                  },
                  "reveil": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Wake date: before it, the task sleeps (hidden from day/week views, still visible on its project, never a next action), unless it is en_attente."
                  },
                  "focus": {
                    "type": "boolean",
                    "description": "\"I am doing it today\" (the star, \"ma journée\"). Reset to false for undone tasks at the first request of each new day. Team mode: only the responsable can star; starring an unassigned task assigns it to the actor (attribueeA); reassigning a starred task removes the star (focusRetire)."
                  },
                  "duree": {
                    "description": "Estimated duration in minutes (used by KPI workload)."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tags."
                  },
                  "attenteDe": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who we are waiting on."
                  },
                  "recurrence": {
                    "description": "Repetition. Completing the task creates the next occurrence immediately (same responsable, created by whoever completed it)."
                  },
                  "sousTaches": {
                    "description": "Subtasks (REST only)."
                  },
                  "ordre": {
                    "type": "number",
                    "description": "Manual order (lower first); the project's next action is its first actionable task by ordre."
                  },
                  "responsable": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who does the task. Absent at creation = the creator (null for the service token)."
                  },
                  "noteAjout": {
                    "type": "string",
                    "description": "Appends \"[DD/MM HH:MM <Name> via <via>] text\" at the end of the notes (trimmed; empty refused; notes must stay within 20000 chars). Cannot be combined with notes."
                  },
                  "siMaj": {
                    "type": "string",
                    "description": "Precondition: the task maj as read. If it changed: 409 conflit with actuelle and par; nothing written."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 <task> (+ attribueeA: <person> when starring an unassigned task took it; + focusRetire: true when reassigning removed the star).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (unknown field, bad value, notes + noteAjout, notes too long); 400 { erreur, choix } unknown projet (no code); 409 conflit (champ siMaj, recu, par, actuelle); 409 tache_d_un_autre; 400 personne_requise; 404 unknown task",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tasks"
        ],
        "summary": "Move a task to the trash",
        "operationId": "deleteTachesId",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: DELETE /api/taches/5effad242245 -> 200 { \"supprime\": \"5effad242245\" }",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "200 { supprime: <id> }. The task goes to the trash (restorable for 30 days).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 unknown task",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/projets": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "List projects",
        "operationId": "getProjets",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/projets?etat=actif -> 200 { \"total\": 1, \"filtre\": \"actif\", \"projets\": [ { \"id\": \"29eb5031d2ac\", \"nom\": \"Site Ferrand\", \"couleur\": \"#0ea5e9\", \"etat\": \"actif\", \"clientId\": \"8b2a1bac1384\", \"responsable\": null, \"echeance\": \"2026-10-16\", \"budget\": 12500, ..., \"ouvertes\": 1, \"faites\": 0, \"prochaineAction\": { \"id\": \"671ccd5f37e8\", \"titre\": \"Maquette\", ... }, \"client\": { \"id\": \"8b2a1bac1384\", \"nom\": \"Lucas Martin\", \"entreprise\": \"Domaine Ferrand\" }, \"tachesEnRetard\": 0, \"avancement\": 0, \"joursRestants\": 9, \"risque\": \"a_risque\" } ] }",
        "parameters": [
          {
            "name": "etat",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "State filter; by default every project, archived included. Values: tous (default) | actif | veille | termine | archive."
          }
        ],
        "responses": {
          "200": {
            "description": "{ total, filtre, projets: [enriched project] } sorted by ordre (see project_fields: ouvertes, faites, prochaineAction, client, tachesEnRetard, avancement, joursRestants, risque).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (any other parameter, or an unknown etat)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Projects"
        ],
        "summary": "Create a project",
        "operationId": "postProjets",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/projets { \"nom\": \"Site Ferrand\", \"contact\": \"Domaine Ferrand\", \"echeance\": \"2026-10-12\", \"budget\": 12500.456, \"note\": \"Refonte\" } -> 201 { \"clientId\": \"<Lucas Martin id>\", \"budget\": 12500.46, \"termineLe\": null, ... }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nom": {
                    "type": "string",
                    "description": "Name (trimmed, 60 chars max)."
                  },
                  "couleur": {
                    "type": "string",
                    "description": "#rrggbb (default: taken from a palette)."
                  },
                  "etat": {
                    "type": "string",
                    "description": "Created termine: termineLe set now. Values: actif | veille | termine | archive.",
                    "default": "actif"
                  },
                  "contact": {
                    "type": "string",
                    "nullable": true,
                    "description": "Client by contact name, company, email, id or unique words (resolved to clientId). Cannot be combined with clientId."
                  },
                  "clientId": {
                    "type": "string",
                    "nullable": true,
                    "description": "Client contact id."
                  },
                  "responsable": {
                    "type": "string",
                    "nullable": true,
                    "description": "moi, a person id, or null (default null)."
                  },
                  "echeance": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Promised delivery date."
                  },
                  "budget": {
                    "type": "number",
                    "nullable": true,
                    "description": "Euros excluding tax, 0 to 1 000 000 000, rounded to the cent."
                  },
                  "lien": {
                    "type": "string",
                    "description": "http(s) URL or empty, 500 chars max."
                  },
                  "dossier": {
                    "type": "string",
                    "description": "Local folder path, 500 chars max."
                  },
                  "note": {
                    "type": "string",
                    "description": "20000 chars max."
                  },
                  "ordre": {
                    "type": "number",
                    "description": "Display order."
                  },
                  "strict": {
                    "type": "boolean",
                    "description": "true: a taken name is 409 nom_deja_pris instead of returning the existing project."
                  },
                  "id": {
                    "type": "string",
                    "description": "Optional client id; an existing id is a replay (200 deja: true)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201 <project>. A name already taken (compared ignoring case/accents/punctuation): 200 { ...<existing enriched project>, deja: true } and nothing is changed; with strict: 409 nom_deja_pris { projet }.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 { erreur: \"nom vide\" } (no code); 400 champ_de_service (termineLe); 400 contact_introuvable / contact_ambigu (choix); 400 parametre_invalide; 400 id_invalide; 409 nom_deja_pris",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/projets/{idOuNom}": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Read a project",
        "operationId": "getProjetsIdOuNom",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/projets/boutique",
        "parameters": [
          {
            "name": "idOuNom",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Project identifier or name (URL-encoded; matched ignoring case, accents and punctuation: \"cockpit\" finds \"Cockpit\", \"energie\" finds \"Énergie\")."
          }
        ],
        "responses": {
          "200": {
            "description": "The enriched project plus taches: all its tasks (full objects) sorted by ordre.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 { erreur, choix } when the name is unknown or ambiguous: choix lists non-archived projects { id, nom } (no code field)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Projects"
        ],
        "summary": "Update a project",
        "operationId": "patchProjetsIdOuNom",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: PATCH /api/projets/Site%20Ferrand { \"contact\": \"Domaine Ferrand\", \"echeance\": \"2026-10-16\", \"budget\": 12500 } -> 200 { \"id\": \"29eb5031d2ac\", \"nom\": \"Site Ferrand\", \"etat\": \"actif\", \"clientId\": \"8b2a1bac1384\", \"echeance\": \"2026-10-16\", \"budget\": 12500, ... }",
        "parameters": [
          {
            "name": "idOuNom",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier or the name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nom": {
                    "type": "string",
                    "description": "Name; a project can be designated by its name wherever an id is expected."
                  },
                  "couleur": {
                    "type": "string",
                    "description": "Display colour (defaults from a palette)."
                  },
                  "etat": {
                    "description": "State (default actif)."
                  },
                  "contact": {
                    "description": "Given fields replace the old ones. etat termine sets termineLe (from actif/veille); back to actif/veille clears it; archiving keeps it."
                  },
                  "clientId": {
                    "type": "string",
                    "nullable": true,
                    "description": "The client contact."
                  },
                  "responsable": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who owns the project (default null)."
                  },
                  "echeance": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Promised delivery date; the only date that makes a project late."
                  },
                  "budget": {
                    "type": "number",
                    "nullable": true,
                    "description": "Budget in euros excluding tax (hors taxes)."
                  },
                  "lien": {
                    "type": "string",
                    "description": "Production website URL."
                  },
                  "dossier": {
                    "type": "string",
                    "description": "Local folder path."
                  },
                  "note": {
                    "type": "string",
                    "description": "Free context; noteAjout appends signed lines."
                  },
                  "ordre": {
                    "type": "number",
                    "description": "Display order."
                  },
                  "noteAjout": {
                    "type": "string",
                    "description": "Appends a signed, dated line to the note (not combinable with note)."
                  },
                  "siMaj": {
                    "type": "string",
                    "description": "Precondition: 409 conflit with actuel if the project changed since read."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 <project> (not enriched). The journal records projet_terminer when it enters termine.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 champ_de_service (termineLe); 400 contact_introuvable / contact_ambigu; 400 parametre_invalide; 409 conflit (actuel); 404 { erreur, choix } unknown project (no code)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Projects"
        ],
        "summary": "Move a project to the trash",
        "operationId": "deleteProjetsIdOuNom",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: DELETE /api/projets/boutique { \"force\": true }",
        "parameters": [
          {
            "name": "idOuNom",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier or the name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "force": {
                    "type": "boolean",
                    "description": "true: delete even with open tasks (they are detached, not deleted, and come back if the project is restored)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 { supprime: <id> }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "409 { erreur: \"projet non vide\", taches: <open task count>, projet: <name> } (no code); 404 { erreur, choix }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/contacts": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "List and search contacts",
        "operationId": "getContacts",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/contacts -> 200 { \"total\": 1, \"decalage\": 0, \"limite\": 200, \"tronquee\": false, \"revision\": 4, \"contacts\": [ { \"id\": \"8b2a1bac1384\", \"nom\": \"Lucas Martin\", \"entreprise\": \"Domaine Ferrand\", \"role\": \"Gérant\", \"email\": \"lucas@ferrand.fr\", \"telephone\": \"06 12 34 56 78\", \"lien\": \"\", \"type\": \"client\", \"tags\": [\"vin\"], \"responsable\": null, \"relance\": \"2026-10-09\", \"dernierEchange\": \"2026-10-07\", \"note\": \"[07/10 10:09] Appelé : il valide le devis.\", \"cree\": \"2026-10-07T08:09:29.468Z\", \"creePar\": null, \"maj\": \"2026-10-07T08:09:29.573Z\", \"majPar\": null } ] }",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Free text in name, company, role, email, phone, tags and note, accent-insensitive."
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Contact type filter. Values: prospect,client,partenaire,fournisseur,autre (comma-separated)."
          },
          {
            "name": "relance",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "en_retard: follow-up before today; aujourdhui: today or earlier; semaine: within 7 days, overdue included; sans: none; a date: on or before it. Values: en_retard | aujourdhui | semaine | sans | YYYY-MM-DD."
          },
          {
            "name": "responsable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Who follows the contact. Values: moi | <person id> | aucun."
          },
          {
            "name": "tri",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Sort order. Values: nom (default) | relance | maj | cree."
          },
          {
            "name": "limite",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "default": 200
            },
            "description": "1 to 1000."
          },
          {
            "name": "decalage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "default": 0
            },
            "description": "Offset."
          },
          {
            "name": "forme",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Compact contacts: id, nom, entreprise, type, email, telephone, relance, dernierEchange (+ responsable in team mode). Values: compacte."
          }
        ],
        "responses": {
          "200": {
            "description": "{ total, decalage, limite, tronquee, contacts: [contact | compact contact], revision }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (unknown filter or value, with champ and attendu); 400 personne_inconnue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Create a contact",
        "operationId": "postContacts",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/contacts { \"nom\": \"Lucas Martin\", \"entreprise\": \"Domaine Ferrand\", \"role\": \"Gérant\", \"email\": \"lucas@ferrand.fr\", \"telephone\": \"+33 6 12 34 56 78\", \"type\": \"client\", \"tags\": [\"Vin\", \"Bourgogne\"] } -> 201 { ..., \"tags\": [\"vin\", \"bourgogne\"] }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nom": {
                    "type": "string",
                    "description": "Person or company name (120 chars max)."
                  },
                  "entreprise": {
                    "type": "string",
                    "description": "Company."
                  },
                  "role": {
                    "type": "string",
                    "description": "Position."
                  },
                  "email": {
                    "type": "string",
                    "description": "Email (also usable to designate the contact, case-insensitive)."
                  },
                  "telephone": {
                    "type": "string",
                    "description": "Phone."
                  },
                  "lien": {
                    "type": "string",
                    "description": "Website or page."
                  },
                  "type": {
                    "description": "Type (default autre)."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tags."
                  },
                  "responsable": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who follows the contact (default: the creator)."
                  },
                  "relance": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Follow-up date: the only contact date that signals lateness (briefing, KPIs)."
                  },
                  "dernierEchange": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Date of the last exchange."
                  },
                  "note": {
                    "type": "string",
                    "description": "Free notes; noteAjout appends signed, dated lines (call reports)."
                  },
                  "id": {
                    "type": "string",
                    "description": "Optional client id; existing: 200 deja: true (replay)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201 <contact>; 200 { ...<existing>, deja: true } on id replay. Duplicate names are allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 nom_vide (nom missing); 400 parametre_invalide (bad value or unknown field, e.g. email, telephone, type, relance, lien); 400 champ_de_service (cree, maj, creePar, majPar); 400 id_invalide; 400 personne_inconnue / personne_requise",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/contacts/{idOuNom}": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Read a contact",
        "operationId": "getContactsIdOuNom",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/contacts/lucas -> 404 { \"erreur\": \"« lucas » désigne 2 contacts, précisez ou utilisez un identifiant\", \"code\": \"contact_ambigu\", \"choix\": [ ... ], \"champ\": \"contact\", \"recu\": \"lucas\" }",
        "parameters": [
          {
            "name": "idOuNom",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier, email (case-insensitive), name or company (ignoring case and accents), or words only that contact carries (\"lucas ferrand\" finds Lucas Martin of Domaine Ferrand)."
          }
        ],
        "responses": {
          "200": {
            "description": "The full contact plus projets: the projects it is the client of, as compact projects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 contact_ambigu (choix: up to 20 { id, nom, entreprise }, champ \"contact\", recu); 404 contact_introuvable (choix, champ, recu)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Contacts"
        ],
        "summary": "Update a contact",
        "operationId": "patchContactsIdOuNom",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: PATCH /api/contacts/lucas%20ferrand { \"echange\": true, \"noteAjout\": \"Appelé : il valide le devis.\" } -> 200 { \"id\": \"8b2a1bac1384\", \"nom\": \"Lucas Martin\", ..., \"dernierEchange\": \"2026-10-07\", \"note\": \"[07/10 10:09] Appelé : il valide le devis.\", ... }",
        "parameters": [
          {
            "name": "idOuNom",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier or the name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nom": {
                    "type": "string",
                    "description": "Person name, or company name for a company contact (entreprise empty). Duplicates allowed."
                  },
                  "entreprise": {
                    "type": "string",
                    "description": "Company."
                  },
                  "role": {
                    "type": "string",
                    "description": "Position."
                  },
                  "email": {
                    "type": "string",
                    "description": "Email (also usable to designate the contact, case-insensitive)."
                  },
                  "telephone": {
                    "type": "string",
                    "description": "Phone."
                  },
                  "lien": {
                    "type": "string",
                    "description": "Website or page."
                  },
                  "type": {
                    "description": "Type (default autre)."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tags."
                  },
                  "responsable": {
                    "type": "string",
                    "nullable": true,
                    "description": "Who follows the contact (default: the creator)."
                  },
                  "relance": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Follow-up date: the only contact date that signals lateness (briefing, KPIs)."
                  },
                  "dernierEchange": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Date of the last exchange."
                  },
                  "note": {
                    "type": "string",
                    "description": "Free notes; noteAjout appends signed, dated lines (call reports)."
                  },
                  "noteAjout": {
                    "type": "string",
                    "description": "Appends a signed, dated line to the note (not combinable with note)."
                  },
                  "echange": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "true sets dernierEchange to today (not combinable with dernierEchange; false is refused)."
                  },
                  "siMaj": {
                    "type": "string",
                    "description": "Precondition: 409 conflit with actuel and par if changed since read."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 <contact>",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (incl. note + noteAjout, echange + dernierEchange, echange: false, note too long); 409 conflit (actuel, par); 404 contact_ambigu / contact_introuvable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "summary": "Move a contact to the trash",
        "operationId": "deleteContactsIdOuNom",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: DELETE /api/contacts/<id> -> 409 { \"code\": \"contact_client\", \"projets\": [ ... ] } ; with { \"force\": true } -> 200",
        "parameters": [
          {
            "name": "idOuNom",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier or the name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "force": {
                    "type": "boolean",
                    "description": "true: delete even if it is the client of projects (they lose their client and get it back on restore)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 { supprime: <id>, projetsDetaches: <n> }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "409 contact_client (projets: [ { id, nom } ]); 404 contact_ambigu / contact_introuvable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/kpi": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Key figures",
        "operationId": "getKpi",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nA task is on time when done on or before its due date; tasks without a due date count neither way (tauxATemps is null if none). delaiMoyenJours runs from creation to completion. A project counts as completed on its termineLe (index.js:2296-2326). charge = estimated hours (duree) of open tasks due by the end of the period (overdue included) / remaining capacity (capacite of equipe.json, hours per week, over 5 working days). No capacite: null (index.js:2368-2393). Computed on present objects only: deleted or cleaned-up tasks no longer count (regles.perimetre).\n\nExample: GET /api/kpi?periode=mois&decalage=-1",
        "parameters": [
          {
            "name": "periode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Period. Values: semaine (default, Monday-Sunday) | mois | trimestre (calendar quarter) | annee."
          },
          {
            "name": "decalage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "-120 to 12: 0 the current period, -1 the previous one."
          },
          {
            "name": "pour",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Restrict to the tasks, projects and contacts whose responsable is that person. Values: equipe (default) | moi | <person id>."
          }
        ],
        "responses": {
          "200": {
            "description": "{ parametres, periode: { nom, debut, fin, libelle, enCours }, precedente: { debut, fin, libelle, ...flux counters }, aujourdhui, flux: { creees, faites, faitesAvecEcheance, faitesATemps, tauxATemps, delaiMoyenJours, heuresFaites, projetsTermines, budgetTermine, contactsNouveaux, echanges }, serie: [ { debut, fin, libelle, creees, faites } ], maintenant: { ouvertes, enRetard, enAttente, echeancesAVenir, projetsActifs, projetsEnRetard, projetsARisque, projetsSansProchaineAction, budgetEnCours, relancesEnRetard, relancesAVenir }, personnes: [ { id, nom, initiale, faites, ouvertes, enRetard, heuresPrevues, sansDuree, capacite, capaciteRestante, charge } ] | null, projets: [compact project, late first, then at risk, then by due date], contacts: { total, parType, aRelancer }, regles: { aTemps, risque, charge, perimetre } (French prose) }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (unknown parameter, unknown periode, decalage out of -120..12 or not an integer); 400 personne_inconnue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/journal": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Activity log",
        "operationId": "getJournal",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/journal?depuis=2026-09-23&responsable=moi&sauf_par=moi -> what others did on my tasks since midnight",
        "parameters": [
          {
            "name": "depuis",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD (midnight, server local time) or ISO timestamp: lines written after it."
          },
          {
            "name": "par",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Lines by that person (aucun: lines with no person). Values: moi | <person id> | aucun."
          },
          {
            "name": "sauf_par",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "All other lines. Values: moi | <person id> | aucun."
          },
          {
            "name": "responsable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Lines of tasks whose responsable (after the write) is that person. Values: moi | <person id> | aucun."
          },
          {
            "name": "tache",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A task identifier, even of a deleted task: its lines and lines naming it in ids."
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One or more actions, comma-separated (see enums.journal_actions)."
          },
          {
            "name": "limite",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100
            },
            "description": "1 to 500."
          }
        ],
        "responses": {
          "200": {
            "description": "{ total, limite, tronquee, illisibles, lignes: [ { le, rev, par, via, action, cible: { type, id, titre }, responsable?, champs?, ids?, copie? } ] } most recent first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 parametre_invalide (unknown filter, bad depuis, limite out of range, unknown action); 400 id_invalide (tache); 400 personne_inconnue; 503 base_injoignable (database mode: the journal is read from the database)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/etat": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Full state, or what changed since a revision",
        "operationId": "getEtat",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nThis is what the web interface loads. No route returns the timestamp to pass as depuis: note your own before each call (API.md:1578-1581).\n\nExample: GET /api/etat?depuis=2026-09-17T11:00:00.000Z -> { \"revision\": 98, \"aujourdhui\": \"2026-09-17\", \"partiel\": true, \"depuis\": \"...\", \"taches\": [], \"projets\": [], \"contacts\": [], \"corbeille\": [ { \"id\": \"abc72df8e401\", \"type\": \"tache\", \"le\": \"2026-09-17T11:02:44.310Z\", ... } ] }",
        "parameters": [
          {
            "name": "depuis",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only objects whose maj is after it, and trash entries after it. Not validated (string comparison). Other parameters are not checked on this route."
          }
        ],
        "responses": {
          "200": {
            "description": "Full: the whole data state { version, revision, jourCourant, projets, taches, contacts, corbeille, parametres } plus aujourdhui and equipe: { moi, personnes: [ { id, nom, initiale } ] } | null. Partial (depuis): { revision, aujourdhui, partiel: true, depuis, taches, projets, contacts, corbeille }. corbeille holds tombstones { id, type, le, par, titre, objet? } (the last 500).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/flux": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Live change stream (Server-Sent Events)",
        "operationId": "getFlux",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed. The identity of a stream is re-checked when equipe.json or jetons.json change; a revoked token or removed person gets the stream closed.\n\nExample: retry: 3000\n\ndata: {\"revision\":<current>,\"origine\":null,\"par\":null,\"via\":null,\"action\":null,\"cible\":null,\"responsable\":null}\n\ndata: {\"revision\":2,\"origine\":null,\"par\":\"flo\",\"via\":\"tailscale\",\"action\":\"creer\",\"cible\":{\"type\":\"lot\",\"id\":null,\"titre\":\"2 tâches\"},\"responsable\":\"robin\"}\n\n(first event: index.js:3170-3171; batch event captured in API.md:827)",
        "responses": {
          "200": {
            "description": "Server-Sent Events (text/event-stream). First \"retry: 3000\", then data: { revision, origine: null, par: null, via: null, action: null, cible: null, responsable: null }, then one data: event per write: { revision, origine (the client field of the writing request), par, via, action, cible: { type, id, titre (80 chars max) }, responsable }. A request touching several tasks emits one event with cible { type: \"lot\", id: null, titre: \"3 tâches\" }. \": ping\" comment every 25 s. In database mode, a named event \"bdd\" (not delivered to onmessage).",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/corbeille": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "List the trash",
        "operationId": "getCorbeille",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/corbeille -> 200 { \"total\": 4, \"retenuJours\": 30, \"elements\": [ { \"id\": \"95579ce15738\", \"type\": \"tache\", \"titre\": \"Relire les fiches\", \"le\": \"2026-09-17T11:59:17.402Z\", \"par\": \"flo\", \"restaurable\": true } ] }",
        "responses": {
          "200": {
            "description": "{ total, retenuJours: 30, elements: [ { id, type: \"tache\" | \"projet\" | \"contact\", titre, le, par, restaurable } ] } most recent first. restaurable turns false after 30 days (the trace stays, the content is dropped).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/export": {
      "get": {
        "tags": [
          "Read"
        ],
        "summary": "Export everything as JSON",
        "operationId": "getExport",
        "description": "Auth: Personal token (Authorization: Bearer ck_...) or browser session cookie (cockpit_session). Read-only tokens allowed.\n\nExample: GET /api/export",
        "responses": {
          "200": {
            "description": "The complete data file as an attachment (Content-Disposition: attachment; filename=\"cockpit-YYYY-MM-DD.json\").",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/analyser": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Parse a quick-add line without saving",
        "operationId": "postAnalyser",
        "description": "Auth: POST: Bearer token, or session plus X-Cockpit: 1. Allowed for read-only tokens (it writes nothing).\n\nDates are not calendar-checked here (e.g. 31/02 parses to a non-existent date); POST /api/taches refuses them.\n\nExample: POST /api/analyser { \"saisie\": \"Relire la page tarifs @cockpit !haute demain ~45m #redaction >lun // avis de Paul\" } -> 200 { \"titre\": \"Relire la page tarifs\", \"projet\": \"cockpit\", \"priorite\": \"haute\", \"echeance\": \"2026-09-18\", \"reveil\": \"2026-09-21\", \"duree\": 45, \"tags\": [\"redaction\"], \"attenteDe\": null, \"recurrence\": null, \"notes\": \"avis de Paul\", \"statut\": \"a_faire\" }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "saisie": {
                    "type": "string",
                    "description": "A quick-add line to parse without saving."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ titre, projet (raw @ text, not resolved), priorite, echeance, reveil, duree, tags, attenteDe, recurrence, notes, statut } plus, in team mode, responsable (the &name person or null), responsableParDefaut (the writer, null for the service token) and erreurs: [ { code, erreur, jeton, recu, choix, ... } ] for refused &names.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/taches/{id}/basculer": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Toggle a task done or open",
        "operationId": "postTachesIdBasculer",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/taches/<id>/basculer -> 200 { \"tache\": { \"statut\": \"fait\", \"faitLe\": \"...\" }, \"suivante\": { \"id\": \"...\", \"echeance\": \"2026-10-17\" } }",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "200 { tache, suivante } : toggles done/not done. Completing a recurring task creates the next occurrence (suivante). Not idempotent: replaying it undoes it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 unknown task; 405 methode_refusee (any verb but POST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/taches/{id}/terminer": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Mark a task done",
        "operationId": "postTachesIdTerminer",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/taches/9e396af171ea/terminer -> 200 { \"tache\": { \"id\": \"9e396af171ea\", \"statut\": \"fait\", \"echeance\": \"2026-09-30\", \"faitLe\": \"2026-09-23T13:07:05.064Z\", \"faitPar\": \"robin\", ... }, \"suivante\": { \"id\": \"8edae787e171\", \"statut\": \"a_faire\", \"echeance\": \"2026-10-30\", \"responsable\": \"robin\", ... }, \"deja\": false }",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "200 { tache, suivante, deja }. Idempotent: already done gives deja: true, suivante: null and writes nothing. Sets faitLe, faitPar, removes the star; a recurring task gets its next occurrence and keeps its id in suivanteId.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 unknown task; 405 methode_refusee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/taches/{id}/rouvrir": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Reopen a task",
        "operationId": "postTachesIdRouvrir",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/taches/9e396af171ea/rouvrir -> 200 { \"tache\": { \"id\": \"9e396af171ea\", \"statut\": \"a_faire\", \"suivanteId\": null, ... }, \"suivante\": null, \"deja\": false, \"suivanteRetiree\": { \"id\": \"8edae787e171\", \"titre\": \"Payer le loyer\", \"echeance\": \"2026-10-30\" }, \"suivanteLaissee\": null }",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "200 { tache, suivante: null, deja, suivanteRetiree, suivanteLaissee }. Back to a_faire, faitLe/faitPar cleared. The occurrence created by terminer is sent to the trash if untouched since (suivanteRetiree: { id, titre, echeance }), else kept (suivanteLaissee: { id, titre, echeance, statut, raison: modifiee_depuis | deja_faite }). Idempotent (deja: true when not done).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 unknown task; 405 methode_refusee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/lot": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Update or delete several tasks at once",
        "operationId": "postLot",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/lot { \"ids\": [\"a\", \"b\"], \"champs\": { \"priorite\": \"haute\", \"focus\": true } } ; { \"ids\": [\"a\", \"b\"], \"action\": \"supprimer\" }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Target task ids."
                  },
                  "champs": {
                    "type": "object",
                    "description": "Fields to set on all (task fields incl. responsable; not noteAjout/siMaj). The star rule is checked on every task before any change."
                  },
                  "action": {
                    "type": "string",
                    "description": "Instead of champs: delete (to trash) or toggle all. Values: supprimer | basculer."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 { touchees, ignores } (ignores = unknown ids). With champs also majs: { <id>: <maj> } (for undo via siMaj), attribuees + attribueeA, focusRetirees.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 ids_introuvables (none exists); 400 parametre_invalide (unknown action, bad field); 400 champs_vides; 409 tache_d_un_autre (+ tache: { id, titre })",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/ordre": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Reorder tasks",
        "operationId": "postOrdre",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/ordre { \"ids\": [\"a\", \"b\", \"c\"] }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Task ids in the wanted order (ordre = index)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 { ok: true, reordonnees, ignores }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "400 ids_introuvables",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/projets/ordre": {
      "post": {
        "tags": [
          "Projects"
        ],
        "summary": "Reorder projects",
        "operationId": "postProjetsOrdre",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/projets/ordre { \"ids\": [\"29eb5031d2ac\", \"2b75c588d9f3\"] }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Project ids in the wanted order."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 { ok: true }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/corbeille/{id}/restaurer": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Restore an item from the trash",
        "operationId": "postCorbeilleIdRestaurer",
        "description": "Auth: Personal token in Authorization: Bearer (no X-Cockpit needed), or session cookie plus header X-Cockpit: 1. Read-only tokens: 403 droits_insuffisants.\n\nExample: POST /api/corbeille/<id>/restaurer -> 200 { \"restaure\": { ... }, \"type\": \"contact\", \"projetsRendus\": 1 }",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id of the deleted task, project or contact."
          }
        ],
        "responses": {
          "200": {
            "description": "200 { restaure: <object>, type: \"tache\" | \"projet\" | \"contact\", tachesRendues? (project: tasks put back), projetsRendus? (contact: projects that got it back as client) }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "404 corbeille_introuvable; 404 corbeille_expiree (older than 30 days); 409 existe_deja",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/menage": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Clean up done tasks",
        "operationId": "postMenage",
        "description": "Auth: Session of a person listed in admins of equipe.json, plus X-Cockpit: 1. Any token, even an admin's or the service token: 403 reserve_admin, before anything is written.\n\nExample: POST /api/menage (Flo, not admin) -> 403 { \"erreur\": \"le ménage est réservé aux administrateurs de l'équipe\", \"code\": \"reserve_admin\", \"champ\": \"personne\", \"recu\": \"flo\", \"attendu\": [\"robin\"], \"indice\": \"...\" }",
        "responses": {
          "200": {
            "description": "200 { retirees: <n> }: removes tasks done more than 30 days ago (each to the trash, with a menage journal line).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "403 reserve_admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/import": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Import tasks from a JSON export",
        "operationId": "postImport",
        "description": "Auth: Session of a person listed in admins of equipe.json, plus X-Cockpit: 1. Any token, even an admin's or the service token: 403 reserve_admin, before anything is written.\n\nThe only truly irreversible operation besides the automatic backup copy (API.md:1621-1622).\n\nExample: POST /api/import <file from GET /api/export>",
        "responses": {
          "200": {
            "description": "200 { ok: true, taches: <n> }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "403 reserve_admin; 400 { erreur: \"fichier invalide\" } (no taches array; no code); 400 version_trop_recente; 400 parametre_invalide (version); 400 hors_schema (database mode)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "tags": [
          "MCP"
        ],
        "summary": "MCP endpoint (Streamable HTTP, JSON-RPC 2.0)",
        "operationId": "postMcp",
        "description": "Auth: Authorization: Bearer <personal token> always (never a session cookie, never a query parameter). X-Cockpit not required. An Origin header, if present, must be the app host, loopback or a declared host.\n\nExample: POST https://app.cockpilot.si/mcp  Authorization: Bearer ck_...  Accept: application/json, text/event-stream  MCP-Protocol-Version: 2025-11-25  { \"jsonrpc\": \"2.0\", \"id\": 4, \"method\": \"tools/call\", \"params\": { \"name\": \"cockpit_ajouter\", \"arguments\": { \"saisie\": \"Essai MCP @prospection demain\" } } }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "A JSON-RPC 2.0 message: initialize, tools/list, tools/call, prompts/list, resources/list..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response as application/json; 202 with no body for a notification. See mcp_protocol and mcp_tools.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "401 jeton_requis / jeton_invalide / jeton_orphelin (JSON-RPC -31000, WWW-Authenticate: Bearer realm=\"cockpit\"); 400 jeton_dans_url (-32600); 403 origine_refusee (-31000); 405 for GET/HEAD/DELETE (Allow: POST); 406 Accept missing application/json or text/event-stream; 413 body over 1 MB; 415 Content-Type not application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/arbre": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "Spaces as a tree of folders",
        "operationId": "getArbre",
        "description": "Each project with its groups and subgroups, with open and done tasks, progress and risk. Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/agents/resume": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "What the agents are doing",
        "operationId": "getAgentsResume",
        "description": "Per agent: open, running, waiting and delivered tasks. Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/deplacer": {
      "post": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "File tasks and spaces into a space",
        "operationId": "postDeplacer",
        "description": "Body: taches (task ids) and/or espaces (groups or projects, by name, id or path), vers (the target space, or null for no project / the root), optional siMaj and confirmer. All or nothing. Details: https://cockpilot.si/docs/",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pages": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "List pages",
        "operationId": "getPages",
        "description": "Pages of a space (doc, roadmap, budget, objectifs, moodboard, indicateurs). Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "Create a page",
        "operationId": "postPages",
        "description": "Body: projet (required), genre, titre, and contenu.blocs for a doc page. Details: https://cockpilot.si/docs/",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/mesures": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "Read metric series",
        "operationId": "getMesures",
        "description": "The series of a space, with their latest values and totals. Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "Record metric values",
        "operationId": "postMesures",
        "description": "Body: projet, and either cle and valeur (with optional jour, libelle, unite, nature, sens, ajouter) or mesures, a list of values. Details: https://cockpilot.si/docs/",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/totaux": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "Totals across connected sources",
        "operationId": "getTotaux",
        "description": "Revenue and traffic totals for a period. Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sources": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "List data sources",
        "operationId": "getSources",
        "description": "Connected sources (AdSense, AdMob, AppSumo, Stripe, Datalenk, Upload-Post...) with their last reading. Never returns a key. Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/declencheurs": {
      "get": {
        "tags": [
          "Pages, metrics and automations"
        ],
        "summary": "List triggers",
        "operationId": "getDeclencheurs",
        "description": "The outgoing triggers an administrator declared. Details: https://cockpilot.si/docs/",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "description": "Refused; nothing was changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "A personal token (ck_ followed by 43 characters), created by an administrator of the workspace, or an OAuth 2.1 access token (authorization code with PKCE, from /oauth/authorize and /oauth/token of the workspace)."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "erreur"
        ],
        "properties": {
          "erreur": {
            "type": "string",
            "description": "What went wrong, in French, meant to be read."
          },
          "code": {
            "type": "string",
            "description": "A stable machine code (snake_case), such as parametre_invalide or introuvable."
          },
          "champ": {
            "type": "string",
            "description": "The faulty field."
          },
          "recu": {
            "description": "The value received."
          },
          "attendu": {
            "description": "What is accepted: a list or a phrase."
          },
          "choix": {
            "type": "array",
            "description": "Candidates (projects, contacts, people) when a name was ambiguous or unknown."
          },
          "indice": {
            "type": "string",
            "description": "A hint, in French; it says when nothing was written."
          }
        }
      }
    }
  }
}
