{
  "info": {
    "name": "Tondo",
    "description": "API globale du projet Tondo (par Paynala).\n\n## Structure\n\n- **API Dashboard** — endpoints `/api/admin/*` consommés par le dashboard Next.js. Auth via Laravel Sanctum (Bearer token sur `tondo_admins`).\n- **API Mobile** — endpoints `/api/mobile/*` consommés par l'app Flutter. Auth via Supabase phone OTP (middleware JWT à brancher — endpoints en stub 501 pour l'instant).\n- **Health** — endpoint public de monitoring.\n\n## Variables d'environnement\n\n- `base_url` : URL du backend Laravel (par défaut `http://127.0.0.1:8000`).\n- `admin_token` : automatiquement rempli après le login admin (Tests script du POST /api/admin/login).\n\n## Démarrage\n\n1. Lance `php artisan serve` dans `backend/`.\n2. Importe cette collection dans Postman.\n3. Exécute « API Dashboard → Auth → Login ». Le token est stocké automatiquement.\n4. Tous les autres endpoints utilisent ce token via Authorization Bearer auto-hérité.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_postman_id": "tondo-global-collection"
  },
  "auth": {
    "type": "noauth"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "http://127.0.0.1:8000",
      "type": "string"
    },
    {
      "key": "admin_token",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "GET /api/health",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/health", "host": ["{{base_url}}"], "path": ["api", "health"] }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status 200', () => pm.response.to.have.status(200));",
                  "pm.test('Service ok', () => pm.expect(pm.response.json().status).to.eql('ok'));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "API Dashboard",
      "description": "Endpoints consommés par le dashboard admin Next.js. Auth Sanctum.",
      "auth": {
        "type": "bearer",
        "bearer": [{ "key": "token", "value": "{{admin_token}}", "type": "string" }]
      },
      "item": [
        {
          "name": "Auth",
          "item": [
            {
              "name": "POST /api/admin/login",
              "request": {
                "auth": { "type": "noauth" },
                "method": "POST",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"email\": \"daniel@paynala.com\",\n  \"password\": \"S@rdines88\",\n  \"device_name\": \"postman\"\n}"
                },
                "url": { "raw": "{{base_url}}/api/admin/login", "host": ["{{base_url}}"], "path": ["api", "admin", "login"] }
              },
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test('Status 200', () => pm.response.to.have.status(200));",
                      "const data = pm.response.json();",
                      "pm.test('Token reçu', () => pm.expect(data.token).to.be.a('string'));",
                      "pm.collectionVariables.set('admin_token', data.token);",
                      "console.log('Token stocké dans la variable de collection admin_token.');"
                    ]
                  }
                }
              ]
            },
            {
              "name": "GET /api/admin/me",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/me", "host": ["{{base_url}}"], "path": ["api", "admin", "me"] }
              },
              "event": [
                {
                  "listen": "test",
                  "script": { "type": "text/javascript", "exec": ["pm.test('Status 200', () => pm.response.to.have.status(200));"] }
                }
              ]
            },
            {
              "name": "POST /api/admin/logout",
              "request": {
                "method": "POST",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/logout", "host": ["{{base_url}}"], "path": ["api", "admin", "logout"] }
              }
            }
          ]
        },
        {
          "name": "Utilisateurs",
          "description": "Gestion des end-users Tondo (mobile). Lecture seule via le dashboard.",
          "item": [
            {
              "name": "GET /api/admin/users",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/admin/users?per_page=25&page=1",
                  "host": ["{{base_url}}"],
                  "path": ["api", "admin", "users"],
                  "query": [
                    { "key": "per_page", "value": "25" },
                    { "key": "page", "value": "1" },
                    { "key": "q", "value": "", "disabled": true, "description": "recherche nom/prénom/numéro" },
                    { "key": "type_client", "value": "particulier", "disabled": true, "description": "particulier | entreprise | marchand" },
                    { "key": "kyc_valide_only", "value": "true", "disabled": true }
                  ]
                }
              }
            },
            {
              "name": "GET /api/admin/users/{id}",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/users/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "users", ":id"], "variable": [{ "key": "id", "value": "user-uuid" }] }
              }
            }
          ]
        },
        {
          "name": "Administrateurs",
          "description": "CRUD admins. Création/modif/suppression réservées à super_admin.",
          "item": [
            {
              "name": "GET /api/admin/admins",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/admin/admins?per_page=25",
                  "host": ["{{base_url}}"],
                  "path": ["api", "admin", "admins"],
                  "query": [
                    { "key": "per_page", "value": "25" },
                    { "key": "q", "value": "", "disabled": true },
                    { "key": "role", "value": "admin", "disabled": true, "description": "super_admin | admin | operateur | lecteur" }
                  ]
                }
              }
            },
            {
              "name": "POST /api/admin/admins",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"email\": \"nouvel.admin@paynala.com\",\n  \"password\": \"PasswordSolide123!\",\n  \"nom\": \"Dupont\",\n  \"prenom\": \"Marie\",\n  \"role\": \"operateur\"\n}"
                },
                "url": { "raw": "{{base_url}}/api/admin/admins", "host": ["{{base_url}}"], "path": ["api", "admin", "admins"] }
              }
            },
            {
              "name": "GET /api/admin/admins/{id}",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/admins/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "admins", ":id"], "variable": [{ "key": "id", "value": "admin-uuid" }] }
              }
            },
            {
              "name": "PATCH /api/admin/admins/{id}",
              "request": {
                "method": "PATCH",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"role\": \"admin\",\n  \"actif\": true\n}"
                },
                "url": { "raw": "{{base_url}}/api/admin/admins/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "admins", ":id"], "variable": [{ "key": "id", "value": "admin-uuid" }] }
              }
            },
            {
              "name": "DELETE /api/admin/admins/{id}",
              "request": {
                "method": "DELETE",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/admins/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "admins", ":id"], "variable": [{ "key": "id", "value": "admin-uuid" }] }
              }
            }
          ]
        },
        {
          "name": "Tontines & cotisations",
          "description": "Tondo_cagnottes (tontine périodique ET cotisation ouverte).",
          "item": [
            {
              "name": "GET /api/admin/tontines",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/admin/tontines?per_page=25",
                  "host": ["{{base_url}}"],
                  "path": ["api", "admin", "tontines"],
                  "query": [
                    { "key": "per_page", "value": "25" },
                    { "key": "q", "value": "", "disabled": true, "description": "search titre ou reference" },
                    { "key": "type", "value": "tontine_periodique", "disabled": true, "description": "tontine_periodique | cagnotte_ouverte" },
                    { "key": "statut", "value": "active", "disabled": true, "description": "active | cloturee" }
                  ]
                }
              }
            },
            {
              "name": "GET /api/admin/tontines/{id}",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/tontines/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "tontines", ":id"], "variable": [{ "key": "id", "value": "cagnotte-uuid" }] }
              }
            },
            {
              "name": "POST /api/admin/tontines/{id}/cloturer",
              "request": {
                "method": "POST",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/tontines/:id/cloturer", "host": ["{{base_url}}"], "path": ["api", "admin", "tontines", ":id", "cloturer"], "variable": [{ "key": "id", "value": "cagnotte-uuid" }] }
              }
            }
          ]
        },
        {
          "name": "Transactions",
          "description": "Mouvements Mobile Money : payin (cotisation), payout (vers bénéficiaire), payout_paynala (commission Paynala).",
          "item": [
            {
              "name": "GET /api/admin/transactions",
              "description": "Vue unifiée (union des 3 tables transactionnelles).",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/admin/transactions?per_page=25",
                  "host": ["{{base_url}}"],
                  "path": ["api", "admin", "transactions"],
                  "query": [
                    { "key": "per_page", "value": "25" },
                    { "key": "type", "value": "payin", "disabled": true, "description": "payin | payout | payout_paynala" },
                    { "key": "statut", "value": "succes", "disabled": true, "description": "initie | en_cours | succes | echec | annule" },
                    { "key": "q", "value": "", "disabled": true, "description": "search trans_id ou operateur_id" }
                  ]
                }
              }
            },
            {
              "name": "GET /api/admin/transactions/payin",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/transactions/payin?per_page=25", "host": ["{{base_url}}"], "path": ["api", "admin", "transactions", "payin"], "query": [{ "key": "per_page", "value": "25" }] }
              }
            },
            {
              "name": "GET /api/admin/transactions/payout",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/transactions/payout?per_page=25", "host": ["{{base_url}}"], "path": ["api", "admin", "transactions", "payout"], "query": [{ "key": "per_page", "value": "25" }] }
              }
            },
            {
              "name": "GET /api/admin/transactions/payout-paynala",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/transactions/payout-paynala?per_page=25", "host": ["{{base_url}}"], "path": ["api", "admin", "transactions", "payout-paynala"], "query": [{ "key": "per_page", "value": "25" }] }
              }
            }
          ]
        },
        {
          "name": "Signalements",
          "description": "Alertes utilisateurs (fraude suspectée, contenu inapproprié, doublon, autre).",
          "item": [
            {
              "name": "GET /api/admin/signalements",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/admin/signalements?per_page=25",
                  "host": ["{{base_url}}"],
                  "path": ["api", "admin", "signalements"],
                  "query": [
                    { "key": "per_page", "value": "25" },
                    { "key": "statut", "value": "nouveau", "disabled": true, "description": "nouveau | en_traitement | resolu | rejete" },
                    { "key": "motif", "value": "fraude_suspectee", "disabled": true }
                  ]
                }
              }
            },
            {
              "name": "GET /api/admin/signalements/{id}",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/admin/signalements/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "signalements", ":id"], "variable": [{ "key": "id", "value": "signalement-uuid" }] }
              }
            },
            {
              "name": "PATCH /api/admin/signalements/{id}",
              "request": {
                "method": "PATCH",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"statut\": \"resolu\",\n  \"resolu_commentaire\": \"Investigué, faux positif.\"\n}"
                },
                "url": { "raw": "{{base_url}}/api/admin/signalements/:id", "host": ["{{base_url}}"], "path": ["api", "admin", "signalements", ":id"], "variable": [{ "key": "id", "value": "signalement-uuid" }] }
              }
            }
          ]
        },
        {
          "name": "Logs",
          "item": [
            {
              "name": "GET /api/admin/logs",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                  "raw": "{{base_url}}/api/admin/logs?per_page=50",
                  "host": ["{{base_url}}"],
                  "path": ["api", "admin", "logs"],
                  "query": [
                    { "key": "per_page", "value": "50" },
                    { "key": "niveau", "value": "error", "disabled": true, "description": "info | warning | error" },
                    { "key": "acteur_role", "value": "admin", "disabled": true },
                    { "key": "q", "value": "", "disabled": true }
                  ]
                }
              }
            }
          ]
        }
      ]
    },
    {
      "name": "API Mobile",
      "description": "Endpoints consommés par l'app Flutter. Auth Supabase phone OTP (middleware JWT à coder).\n\n**⚠️ Tous en stub 501 pour l'instant.** À implémenter dans une session dédiée après câblage du middleware Supabase JWT.",
      "item": [
        {
          "name": "Auth",
          "item": [
            {
              "name": "POST /api/mobile/auth/check-phone",
              "description": "Vérifier qu'un numéro a déjà un compte Tondo (avant signUp).",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": { "mode": "raw", "raw": "{\n  \"numero\": \"+241XXXXXXXX\"\n}" },
                "url": { "raw": "{{base_url}}/api/mobile/auth/check-phone", "host": ["{{base_url}}"], "path": ["api", "mobile", "auth", "check-phone"] }
              }
            },
            {
              "name": "POST /api/mobile/auth/me",
              "request": {
                "method": "POST",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/mobile/auth/me", "host": ["{{base_url}}"], "path": ["api", "mobile", "auth", "me"] }
              }
            }
          ]
        },
        {
          "name": "Cagnottes",
          "item": [
            {
              "name": "GET /api/mobile/cagnottes",
              "description": "Liste les cagnottes du user connecté (gérées + cotisées).",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/mobile/cagnottes", "host": ["{{base_url}}"], "path": ["api", "mobile", "cagnottes"] }
              }
            },
            {
              "name": "POST /api/mobile/cagnottes",
              "description": "Créer une cagnotte (tontine ou cotisation).",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"type\": \"tontine_periodique\",\n  \"titre\": \"Tontine quartier\",\n  \"nombre_participants\": 12,\n  \"montant_par_cycle\": 50000,\n  \"periodicite\": \"mensuelle\",\n  \"jour_mois\": 5\n}"
                },
                "url": { "raw": "{{base_url}}/api/mobile/cagnottes", "host": ["{{base_url}}"], "path": ["api", "mobile", "cagnottes"] }
              }
            },
            {
              "name": "GET /api/mobile/cagnottes/{reference}",
              "description": "Détail par référence (5 chiffres affichés à l'utilisateur).",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/mobile/cagnottes/:reference", "host": ["{{base_url}}"], "path": ["api", "mobile", "cagnottes", ":reference"], "variable": [{ "key": "reference", "value": "12480" }] }
              }
            }
          ]
        },
        {
          "name": "Cotisations",
          "item": [
            {
              "name": "POST /api/mobile/cotisations",
              "description": "Cotiser sur une cagnotte (déclenche un payin).",
              "request": {
                "method": "POST",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"cagnotte_reference\": \"12480\",\n  \"montant\": 50000,\n  \"numero_tel\": \"+241XXXXXXXX\"\n}"
                },
                "url": { "raw": "{{base_url}}/api/mobile/cotisations", "host": ["{{base_url}}"], "path": ["api", "mobile", "cotisations"] }
              }
            }
          ]
        },
        {
          "name": "Profil",
          "item": [
            {
              "name": "GET /api/mobile/profil",
              "request": {
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": { "raw": "{{base_url}}/api/mobile/profil", "host": ["{{base_url}}"], "path": ["api", "mobile", "profil"] }
              }
            },
            {
              "name": "PATCH /api/mobile/profil",
              "description": "Compléter les champs différés (sexe, adresse, e-mail).",
              "request": {
                "method": "PATCH",
                "header": [
                  { "key": "Accept", "value": "application/json" },
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": { "mode": "raw", "raw": "{\n  \"sexe\": \"homme\",\n  \"adresse\": \"Libreville, Akanda\",\n  \"email\": \"daniel.doviakon@gmail.com\"\n}" },
                "url": { "raw": "{{base_url}}/api/mobile/profil", "host": ["{{base_url}}"], "path": ["api", "mobile", "profil"] }
              }
            }
          ]
        }
      ]
    }
  ]
}
