{
  "openapi": "3.1.0",
  "info": {
    "title": "IA Réceptionniste — API publique",
    "version": "1.0.0",
    "description": "Pilotez votre compte IA Réceptionniste depuis vos outils (Zapier, Make, n8n, votre site). Chaque clé n'agit que sur le compte qui l'a créée, avec les droits choisis à sa création. Documentation lisible : https://iareceptionist.com/docs/api"
  },
  "servers": [
    {
      "url": "https://tpogicoxqrtfeiycvgrt.supabase.co/functions/v1/api-v1"
    }
  ],
  "security": [
    {
      "bearerKey": []
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "summary": "Compte de la clé",
        "description": "Nom du commerce, fuseau horaire, droits et limites de la clé.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/calls": {
      "get": {
        "summary": "Derniers appels",
        "description": "Appels reçus par l'assistante, du plus récent au plus ancien. Données minimales : jamais la transcription.\n\nDroit requis : `calls:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Call"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "nullable": true
                    },
                    "next_offset": {
                      "type": "integer",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "calls:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Nombre d'éléments (1 à 100, 20 par défaut).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Décalage (pagination : next_offset de la réponse précédente).",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Depuis ce jour (AAAA-MM-JJ).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ]
      }
    },
    "/v1/appointments": {
      "get": {
        "summary": "Rendez-vous",
        "description": "Rendez-vous à venir par défaut, ou entre deux jours.\n\nDroit requis : `appointments:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Appointment"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "nullable": true
                    },
                    "next_offset": {
                      "type": "integer",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "appointments:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Nombre d'éléments (1 à 100, 20 par défaut).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Décalage (pagination : next_offset de la réponse précédente).",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Premier jour (AAAA-MM-JJ).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Dernier jour (AAAA-MM-JJ).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "confirmed, modified, cancelled ou pending_calendar.",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "post": {
        "summary": "Prendre un rendez-vous",
        "description": "Réserve un créneau libre avec le même moteur que l'assistante téléphonique (horaires, congés, agenda relié) : jamais de double réservation. Envoyez un en-tête Idempotency-Key : la même valeur renvoie le même rendez-vous si votre outil réessaie.\n\nDroit requis : `appointments:write`.",
        "responses": {
          "200": {
            "description": "Rendez-vous déjà enregistré (même Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "201": {
            "description": "Rendez-vous créé",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          }
        },
        "x-scope": "appointments:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "start_at",
                  "client_name"
                ],
                "properties": {
                  "start_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Début, ISO 8601 avec fuseau."
                  },
                  "client_name": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 80
                  },
                  "client_phone": {
                    "type": "string"
                  },
                  "service": {
                    "type": "string"
                  },
                  "duration_minutes": {
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 480
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/appointments/{id}": {
      "get": {
        "summary": "Un rendez-vous",
        "description": "Un rendez-vous du compte.\n\nDroit requis : `appointments:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "appointments:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifiant",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "patch": {
        "summary": "Déplacer un rendez-vous",
        "description": "Déplace le rendez-vous vers un créneau libre (vérifié par le moteur). Le client est prévenu par SMS selon vos réglages.\n\nDroit requis : `appointments:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "appointments:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifiant",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "start_at"
                ],
                "properties": {
                  "start_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "expected_start_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Début connu de votre outil : refus « changed » si le rendez-vous a été modifié entre-temps."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/appointments/{id}/cancel": {
      "post": {
        "summary": "Annuler un rendez-vous",
        "description": "Annule le rendez-vous. Le client est prévenu par SMS selon vos réglages.\n\nDroit requis : `appointments:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "appointments:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifiant",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/v1/availability": {
      "get": {
        "summary": "Créneaux libres d'un jour",
        "description": "Créneaux libres calculés par le moteur de l'assistante.\n\nDroit requis : `appointments:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Availability"
                    },
                    "calendar_unverified": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "appointments:read",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "Jour (AAAA-MM-JJ).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "service",
            "in": "query",
            "required": false,
            "description": "Prestation (sa durée est utilisée).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "duration_minutes",
            "in": "query",
            "required": false,
            "description": "Durée en minutes.",
            "schema": {
              "type": "integer"
            }
          }
        ]
      }
    },
    "/v1/requests": {
      "get": {
        "summary": "Demandes à rappeler",
        "description": "Demandes notées par l'assistante (pending par défaut).\n\nDroit requis : `requests:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Request"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "nullable": true
                    },
                    "next_offset": {
                      "type": "integer",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "requests:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Nombre d'éléments (1 à 100, 20 par défaut).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Décalage (pagination : next_offset de la réponse précédente).",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "pending, done ou all.",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/requests/{id}/done": {
      "post": {
        "summary": "Marquer une demande traitée",
        "description": "Même effet que « Traité » dans le tableau de bord. Sans effet si déjà traitée (unchanged = true).\n\nDroit requis : `requests:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "requests:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifiant",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/v1/faq": {
      "get": {
        "summary": "Questions fréquentes",
        "description": "Liste avec la position de chaque question.\n\nDroit requis : `faq:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "faq:read"
      },
      "post": {
        "summary": "Ajouter une question",
        "description": "Ajoute une question, puis transmet le changement à l'assistante (résultat réel dans assistant_sync).\n\nDroit requis : `faq:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "faq:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Faq"
              }
            }
          }
        }
      },
      "put": {
        "summary": "Remplacer toutes les questions",
        "description": "Remplace la liste (50 au plus).\n\nDroit requis : `faq:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "faq:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "faqs"
                ],
                "properties": {
                  "faqs": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "$ref": "#/components/schemas/Faq"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/faq/{position}": {
      "delete": {
        "summary": "Supprimer une question",
        "description": "Supprime la question à cette position SI son texte correspond au paramètre question (sécurité contre une liste modifiée entre-temps).\n\nDroit requis : `faq:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "faq:write",
        "parameters": [
          {
            "name": "position",
            "in": "path",
            "required": true,
            "description": "Position (1 = première).",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "question",
            "in": "query",
            "required": true,
            "description": "Texte exact de la question.",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/hours": {
      "get": {
        "summary": "Horaires",
        "description": "Horaires de la semaine (un élément par jour).\n\nDroit requis : `hours:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "hours:read"
      },
      "put": {
        "summary": "Remplacer les horaires",
        "description": "Remplace les horaires ; les jours absents sont fermés.\n\nDroit requis : `hours:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "hours:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "hours"
                ],
                "properties": {
                  "hours": {
                    "type": "array",
                    "maxItems": 7,
                    "items": {
                      "$ref": "#/components/schemas/DayHours"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/closures": {
      "get": {
        "summary": "Congés et fermetures",
        "description": "Liste avec la position de chaque fermeture.\n\nDroit requis : `closures:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "closures:read"
      },
      "post": {
        "summary": "Ajouter des congés ou un créneau bloqué",
        "description": "{from, to, reason} : jours entiers, du premier au dernier inclus. {date, start, end, reason} : un créneau. L'assistante ne propose plus ces moments.\n\nDroit requis : `closures:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "closures:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClosureInput"
              }
            }
          }
        }
      }
    },
    "/v1/closures/{position}": {
      "delete": {
        "summary": "Supprimer une fermeture",
        "description": "Supprime la fermeture à cette position SI son début correspond au paramètre start.\n\nDroit requis : `closures:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "closures:write",
        "parameters": [
          {
            "name": "position",
            "in": "path",
            "required": true,
            "description": "Position.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": true,
            "description": "Début exact, tel que listé.",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/services": {
      "get": {
        "summary": "Prestations",
        "description": "Liste avec la position de chaque prestation.\n\nDroit requis : `services:read`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "services:read"
      },
      "post": {
        "summary": "Ajouter une prestation",
        "description": "Ajoute une prestation (nom unique).\n\nDroit requis : `services:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "services:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Service"
              }
            }
          }
        }
      },
      "put": {
        "summary": "Remplacer les prestations",
        "description": "Remplace la liste (60 au plus).\n\nDroit requis : `services:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "services:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "services"
                ],
                "properties": {
                  "services": {
                    "type": "array",
                    "maxItems": 60,
                    "items": {
                      "$ref": "#/components/schemas/Service"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/services/{position}": {
      "delete": {
        "summary": "Supprimer une prestation",
        "description": "Supprime la prestation à cette position SI son nom correspond au paramètre name.\n\nDroit requis : `services:write`.",
        "responses": {
          "200": {
            "description": "Réponse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {},
                    "assistant_sync": {
                      "$ref": "#/components/schemas/AssistantSync"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-scope": "services:write",
        "parameters": [
          {
            "name": "position",
            "in": "path",
            "required": true,
            "description": "Position.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "description": "Nom exact.",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Clé d'API créée dans Intégrations › API (format iar_…). Aussi accepté : en-tête X-Api-Key."
      }
    },
    "responses": {
      "Error": {
        "description": "Erreur : un code stable et une phrase simple.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Secondes à attendre (429)."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Call": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "ended_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "duration_seconds": {
            "type": "integer",
            "nullable": true
          },
          "caller_name": {
            "type": "string",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "urgent": {
            "type": "boolean"
          },
          "summary": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "Appointment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "confirmed",
              "modified",
              "cancelled",
              "pending_calendar"
            ]
          },
          "start_at": {
            "type": "string",
            "format": "date-time"
          },
          "end_at": {
            "type": "string",
            "format": "date-time"
          },
          "timezone": {
            "type": "string"
          },
          "service": {
            "type": "string",
            "nullable": true
          },
          "client_name": {
            "type": "string",
            "nullable": true
          },
          "client_phone": {
            "type": "string",
            "nullable": true
          },
          "booked_by": {
            "type": "string",
            "enum": [
              "assistant",
              "manager"
            ]
          }
        }
      },
      "Availability": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "day_status": {
            "type": "string"
          },
          "duration_minutes": {
            "type": "integer"
          },
          "slots": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "start_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "end_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "time": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Request": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "done"
            ]
          },
          "urgent": {
            "type": "boolean"
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "caller_name": {
            "type": "string",
            "nullable": true
          },
          "caller_number": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Faq": {
        "type": "object",
        "required": [
          "question",
          "answer"
        ],
        "properties": {
          "question": {
            "type": "string",
            "maxLength": 300
          },
          "answer": {
            "type": "string",
            "maxLength": 1000
          }
        }
      },
      "DayHours": {
        "type": "object",
        "required": [
          "day"
        ],
        "properties": {
          "day": {
            "type": "string",
            "enum": [
              "monday",
              "tuesday",
              "wednesday",
              "thursday",
              "friday",
              "saturday",
              "sunday"
            ]
          },
          "timeSlots": {
            "type": "array",
            "maxItems": 4,
            "items": {
              "type": "object",
              "properties": {
                "start": {
                  "type": "string",
                  "example": "09:00"
                },
                "end": {
                  "type": "string",
                  "example": "12:00"
                }
              }
            }
          }
        }
      },
      "ClosureInput": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "from",
              "to"
            ],
            "properties": {
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              },
              "reason": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "date",
              "start",
              "end"
            ],
            "properties": {
              "date": {
                "type": "string",
                "format": "date"
              },
              "start": {
                "type": "string"
              },
              "end": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            }
          }
        ]
      },
      "Service": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "duration": {
            "type": "string",
            "example": "1h30"
          },
          "price": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "at_pro",
              "at_client",
              "both"
            ]
          }
        }
      },
      "AssistantSync": {
        "type": "object",
        "description": "Résultat RÉEL de la transmission à l'assistante téléphonique.",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "unchanged",
              "failed",
              "no_assistant"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}