{
  "_meta": {
    "document": "Aide-Mémoire Interne & Référentiel des Commandes API Qonto v2 — PAC360 (SASU P'TIT HOLDING)",
    "version": "1.0.0",
    "updated_at": "2026-11-28",
    "base_url": "https://thirdparty.qonto.com/v2",
    "accounting_sync": "Synchronisation automatique Qonto -> Dougs (Mode Avancé par clé API toutes les 4h : transactions + PDF Factur-X rattachés)"
  },
  "organization_extracted_live": {
    "organization_id": "01a203b7-edfb-7e3e-8090-4cfd897f91a8",
    "legal_name": "P'TIT HOLDING",
    "legal_form": "SASU",
    "legal_share_capital_eur": 33000.0,
    "siret": "13083982200017",
    "naf_code": "7010Z",
    "legal_address": "4 RUE DE LA NANTAISERIE 44370 LOIREAUXENCE FRANCE",
    "qonto_login_slug": "p-tit-holding-1360",
    "primary_bank_account": {
      "QONTO_BANK_ACCOUNT_ID": "01a203b9-c3b3-778e-ba93-8a043619f396",
      "QONTO_BANK_ACCOUNT_SLUG": "p-tit-holding-1360-bank-account-1",
      "name": "Compte principal",
      "status": "active",
      "currency": "EUR",
      "QONTO_IBAN": "FR7616958000018231092847076",
      "QONTO_BIC": "QNTOFRP1XXX"
    }
  },
  "authentication_modes": {
    "mode_1_api_key_direct": {
      "description": "Authentification directe par Clé API (Login + Clé Secrète générée dans Paramètres > Intégrations et Partenariats > Clé API). Utilisée par PAC360 et par Dougs (Mode Avancé).",
      "http_header": "Authorization: p-tit-holding-1360:<QONTO_SECRET_KEY>",
      "endpoints_supported_immediately": [
        "GET /v2/organization",
        "GET /v2/transactions",
        "GET /v2/clients",
        "POST /v2/clients",
        "GET /v2/client_invoices",
        "POST /v2/client_invoices",
        "GET /v2/quotes",
        "POST /v2/quotes",
        "GET /v2/credit_notes",
        "GET /v2/statements",
        "GET /v2/labels",
        "GET /v2/memberships",
        "GET /v2/beneficiaries",
        "GET /v2/external_transfers"
      ]
    },
    "mode_2_oauth2_bearer": {
      "description": "Authentification OAuth 2.0 Bearer (requise uniquement pour les endpoints de Prélèvement SEPA Direct Debit, Payment Links Mollie et création de Webhooks par API).",
      "http_header": "Authorization: Bearer <QONTO_OAUTH_TOKEN>",
      "required_scopes": [
        "organization.read",
        "client.read",
        "client.write",
        "client_invoice.read",
        "client_invoice.write",
        "payment_link.read",
        "payment_link.write",
        "sepa_direct_debit.read",
        "sepa_direct_debit.write",
        "webhook"
      ],
      "endpoints_requiring_oauth2": [
        "GET/POST /v2/sepa/direct_debit_mandates",
        "GET/POST /v2/sepa/direct_debit_subscriptions",
        "GET/POST /v2/payment_links",
        "GET/POST /v2/webhook_subscriptions"
      ]
    }
  },
  "commands_catalog": {
    "1_get_organization_and_bank_account": {
      "title": "Récupérer les informations de la société et l'UUID du compte bancaire (bank_account_id)",
      "auth_type": "API Key (login:secret_key)",
      "method": "GET",
      "endpoint": "https://thirdparty.qonto.com/v2/organization",
      "curl_example": "curl -s -X GET \"https://thirdparty.qonto.com/v2/organization\" -H \"Authorization: p-tit-holding-1360:$QONTO_SECRET_KEY\" -H \"Accept: application/json\"",
      "php_pac360_helper": "$bankAccountId = \\PAC360\\Config\\QontoHandler::resolvePrimaryBankAccountId();"
    },
    "2_list_incoming_transactions": {
      "title": "Lister les encaissements (virements & prélèvements reçus) sur le compte principal P'tit Holding",
      "auth_type": "API Key (login:secret_key)",
      "method": "GET",
      "endpoint": "https://thirdparty.qonto.com/v2/transactions?bank_account_id=01a203b9-c3b3-778e-ba93-8a043619f396&side=credit",
      "query_params": {
        "bank_account_id": "01a203b9-c3b3-778e-ba93-8a043619f396",
        "side": "credit (encaissements uniquement) ou debit (dépenses)",
        "status[]": "completed",
        "updated_at_from": "2026-11-01T00:00:00.000Z"
      },
      "curl_example": "curl -s -X GET \"https://thirdparty.qonto.com/v2/transactions?bank_account_id=01a203b9-c3b3-778e-ba93-8a043619f396&side=credit\" -H \"Authorization: p-tit-holding-1360:$QONTO_SECRET_KEY\" -H \"Accept: application/json\"",
      "php_pac360_helper": "$tx = \\PAC360\\Config\\QontoHandler::callQontoApi('/v2/transactions', ['bank_account_id' => '01a203b9-c3b3-778e-ba93-8a043619f396', 'side' => 'credit'], 'GET');"
    },
    "3_list_b2b_clients": {
      "title": "Lister ou rechercher un client B2B dans Qonto",
      "auth_type": "API Key (login:secret_key)",
      "method": "GET",
      "endpoint": "https://thirdparty.qonto.com/v2/clients",
      "curl_example": "curl -s -X GET \"https://thirdparty.qonto.com/v2/clients?email=client@entreprise-cvc.fr\" -H \"Authorization: p-tit-holding-1360:$QONTO_SECRET_KEY\" -H \"Accept: application/json\"",
      "php_pac360_helper": "$clients = \\PAC360\\Config\\QontoHandler::callQontoApi('/v2/clients', ['email' => $email], 'GET');"
    },
    "4_create_b2b_client": {
      "title": "Créer un client professionnel B2B avec SIRET dans Qonto",
      "auth_type": "API Key (login:secret_key)",
      "method": "POST",
      "endpoint": "https://thirdparty.qonto.com/v2/clients",
      "payload_example": {
        "name": "SARL CLIMATISATION DUPONT",
        "type": "company",
        "email": "contact@clim-dupont.fr",
        "tax_identification_number": "12345678900014",
        "currency": "EUR",
        "locale": "fr",
        "billing_address": {
          "street_address": "12 Rue des Artisans",
          "city": "Nantes",
          "zip_code": "44000",
          "country_code": "FR"
        }
      },
      "curl_example": "curl -s -X POST \"https://thirdparty.qonto.com/v2/clients\" -H \"Authorization: p-tit-holding-1360:$QONTO_SECRET_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"SARL CLIMATISATION DUPONT\",\"type\":\"company\",\"email\":\"contact@clim-dupont.fr\",\"tax_identification_number\":\"12345678900014\",\"currency\":\"EUR\",\"locale\":\"fr\"}'",
      "php_pac360_helper": "$clientId = \\PAC360\\Config\\QontoHandler::createOrGetClient($email, $companyName, $siret);"
    },
    "5_create_client_invoice_facturx_dougs": {
      "title": "Émettre une facture client Factur-X (série dédiée PAC360- conforme CGI Art. 242 nonies A pour remontée auto dans Dougs)",
      "auth_type": "API Key (login:secret_key)",
      "method": "POST",
      "endpoint": "https://thirdparty.qonto.com/v2/client_invoices",
      "payload_example": {
        "client_id": "<UUID_CLIENT_QONTO>",
        "issue_date": "2026-11-28",
        "due_date": "2026-11-28",
        "currency": "EUR",
        "number": "PAC360-20261128-A1B2C3",
        "payment_methods": {
          "iban": "FR7616958000018231092847076"
        },
        "items": [
          {
            "title": "PAC360 - Abonnement Artisan Solo Illimité (Annuel - 2 mois offerts)",
            "description": "Licence annuelle de dimensionnement réglementaire CVC PAC360 (1 utilisateur)",
            "quantity": "1",
            "unit_price": {
              "value": "290.00",
              "currency": "EUR"
            },
            "vat_rate": "0.20"
          }
        ],
        "footer": "Facture émise par SASU P'tit Holding (PAC360) — Synchronisation comptable automatique Qonto -> Dougs (Série dédiée CGI Art. 242 nonies A)."
      },
      "php_pac360_helper": "$invoice = \\PAC360\\Config\\QontoHandler::createClientInvoice($qontoClientId, 'plan_solo_annuel', 0, ['user_id' => $userId]);"
    },
    "6_list_client_invoices": {
      "title": "Lister les factures clients et vérifier leur statut de paiement (unpaid / paid / canceled)",
      "auth_type": "API Key (login:secret_key)",
      "method": "GET",
      "endpoint": "https://thirdparty.qonto.com/v2/client_invoices",
      "query_params": {
        "status": "paid | unpaid | draft | canceled"
      },
      "curl_example": "curl -s -X GET \"https://thirdparty.qonto.com/v2/client_invoices?status=paid\" -H \"Authorization: p-tit-holding-1360:$QONTO_SECRET_KEY\" -H \"Accept: application/json\"",
      "php_pac360_helper": "$paidInvoices = \\PAC360\\Config\\QontoHandler::callQontoApi('/v2/client_invoices', ['status' => 'paid'], 'GET');"
    },
    "7_create_sepa_direct_debit_subscription": {
      "title": "Créer un abonnement récurrent par Prélèvement SEPA B2B (nécessite ICS actif + jeton OAuth2)",
      "auth_type": "OAuth 2.0 Bearer (scope: sepa_direct_debit.write)",
      "method": "POST",
      "endpoint": "https://thirdparty.qonto.com/v2/sepa/direct_debit_subscriptions",
      "payload_example": {
        "direct_debit_subscription": {
          "client_id": "<UUID_CLIENT_QONTO>",
          "bank_account_id": "01a203b9-c3b3-778e-ba93-8a043619f396",
          "initial_collection_date": "2026-11-30",
          "amount": {
            "value": "34.80",
            "currency": "EUR"
          },
          "reference": "PAC360-PLAN_SOLO_MENSUEL",
          "notify_client": true,
          "schedule_type": "monthly"
        }
      }
    },
    "8_create_invoice_payment_link": {
      "title": "Générer un lien de paiement CB / Virement instantané sur une facture Qonto (nécessite Liens de paiement Mollie actifs + OAuth2)",
      "auth_type": "OAuth 2.0 Bearer (scope: payment_link.write)",
      "method": "POST",
      "endpoint": "https://thirdparty.qonto.com/v2/payment_links",
      "payload_example": {
        "invoice_id": "<UUID_FACTURE_QONTO>",
        "client_id": "<UUID_CLIENT_QONTO>",
        "amount": {
          "value": "58.80",
          "currency": "EUR"
        },
        "potential_payment_methods": [
          "credit_card",
          "sepa_instant"
        ]
      }
    },
    "9_register_webhook_subscription": {
      "title": "Enregistrer le Webhook PAC360 auprès de Qonto par API",
      "auth_type": "OAuth 2.0 Bearer (scope: webhook)",
      "method": "POST",
      "endpoint": "https://thirdparty.qonto.com/v2/webhook_subscriptions",
      "payload_example": {
        "url": "https://api.pac360.fr/api/qonto_webhook.php",
        "types": [
          "v1/sepa-direct-debit-mandates",
          "v1/sepa-direct-debit-collections",
          "v1/payment-links",
          "v1/client-invoices"
        ]
      },
      "php_pac360_helper": "\\PAC360\\Config\\QontoHandler::autoRegisterWebhook('https://api.pac360.fr/api/qonto_webhook.php');"
    }
  }
}
