Tickets — CRUD
Gestion des tickets de support liés à un client.
Source : server/publicApi/routes/tickets.ts. Schéma : insertTicketSchema dans shared/schema.ts.
Vue d'ensemble
| Méthode | Path | Scope |
|---|---|---|
GET | /tickets | tickets:read |
GET | /tickets/:id | tickets:read |
POST | /tickets | tickets:write |
PATCH | /tickets/:id | tickets:write |
DELETE | /tickets/:id | tickets:delete |
Webhooks émis : ticket.created, ticket.updated, ticket.deleted, ticket.status_changed (émis en plus de ticket.updated quand le champ status change).
Multi-tenant
Les tickets n'ont pas d'agencyId direct : le scoping passe par tickets.clientId → clients.agencyId. Toute requête est filtrée en conséquence.
GET /tickets
Liste paginée des tickets dont le client appartient à l'agence.
Query params
| Param | Type | Description |
|---|---|---|
limit | int | Défaut 50, max 100 |
offset | int | Offset |
status | string | Filtre sur statut (ex: open, closed, in_progress) |
clientId | int | Filtre sur un client |
Réponse 200
{
"data": [
{
"id": 1,
"clientId": 42,
"title": "Bug formulaire de contact",
"status": "open",
"priority": "high",
"createdAt": "2026-04-25T10:00:00.000Z"
}
],
"total": 14,
"limit": 50,
"offset": 0
}POST /tickets
Création d'un ticket. Le clientId doit appartenir à votre agence.
Body
Validé via insertTicketSchema.strict() — tout champ inconnu est rejeté.
{
"clientId": 42,
"title": "Bug formulaire de contact",
"description": "Le formulaire ne renvoie pas d'email",
"status": "open",
"priority": "high"
}Réponses
201: ticket créé400 Client invalide pour cette agence:clientIdhors agence400 Données invalides: Zod (incluant champs inconnus en mode strict)
Webhook émis
ticket.created avec { "ticket": <objet créé> }.
PATCH /tickets/:id
Mise à jour partielle. Si clientId est modifié, vérification de l'appartenance à l'agence.
Webhooks émis
ticket.updated: toujoursticket.status_changed: sistatuschange, avec payload :json{ "ticket": <objet mis à jour>, "previousStatus": "open", "newStatus": "in_progress" }
Exemple — passer un ticket à in_progress
curl -X PATCH \
-H "x-api-key: spk_..." \
-H "Content-Type: application/json" \
-d '{"status":"in_progress"}' \
https://beta.stormeo.io/api/public/v1/tickets/42DELETE /tickets/:id
Suppression définitive (hard delete via db.delete).
Webhook émis
ticket.deleted avec { "id": 42 }.