Authentication
All requests to the TreasuryHub API are authenticated using two HTTP headers: X-Client-Id and X-Access-Token. This is a machine-to-machine (H2H) integration. There is no OAuth flow, no Bearer token, and no end-user authentication layer.
Environments
Section titled “Environments”| Environment | Base URL | Token expiration | Credential management |
|---|---|---|---|
| Production | https://api.gateway.treasuryhub.ai | Defined by client in Portal | TreasuryHub Portal |
| Sandbox | https://sandbox.api.gateway.treasuryhub.ai | Never expire | Provided by TreasuryHub |
Tokens from one environment do not work in the other.
Required headers
Section titled “Required headers”Every request — including GET — must include all three headers:
X-Client-Id: {{tenant_id}}X-Access-Token: {{api_key}}Content-Type: application/jsonX-Client-Id identifies the tenant. Client and Tenant refer to the same concept throughout this API.
Token formats
Section titled “Token formats”| Prefix | Environment |
|---|---|
th_live_ | Production |
th_test_ | Sandbox |
Examples:
- Production:
th_live_xxxxxxxxxxxx - Sandbox:
th_test_xxxxxxxxxxxx
Getting credentials
Section titled “Getting credentials”Sandbox
Section titled “Sandbox”- Request manual creation of a Client and credentials — there is no automated provisioning in sandbox.
- Provide a fixed IP address — the sandbox enforces an IP allowlist at tenant level.
- Your
X-Access-Tokendoes not expire in sandbox.
Production
Section titled “Production”- Log in to the TreasuryHub Portal.
- Create a client (tenant) and generate credentials.
- Configure token expiration and allowed IP ranges.
- Token expiration is defined by the client; a token from another environment will not work.
Example request
Section titled “Example request”curl -X POST https://sandbox.api.gateway.treasuryhub.ai/api/h2h/ingestion/financial-events \ -H "X-Client-Id: {{tenant_id}}" \ -H "X-Access-Token: th_test_xxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{"externalId":"ext-001","type":"INTERNAL_PAYIN","countryCode":"MX","currencyCode":"MXN","amount":1500.00,"status":"PENDING","originalStatus":"CREATED","payload":{}}'Rate limits
Section titled “Rate limits”The default limit is 1000 requests per minute per tenant. When the limit is exceeded, the API returns 429. Tenants can request a higher limit via the TreasuryHub Portal.
Security best practices
Section titled “Security best practices”- Never expose
X-Client-IdorX-Access-Tokenin client-side code or public repositories. - Store credentials in environment variables or a secrets manager such as Azure Key Vault.
- Configure a fixed IP allowlist for all environments.
- Rotate tokens immediately upon any suspected compromise.
- Do not share tokens across environments.
Todas las solicitudes a la API de TreasuryHub se autentican mediante dos encabezados HTTP: X-Client-Id y X-Access-Token. Esta es una integración máquina a máquina (H2H). No existe flujo OAuth, ni Bearer token, ni capa de autenticación de usuarios finales.
Entornos
Section titled “Entornos”| Entorno | URL base | Expiración del token | Gestión de credenciales |
|---|---|---|---|
| Producción | https://api.gateway.treasuryhub.ai | Definida por el cliente en el Portal | TreasuryHub Portal |
| Sandbox | https://sandbox.api.gateway.treasuryhub.ai | No expiran | Provista por TreasuryHub |
Los tokens de un entorno no funcionan en el otro.
Encabezados requeridos
Section titled “Encabezados requeridos”Toda solicitud — incluyendo GET — debe incluir los tres encabezados:
X-Client-Id: {{tenant_id}}X-Access-Token: {{api_key}}Content-Type: application/jsonX-Client-Id identifica al tenant. Client y Tenant se refieren al mismo concepto en esta API.
Formatos de token
Section titled “Formatos de token”| Prefijo | Entorno |
|---|---|
th_live_ | Producción |
th_test_ | Sandbox |
Ejemplos:
- Producción:
th_live_xxxxxxxxxxxx - Sandbox:
th_test_xxxxxxxxxxxx
Obtener credenciales
Section titled “Obtener credenciales”Sandbox
Section titled “Sandbox”- Solicitar la creación manual de un Client y sus credenciales — no existe aprovisionamiento automatizado en sandbox.
- Proporcionar una dirección IP fija — el sandbox aplica una lista de IPs permitidas a nivel de tenant.
- El
X-Access-Tokenno expira en sandbox.
Producción
Section titled “Producción”- Iniciar sesión en el TreasuryHub Portal.
- Crear un client (tenant) y generar las credenciales.
- Configurar la expiración del token y los rangos de IP permitidos.
- La expiración del token la define el cliente; un token de otro entorno no funcionará.
Ejemplo de solicitud
Section titled “Ejemplo de solicitud”curl -X POST https://sandbox.api.gateway.treasuryhub.ai/api/h2h/ingestion/financial-events \ -H "X-Client-Id: {{tenant_id}}" \ -H "X-Access-Token: th_test_xxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{"externalId":"ext-001","type":"INTERNAL_PAYIN","countryCode":"MX","currencyCode":"MXN","amount":1500.00,"status":"PENDING","originalStatus":"CREATED","payload":{}}'Límites de tasa
Section titled “Límites de tasa”El límite predeterminado es de 1000 solicitudes por minuto por tenant. Cuando se supera el límite, la API devuelve 429. Los tenants pueden solicitar un límite más alto a través del TreasuryHub Portal.
Buenas prácticas de seguridad
Section titled “Buenas prácticas de seguridad”- Nunca expongas
X-Client-IdniX-Access-Tokenen código del lado del cliente ni en repositorios públicos. - Almacena las credenciales en variables de entorno o en un gestor de secretos como Azure Key Vault.
- Configura una lista de IPs fijas permitidas para todos los entornos.
- Rota los tokens de inmediato ante cualquier sospecha de compromiso.
- No compartas tokens entre entornos.