Guide

Direct API Integration Integracion Directa por API

Send events directly via REST API for maximum control. Best for server-side tracking, custom integrations, and webhook receivers. Envia eventos directamente por API REST para maximo control. Ideal para tracking server-side, integraciones custom, y receptores de webhooks.

Authentication Autenticacion

All API requests require a Bearer token in the Authorization header. Contact your RELO account manager to receive your token and client_id. Todas las requests de API requieren un Bearer token en el header Authorization. Contacta a tu account manager de RELO para recibir tu token y client_id.

Authorization: Bearer YOUR_API_TOKEN
Base URL: https://ingest.relo.mx for event ingestion. https://relo-api.quomx.workers.dev for platform API. URL Base: https://ingest.relo.mx para ingestion de eventos. https://relo-api.quomx.workers.dev para API de plataforma.

Health Check Health Check

Verify the service is running before sending events: Verifica que el servicio esta corriendo antes de enviar eventos:

GET https://ingest.relo.mx/health

// Response 200:
{
  "status": "ok",
  "version": "7.1.0",
  "uptime_sec": 864000,
  "clickhouse": "ok",
  "dragonfly": "ok",
  "supabase": "ok"
}

Batch Event Ingest Ingestion de Eventos en Batch

Send up to 10,000 events per request to the batch endpoint. Events are validated, enriched (GeoIP, identity resolution, fraud scoring), and written to ClickHouse. Envia hasta 10,000 eventos por request al endpoint de batch. Los eventos se validan, enriquecen (GeoIP, resolucion de identidad, scoring de fraude), y se escriben en ClickHouse.

POST https://ingest.relo.mx/ingest/batch
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "events": [
    {
      "t": "purchase",
      "ts": 1710244800000,
      "cid": 3,
      "did": "device-abc-123",
      "props": {
        "order_id": "ORD-001",
        "revenue": 24999.00,
        "currency": "MXN",
        "product_id": "SM-S921BZKDMXO",
        "product_name": "Galaxy S24 Ultra 256GB",
        "product_line": "MX",
        "quantity": 1
      }
    },
    {
      "t": "page_view",
      "ts": 1710244750000,
      "cid": 3,
      "did": "device-abc-123",
      "url": "https://samsung.com.mx/smartphones/galaxy-s24/",
      "ref": "https://google.com/search?q=galaxy+s24"
    }
  ]
}

// Response 200:
{
  "accepted": 2,
  "rejected": 0,
  "errors": []
}

Event Types Tipos de Eventos

TypeTipo DescriptionDescripcion Required PropsProps Requeridos
page_view Page load / screen viewCarga de pagina / vista de pantalla url
view_product Product detail pagePagina de detalle de producto product_id, price
add_to_cart Added item to cartAgrego item al carrito product_id, price, quantity
begin_checkout Started checkoutInicio checkout cart_value
purchase Completed purchaseCompra completada order_id, revenue, product_id, quantity
install App installInstalacion de app (none)(ninguno)
custom Any custom eventCualquier evento custom Any key-value pairs in propsCualquier par clave-valor en props

Event Schema Schema de Eventos

FieldCampo TypeTipo RequiredRequerido DescriptionDescripcion
tstringYesEvent type (see table above)Tipo de evento (ver tabla arriba)
tsintegerYesClient timestamp (Unix ms)Timestamp del cliente (Unix ms)
cidintegerYesRELO client IDID de cliente RELO
didstringYesDevice identifier (GAID, IDFA, fingerprint, or your own ID)Identificador de dispositivo (GAID, IDFA, fingerprint, o tu propio ID)
urlstringNoPage URL (for web events)URL de la pagina (para eventos web)
refstringNoReferrer URLURL de referencia
ipstringNoClient IP (auto-detected if omitted)IP del cliente (auto-detectado si se omite)
uastringNoUser-Agent (auto-detected if omitted)User-Agent (auto-detectado si se omite)
consentintegerNoConsent bitmask (default 0xFF = all)Bitmask de consentimiento (default 0xFF = todos)
propsobjectNoEvent-specific propertiesPropiedades especificas del evento

Purchase Props (inside props) Props de Compra (dentro de props)

FieldCampo TypeTipo DescriptionDescripcion
order_idstringUnique order identifierIdentificador unico de la orden
revenuenumberTotal revenue (after discounts)Revenue total (despues de descuentos)
currencystringISO 4217 currency code (default MXN)Codigo de moneda ISO 4217 (default MXN)
product_idstringProduct SKUSKU del producto
product_namestringProduct nameNombre del producto
product_linestringSegment: MX, VD, DA, HA, IT, NWSegmento: MX, VD, DA, HA, IT, NW
quantityintegerNumber of unitsNumero de unidades

Example: Sending a Purchase Event Ejemplo: Enviando un Evento de Compra

curl -X POST https://ingest.relo.mx/ingest/batch \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "t": "purchase",
        "ts": 1710244800000,
        "cid": 3,
        "did": "fp_a1b2c3d4e5f6",
        "props": {
          "order_id": "MX260318-12345678",
          "revenue": 24999.00,
          "currency": "MXN",
          "product_id": "SM-S921BZKDMXO",
          "product_name": "Galaxy S24 Ultra 256GB",
          "product_line": "MX",
          "quantity": 1
        }
      }
    ]
  }'

Example: Sending a Batch of 1,000 Events Ejemplo: Enviando un Batch de 1,000 Eventos

# Python example: batch send
import requests
import json
import time

events = []
for i in range(1000):
    events.append({
        "t": "page_view",
        "ts": int(time.time() * 1000) - (i * 1000),
        "cid": 3,
        "did": f"device-{i % 100:03d}",
        "url": f"https://samsung.com.mx/product-{i}"
    })

response = requests.post(
    "https://ingest.relo.mx/ingest/batch",
    headers={
        "Authorization": "Bearer YOUR_TOKEN",
        "Content-Type": "application/json"
    },
    json={"events": events}
)

print(response.json())
# {"accepted": 1000, "rejected": 0, "errors": []}

Error Handling & Retries Manejo de Errores y Reintentos

Status CodeCodigo de Estado MeaningSignificado ActionAccion
200Events acceptedEventos aceptadosCheck rejected countRevisa el conteo de rejected
400Invalid payloadPayload invalidoFix the request body, do not retryCorrige el body del request, no reintentar
401Invalid or missing tokenToken invalido o faltanteCheck your Bearer tokenRevisa tu Bearer token
429Rate limitedLimite de tasaBack off, retry after 1-5 secondsEspera, reintenta despues de 1-5 segundos
500 / 502 / 503Server errorError del servidorRetry with exponential backoff (1s, 2s, 4s, max 3 retries)Reintenta con backoff exponencial (1s, 2s, 4s, max 3 reintentos)
Retry strategy: On 5xx errors, retry with exponential backoff: 1s, 2s, 4s. Max 3 retries. On 4xx errors, do not retry — fix the request instead. Buffer events locally during outages and send when the service recovers. Estrategia de reintento: En errores 5xx, reintenta con backoff exponencial: 1s, 2s, 4s. Max 3 reintentos. En errores 4xx, no reintentar — corrige el request. Almacena eventos localmente durante outages y envia cuando el servicio se recupere.

Rate Limits Limites de Tasa

EndpointEndpoint LimitLimite WindowVentana
/ingest/batch100 requests100 requestsper minute per tokenpor minuto por token
/ingest/batch10,000 events10,000 eventosper request (body size)por request (tamano del body)
/healthNo limitSin limite-

At maximum rate (100 requests x 10,000 events), you can send 1 million events per minute. If you need higher throughput, contact your RELO account manager. A tasa maxima (100 requests x 10,000 eventos), puedes enviar 1 millon de eventos por minuto. Si necesitas mayor throughput, contacta a tu account manager de RELO.