API MSP
Endpoints /partner/* pour automatiser la gestion de vos tenants — API keys MSP, rate limits, exemples
API MSP
L'API MSP expose des endpoints dédiés /partner/* pour automatiser la gestion de vos tenants. Cela permet l'intégration avec votre CRM, votre système de ticketing, vos rapports BI internes, etc.
API keys MSP
Les API keys MSP sont distinctes des API keys de tenant standard. Source : table msp_api_keys (migration 000154_msp_api_keys.up.sql).
Différences
| Caractéristique | API key tenant standard | API key MSP |
|---|---|---|
| Scope | 1 tenant | Tous vos tenants gérés |
| Endpoint d'auth | Authorization: Bearer ou X-API-Key | X-MSP-API-Key |
| Endpoints accessibles | Tous (selon scopes) | /partner/* + endpoints tenants en mode act_as_tenant |
| Rate limit | Selon plan tenant | msp_accounts.api_rate_limit_per_min (configurable, 60 par défaut) |
Créer une API key MSP
- Naviguez vers
/partner/api. - Cliquez sur Nouvelle clé MSP.
- Renseignez :
- Nom : libellé interne (ex. « CI/CD Provisioning », « CRM HubSpot »)
- Permissions : array de scopes
tenants:read— lister vos tenantstenants:write— créer / modifier / supprimertenants:act_as— opérer comme un tenant via APIbilling:read— lire vos facturesusage:read— lire la consommationdashboard:read— KPIs MSP
- Rate limit : par minute (max =
msp_accounts.api_rate_limit_per_min)
- Cliquez sur Créer. La clé est affichée une seule fois — copiez-la immédiatement.
Format : mskp_live_xxxxxxxxxxxx (32 chars hex).
La clé est hachée bcrypt en DB et n'est jamais re-affichable.
Endpoints MSP principaux
Source : secuscan-api/internal/bootstrap/routes.go + secuscan-api/internal/api/handlers/partner.go, partner_msp.go.
Tier et compte
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/tiers | Lister les tiers disponibles (Reseller, MSP, White-Label) |
GET | /v1/partner/tiers/{slug} | Détails d'un tier |
POST | /v1/partner/enroll | S'enrôler en tant que partenaire (auto pour Reseller) |
GET | /v1/partner/account | Lire votre compte MSP |
PATCH | /v1/partner/account | Mettre à jour (nom, branding, billing settings) |
GET | /v1/partner/dashboard | KPIs MSP (MRR, tenants actifs, AI usage, posture moyenne) |
Gestion des tenants gérés
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/tenants | Liste des tenants gérés |
POST | /v1/partner/tenants | Créer un tenant client |
GET | /v1/partner/tenants/{id} | Détails d'un tenant géré |
PATCH | /v1/partner/tenants/{id} | Modifier (plan, billing_delegated, tags, status) |
POST | /v1/partner/tenants/{id}/suspend | Suspendre |
POST | /v1/partner/tenants/{id}/resume | Réactiver |
DELETE | /v1/partner/tenants/{id} | Supprimer (workflow Loi 25) |
Opérer comme un tenant
| Méthode | Path | Description |
|---|---|---|
POST | /v1/partner/tenants/{id}/act-as | Obtenir un JWT temporaire pour agir comme ce tenant |
Réponse :
{
"act_as_token": "eyJhbGc...",
"expires_in": 3600,
"tenant_id": "uuid-du-tenant",
"tenant_name": "Cabinet Tremblay"
}Vous utilisez ensuite ce act_as_token comme un Bearer JWT classique pour appeler n'importe quel endpoint tenant standard. L'action est journalisée dans audit_logs (action='msp_act_as_tenant').
Branding
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/branding | Lire la config branding |
PUT | /v1/partner/branding | Mettre à jour |
POST | /v1/partner/branding/logo | Upload logo (multipart) |
Custom domains (White-Label)
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/domains | Liste des domaines configurés |
POST | /v1/partner/domains | Ajouter un domaine |
GET | /v1/partner/domains/{domain} | Détails (statut DNS + cert TLS) |
PUT | /v1/partner/domains/{domain} | Mettre à jour |
DELETE | /v1/partner/domains/{domain} | Retirer |
POST | /v1/partner/domains/{domain}/verify | Forcer la re-vérification DNS + Let's Encrypt |
Billing
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/invoices | Liste de vos factures wholesale |
GET | /v1/partner/invoices/{id} | Détails d'une facture |
GET | /v1/partner/invoices/{id}/pdf | Télécharger le PDF |
GET | /v1/partner/usage?month=2026-04 | Consommation détaillée par tenant pour le mois |
GET | /v1/partner/cashback?period=ytd | Total cashback accumulé sur la période |
Reseller code
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/reseller/code | Lire votre code unique |
POST | /v1/partner/reseller/code/regenerate | Régénérer (action sensible — révoque l'ancien) |
GET | /v1/partner/reseller/signups | Liste des tenants attribués via votre code |
Compliance MSP
| Méthode | Path | Description |
|---|---|---|
GET | /v1/partner/compliance/summary | Sommaire compliance agrégé sur tous vos tenants |
Source : secuscan-api/internal/api/handlers/compliance_msp.go.
Exemples complets
Lister tous les tenants gérés
curl https://api.scanyze.com/v1/partner/tenants \
-H "X-MSP-API-Key: mskp_live_xxx"Réponse :
{
"data": [
{
"id": "uuid-tenant-1",
"name": "Cabinet Tremblay",
"plan_slug": "pro",
"billing_delegated": true,
"status": "active",
"posture_score": 78,
"findings_open": 23,
"findings_critical": 2,
"ai_credits_used_this_month": 412,
"onboarded_at": "2026-01-15T09:00:00Z"
},
...
],
"pagination": {
"total": 42,
"limit": 50,
"offset": 0
}
}Créer un nouveau client en mode delegated
curl -X POST https://api.scanyze.com/v1/partner/tenants \
-H "X-MSP-API-Key: mskp_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"organization_name": "Notaire Bouchard",
"contact_email": "info@notairebouchard.ca",
"contact_name": "Sylvie Bouchard",
"plan_slug": "pro",
"billing_delegated": true,
"tags": ["secteur:juridique", "region:saguenay"]
}'Opérer comme un client (act-as) — créer une cible pour lui
# 1. Obtenir un act-as token
ACT_TOKEN=$(curl -X POST https://api.scanyze.com/v1/partner/tenants/uuid-tenant-1/act-as \
-H "X-MSP-API-Key: mskp_live_xxx" \
| jq -r .act_as_token)
# 2. Utiliser le token pour créer une cible chez ce tenant
curl -X POST https://api.scanyze.com/v1/targets \
-H "Authorization: Bearer $ACT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Site corporatif",
"domain": "notairebouchard.ca"
}'L'action sera journalisée dans le tenant cible avec actor=MSP MaBoite Sécurité Inc. et son audit trail.
Récupérer le dashboard MSP
curl https://api.scanyze.com/v1/partner/dashboard \
-H "X-MSP-API-Key: mskp_live_xxx"Réponse :
{
"tenants_active": 42,
"tenants_suspended": 3,
"monthly_recurring_revenue_cad": 18435.50,
"ai_credits_used_this_month": 14275,
"average_posture_score": 71,
"critical_findings_total": 89,
"pending_actions": 12,
"trend_30d": {
"tenants_active": "+5",
"mrr_pct": "+12.4",
"posture_pct": "+3.2"
}
}Webhooks sortants MSP
/partner/api → onglet Webhooks
Configurer des webhooks pour recevoir les événements MSP en push :
| Événement | Description |
|---|---|
msp.tenant.created | Nouveau tenant créé via votre code reseller (mode direct) |
msp.tenant.suspended | Un de vos tenants suspendu |
msp.tenant.upgrade | Un de vos tenants upgrade de plan |
msp.tenant.downgrade | Idem downgrade |
msp.tenant.delete_requested | Workflow de suppression Loi 25 démarré |
msp.invoice.issued | Nouvelle facture wholesale émise |
msp.cashback.calculated | Cashback du mois calculé |
msp.tenant.finding.critical | Nouveau finding critique chez un de vos tenants |
msp.quota.warning | Vous atteignez 90% du quota tenants gérés |
Chaque webhook est signé HMAC-SHA256 avec le secret stocké dans /partner/api. Vérifier le header X-Scanyze-MSP-Signature.
Rate limits
Configurable par MSP via msp_accounts.api_rate_limit_per_min (défaut 60 r/min).
Maximums par tier :
| Tier | Rate limit max |
|---|---|
| Reseller | 60 r/min |
| MSP | 300 r/min |
| White-Label | 1000 r/min |
Pour des intégrations à très fort volume (sync minutaire avec un CRM, par exemple), demandez un upgrade à partners@scanyze.com.
Sources de cette page
- Backend :
secuscan-api/internal/api/handlers/partner.go,partner_msp.go,compliance_msp.go,custom_domains.go - Migration :
000154_msp_api_keys.up.sql - Modèle :
secuscan-api/internal/domain/models/msp_api_key.go
À jour pour Scanyze v0.130.x.