{
  "info": {
    "name": "Fatoora Partner API",
    "description": "Collection pour l'intégration partenaire Fatoora — soumettre des factures TEIF au nom d'une organisation cliente autorisée.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://business.fatoora.tn",
      "type": "string"
    },
    {
      "key": "client_id",
      "value": "ak_partner_sample00000000",
      "type": "string"
    },
    {
      "key": "client_secret",
      "value": "YOUR_SECRET_ID_HERE",
      "type": "string"
    },
    {
      "key": "org_id",
      "value": "TARGET_CLIENT_ORG_UUID",
      "type": "string"
    },
    {
      "key": "access_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "app_only_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "invoice_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "job_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhook_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhook_secret",
      "value": "",
      "type": "string"
    },
    {
      "key": "tax_id",
      "value": "1234567ABC000",
      "type": "string"
    },
    {
      "key": "seller_tax_id",
      "value": "1234567ABC000",
      "type": "string"
    },
    {
      "key": "buyer_tax_id",
      "value": "1234567RAM000",
      "type": "string"
    },
    {
      "key": "seller_name",
      "value": "Ma Société SARL",
      "type": "string"
    },
    {
      "key": "buyer_name",
      "value": "Mon Client SARL",
      "type": "string"
    },
    {
      "key": "seller_address_desc",
      "value": "Avenue Habib, Tunis",
      "type": "string"
    },
    {
      "key": "seller_street",
      "value": "Avenue Habib",
      "type": "string"
    },
    {
      "key": "seller_city",
      "value": "Tunis",
      "type": "string"
    },
    {
      "key": "seller_postal_code",
      "value": "3455",
      "type": "string"
    },
    {
      "key": "buyer_address_desc",
      "value": "RUE Habib, Tunis",
      "type": "string"
    },
    {
      "key": "buyer_street",
      "value": "RUE Habib",
      "type": "string"
    },
    {
      "key": "buyer_city",
      "value": "Tunis",
      "type": "string"
    },
    {
      "key": "buyer_postal_code",
      "value": "1000",
      "type": "string"
    },
    {
      "key": "seller_phone",
      "value": "23445656",
      "type": "string"
    },
    {
      "key": "seller_email",
      "value": "contact@masociete.tn",
      "type": "string"
    },
    {
      "key": "seller_contact_id",
      "value": "C001",
      "type": "string"
    },
    {
      "key": "seller_contact_name",
      "value": "Service Facturation",
      "type": "string"
    },
    {
      "key": "invoice_number",
      "value": "FACT-2026-000001",
      "type": "string"
    },
    {
      "key": "invoice_date_ddMMyy",
      "value": "150726",
      "type": "string"
    },
    {
      "key": "line1_item_id",
      "value": "1",
      "type": "string"
    },
    {
      "key": "line1_item_code",
      "value": "ART-001",
      "type": "string"
    },
    {
      "key": "line1_description",
      "value": "Mon article client",
      "type": "string"
    },
    {
      "key": "line1_qty",
      "value": "2",
      "type": "string"
    },
    {
      "key": "line1_unit",
      "value": "PCE",
      "type": "string"
    },
    {
      "key": "line1_ht",
      "value": "1000.000",
      "type": "string"
    },
    {
      "key": "line1_ttc",
      "value": "1190.000",
      "type": "string"
    },
    {
      "key": "total_ht",
      "value": "1000.000",
      "type": "string"
    },
    {
      "key": "total_tva_pct",
      "value": "19",
      "type": "string"
    },
    {
      "key": "total_tva",
      "value": "190.000",
      "type": "string"
    },
    {
      "key": "total_timbre",
      "value": "5.000",
      "type": "string"
    },
    {
      "key": "total_taxes",
      "value": "195.000",
      "type": "string"
    },
    {
      "key": "total_ttc",
      "value": "1195.000",
      "type": "string"
    },
    {
      "key": "partner_app_id",
      "value": "partn_sample000000000000",
      "type": "string"
    },
    {
      "key": "payment_condition_code",
      "value": "I-122",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "🔐 Authentification",
      "item": [
        {
          "name": "1 — Token app-only (découverte orgs, sans org_id)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.access_token) {",
                  "  pm.collectionVariables.set('app_only_token', json.access_token);",
                  "  console.log('✅ app_only_token sauvegardé. Expire dans ' + json.expires_in + 's');",
                  "} else {",
                  "  console.error('❌ Pas de access_token:', JSON.stringify(json));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/x-www-form-urlencoded"
              }
            ],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "client_credentials",
                  "description": "Doit être 'client_credentials'"
                },
                {
                  "key": "client_id",
                  "value": "{{client_id}}",
                  "description": "Votre App ID (page identifiants)"
                },
                {
                  "key": "client_secret",
                  "value": "{{client_secret}}",
                  "description": "Votre Secret ID (page identifiants)"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/oauth/token",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "oauth",
                "token"
              ]
            },
            "description": "Obtenir un token **app-only** (sans org_id) pour les API de découverte des organisations.\n\nCe token est lié à votre application partenaire uniquement — il n'agit pas au nom d'une organisation cliente.\n\n**Utilisez-le pour** :\n- `GET /api/partner/authorized-orgs`\n- `GET /api/partner/resolve-org?taxId=XXX`\n\nLe script de test sauvegarde automatiquement le token dans la variable `app_only_token`."
          },
          "response": [
            {
              "name": "200 OK — app-only token",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/oauth/token",
                  "host": [
                    "{{base_url}}/oauth/token"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6InBhcnRuX3h4eHgifQ.SIGNATURE\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 3600,\n  \"scope\": \"invoice:write invoice:read ttn:submit\"\n}"
            },
            {
              "name": "401 Unauthorized — invalid_client",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/oauth/token",
                  "host": [
                    "{{base_url}}/oauth/token"
                  ]
                }
              },
              "status": "Unauthorized",
              "code": 401,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"error\": \"invalid_client\",\n  \"error_description\": \"Invalid client credentials.\"\n}"
            }
          ]
        },
        {
          "name": "2 — Token org-scoped (factures, signature)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.access_token) {",
                  "  pm.collectionVariables.set('access_token', json.access_token);",
                  "  console.log('✅ access_token sauvegardé. Expire dans ' + json.expires_in + 's');",
                  "  console.log('Scopes effectifs:', json.scope);",
                  "} else {",
                  "  console.error('❌ Pas de access_token:', JSON.stringify(json));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/x-www-form-urlencoded"
              }
            ],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "client_credentials",
                  "description": "Doit être 'client_credentials'"
                },
                {
                  "key": "client_id",
                  "value": "{{client_id}}",
                  "description": "Votre App ID (page identifiants)"
                },
                {
                  "key": "client_secret",
                  "value": "{{client_secret}}",
                  "description": "Votre Secret ID (page identifiants)"
                },
                {
                  "key": "org_id",
                  "value": "{{org_id}}",
                  "description": "UUID de l'organisation cliente cible — obtenu via l'étape découverte"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/oauth/token",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "oauth",
                "token"
              ]
            },
            "description": "Obtenir un token **org-scoped** pour agir au nom d'une organisation cliente spécifique.\n\n**org_id** : UUID de l'organisation cliente — récupéré via `GET /api/partner/resolve-org` ou `GET /api/partner/authorized-orgs`.\n\n**Utilisez ce token pour** :\n- `POST /api/core-proxy/invoices/submit`\n- `POST /api/core-proxy/invoices/submit-xml`\n- `POST /api/core-proxy/invoices/:id/sign-and-send`\n\nLe script de test sauvegarde automatiquement le token dans la variable `access_token`."
          },
          "response": [
            {
              "name": "200 OK — org-scoped token",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/oauth/token",
                  "host": [
                    "{{base_url}}/oauth/token"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJwYXJ0bl94eHh4Iiwib3JnSWQiOiJvcmdfeHh4eCJ9.SIGNATURE\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 3600,\n  \"scope\": \"invoice:write invoice:read ttn:submit seal:sign\"\n}"
            },
            {
              "name": "403 Forbidden — org not authorized",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/oauth/token",
                  "host": [
                    "{{base_url}}/oauth/token"
                  ]
                }
              },
              "status": "Forbidden",
              "code": 403,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"error\": \"access_denied\",\n  \"error_description\": \"Organization has not authorized this partner application.\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "🏢 Découverte des organisations",
      "item": [
        {
          "name": "Lister les organisations autorisées",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "const orgs = json.authorizedOrgs || [];",
                  "if (orgs.length > 0) {",
                  "  pm.collectionVariables.set('org_id', orgs[0].orgId);",
                  "  pm.collectionVariables.set('seller_tax_id', orgs[0].taxIdentifier);",
                  "  console.log('✅ org_id sauvegardé (1ère org) :', orgs[0].orgId, '—', orgs[0].orgName);",
                  "  console.log('✅ seller_tax_id sauvegardé :', orgs[0].taxIdentifier);",
                  "  console.log('   Matricule :', orgs[0].taxIdentifier);",
                  "  console.log('   Scopes :', (orgs[0].allowedScopes || []).join(', '));",
                  "  if (orgs.length > 1) {",
                  "    console.log('ℹ️ ' + (orgs.length - 1) + ' autre(s) org(s) disponible(s). Modifiez {{org_id}} manuellement si besoin.');",
                  "  }",
                  "} else {",
                  "  console.warn('⚠️ Aucune organisation autorisée trouvée.');",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{app_only_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/partner/authorized-orgs",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "partner",
                "authorized-orgs"
              ]
            },
            "description": "Récupérer toutes les organisations qui ont autorisé cette application partenaire.\n\n**Token requis** : `app_only_token` (obtenu via l'authentification #1 sans org_id).\n\n**Script de test automatique** : sauvegarde l'`org_id` de la première organisation dans `{{org_id}}` — utilisé par l'authentification #2 pour obtenir un token org-scoped."
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/partner/authorized-orgs",
                  "host": [
                    "{{base_url}}/api/partner/authorized-orgs"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"authorizedOrgs\": [\n    {\n      \"orgId\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n      \"orgName\": \"Société ABC SARL\",\n      \"taxIdentifier\": \"1234567ABCD000\",\n      \"allowedScopes\": [\n        \"invoice:write\",\n        \"invoice:read\",\n        \"seal:sign\",\n        \"ttn:submit\"\n      ],\n      \"authorizedAt\": \"2026-05-01 10:00:00.000000\"\n    }\n  ],\n  \"total\": 1\n}"
            }
          ]
        },
        {
          "name": "Résoudre un matricule fiscal → org_id",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.orgId) {",
                  "  pm.collectionVariables.set('org_id', json.orgId);",
                  "  console.log('✅ org_id sauvegardé :', json.orgId, '—', json.orgName);",
                  "  console.log('   Matricule :', json.taxIdentifier);",
                  "  console.log('   Scopes :', (json.allowedScopes || []).join(', '));",
                  "} else if (json.error === 'ORG_NOT_FOUND') {",
                  "  console.error('❌ Matricule non trouvé. Vérifiez {{tax_id}} et que l\\'organisation a bien autorisé votre app.');",
                  "} else {",
                  "  console.error('❌ Erreur :', JSON.stringify(json));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{app_only_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/partner/resolve-org?taxId={{seller_tax_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "partner",
                "resolve-org"
              ],
              "query": [
                {
                  "key": "taxId",
                  "value": "{{seller_tax_id}}",
                  "description": "Matricule fiscal (8 ou 13 caractères)"
                }
              ]
            },
            "description": "Résoudre un matricule fiscal tunisien (8 ou 13 caractères) en org_id Fatoora.\n\n**Token requis** : `app_only_token` (obtenu via l'authentification #1 sans org_id).\n\n**Formats acceptés** :\n- 8 car. : `NNNNNNNL` (ancien format)\n- 13 car. : `NNNNNNNLCCCNNN` (nouveau format)\n\n**Script de test automatique** : sauvegarde l'`org_id` résolu dans `{{org_id}}` — utilisé ensuite par l'authentification #2."
          },
          "response": [
            {
              "name": "200 OK — resolved",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/partner/resolve-org?taxId={{seller_tax_id}}",
                  "host": [
                    "{{base_url}}/api/partner/resolve-org?taxId={{seller_tax_id}}"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"orgId\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n  \"orgName\": \"Société ABC SARL\",\n  \"taxIdentifier\": \"1234567ABCD000\",\n  \"allowedScopes\": [\n    \"invoice:write\",\n    \"seal:sign\"\n  ],\n  \"authorizedAt\": \"2026-05-01 10:00:00.000000\"\n}"
            },
            {
              "name": "404 Not Found — ORG_NOT_FOUND",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/partner/resolve-org?taxId={{tax_id}}",
                  "host": [
                    "{{base_url}}/api/partner/resolve-org?taxId={{tax_id}}"
                  ]
                }
              },
              "status": "Not Found",
              "code": 404,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"error\": \"ORG_NOT_FOUND\",\n  \"message\": \"Aucune organisation autorisée trouvée pour le matricule \\\"{{tax_id}}\\\". Assurez-vous que l'organisation a bien activé votre application partenaire.\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "📄 Factures — JSON TEIF",
      "item": [
        {
          "name": "Soumettre une facture (JSON TEIF)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201 || pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  if (json.id) {",
                  "    pm.collectionVariables.set('invoice_id', json.id);",
                  "    console.log('✅ invoice_id sauvegardé :', json.id);",
                  "  }",
                  "} else {",
                  "  console.error('❌ Facture non créée, invoice_id inchangé:', pm.response.text());",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Allow-Partner-Upsert",
                "value": "true"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"version\": \"1.8.8\",\n  \"controlingAgency\": \"TTN\",\n  \"header\": {\n    \"MessageSenderIdentifier\": {\n      \"@type\": \"I-01\",\n      \"#text\": \"{{seller_tax_id}}\"\n    },\n    \"MessageRecieverIdentifier\": {\n      \"@type\": \"I-01\",\n      \"#text\": \"{{buyer_tax_id}}\"\n    }\n  },\n  \"body\": {\n    \"bgm\": {\n      \"documentIdentifier\": \"{{invoice_number}}\",\n      \"documentTypeCode\": \"I-11\",\n      \"documentType\": \"Facture\"\n    },\n    \"dtm\": {\n      \"dateText\": [\n        {\n          \"functionCode\": \"I-31\",\n          \"format\": \"ddMMyy\",\n          \"value\": \"{{invoice_date_ddMMyy}}\"\n        }\n      ]\n    },\n    \"partnerSection\": {\n      \"partnerDetails\": [\n        {\n          \"functionCode\": \"I-62\",\n          \"nad\": {\n            \"partnerIdentifier\": {\n              \"type\": \"I-01\",\n              \"value\": \"{{seller_tax_id}}\"\n            },\n            \"partnerName\": {\n              \"nameType\": \"Qualification\",\n              \"value\": \"{{seller_name}}\"\n            },\n            \"partnerAdresses\": [\n              {\n                \"adressDescription\": \"Siège social\",\n                \"street\": \"{{seller_street}}\",\n                \"cityName\": \"{{seller_city}}\",\n                \"postalCode\": \"{{seller_postal_code}}\",\n                \"country\": {\n                  \"codeList\": \"ISO_3166-1\",\n                  \"value\": \"TN\"\n                }\n              }\n            ]\n          },\n          \"ctaSection\": [],\n          \"rffSection\": [],\n          \"loc\": []\n        },\n        {\n          \"functionCode\": \"I-61\",\n          \"nad\": {\n            \"partnerIdentifier\": {\n              \"type\": \"I-01\",\n              \"value\": \"{{buyer_tax_id}}\"\n            },\n            \"partnerName\": {\n              \"nameType\": \"Qualification\",\n              \"value\": \"{{buyer_name}}\"\n            },\n            \"partnerAdresses\": [\n              {\n                \"adressDescription\": \"Siège social\",\n                \"street\": \"{{buyer_street}}\",\n                \"cityName\": \"{{buyer_city}}\",\n                \"postalCode\": \"{{buyer_postal_code}}\",\n                \"country\": {\n                  \"codeList\": \"ISO_3166-1\",\n                  \"value\": \"TN\"\n                }\n              }\n            ]\n          },\n          \"ctaSection\": [],\n          \"rffSection\": [],\n          \"loc\": []\n        }\n      ]\n    },\n    \"linSection\": {\n      \"lin\": [\n        {\n          \"itemIdentifier\": \"1\",\n          \"linImd\": {\n            \"lang\": \"fr\",\n            \"itemCode\": \"{{line1_item_code}}\",\n            \"itemDescription\": \"{{line1_description}}\"\n          },\n          \"linQty\": {\n            \"quantity\": {\n              \"measurementUnit\": \"C62\",\n              \"value\": \"{{line1_qty}}\"\n            }\n          },\n          \"linTax\": {\n            \"taxTypeName\": {\n              \"code\": \"I-66\",\n              \"value\": \"TVA\"\n            },\n            \"taxDetails\": {\n              \"taxRate\": \"19\",\n              \"taxRateBasis\": \"Percentage\"\n            }\n          },\n          \"linMoa\": {\n            \"moaDetails\": [\n              {\n                \"moa\": {\n                  \"amountTypeCode\": \"I-188\",\n                  \"currencyCodeList\": \"ISO_4217\",\n                  \"amount\": {\n                    \"currencyIdentifier\": \"TND\",\n                    \"value\": \"{{line1_ht}}\"\n                  }\n                }\n              }\n            ]\n          },\n          \"subLin\": []\n        }\n      ]\n    },\n    \"invoiceTax\": {\n      \"invoiceTaxDetails\": [\n        {\n          \"tax\": {\n            \"taxTypeName\": {\n              \"code\": \"I-66\",\n              \"value\": \"TVA\"\n            },\n            \"taxCategory\": \"I-1602\",\n            \"taxDetails\": {\n              \"taxRate\": \"19.000\",\n              \"taxRateBasis\": \"Percentage\"\n            }\n          },\n          \"amountDetails\": [\n            {\n              \"moa\": {\n                \"amountTypeCode\": \"I-177\",\n                \"currencyCodeList\": \"ISO_4217\",\n                \"amount\": {\n                  \"currencyIdentifier\": \"TND\",\n                  \"value\": \"{{total_ht}}\"\n                }\n              }\n            },\n            {\n              \"moa\": {\n                \"amountTypeCode\": \"I-178\",\n                \"currencyCodeList\": \"ISO_4217\",\n                \"amount\": {\n                  \"currencyIdentifier\": \"TND\",\n                  \"value\": \"{{total_tva}}\"\n                }\n              }\n            }\n          ]\n        }\n      ]\n    },\n    \"invoiceMoa\": {\n      \"amountDetails\": [\n        {\n          \"moa\": {\n            \"amountTypeCode\": \"I-172\",\n            \"currencyCodeList\": \"ISO_4217\",\n            \"amount\": {\n              \"currencyIdentifier\": \"TND\",\n              \"value\": \"{{total_ht}}\"\n            }\n          }\n        },\n        {\n          \"moa\": {\n            \"amountTypeCode\": \"I-181\",\n            \"currencyCodeList\": \"ISO_4217\",\n            \"amount\": {\n              \"currencyIdentifier\": \"TND\",\n              \"value\": \"{{total_taxes}}\"\n            }\n          }\n        },\n        {\n          \"moa\": {\n            \"amountTypeCode\": \"I-180\",\n            \"currencyCodeList\": \"ISO_4217\",\n            \"amount\": {\n              \"currencyIdentifier\": \"TND\",\n              \"value\": \"{{total_ttc}}\"\n            }\n          }\n        },\n        {\n          \"moa\": {\n            \"amountTypeCode\": \"I-177\",\n            \"currencyCodeList\": \"ISO_4217\",\n            \"amount\": {\n              \"currencyIdentifier\": \"TND\",\n              \"value\": \"{{total_ht}}\"\n            }\n          }\n        },\n        {\n          \"moa\": {\n            \"amountTypeCode\": \"I-176\",\n            \"currencyCodeList\": \"ISO_4217\",\n            \"amount\": {\n              \"currencyIdentifier\": \"TND\",\n              \"value\": \"{{total_ht}}\"\n            }\n          }\n        }\n      ]\n    },\n    \"pyt\": {\n      \"pytSectionDetails\": [\n        {\n          \"pytPai\": {\n            \"paiConditionCode\": \"{{payment_condition_code}}\",\n            \"paiMeansCode\": \"42\"\n          }\n        }\n      ]\n    }\n  },\n  \"additionnalDocuments\": null,\n  \"refTtnVal\": null,\n  \"signatures\": []\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices/submit",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices",
                "submit"
              ]
            },
            "description": "Soumettre une facture TEIF au nom de l'organisation cliente spécifiée dans le token.\n\n**Scope requis** : `invoice:write`\n\n**Types de document (documentTypeCode)** :\n- `I-11` → Facture standard\n- `I-12` → Note de débit\n- `I-13` → Avoir (crédit)"
          },
          "response": [
            {
              "name": "201 Created",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/submit",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/submit"
                  ]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n  \"orgId\": \"{{org_id}}\",\n  \"invoiceNumber\": \"FACT-2026-000001\",\n  \"invoiceTypeCode\": \"I-11\",\n  \"invoiceDate\": \"2026-07-12\",\n  \"status\": \"VALIDATED\",\n  \"senderName\": \"Ma Société SARL\",\n  \"receiverName\": \"Mon Client SARL\",\n  \"receiverIdentifierType\": \"I-01\",\n  \"receiverIdentifierValue\": \"1234567RAM000\",\n  \"totalAmountExclTax\": 1000,\n  \"totalTaxAmount\": null,\n  \"totalAmountInclTax\": null,\n  \"currencyCode\": \"TND\",\n  \"ttnGeneratedRef\": null,\n  \"ttnIdSaveEfact\": null,\n  \"createdAt\": \"2026-07-11T20:04:58.237547\",\n  \"submittedAt\": \"2026-07-11T20:04:58.223037\",\n  \"signedAt\": null,\n  \"createdBy\": \"{{client_id}}\",\n  \"isQuotation\": false,\n  \"quotationStatus\": null,\n  \"duplicateCopy\": false,\n  \"importSource\": null,\n  \"importBlockedResign\": false,\n  \"direction\": \"SENT\",\n  \"partnerAppId\": \"{{partner_app_id}}\"\n}"
            },
            {
              "name": "400 Bad Request — validation error",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/submit",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/submit"
                  ]
                }
              },
              "status": "Bad Request",
              "code": 400,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"code\": \"VALIDATION_ERROR\",\n  \"error\": \"VALIDATION_ERROR\",\n  \"message\": \"TEIF payload failed schema validation.\",\n  \"details\": [\n    {\n      \"field\": \"body.partnerSection.partnerDetails[1].nad.partnerAdresses\",\n      \"reason\": \"Address is required to auto-create a new partner (X-Allow-Partner-Upsert).\"\n    }\n  ],\n  \"path\": \"/api/v1/invoices/submit\",\n  \"timestamp\": \"2026-07-11T00:00:00Z\",\n  \"status\": 400\n}"
            }
          ]
        },
        {
          "name": "Lister les factures du partenaire",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/partner/invoices",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "partner",
                "invoices"
              ]
            },
            "description": "Récupérer toutes les factures soumises par votre app sur toutes les organisations autorisées.\n\n**Scope requis** : `invoice:read`"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/partner/invoices",
                  "host": [
                    "{{base_url}}/api/partner/invoices"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"invoices\": [\n    {\n      \"id\": \"inv_xxxxxxxxxxxxxxxx\",\n      \"teifId\": \"FACT-2026-000001\",\n      \"invoiceNumber\": \"FACT-2026-000001\",\n      \"invoiceDate\": \"2026-07-11\",\n      \"organizationId\": \"org_xxxx\",\n      \"organizationName\": \"Mon Client SARL\",\n      \"status\": \"ACCEPTED_TTN\",\n      \"totalAmount\": 1195,\n      \"totalAmountExclTax\": 1000,\n      \"totalTaxAmount\": 195,\n      \"currency\": \"TND\",\n      \"ttnGeneratedRef\": \"TTN-REF-000123\",\n      \"submittedAt\": \"2026-07-11T00:00:00Z\",\n      \"signedAt\": \"2026-07-11T00:05:00Z\",\n      \"createdAt\": \"2026-07-11T00:00:00Z\"\n    }\n  ]\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "📋 Factures — Consultation",
      "item": [
        {
          "name": "Lister les factures (paginé)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices?page=0&pageSize=20&direction=SENT",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "0",
                  "description": "Numéro de page (commence à 0)"
                },
                {
                  "key": "pageSize",
                  "value": "20",
                  "description": "Nombre de résultats par page (max 100)"
                },
                {
                  "key": "direction",
                  "value": "SENT",
                  "description": "SENT = factures émises, RECEIVED = reçues"
                },
                {
                  "key": "status",
                  "value": "",
                  "description": "Filtrer par statut : DRAFT, SIGNED, ACCEPTED_TTN, REJECTED — laisser vide pour tous",
                  "disabled": true
                },
                {
                  "key": "invoiceNumber",
                  "value": "",
                  "description": "Recherche par numéro de facture (partiel)",
                  "disabled": true
                },
                {
                  "key": "startDate",
                  "value": "",
                  "description": "Date de début ISO 8601 (ex: 2026-01-01)",
                  "disabled": true
                },
                {
                  "key": "endDate",
                  "value": "",
                  "description": "Date de fin ISO 8601 (ex: 2026-12-31)",
                  "disabled": true
                }
              ]
            },
            "description": "Lister les factures de l'organisation cliente liée au token (org-scoped), avec pagination.\n\n**Scope requis** : `invoice:read`\n\n**Paramètres de pagination** :\n- `page` : numéro de page (0-indexé)\n- `pageSize` : résultats par page (défaut 20, max 100)\n\n**Filtres disponibles** :\n- `direction` : `SENT` (émises) / `RECEIVED` (reçues)\n- `status` : `DRAFT`, `SIGNED`, `ACCEPTED_TTN`, `REJECTED`\n- `invoiceNumber` : recherche partielle\n- `startDate` / `endDate` : plage de dates\n\n**Réponse** : `{ content: [...], totalElements, totalPages, number, size }`"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices?page=0&pageSize=20&direction=SENT",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices?page=0&pageSize=20&direction=SENT"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"content\": [\n    {\n      \"id\": \"inv_xxxxxxxxxxxxxxxx\",\n      \"invoiceNumber\": \"FACT-2026-000001\",\n      \"invoiceTypeCode\": \"I-11\",\n      \"invoiceDate\": \"2026-07-11\",\n      \"status\": \"ACCEPTED_TTN\",\n      \"senderName\": \"Ma Société SARL\",\n      \"receiverName\": \"Mon Client SARL\",\n      \"totalAmountExclTax\": 1000,\n      \"totalTaxAmount\": 195,\n      \"totalAmountInclTax\": 1195,\n      \"currencyCode\": \"TND\",\n      \"ttnGeneratedRef\": \"TTN-REF-000123\",\n      \"direction\": \"SENT\"\n    }\n  ],\n  \"page\": 0,\n  \"pageSize\": 20,\n  \"totalElements\": 1,\n  \"totalPages\": 1\n}"
            }
          ]
        },
        {
          "name": "Détail d'une facture",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices",
                "{{invoice_id}}"
              ]
            },
            "description": "Récupérer les détails complets d'une facture par son ID interne Fatoora.\n\n**Scope requis** : `invoice:read`\n\n**Réponse** : `{ invoice, teifJson, teifXml, ttnQrCodeBase64, localSignedXml, validationErrors, ttnAcknowledgments }` — l'objet facture est dans le champ `invoice`, avec le JSON et le XML TEIF générés inclus directement dans la réponse.\n\n**Statuts possibles** (`invoice.status`) :\n- `DRAFT` / `SUBMITTED` / `VALIDATED` : en amont de la signature\n- `SIGNED` / `SENT_TTN` : signée, en attente ou en cours d'envoi TTN\n- `ACCEPTED_TTN` : acceptée par TTN (Tunisia Trade Net)\n- `REJECTED_TTN` : rejetée\n\n**Note** : il n'existe pas d'endpoint dédié pour le statut seul — lisez le champ `status` de cette réponse."
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"invoice\": {\n    \"id\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n    \"orgId\": \"{{org_id}}\",\n    \"invoiceNumber\": \"FACT-2026-000001\",\n    \"invoiceTypeCode\": \"I-11\",\n    \"invoiceDate\": \"2026-07-12\",\n    \"status\": \"VALIDATED\",\n    \"senderName\": \"Ma Société SARL\",\n    \"receiverName\": \"Mon Client SARL\",\n    \"receiverIdentifierType\": \"I-01\",\n    \"receiverIdentifierValue\": \"1234567RAM000\",\n    \"totalAmountExclTax\": 1000,\n    \"totalTaxAmount\": 195,\n    \"totalAmountInclTax\": 1195,\n    \"currencyCode\": \"TND\",\n    \"ttnGeneratedRef\": null,\n    \"ttnIdSaveEfact\": null,\n    \"createdAt\": \"2026-07-11T20:05:48.103042\",\n    \"submittedAt\": \"2026-07-11T20:05:48.102170\",\n    \"signedAt\": null,\n    \"createdBy\": \"{{client_id}}\",\n    \"isQuotation\": false,\n    \"quotationStatus\": null,\n    \"duplicateCopy\": false,\n    \"importSource\": null,\n    \"importBlockedResign\": false,\n    \"direction\": \"SENT\",\n    \"partnerAppId\": \"{{partner_app_id}}\"\n  },\n  \"teifJson\": \"{\\\"body\\\":{\\\"bgm\\\":{...}},\\\"header\\\":{...},\\\"version\\\":\\\"1.8.8\\\"}\",\n  \"teifXml\": \"<TEIF controlingAgency=\\\"TTN\\\" version=\\\"1.8.8\\\">...</TEIF>\",\n  \"ttnQrCodeBase64\": null,\n  \"localSignedXml\": null,\n  \"validationErrors\": null,\n  \"ttnAcknowledgments\": null\n}"
            },
            {
              "name": "404 Not Found",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}"
                  ]
                }
              },
              "status": "Not Found",
              "code": 404,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"error\": \"InvoiceNotFoundException\",\n  \"message\": \"Invoice not found.\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "📋 Factures — XML TEIF",
      "item": [
        {
          "name": "Soumettre une facture (XML TEIF)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201 || pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  if (json.id) {",
                  "    pm.collectionVariables.set('invoice_id', json.id);",
                  "    console.log('✅ invoice_id sauvegardé :', json.id);",
                  "  }",
                  "} else {",
                  "  console.error('❌ Facture non créée, invoice_id inchangé:', pm.response.text());",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/xml"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "<TEIF controlingAgency=\"TTN\" version=\"1.8.8\">\n<InvoiceHeader>\n                  <MessageSenderIdentifier type=\"I-01\">{{seller_tax_id}}</MessageSenderIdentifier>\n<MessageRecieverIdentifier type=\"I-01\">{{buyer_tax_id}}</MessageRecieverIdentifier>\n</InvoiceHeader>\n<InvoiceBody>\n<Bgm>\n<DocumentIdentifier>{{invoice_number}}</DocumentIdentifier>\n<DocumentType code=\"I-11\">Facture</DocumentType>\n</Bgm>\n<Dtm>\n<DateText format=\"ddMMyy\" functionCode=\"I-31\">{{invoice_date_ddMMyy}}</DateText>\n</Dtm>\n<PartnerSection>\n<PartnerDetails functionCode=\"I-63\">\n<Nad>\n<PartnerIdentifier type=\"I-01\">{{seller_tax_id}}</PartnerIdentifier>\n<PartnerName nameType=\"Physical\">{{seller_name}}</PartnerName>\n<PartnerAdresses lang=\"fr\">\n<AdressDescription>{{seller_address_desc}}</AdressDescription>\n<Street>{{seller_street}}</Street>\n<CityName>{{seller_city}}</CityName>\n<PostalCode>{{seller_postal_code}}</PostalCode>\n<Country codeList=\"ISO_3166-1\">TN</Country>\n</PartnerAdresses>\n</Nad>\n<CtaSection>\n<Contact functionCode=\"I-91\">\n<ContactIdentifier>{{seller_phone}}</ContactIdentifier>\n<ContactName>{{seller_contact_name}}</ContactName>\n</Contact>\n<Communication>\n<ComMeansType>I-102</ComMeansType>\n<ComAdress>{{seller_phone}}</ComAdress>\n</Communication>\n</CtaSection>\n<CtaSection>\n<Contact functionCode=\"I-91\">\n<ContactIdentifier>{{seller_contact_id}}</ContactIdentifier>\n<ContactName>{{seller_contact_name}}</ContactName>\n</Contact>\n<Communication>\n<ComMeansType>I-101</ComMeansType>\n<ComAdress>{{seller_email}}</ComAdress>\n</Communication>\n</CtaSection>\n</PartnerDetails>\n<PartnerDetails functionCode=\"I-64\">\n<Nad>\n<PartnerIdentifier type=\"I-01\">{{buyer_tax_id}}</PartnerIdentifier>\n<PartnerName nameType=\"Physical\">{{buyer_name}}</PartnerName>\n<PartnerAdresses lang=\"fr\">\n<AdressDescription>{{buyer_address_desc}}</AdressDescription>\n<Street>{{buyer_street}}</Street>\n<CityName>{{buyer_city}}</CityName>\n<PostalCode>{{buyer_postal_code}}</PostalCode>\n                                  <Country codeList=\"ISO_3166-1\">TN</Country>\n</PartnerAdresses>\n</Nad>\n</PartnerDetails>\n</PartnerSection>\n<LinSection>\n<Lin>\n<ItemIdentifier>{{line1_item_id}}</ItemIdentifier>\n<LinImd lang=\"fr\">\n<ItemCode>{{line1_item_code}}</ItemCode>\n<ItemDescription>{{line1_description}}</ItemDescription>\n</LinImd>\n<LinQty>\n<Quantity measurementUnit=\"{{line1_unit}}\">{{line1_qty}}</Quantity>\n</LinQty>\n<LinTax>\n<TaxTypeName code=\"I-1602\">TVA</TaxTypeName>\n<TaxCategory>S</TaxCategory>\n<TaxDetails>\n<TaxRate>{{total_tva_pct}}</TaxRate>\n</TaxDetails>\n</LinTax>\n<LinMoa>\n<MoaDetails>\n<Moa amountTypeCode=\"I-188\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{line1_ht}}</Amount>\n</Moa>\n</MoaDetails>\n<MoaDetails>\n<Moa amountTypeCode=\"I-171\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{line1_ht}}</Amount>\n</Moa>\n</MoaDetails>\n</LinMoa>\n</Lin>\n</LinSection>\n<InvoiceMoa>\n<AmountDetails>\n<Moa amountTypeCode=\"I-172\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_ht}}</Amount>\n</Moa>\n</AmountDetails>\n<AmountDetails>\n<Moa amountTypeCode=\"I-181\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_taxes}}</Amount>\n</Moa>\n</AmountDetails>\n<AmountDetails>\n<Moa amountTypeCode=\"I-180\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_ttc}}</Amount>\n</Moa>\n</AmountDetails>\n<AmountDetails>\n<Moa amountTypeCode=\"I-177\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_ht}}</Amount>\n</Moa>\n</AmountDetails>\n<AmountDetails>\n<Moa amountTypeCode=\"I-176\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_ht}}</Amount>\n</Moa>\n</AmountDetails>\n</InvoiceMoa>\n<InvoiceTax>\n<InvoiceTaxDetails>\n<Tax>\n<TaxTypeName code=\"I-1602\">TVA</TaxTypeName>\n<TaxCategory>S</TaxCategory>\n<TaxDetails>\n<TaxRate>{{total_tva_pct}}</TaxRate>\n</TaxDetails>\n</Tax>\n<AmountDetails>\n<Moa amountTypeCode=\"I-178\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_tva}}</Amount>\n</Moa>\n</AmountDetails>\n</InvoiceTaxDetails>\n<InvoiceTaxDetails>\n<Tax>\n<TaxTypeName code=\"I-1601\">Timbre</TaxTypeName>\n<TaxCategory>O</TaxCategory>\n<TaxDetails>\n<TaxRate>0</TaxRate>\n</TaxDetails>\n</Tax>\n<AmountDetails>\n<Moa amountTypeCode=\"I-178\" currencyCodeList=\"ISO_4217\">\n<Amount currencyIdentifier=\"TND\">{{total_timbre}}</Amount>\n</Moa>\n</AmountDetails>\n</InvoiceTaxDetails>\n</InvoiceTax>\n</InvoiceBody>\n</TEIF>",
              "options": {
                "raw": {
                  "language": "xml"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices/submit-xml",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices",
                "submit-xml"
              ]
            }
          },
          "response": [
            {
              "name": "201 Created",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/submit-xml",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/submit-xml"
                  ]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n  \"orgId\": \"{{org_id}}\",\n  \"invoiceNumber\": \"FACT-2026-000001\",\n  \"invoiceTypeCode\": \"I-11\",\n  \"invoiceDate\": \"2026-07-12\",\n  \"status\": \"VALIDATED\",\n  \"senderName\": \"Ma Société SARL\",\n  \"receiverName\": \"Mon Client SARL\",\n  \"receiverIdentifierType\": \"I-01\",\n  \"receiverIdentifierValue\": \"1234567RAM000\",\n  \"totalAmountExclTax\": 1000,\n  \"totalTaxAmount\": 195,\n  \"totalAmountInclTax\": 1195,\n  \"currencyCode\": \"TND\",\n  \"ttnGeneratedRef\": null,\n  \"ttnIdSaveEfact\": null,\n  \"createdAt\": \"2026-07-11T20:05:48.103042\",\n  \"submittedAt\": \"2026-07-11T20:05:48.102170\",\n  \"signedAt\": null,\n  \"createdBy\": \"{{client_id}}\",\n  \"isQuotation\": false,\n  \"quotationStatus\": null,\n  \"duplicateCopy\": false,\n  \"importSource\": null,\n  \"importBlockedResign\": false,\n  \"direction\": \"SENT\",\n  \"partnerAppId\": \"{{partner_app_id}}\"\n}"
            }
          ]
        },
        {
          "name": "Valider un XML (XSD uniquement)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"xml\": \"<TEIF controlingAgency=\\\"TTN\\\" version=\\\"1.8.8\\\"><InvoiceHeader><MessageSenderIdentifier type=\\\"I-01\\\">1234567ABC000</MessageSenderIdentifier><MessageRecieverIdentifier type=\\\"I-01\\\">1234567RAM000</MessageRecieverIdentifier></InvoiceHeader><InvoiceBody><!-- ... corps complet ... --></InvoiceBody></TEIF>\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/core-proxy/teif/validate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "teif",
                "validate"
              ]
            },
            "description": "Valider un XML TEIF contre le schéma XSD sans créer de facture. Utile pour tester votre XML avant soumission.\n\n**Attention au chemin** : c'est bien `/api/core-proxy/teif/validate` (pas `/api/core-proxy/invoices/teif/validate-xml-xsd`, qui 404 — c'est le chemin interne de fatooraCore, jamais exposé tel quel par le BFF). Le champ du corps est `xml`, pas `xmlContent`."
          },
          "response": [
            {
              "name": "200 OK — valid",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/teif/validate",
                  "host": [
                    "{{base_url}}/api/core-proxy/teif/validate"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"valid\": true,\n  \"issues\": []\n}"
            },
            {
              "name": "200 OK — invalid",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/teif/validate",
                  "host": [
                    "{{base_url}}/api/core-proxy/teif/validate"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"valid\": false,\n  \"issues\": [\n    {\n      \"type\": \"XML_SCHEMA_VIOLATION\",\n      \"message\": \"schema rule (cvc-)complex-type.2.4.a: Invalid content was found starting with element 'NotValid'. One of '{InvoiceHeader}' is expected.\",\n      \"severity\": \"ERROR\",\n      \"xpath\": \"line:1\"\n    }\n  ]\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "✍️ Signature et envoi TTN",
      "item": [
        {
          "name": "Signer et envoyer à TTN (SEAL)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.jobId) {",
                  "  pm.collectionVariables.set('job_id', json.jobId);",
                  "  console.log('✅ job_id sauvegardé :', json.jobId);",
                  "} else {",
                  "  console.error('❌ Pas de jobId:', JSON.stringify(json));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"signatureType\": \"SEAL\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/sign-and-send",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices",
                "{{invoice_id}}",
                "sign-and-send"
              ]
            },
            "description": "Déclencher la signature automatique SEAL et l'envoi à TTN (Tunisia Trade Net) en une seule opération.\n\n**Scopes requis** : `invoice:write` + `seal:sign`\n\n**Pré-requis** : L'organisation cliente doit avoir accordé le scope `seal:sign` ET avoir une configuration SEAL active.\n\n**Vérifiez** `allowedScopes` de l'étape 0 avant d'appeler cet endpoint.\n\nPour DigiGO, utilisez `\"signatureType\": \"DIGIGO\"` avec le scope `digigo:sign`.\n\nLe script de test sauvegarde automatiquement le `jobId` dans la variable `job_id` — utilisé ensuite pour interroger `GET /api/core-proxy/jobs/{{job_id}}`."
          },
          "response": [
            {
              "name": "200 OK — job created (SEAL)",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/sign-and-send",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/sign-and-send"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"jobId\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n  \"invoiceId\": \"{{invoice_id}}\",\n  \"jobType\": \"SIGN_AND_SUBMIT_SEAL\",\n  \"status\": \"PENDING\",\n  \"success\": true,\n  \"message\": \"Invoice queued for signature and TTN submission\"\n}"
            },
            {
              "name": "402 Payment Required — no signature credits",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/sign-and-send",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/sign-and-send"
                  ]
                }
              },
              "status": "Payment Required",
              "code": 402,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"error\": \"NO_SIGNATURE_CREDITS\",\n  \"message\": \"No signing quota or signature-pack credits available. Buy a pack or subscribe/upgrade to sign and submit to TTN.\",\n  \"packsRemaining\": 0\n}"
            }
          ]
        },
        {
          "name": "Suivre le job de signature (poll)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/jobs/{{job_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "jobs",
                "{{job_id}}"
              ]
            },
            "description": "Interroger le statut du job créé par `sign-and-send` (asynchrone). `status` passe de `PENDING` à `COMPLETED` ou `FAILED`. En cas d'échec, `outputData` détaille l'étape fautive (ex. certificat SEAL/DigiGO non configuré).\n\n**Scope requis** : `invoice:read`"
          },
          "response": [
            {
              "name": "200 OK — completed",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/jobs/{{job_id}}",
                  "host": [
                    "{{base_url}}/api/core-proxy/jobs/{{job_id}}"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"jobId\": \"{{job_id}}\",\n  \"invoiceId\": \"{{invoice_id}}\",\n  \"jobType\": \"SIGN_AND_SUBMIT_SEAL\",\n  \"status\": \"COMPLETED\",\n  \"progress\": 100,\n  \"currentStep\": \"TTN_SUBMISSION\",\n  \"errorMessage\": null,\n  \"errorData\": null,\n  \"outputData\": {\n    \"step0CertVerification\": {\n      \"valid\": true,\n      \"success\": true\n    }\n  },\n  \"signatureResult\": {\n    \"signed\": true\n  },\n  \"ttnSubmissionResult\": {\n    \"accepted\": true,\n    \"ttnGeneratedRef\": \"TTN-REF-000123\"\n  },\n  \"ttnFinalResult\": {\n    \"status\": \"ACCEPTED_TTN\"\n  },\n  \"createdAt\": \"2026-07-11T20:07:14.706Z\",\n  \"startedAt\": \"2026-07-11T20:07:14.836Z\",\n  \"completedAt\": \"2026-07-11T20:07:16.943Z\",\n  \"retryCount\": 0\n}"
            },
            {
              "name": "200 OK — failed (missing signing credential)",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/jobs/{{job_id}}",
                  "host": [
                    "{{base_url}}/api/core-proxy/jobs/{{job_id}}"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"jobId\": \"{{job_id}}\",\n  \"invoiceId\": \"{{invoice_id}}\",\n  \"jobType\": \"SIGN_AND_SUBMIT_DIGIGO\",\n  \"status\": \"FAILED\",\n  \"progress\": 0,\n  \"currentStep\": \"CERT_VERIFICATION\",\n  \"errorMessage\": null,\n  \"errorData\": null,\n  \"outputData\": {\n    \"step0CertVerification\": {\n      \"error\": \"Credential ID DigiGO (email) non configuré pour cette organisation\",\n      \"valid\": false,\n      \"success\": false,\n      \"errorCode\": \"MISSING_DIGIGO_CREDENTIAL_ID\",\n      \"certificates\": []\n    }\n  },\n  \"signatureResult\": null,\n  \"ttnSubmissionResult\": null,\n  \"ttnFinalResult\": null,\n  \"createdAt\": \"2026-07-11T20:07:14.706Z\",\n  \"startedAt\": \"2026-07-11T20:07:14.836Z\",\n  \"completedAt\": \"2026-07-11T20:07:14.943Z\",\n  \"retryCount\": 0\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "📎 Artefacts (XML / PDF)",
      "item": [
        {
          "name": "Télécharger le PDF de la facture",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/pdf",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices",
                "{{invoice_id}}",
                "pdf"
              ],
              "query": [
                {
                  "key": "pdfTemplate",
                  "value": "",
                  "description": "Optionnel — sinon le modèle par défaut de l'organisation cliente est utilisé",
                  "disabled": true
                },
                {
                  "key": "lang",
                  "value": "",
                  "description": "Optionnel — langue du document (fr/en/ar)",
                  "disabled": true
                }
              ]
            },
            "description": "Réponse binaire (`application/pdf`), quel que soit le statut de la facture (brouillon inclus).\n\n**Scope requis** : `invoice:read`."
          },
          "response": []
        },
        {
          "name": "Récupérer le XML TEIF généré",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/generated-xml",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "invoices",
                "{{invoice_id}}",
                "generated-xml"
              ]
            },
            "description": "⚠️ **Au-delà du statut SIGNED, cet endpoint régénère un XML NON SIGNÉ à la volée** (il perd la signature et le QR code TTN). Pour l'artefact final réellement signé/horodaté TTN, lisez plutôt le champ `teifXml` retourné par « Détail d'une facture » (`GET /api/core-proxy/invoices/{{invoice_id}}`), pas cet endpoint.\n\n**Scope requis** : `invoice:read`."
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/generated-xml",
                  "host": [
                    "{{base_url}}/api/core-proxy/invoices/{{invoice_id}}/generated-xml"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"note\": \"corps brut application/xml, pas du JSON\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "🏢 Organisation cliente",
      "item": [
        {
          "name": "Récupérer l’identité générale de l’organisation cliente",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/organization",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "organization"
              ]
            },
            "description": "Retourne uniquement orgId, orgName et taxIdentifier pour l’organisation liée au token org-scoped. Les plans, crédits, statistiques, clés API et indicateurs internes restent privés."
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/organization",
                  "host": [
                    "{{base_url}}/api/core-proxy/organization"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"orgId\": \"5b1e2b7a-4c31-4e2a-9d9a-7b0f9e6a1234\",\n  \"orgName\": \"Société ABC SARL\",\n  \"taxIdentifier\": \"1234567ABCD000\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "🔔 Webhooks",
      "item": [
        {
          "name": "Créer un webhook",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.id) {",
                  "  pm.collectionVariables.set('webhook_id', json.id);",
                  "  if (json.secret) { pm.collectionVariables.set('webhook_secret', json.secret); }",
                  "  console.log('✅ webhook_id sauvegardé :', json.id);",
                  "  console.log('🔑 webhook_secret (à conserver, non réaffiché) :', json.secret);",
                  "} else {",
                  "  console.error('❌ Webhook non créé :', JSON.stringify(json));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://votre-erp.example.com/webhooks/fatoora\",\n  \"events\": [\n    \"invoice.validated\",\n    \"invoice.signed\",\n    \"invoice.accepted_ttn\",\n    \"invoice.rejected_ttn\"\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/core-proxy/webhooks",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "webhooks"
              ]
            },
            "description": "Crée un abonnement webhook pour l'organisation cliente ciblée par le token org-scoped (`{{access_token}}` obtenu à l'étape 1 — aucun header `X-Org-ID` à gérer manuellement, il est déduit automatiquement du token).\n\n**Scope requis** : `invoice:write`\n\n**Pré-requis** : votre application partenaire doit être autorisée pour cette organisation (sinon `401 PARTNER_NOT_AUTHORIZED`).\n\nLe `secret` est retourné **une seule fois** dans cette réponse — sauvegardez-le, il sert à vérifier la signature `X-HMAC-Signature` des évènements reçus.\n\n**Types d'évènements par défaut** (si `events` est omis) : `invoice.created`, `invoice.validated`, `invoice.signed`, `invoice.submitted_ttn`, `invoice.accepted_ttn`, `invoice.rejected_ttn`, `webhook.test`. Ajoutez explicitement `invoice.validation_failed` si vous en avez besoin (non inclus par défaut)."
          },
          "response": [
            {
              "name": "201 Created",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/webhooks",
                  "host": [
                    "{{base_url}}/api/core-proxy/webhooks"
                  ]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"wh_xxxxxxxxxxxxxxxx\",\n  \"appId\": \"{{client_id}}\",\n  \"url\": \"https://votre-erp.example.com/webhooks/fatoora\",\n  \"events\": [\n    \"invoice.validated\",\n    \"invoice.signed\",\n    \"invoice.accepted_ttn\",\n    \"invoice.rejected_ttn\"\n  ],\n  \"status\": \"ACTIVE\",\n  \"secret\": \"whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n  \"expiresAt\": \"2026-08-14T00:00:00\",\n  \"createdAt\": \"2026-07-15T00:00:00\"\n}"
            },
            {
              "name": "401 Unauthorized — partenaire non autorisé",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/webhooks",
                  "host": [
                    "{{base_url}}/api/core-proxy/webhooks"
                  ]
                }
              },
              "status": "Unauthorized",
              "code": 401,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"errorCode\": \"PARTNER_NOT_AUTHORIZED\",\n  \"message\": \"Partner application is not authorized for this organization.\"\n}"
            }
          ]
        },
        {
          "name": "Lister les webhooks",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/webhooks",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "webhooks"
              ]
            },
            "description": "Liste les webhooks que **votre application partenaire** a créés pour cette organisation cliente (pas ceux créés par la clé API propre de l'organisation, ni par un autre partenaire).\n\n**Scope requis** : `invoice:read`"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/webhooks",
                  "host": [
                    "{{base_url}}/api/core-proxy/webhooks"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "[\n  {\n    \"id\": \"{{webhook_id}}\",\n    \"appId\": \"{{client_id}}\",\n    \"url\": \"https://votre-erp.example.com/webhooks/fatoora\",\n    \"events\": [\n      \"invoice.validated\",\n      \"invoice.signed\"\n    ],\n    \"status\": \"ACTIVE\",\n    \"expiresAt\": \"2026-08-14T00:00:00\",\n    \"createdAt\": \"2026-07-15T00:00:00\"\n  }\n]"
            }
          ]
        },
        {
          "name": "Envoyer un évènement de test",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/webhooks/{{webhook_id}}/test",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "webhooks",
                "{{webhook_id}}",
                "test"
              ]
            },
            "description": "Déclenche un évènement `webhook.test` livré immédiatement à l'URL configurée — utile pour valider votre récepteur (vérification de signature comprise) avant de traiter de vrais évènements de facture.\n\n**Scope requis** : `invoice:write`"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/webhooks/{{webhook_id}}/test",
                  "host": [
                    "{{base_url}}/api/core-proxy/webhooks/{{webhook_id}}/test"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"status\": \"queued\",\n  \"subscriptionId\": \"{{webhook_id}}\",\n  \"eventType\": \"webhook.test\"\n}"
            }
          ]
        },
        {
          "name": "Supprimer un webhook",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/core-proxy/webhooks/{{webhook_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "core-proxy",
                "webhooks",
                "{{webhook_id}}"
              ]
            },
            "description": "**Scope requis** : `invoice:write`"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "DELETE",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/api/core-proxy/webhooks/{{webhook_id}}",
                  "host": [
                    "{{base_url}}/api/core-proxy/webhooks/{{webhook_id}}"
                  ]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"deleted\": true,\n  \"id\": \"{{webhook_id}}\"\n}"
            }
          ]
        }
      ]
    }
  ]
}
