{
  "components": {
    "schemas": {
      "ExternalCapabilities": {
        "additionalProperties": false,
        "properties": {
          "connection_ref": {
            "pattern": "^[A-Za-z0-9_.-]{1,128}$",
            "type": "string"
          },
          "delivery_types": {
            "items": {
              "enum": [
                "license_key",
                "activation_url",
                "instructions"
              ],
              "type": "string"
            },
            "minItems": 1,
            "type": "array"
          },
          "devices": {
            "const": false,
            "type": "boolean"
          },
          "environment": {
            "enum": [
              "sandbox",
              "live"
            ],
            "type": "string"
          },
          "identity_exchange": {
            "const": false,
            "type": "boolean"
          },
          "protocol": {
            "const": "launch-external-licensing-v1",
            "type": "string"
          },
          "purchase_types": {
            "items": {
              "enum": [
                "perpetual",
                "fixed_term"
              ],
              "type": "string"
            },
            "minItems": 1,
            "type": "array"
          }
        },
        "required": [
          "protocol",
          "connection_ref",
          "environment",
          "purchase_types",
          "delivery_types"
        ],
        "type": "object"
      },
      "ExternalCapabilitiesResponse": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExternalCapabilities"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "type": "object"
      },
      "ExternalDelivery": {
        "additionalProperties": false,
        "properties": {
          "connection_ref": {
            "pattern": "^[A-Za-z0-9_.-]{1,128}$",
            "type": "string"
          },
          "delivery": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ExternalDeliveryValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "entitlement_ref": {
            "pattern": "^[A-Za-z0-9_-]{1,128}$",
            "type": "string"
          },
          "environment": {
            "enum": [
              "sandbox",
              "live"
            ],
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "ready",
              "unavailable"
            ],
            "type": "string"
          },
          "version": {
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "connection_ref",
          "environment",
          "entitlement_ref",
          "version",
          "status",
          "delivery"
        ],
        "type": "object"
      },
      "ExternalDeliveryResponse": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExternalDelivery"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "type": "object"
      },
      "ExternalDeliveryValue": {
        "additionalProperties": false,
        "properties": {
          "expires_at": {
            "anyOf": [
              {
                "format": "date-time",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": {
            "enum": [
              "license_key",
              "activation_url",
              "instructions"
            ],
            "type": "string"
          },
          "value": {
            "description": "Contenu sensible ; maximum 4096 octets UTF-8. Ne jamais le journaliser. Les URL d’activation doivent utiliser une origine HTTPS configurée.",
            "maxLength": 4096,
            "type": "string"
          }
        },
        "required": [
          "type",
          "value",
          "expires_at"
        ],
        "type": "object"
      },
      "ExternalError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "type": "object"
      },
      "ExternalReceipt": {
        "additionalProperties": false,
        "properties": {
          "connection_ref": {
            "pattern": "^[A-Za-z0-9_.-]{1,128}$",
            "type": "string"
          },
          "entitlement_ref": {
            "pattern": "^[A-Za-z0-9_-]{1,128}$",
            "type": "string"
          },
          "environment": {
            "enum": [
              "sandbox",
              "live"
            ],
            "type": "string"
          },
          "error_code": {
            "anyOf": [
              {
                "maxLength": 96,
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "event_id": {
            "format": "uuid",
            "type": "string"
          },
          "payload_sha256": {
            "pattern": "^[0-9a-f]{64}$",
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "applied",
              "rejected",
              "manual_review"
            ],
            "type": "string"
          },
          "version": {
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "event_id",
          "connection_ref",
          "environment",
          "entitlement_ref",
          "version",
          "payload_sha256",
          "status",
          "error_code"
        ],
        "type": "object"
      },
      "ExternalReceiptResponse": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExternalReceipt"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "type": "object"
      },
      "ExternalSnapshot": {
        "additionalProperties": false,
        "properties": {
          "account_ref": {
            "pattern": "^[A-Za-z0-9_-]{1,128}$",
            "type": "string"
          },
          "change_reason": {
            "enum": [
              "purchase",
              "renewal",
              "upgrade",
              "refund",
              "reversal",
              "suspension",
              "resumption",
              "expiry",
              "reconciliation"
            ],
            "type": "string"
          },
          "connection_ref": {
            "pattern": "^[A-Za-z0-9_.-]{1,128}$",
            "type": "string"
          },
          "desired_state": {
            "enum": [
              "active",
              "suspended",
              "expired",
              "revoked"
            ],
            "type": "string"
          },
          "entitlement_ref": {
            "pattern": "^[A-Za-z0-9_-]{1,128}$",
            "type": "string"
          },
          "environment": {
            "enum": [
              "sandbox",
              "live"
            ],
            "type": "string"
          },
          "event_id": {
            "format": "uuid",
            "type": "string"
          },
          "launch_plan_version_id": {
            "format": "uuid",
            "type": "string"
          },
          "launch_product_id": {
            "format": "uuid",
            "type": "string"
          },
          "plan_ref": {
            "pattern": "^[A-Za-z0-9_.-]{1,128}$",
            "type": "string"
          },
          "product_ref": {
            "pattern": "^[A-Za-z0-9_.-]{1,128}$",
            "type": "string"
          },
          "schema": {
            "const": "launch-external-licensing-v1",
            "type": "string"
          },
          "type": {
            "const": "entitlement.snapshot",
            "type": "string"
          },
          "valid_from": {
            "format": "date-time",
            "type": "string"
          },
          "valid_until": {
            "anyOf": [
              {
                "format": "date-time",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "version": {
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "schema",
          "event_id",
          "connection_ref",
          "environment",
          "type",
          "change_reason",
          "account_ref",
          "entitlement_ref",
          "launch_product_id",
          "launch_plan_version_id",
          "product_ref",
          "plan_ref",
          "version",
          "desired_state",
          "valid_from",
          "valid_until"
        ],
        "type": "object"
      }
    }
  },
  "info": {
    "description": "Mis en œuvre par le service de licences marchandes, appelé par Launch. Il s'agit d'un protocole état-commercial, pas d'un générateur de licences ou d'un SDK d'exécution. Les octets exacts de la requête sont signés ; les tentatives de nouvelle envoi conservent l'ID de l'événement et la charge utile. Lisez le guide d'intégration fourni.",
    "title": "Pont de licence externe Launch",
    "version": "1.0.0",
    "x-document-language": "fr"
  },
  "openapi": "3.1.0",
  "paths": {
    "/launch/v1/capabilities": {
      "get": {
        "operationId": "externalCapabilities",
        "parameters": [
          {
            "description": "L'ID de clé configuré.",
            "in": "header",
            "name": "X-Launch-Key-Id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Secondes Unix décimales, dans +/-300 secondes.",
            "in": "header",
            "name": "X-Launch-Timestamp",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Au moins 16 octets aléatoires, base64url sans remplissage ; éviter les doublons pendant 600 secondes.",
            "in": "header",
            "name": "X-Launch-Nonce",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "v1=base64url(HMAC-SHA256(key, requête canonique)); voir le guide d'intégration pour les octets exacts.",
            "in": "header",
            "name": "X-Launch-Signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCapabilitiesResponse"
                }
              }
            },
            "description": "Réponse réussie"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Signature ou horodatage invalide"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Incompatibilité connexion/environnement"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Rejeu, idempotence ou conflit d'état"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Limité par le débit ; respecter Retry-After"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Temporairement indisponible"
          }
        },
        "summary": "Valider la connexion et le protocole pris en charge"
      }
    },
    "/launch/v1/entitlements/{entitlement_ref}/delivery": {
      "get": {
        "operationId": "getExternalDelivery",
        "parameters": [
          {
            "description": "L'ID de clé configuré.",
            "in": "header",
            "name": "X-Launch-Key-Id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Secondes Unix décimales, dans +/-300 secondes.",
            "in": "header",
            "name": "X-Launch-Timestamp",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Au moins 16 octets aléatoires, base64url sans remplissage ; éviter les doublons pendant 600 secondes.",
            "in": "header",
            "name": "X-Launch-Nonce",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "v1=base64url(HMAC-SHA256(key, requête canonique)); voir le guide d'intégration pour les octets exacts.",
            "in": "header",
            "name": "X-Launch-Signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "entitlement_ref",
            "required": true,
            "schema": {
              "pattern": "^[A-Za-z0-9_-]{1,128}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalDeliveryResponse"
                }
              }
            },
            "description": "Réponse réussie"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Signature ou horodatage invalide"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Incompatibilité connexion/environnement"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Aucun achat de ce type"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Rejeu, idempotence ou conflit d'état"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Limité par le débit ; respecter Retry-After"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Temporairement indisponible"
          }
        },
        "summary": "Lire la livraison existante ; ne jamais créer une autre licence"
      }
    },
    "/launch/v1/events": {
      "post": {
        "operationId": "submitExternalPurchase",
        "parameters": [
          {
            "description": "L'ID de clé configuré.",
            "in": "header",
            "name": "X-Launch-Key-Id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Secondes Unix décimales, dans +/-300 secondes.",
            "in": "header",
            "name": "X-Launch-Timestamp",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Au moins 16 octets aléatoires, base64url sans remplissage ; éviter les doublons pendant 600 secondes.",
            "in": "header",
            "name": "X-Launch-Nonce",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "v1=base64url(HMAC-SHA256(key, requête canonique)); voir le guide d'intégration pour les octets exacts.",
            "in": "header",
            "name": "X-Launch-Signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalSnapshot"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalReceiptResponse"
                }
              }
            },
            "description": "Événement existant ou résultat appliqué de manière synchrone"
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalReceiptResponse"
                }
              }
            },
            "description": "Accepté de façon durable ; en attente n'est pas une réalisation"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Signature ou horodatage invalide"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Incompatibilité connexion/environnement"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Rejeu, idempotence ou conflit d'état"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Plan inconnu ou type d'achat non pris en charge"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Limité par le débit ; respecter Retry-After"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Temporairement indisponible"
          }
        },
        "summary": "Conserver un instantané complet et absolu de l'achat ; ne pas émettre deux fois"
      }
    },
    "/launch/v1/events/{event_id}": {
      "get": {
        "operationId": "getExternalEvent",
        "parameters": [
          {
            "description": "L'ID de clé configuré.",
            "in": "header",
            "name": "X-Launch-Key-Id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Secondes Unix décimales, dans +/-300 secondes.",
            "in": "header",
            "name": "X-Launch-Timestamp",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Au moins 16 octets aléatoires, base64url sans remplissage ; éviter les doublons pendant 600 secondes.",
            "in": "header",
            "name": "X-Launch-Nonce",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "v1=base64url(HMAC-SHA256(key, requête canonique)); voir le guide d'intégration pour les octets exacts.",
            "in": "header",
            "name": "X-Launch-Signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "event_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalReceiptResponse"
                }
              }
            },
            "description": "Réponse réussie"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Signature ou horodatage invalide"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Incompatibilité connexion/environnement"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "EVENT_NOT_FOUND : seul ce résultat permet de renvoyer l'événement original"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Rejeu, idempotence ou conflit d'état"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Limité par le débit ; respecter Retry-After"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalError"
                }
              }
            },
            "description": "Temporairement indisponible"
          }
        },
        "summary": "Récupérer/interroger le reçu de l'événement original"
      }
    }
  },
  "servers": [
    {
      "url": "https://licenses.example.com"
    }
  ]
}
