Autenticación
La API de AS2Expert utiliza autenticación basada en Bearer Token para garantizar un acceso seguro a sus recursos. Para autenticar tus peticiones, debes incluir tu token de API en el header Authorization en cada solicitud HTTP. Este mecanismo permite identificar de forma única tu cuenta y aplicar los permisos correspondientes.
Header de Autenticación
Todas las peticiones a la API deben incluir este header. El prefijo Bearer indica el tipo de autenticación y debe ir seguido de un espacio y tu token de acceso.
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Obtener Token
El alta pública ya no genera un token de API automáticamente. El registro crea tu usuario y tu estación inicial, pero la habilitación del token debe hacerse más adelante desde el entorno autenticado o desde la operativa administrativa correspondiente.
Esta separación evita exponer credenciales sensibles en el flujo público de onboarding y permite controlar mejor los scopes asignados a cada integración.
Endpoint reservado para gestión futura de tokens. La API actual ya valida scopes read, write y admin sobre cada token, pero el aprovisionamiento todavía se hace fuera de esta documentación pública.
Free onboarding flow
The public Free flow and the public API token lifecycle are intentionally separated:
- Register a Free account on the public site.
- The onboarding flow creates your user and your initial station for the current domain.
- No API token is issued during public signup.
- The token is enabled later from the authenticated environment or from the administrative workflow.
Station visibility is domain-scoped. The same token can only see the stations, partners, certificates, and messages exposed by the domain where the API is published, such as free.as2expert.com.
Scopes
| Scope | Significado |
|---|---|
| read | Permite listar, consultar detalle y leer métricas |
| write | Permite crear entidades, enviar mensajes y configurar webhooks |
| admin | Permite operaciones de escritura en los endpoints que aceptan write o admin |
Authentication examples
curl -X POST "https://free.as2expert.com/api/v1/stations" -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" -d '{}'
import requests
API_TOKEN = "your_token_here"
headers = {
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
}
# Example authenticated request
response = requests.post(
"https://free.as2expert.com/api/v1/stations",
headers=headers,
json={}
)
const response = await fetch("https://free.as2expert.com/api/v1/stations", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({})
});
Errores de Autenticación
Si el token es inválido o ha expirado, la API devolverá:
{
"status": "error",
"msg": "Invalid token"
}