{
  "openapi": "3.1.0",
  "info": {
    "title": "API commerce Inklura",
    "version": "1.0.0",
    "description": "Lisez et mettez à jour le catalogue, les stocks, les commandes et les clients de votre boutique. Créez une clé dans Inklura (Développeurs > Clés d’API), puis envoyez-la dans l’en-tête Authorization: Bearer <clé>. La boutique concernée est celle de la clé : aucun en-tête de site n’est lu. Les montants sont en euros. Les listes sont paginées par curseur (limit jusqu’à 100). Les erreurs ont la forme { error: { code, message } }. Les réponses ne sont jamais mises en cache : chaque lecture renvoie l’état courant de la base."
  },
  "servers": [
    {
      "url": "https://manage.inklura.fr/api/v1/commerce"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ikl_<préfixe>_<secret>"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Clé absente, invalide, révoquée ou expirée",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Autorisation de la clé insuffisante (insufficient_scope), ou clé sans utilisateur utilisée pour une écriture (token_without_user)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Ressource introuvable dans cette boutique",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ValidationError": {
        "description": "Champ invalide ou non modifiable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            },
            "required": [
              "code",
              "message"
            ]
          }
        }
      },
      "Variant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "variant"
          },
          "type": {
            "enum": [
              "variation",
              "packaging"
            ],
            "description": "variation = déclinaison par attributs ; packaging = conditionnement (5 kg, 25 kg…)"
          },
          "productId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "description": "null = prix du produit"
          },
          "salePrice": {
            "type": [
              "number",
              "null"
            ]
          },
          "manageStock": {
            "type": "boolean"
          },
          "stock": {
            "type": [
              "integer",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "weight": {
            "type": [
              "number",
              "null"
            ]
          },
          "packagingQuantity": {
            "type": [
              "number",
              "null"
            ]
          },
          "packagingUnit": {
            "type": [
              "string",
              "null"
            ]
          },
          "position": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "product"
          },
          "siteId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": "number",
            "description": "Prix de vente"
          },
          "salePrice": {
            "type": [
              "number",
              "null"
            ],
            "description": "Prix promotionnel"
          },
          "currency": {
            "const": "EUR"
          },
          "taxRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "isBuyable": {
            "type": "boolean"
          },
          "type": {
            "type": "string"
          },
          "manageStock": {
            "type": "boolean"
          },
          "stock": {
            "type": [
              "integer",
              "null"
            ]
          },
          "lowStockThreshold": {
            "type": [
              "integer",
              "null"
            ]
          },
          "weight": {
            "type": [
              "number",
              "null"
            ]
          },
          "variants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Variant"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ProductInput": {
        "type": "object",
        "description": "Création : name et price requis. Modification : champs partiels. Le stock se modifie par /inventory/adjustments.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 250
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": "number",
            "minimum": 0
          },
          "salePrice": {
            "type": [
              "number",
              "null"
            ]
          },
          "taxRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "isBuyable": {
            "type": "boolean"
          },
          "manageStock": {
            "type": "boolean"
          },
          "lowStockThreshold": {
            "type": [
              "integer",
              "null"
            ]
          },
          "weight": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "VariantInput": {
        "type": "object",
        "properties": {
          "type": {
            "enum": [
              "variation",
              "packaging"
            ],
            "default": "variation"
          },
          "name": {
            "type": "string"
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": [
              "number",
              "null"
            ]
          },
          "salePrice": {
            "type": [
              "number",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "weight": {
            "type": [
              "number",
              "null"
            ]
          },
          "manageStock": {
            "type": "boolean"
          },
          "lowStockThreshold": {
            "type": [
              "integer",
              "null"
            ],
            "description": "packaging uniquement"
          },
          "packagingQuantity": {
            "type": [
              "number",
              "null"
            ],
            "description": "packaging uniquement"
          },
          "packagingUnit": {
            "type": [
              "string",
              "null"
            ],
            "description": "packaging uniquement"
          },
          "position": {
            "type": "integer",
            "description": "packaging uniquement"
          }
        },
        "additionalProperties": false
      },
      "InventoryLevel": {
        "type": "object",
        "properties": {
          "object": {
            "const": "inventory_level"
          },
          "productId": {
            "type": "string",
            "format": "uuid"
          },
          "variantId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "manageStock": {
            "type": "boolean"
          },
          "available": {
            "type": "integer"
          },
          "lowStockThreshold": {
            "type": [
              "integer",
              "null"
            ]
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "InventoryAdjustment": {
        "type": "object",
        "required": [
          "productId",
          "delta"
        ],
        "properties": {
          "productId": {
            "type": "string",
            "format": "uuid"
          },
          "variantId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Déclinaison (type variation) à ajuster"
          },
          "delta": {
            "type": "integer",
            "description": "Variation signée : +5 entrée, -2 sortie"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 240
          },
          "allowNegative": {
            "type": "boolean",
            "default": false,
            "description": "Par défaut, un retrait supérieur au stock disponible est refusé (409 insufficient_stock) et rien n’est enregistré. Avec true, le retrait est appliqué selon la règle de la boutique : si les commandes en rupture sont acceptées, le registre de stock devient négatif et le stock affiché reste à 0 ; sinon tout s’arrête à 0. Le champ applied indique le mouvement réellement enregistré."
          }
        },
        "additionalProperties": false
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "customer"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": "object",
            "properties": {
              "line1": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "postalCode": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "city": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "country": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "isProfessional": {
            "type": "boolean"
          },
          "siret": {
            "type": [
              "string",
              "null"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CustomerInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "line1": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "postalCode": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "city": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "country": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "isProfessional": {
            "type": "boolean"
          },
          "siret": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "order"
          },
          "number": {
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "awaiting_payment",
              "processing",
              "paid",
              "overdue",
              "canceled",
              "closed"
            ]
          },
          "fulfillmentType": {
            "enum": [
              "delivery",
              "pickup"
            ]
          },
          "total": {
            "type": [
              "number",
              "null"
            ]
          },
          "currency": {
            "type": "string"
          },
          "paymentMethod": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "deliveryDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "tracking": {
            "type": [
              "object",
              "null"
            ]
          },
          "customerNote": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "body": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string"
                }
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer"
                },
                "unitPrice": {
                  "type": "number"
                },
                "productId": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "variantId": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "fulfillments": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Customer"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FulfillmentInput": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "orderItemId",
                "quantity"
              ],
              "properties": {
                "orderItemId": {
                  "type": "string",
                  "format": "uuid"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "description": "Absent = tout le reste à expédier"
          },
          "method": {
            "enum": [
              "shipping",
              "pickup",
              "local_delivery",
              "digital"
            ],
            "default": "shipping"
          },
          "carrier": {
            "type": "string"
          },
          "trackingNumber": {
            "type": "string"
          },
          "trackingUrl": {
            "type": "string",
            "format": "uri"
          },
          "notes": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "WebhookEvent": {
        "type": "object",
        "description": "Corps des webhooks sortants. En-têtes : X-Inklura-Event, X-Inklura-Delivery, X-Inklura-Event-Id, X-Inklura-Timestamp, X-Inklura-Signature: t=<ts>,v1=<hex HMAC-SHA256(secret, `${ts}.${corps brut}`)>. Répondez 2xx en moins de 10 s. Sinon nouvel essai après 1 min, 5 min, 30 min, 2 h, 6 h et 24 h, puis abandon.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifiant de l’événement, identique d’un essai à l’autre"
          },
          "type": {
            "enum": [
              "order.created",
              "order.paid",
              "order.fulfilled",
              "product.created",
              "product.updated",
              "inventory.updated",
              "webhook.test"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "siteId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "data": {
            "type": "object",
            "properties": {
              "object": {
                "description": "Order, Product ou InventoryLevel, comme dans l’API"
              },
              "context": {
                "type": "object"
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/products": {
      "get": {
        "summary": "Lister les produits",
        "security": [
          {
            "bearer": [
              "products:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Valeur nextCursor de la page précédente."
          },
          {
            "name": "sku",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "À passer en ?cursor= pour la page suivante."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "post": {
        "summary": "Créer un produit",
        "security": [
          {
            "bearer": [
              "products:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/products/{id}": {
      "get": {
        "summary": "Lire un produit",
        "security": [
          {
            "bearer": [
              "products:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "patch": {
        "summary": "Modifier un produit",
        "security": [
          {
            "bearer": [
              "products:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/products/{id}/variants": {
      "get": {
        "summary": "Lister les déclinaisons d’un produit",
        "security": [
          {
            "bearer": [
              "products:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Variant"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "post": {
        "summary": "Créer une déclinaison",
        "security": [
          {
            "bearer": [
              "products:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VariantInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Variant"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/variants/{id}": {
      "get": {
        "summary": "Lire une déclinaison",
        "security": [
          {
            "bearer": [
              "products:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Variant"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "patch": {
        "summary": "Modifier une déclinaison",
        "security": [
          {
            "bearer": [
              "products:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VariantInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Variant"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/inventory": {
      "get": {
        "summary": "Lister les niveaux de stock",
        "security": [
          {
            "bearer": [
              "inventory:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Valeur nextCursor de la page précédente."
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "sku",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "managed_only",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InventoryLevel"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "À passer en ?cursor= pour la page suivante."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/inventory/adjustments": {
      "post": {
        "summary": "Ajuster un stock",
        "description": "Mouvement signé enregistré dans le journal de stock. En-tête Idempotency-Key conseillé : un rejeu avec la même clé ne bouge pas le stock une deuxième fois.",
        "security": [
          {
            "bearer": [
              "inventory:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryAdjustment"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rejeu idempotent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "201": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Stock insuffisant pour ce retrait (insufficient_stock) ou suivi de stock désactivé pour cet article (stock_not_managed)"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/orders": {
      "get": {
        "summary": "Lister les commandes",
        "security": [
          {
            "bearer": [
              "orders:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Valeur nextCursor de la page précédente."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Une ou plusieurs valeurs séparées par des virgules"
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "created_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Order"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "À passer en ?cursor= pour la page suivante."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "summary": "Lire une commande (articles, expéditions, client)",
        "security": [
          {
            "bearer": [
              "orders:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/orders/{id}/fulfillments": {
      "post": {
        "summary": "Expédier ou remettre une commande",
        "description": "Enregistre une expédition (stock consommé, suivi). Le client n’est pas prévenu par e-mail par cet appel.",
        "security": [
          {
            "bearer": [
              "orders:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FulfillmentInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Déjà expédiée ou statut non expédiable"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/orders/{id}/notes": {
      "post": {
        "summary": "Ajouter une note interne",
        "security": [
          {
            "bearer": [
              "orders:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "body"
                ],
                "properties": {
                  "body": {
                    "type": "string",
                    "maxLength": 4000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/customers": {
      "get": {
        "summary": "Lister les clients",
        "security": [
          {
            "bearer": [
              "customers:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Valeur nextCursor de la page précédente."
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_archived",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Customer"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "À passer en ?cursor= pour la page suivante."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "post": {
        "summary": "Créer un client",
        "security": [
          {
            "bearer": [
              "customers:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Adresse e-mail déjà utilisée"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/customers/{id}": {
      "get": {
        "summary": "Lire un client",
        "security": [
          {
            "bearer": [
              "customers:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "patch": {
        "summary": "Modifier un client",
        "security": [
          {
            "bearer": [
              "customers:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Identifiant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Succès",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    }
  },
  "webhooks": {
    "commerceEvent": {
      "post": {
        "summary": "Événement commerce (webhook sortant)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Réception confirmée (tout code 2xx)"
          }
        }
      }
    }
  }
}