Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cobrix.co/llms.txt

Use this file to discover all available pages before exploring further.

Formato de error

{
  "statusCode": 400,
  "message": "Customer email must be a valid email",
  "error": "Bad Request",
  "timestamp": "2026-03-26T14:30:00.000Z",
  "path": "/api/external/payments"
}
CampoDescripción
statusCodeCódigo HTTP
messageMensaje legible con el detalle del fallo
errorNombre del error HTTP
timestampFecha ISO 8601 del error
pathEndpoint que produjo el error

Códigos HTTP

CódigoSignificadoCuándo
200OKGET, DELETE (cancel)
201CreatedPOST (nuevo pago/key)
204No ContentDELETE (revocar key)
400Bad RequestError de validación, cliente inactivo
401UnauthorizedAPI key faltante, inválida o revocada
403ForbiddenIP no está en la allowlist
404Not FoundPago o key no encontrado
409ConflictIdempotency-Key duplicada, máximo de keys, pago no cancelable
429Too Many RequestsRate limit excedido
500Server ErrorError inesperado

Errores comunes

MensajeCausaSolución
"Client is not active"El cliente no tiene estado activoContactar soporte — datos legacy
"Idempotency-Key header is required"Falta el header en un POSTAgregar Idempotency-Key con UUID v4
"Customer has no pending invoices"Problema de generación de facturaVerifica amountMinor y currency
"Company has reached the maximum number of active sessions"Demasiados pagos hosted activosCancela pagos pendientes o espera a que expiren
"Invalid or revoked API key"Key mal copiada, expirada o revocadaRegenera la key desde el dashboard
"Payment is not cancelable"El pago no está en pendingSolo pending se puede cancelar

Rate limiting

Cada API key tiene un límite por defecto de 60 requests/minuto.
{
  "statusCode": 429,
  "message": "Rate limit exceeded (60 requests/minute)"
}

Estrategia de reintento

  1. Espera 1 segundo tras el primer 429.
  2. Backoff exponencial: 1s, 2s, 4s, 8s…
  3. Máximo 3 reintentos antes de alertar.
  4. Siempre reintenta con la misma Idempotency-Key.
async function withRetry(fn, { maxRetries = 3 } = {}) {
  let delay = 1000
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn()
    } catch (error) {
      const status = error.response?.status ?? error.status
      if (status !== 429 || attempt === maxRetries) throw error
      await new Promise((r) => setTimeout(r, delay))
      delay *= 2
    }
  }
}

Manejo genérico

async function cobrixCall(fn) {
  try {
    return await fn()
  } catch (error) {
    const { statusCode, message } = error.body ?? {}
    switch (statusCode) {
      case 401:
        throw new Error('API key inválida o revocada')
      case 404:
        return null
      case 409:
        throw new Error(`Conflicto: ${message}`)
      case 429:
        // usa withRetry en lugar de lanzar
        throw error
      case 500:
      case 502:
      case 503:
        // reintenta tras unos segundos
        throw error
      default:
        throw error
    }
  }
}

Contactar soporte

Si el error persiste, contacta [email protected] con:
  • timestamp y path del error
  • statusCode y message
  • Endpoint y body (sin datos sensibles)
  • Ambiente (Staging / Producción)