Registrar cliente
Crear o actualizar un cliente.
POST
/api/v1/clients/registerRegistra un nuevo cliente o actualiza uno existente por externalId o email.
Request body
| Parametro | Tipo | Descripcion |
|---|---|---|
| externalId* | string | ID del usuario en tu plataforma (o email como alternativa) |
| string | Email del usuario. Puede usarse como identificador si no hay externalId | |
| firstName | string | Nombre |
| lastName | string | Apellido |
| phone | string | Telefono |
| os | string | Sistema operativo: android, ios o web |
| locale | string | Locale del dispositivo (ej: es-CL) |
| deviceToken | string | Token FCM para push notifications |
| customParams | object | Parametros custom (se mergean con los existentes) |
| geo | object | Ubicacion: { lat: number, lng: number } |
| authProvider | string | Proveedor de autenticacion (ej: google, email) |
| appVersion | string | Version de la app del cliente |
| sdkVersion | string | Version del SDK |
| anonymousClientId | string | ID del cliente anonimo a fusionar (transfiere device tokens y elimina el anonimo) |
| attribution | object | Datos de atribucion: { utmSource, utmMedium, utmCampaign, utmContent, utmTerm, linkId } |
Ejemplo
curl -X POST https://southgames.ai/api/v1/clients/register \
-H "Authorization: Bearer sg_live_xxx" \
-H "X-Org-Id: mi-empresa" \
-H "Content-Type: application/json" \
-d '{
"externalId": "user_123",
"email": "user@example.com",
"firstName": "Juan",
"customParams": { "plan": "premium" }
}'
Respuesta
{
"clientId": "abc123def456",
"created": true,
"deviceTokenSent": false
}
| Campo | Tipo | Descripcion |
|---|---|---|
clientId | string | ID unico del cliente en SouthGames |
created | boolean | true si es nuevo, false si se actualizo |
deviceTokenSent | boolean | true si se incluyo device token |
Fusion de cliente anonimo
Si envias anonymousClientId, el sistema:
- Transfiere los device tokens del cliente anonimo al cliente identificado.
- Elimina el documento del cliente anonimo.
Esto permite registrar dispositivos anonimamente con /clients/register-device y luego vincularlos a un usuario real al hacer login.
Deduplicacion de tokens
Si el deviceToken ya pertenece a otro cliente, se remueve automaticamente del anterior y se asigna al cliente actual.
Webhook
Cuando se crea un nuevo cliente, se dispara el evento client.registered.