The API supports two authentication methods. Pick the one that fits your integration best.
| Method | Header | Recommended for |
|---|---|---|
| API Key | x-api-key: <api_key> | Long-lived server-to-server integrations |
| Bearer Token (JWT) | Authorization: Bearer <token> | Integrations where the token is rotated per session |
The two methods are not interchangeable across the whole API. An API key identifies the integration; a token also identifies the user and their company. Endpoints that need to know who performed the action — to resolve the company, to leave a trace, or to write a history — only accept the token.
| Series | Authorization: Bearer | x-api-key |
|---|---|---|
/v1/cases and all its subresources | ✅ | ❌ |
GET /v1/documents (list) | ✅ | ❌ |
The rest of /v1/documents | ✅ | ✅ |
Sending x-api-key to an endpoint that only accepts a token returns 401.
Each page's examples use the method that endpoint actually accepts. When in doubt,
Authorization: Bearerworks across the entire API.
Request your credentials from your Nexcar contact or support@nexcar.mx. You'll get an api_key for production and another for the sandbox environment.
Never expose your
api_keyin browser-side code or commit it to a public repository.
curl -X POST https://api.nexcar.mx/v1/documents \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"case_id": "11111111-2222-3333-4444-555555555555",
"url": "https://your-storage.example.com/vehicle-invoice.pdf",
"mime_type": "application/pdf",
"type": "factura"
}'
curl -X POST https://api.nexcar.mx/v1/cases \
-H "Authorization: Bearer your_jwt_token" \
-H "Content-Type: application/json" \
-d '{
"internal_id": "EXP-2026-0001",
"vehicle_origin": "Nacional",
"status": "processing"
}'
| HTTP | Code | Cause |
|---|---|---|
401 | AUTHORIZATION_HEADER_MISSING | No credential sent, or x-api-key sent to an endpoint that only accepts a token |
401 | JWT_INVALID | The token is malformed or badly signed; this is also the code for an invalid API key |
401 | JWT_EXPIRED | The token expired. Refresh it and retry |
403 | FORBIDDEN | Credentials are valid but lack permission on the resource |