Error Response Format
All Blnk API errors return a JSON response with anerror field describing the issue:
HTTP Status Codes
The Blnk API uses standard HTTP status codes to indicate the success or failure of requests.Success Codes
OK - Request succeeded. The response body contains the requested data.
Created - Resource created successfully. The response body contains the new resource.
No Content - Request succeeded with no response body (typically for DELETE operations).
Client Error Codes
Bad Request - The request was malformed or contains invalid parameters.Common causes:
- Missing required fields
- Invalid JSON format
- Field validation failures
- Invalid query parameters
Unauthorized - Authentication failed or was not provided.Common causes:
- Missing
X-Blnk-Keyheader - Invalid or expired API key
- Revoked API key
Forbidden - Valid authentication but insufficient permissions.Common causes:
- API key lacks required scope for the resource
- Attempting to access another owner’s resources
- Missing required action permission (read/write/delete)
Not Found - The requested resource does not exist.Common causes:
- Invalid resource ID
- Resource has been deleted
- Incorrect endpoint path
Too Many Requests - Rate limit exceeded.Solution: Reduce request frequency or contact support to increase limits.
Server Error Codes
Internal Server Error - An unexpected error occurred on the server.Action: Retry the request. If the error persists, contact support.
Common Error Scenarios
Authentication Errors
Missing Authentication
Status Code: 401X-Blnk-Key header with your API key or master key.
Invalid API Key
Status Code: 401- API key doesn’t exist in the database
- API key format is incorrect
- Typo in the key
Expired API Key
Status Code: 401Insufficient Permissions
Status Code: 403Validation Errors
Missing Required Field
Status Code: 400Invalid Field Format
Status Code: 400Invalid Query Parameter
Status Code: 400- Non-numeric value for numeric parameters
- Negative values where positive required
- Zero or negative limit/offset values
limit: Integer ≥ 1offset: Integer ≥ 0
Resource Errors
Resource Not Found
Status Code: 404Missing ID Parameter
Status Code: 400Unauthorized Resource Access
Status Code: 403- Attempting to access resources owned by another user
- Missing
ownerquery parameter - Owner parameter doesn’t match authenticated user
owner parameter or use appropriate credentials.
Unknown Resource Type
Status Code: 403Error Codes by Endpoint
Ledger Endpoints
| Endpoint | Error | Status | Description |
|---|---|---|---|
| POST /ledgers | Validation error | 400 | Missing or invalid name field |
| GET /ledgers/:id | Missing ID | 400 | ID parameter not provided |
| GET /ledgers | Invalid filters | 400 | Malformed filter parameters |
| PUT /ledgers/:id | Not found | 400 | Ledger ID doesn’t exist |
Balance Endpoints
| Endpoint | Error | Status | Description |
|---|---|---|---|
| POST /balances | Missing currency | 400 | currency field required |
| GET /balances/:id | Invalid ID | 400 | Balance ID not provided |
| GET /balances/at | Invalid timestamp | 400 | Timestamp format incorrect |
| PUT /balances/:id/identity | Missing identity_id | 400 | identity_id field required |
Transaction Endpoints
| Endpoint | Error | Status | Description |
|---|---|---|---|
| POST /transactions | Validation error | 400 | Missing required transaction fields |
| POST /transactions | Insufficient funds | 500 | Source balance too low |
| GET /transactions/:id | Not found | 400 | Transaction doesn’t exist |
| POST /refund-transaction/:id | Already refunded | 400 | Transaction already refunded |
API Key Endpoints
| Endpoint | Error | Status | Description |
|---|---|---|---|
| POST /api-keys | Validation error | 400 | Missing name, owner, scopes, or expires_at |
| GET /api-keys | Unauthorized | 401 | Missing owner query parameter |
| DELETE /api-keys/:id | Not found | 404 | API key doesn’t exist |
| DELETE /api-keys/:id | Forbidden | 403 | Owner doesn’t match |
Search Endpoints
| Endpoint | Error | Status | Description |
|---|---|---|---|
| POST /search/:collection | Missing collection | 400 | Collection parameter required |
| POST /search/:collection | Invalid query | 400 | Malformed search query |
| GET /search/reindex | Not found | 404 | No reindex operation in progress |
Reconciliation Endpoints
| Endpoint | Error | Status | Description |
|---|---|---|---|
| POST /reconciliation/upload | Upload failed | 500 | Failed to process file upload |
| POST /reconciliation/start | Start failed | 500 | Failed to initiate reconciliation |
| GET /reconciliation/:id | Not found | 404 | Reconciliation record doesn’t exist |
Troubleshooting Guide
”Authentication required” Error
- Check if secure mode is enabled (
BLNK_SERVER_SECURE=true) - Ensure
X-Blnk-Keyheader is included - Verify the header name is correct (case-sensitive)
“Invalid limit value” Error
- Ensure
limitis a positive integer - Check for typos in query parameters
- Use default values when uncertain
”Insufficient permissions” Error
- Check your API key’s scopes:
- Verify the required scope for the operation:
- GET requests need
resource:read - POST/PUT requests need
resource:write - DELETE requests need
resource:delete
- GET requests need
- Use master key for full access during testing
”Unknown resource type” Error
- Verify the endpoint URL matches documented paths
- Check for typos in resource names
- Ensure resource is supported in your Blnk version
”Entity not found” Error
- Confirm the resource ID exists:
- Check for ID typos or incorrect prefixes
- Verify resource hasn’t been deleted
Rate Limit Exceeded
- Implement exponential backoff retry logic
- Reduce request frequency
- Check rate limit configuration:
- Contact support to increase limits if needed
Debugging Tips
Enable Detailed Logging
Check server logs for detailed error information:Validate JSON Payloads
Use a JSON validator before sending requests:Test with cURL
Use verbose mode to see full request/response:Check API Key Status
Verify your API key is valid and not expired:Best Practices
Getting Help
If you encounter errors not covered in this guide:- Check the GitHub Issues for similar problems
- Review server logs for detailed error traces
- Consult the specific endpoint documentation for requirements
- Open a new issue with:
- Error message
- Request details (endpoint, method, payload)
- Expected vs actual behavior
- Blnk version