# Contrat API - MissioFlow Mobile

Document de reference pour les contrats partages entre le mobile, CoolCare backend et MissioFlow SaaS backend.

Pour le workflow des etapes d'intervention (steps), voir STEP_WORKFLOW_CONTRACT.md.

## Contrat QR code

Format JSON unique genere par le panel admin:

```json
{
  "url": "https://tenant.example.com/api/mobile",
  "invite_token": "abc123",
  "email": "tech@example.com"
}
```

Regles:
- url: obligatoire, URL complete de l'API mobile de l'instance
- invite_token: optionnel, token d'invitation pre-authentifie
- email: optionnel, pre-remplissage du champ email au login

## GET /api/mobile-config

But:
- valide que l'instance est joignable et expose bien le contrat mobile
- aucune authentification requise
- appele juste apres saisie URL / scan QR, avant login

Request:
- Method: GET
- Path: /api/mobile-config
- Auth: none

Success response (HTTP 200):

```json
{
  "success": true,
  "data": {
    "app_name": "CoolCare",
    "primary_color": "#1D4ED8",
    "logo_url": "https://...",
    "tenant_id": null
  }
}
```

Champs:
- app_name: obligatoire
- primary_color: obligatoire, format hex (#RRGGBB)
- logo_url: optionnel, peut etre null
- tenant_id: null pour CoolCare, UUID ou int pour MissioFlow SaaS

Error response (HTTP 200):

```json
{
  "success": false,
  "message": "Instance non trouvee"
}
```

Note:
- meme enveloppe ApiEnvelope que le reste de l'API

## Impact mobile (phase 3)

Flux onboarding cible:
1. Saisie URL / scan QR
2. Sauvegarde URL dans EnvironmentService
3. Appel GET /api/mobile-config
4. Si success=true: stockage app_name, primary_color, logo_url, tenant_id puis navigation login
5. Si success=false ou erreur reseau: message "Instance inaccessible ou invalide" et rester sur onboarding
