UniLink API Error Codes (Understand and Handle API Errors)

UniLink API Error Codes (Understand and Handle API Errors)
Every error the UniLink API returns has a predictable structure and a specific HTTP status code — knowing what each one means gets your integration back on track fast.
- All errors return a JSON object with
error(machine code),message(human text), and optionaldetails. - 4xx errors are your fault — bad input, missing auth, wrong scope. 5xx errors are UniLink's fault — retry with backoff.
- 401 and 403 require action on your API key; 429 requires waiting; 400 and 422 require fixing your request.
The UniLink API returns structured error responses that make it straightforward to distinguish between a misconfigured request, an authorization problem, and a server-side issue. Rather than guessing from status codes alone, every error body tells you exactly what went wrong in both machine-readable and human-readable form. Learning the error taxonomy upfront saves hours of debugging time when building and maintaining integrations.
What API Error Responses Look Like
Every error response from the UniLink API has the same JSON envelope. The error field is a snake_case string code identifying the error type — for example, validation_error, unauthorized, or rate_limit_exceeded. The message field is a human-readable sentence explaining what went wrong. The optional details field contains additional context — for validation errors it is an object mapping field names to arrays of error messages; for other errors it may contain a retry_after timestamp or a field name. The HTTP status code and the error string together give you everything you need to decide how to respond programmatically.
The error taxonomy divides into two groups based on who is responsible. 4xx status codes indicate a client error — your request was malformed, your credentials were wrong, or you asked for something that does not exist. These errors do not resolve by retrying the same request. You need to fix the request before trying again. 5xx status codes indicate a server error — UniLink's infrastructure encountered an unexpected problem. These are temporary by nature and should be retried with exponential backoff after a brief delay.
Validation errors (400 and 422) deserve special attention because they carry the most detail. A 400 Bad Request typically means a required field is missing or a value is the wrong type. A 422 Unprocessable Entity means the request was structurally valid JSON but the values violated a business rule — for example, creating a page with a slug that exceeds the maximum length or a price that is negative. The details object in validation error responses maps each invalid field to a list of human-readable messages, making it straightforward to surface exactly what needs to be corrected.
How to Get Started
- Add a global error handler to your HTTP client that reads both the HTTP status code and the JSON response body. Do not rely on status codes alone — the
errorfield gives you the specific error type for routing to the right handler. - Log the full error response body (status,
error,message,details) during development. This context is invaluable for debugging — themessagefield often tells you exactly what is wrong without needing to consult the docs. - Implement separate handling for 4xx and 5xx responses. For 4xx: surface the error to the user or halt and fix the request. For 5xx: retry with exponential backoff starting at 1 second, up to 3–5 retries.
- Add special handling for 429 responses — read the
retry_aftervalue from the response body and sleep precisely until that timestamp before retrying, rather than using a fixed delay. - Test your error handling by deliberately triggering each error type: send a request without an Authorization header (401), request a non-existent resource (404), send a POST with a missing required field (400).
How to Handle Each Error Type
- 400 Bad Request: A required parameter is missing or has the wrong type. Read
detailsto find which field is invalid. Fix the request body or query string and retry immediately — this is not a transient error. - 401 Unauthorized: The Authorization header is missing, malformed, or the token has been revoked. Check that the header is present and formatted as
Bearer YOUR_KEY. If the key was revoked, generate a new one in Settings → API. - 403 Forbidden: The token is valid but lacks the scope for this operation — for example, a read-only key trying to POST. Generate a new key with the required scope (write or admin) and update your configuration.
- 404 Not Found: The requested resource does not exist or has been deleted. Check the ID or slug in your URL. If this is unexpected, the resource may have been archived — check the dashboard to confirm.
- 409 Conflict / 422 Unprocessable Entity / 429 Rate Limited / 500 Server Error: For 409 (duplicate), adjust your payload to use a unique identifier. For 422, read
detailsfor the specific rule violation. For 429, wait untilretry_after. For 500, retry with exponential backoff — it is a transient server issue.
Key Settings
| Setting | What It Does | Recommended |
|---|---|---|
| Error Logging | Recording full error responses for debugging | Log status code + full body in development; log status + error code in production |
| Retry Logic | Automatically retrying failed requests | Retry 5xx and 429 only — never auto-retry 4xx errors |
| Backoff Strategy | Delay between retry attempts | Exponential backoff: 1s, 2s, 4s, 8s with ±25% jitter; cap at 60s |
| Max Retries | Maximum number of retry attempts before giving up | 3–5 retries for 5xx; a single retry for 429 after the reset window |
| Alerting on 5xx | Notifying your team when server errors occur | Alert on sustained 5xx errors (more than 3 in 5 minutes) — may indicate a platform incident |
Get the Most Out Of Error Handling
Build your error handler as a central function rather than duplicating try/catch logic across every API call. Your central handler should accept the HTTP response, classify it by status code, extract the error and message fields, and either throw a typed exception your business logic can catch, or return a typed error object. This pattern means you fix error handling once and every part of your integration benefits immediately.
Distinguish between retryable and non-retryable errors at the classification level. Retryable: 429, 500, 502, 503, 504, and network timeouts. Non-retryable: 400, 401, 403, 404, 409, 422. Writing this distinction into your error classifier prevents a common bug where validation errors are retried in a loop until rate limits are exhausted — often the symptom that surfaces is a 429 error, misleadingly suggesting a rate limit problem when the root cause is a bad request.
Surface 401 and 403 errors to your operations team immediately rather than silently retrying or swallowing them. A 401 usually means your API key was accidentally revoked or the environment variable is missing from a deployment. A 403 usually means the key's scope was set incorrectly. Both are configuration problems that require human intervention — automated retries will not resolve them, but an alert will get them fixed quickly.
Use the error code field (not just the HTTP status) to drive your error UI messages. The error field distinguishes between multiple scenarios that share the same HTTP status — for example, a 400 response might have an error of missing_required_field, invalid_format, or value_out_of_range. Routing on the specific error code lets you show contextually accurate messages rather than a generic "something went wrong" for every 400.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Getting 422 despite valid-looking data | Business rule violation not visible from field types alone | Read the details object — it lists the specific rule violated per field (e.g., "slug already taken", "price must be positive") |
| Sporadic 500 errors on specific endpoints | Transient server issue or payload too large | Retry with backoff; if persistent on the same payload, check body size limits and contact UniLink support |
| 409 Conflict when creating a resource | A resource with the same unique identifier already exists | Check for an existing resource with the same slug or email before creating; use PUT to update if it already exists |
| Error messages appear in English but you need localization | API message fields are always in English | Use the machine-readable error code to map to your own translated messages for user-facing display |
- Consistent error envelope across all endpoints makes a single error handler sufficient for the entire API
- Machine-readable
errorcode enables precise programmatic error routing without string parsing - Validation error
detailsmaps field names to messages, making it easy to build inline form error UIs - Clear separation between 4xx (client errors) and 5xx (server errors) simplifies retry logic design
- Error messages are English-only — localization requires mapping
errorcodes to your own translations - 409 Conflict error does not always indicate which specific field caused the conflict in
details - 5xx errors provide limited detail by design — investigation requires checking the UniLink status page
What does a UniLink API error response look like?
All error responses are JSON with the structure: {"error": "error_code", "message": "Human-readable description", "details": {...}}. The details field is present only when additional context is available, such as field-level validation errors.
What is the difference between 400 and 422?
400 Bad Request means the request was malformed — a required field is missing or a value is the wrong type. 422 Unprocessable Entity means the request was structurally valid but violated a business rule — for example, trying to create a duplicate slug or setting an invalid price value.
Should I retry a 401 error?
No. A 401 means your API key is missing, invalid, or revoked. Retrying will produce the same 401 every time. Fix the issue by checking your Authorization header or generating a new key in the dashboard.
How long should I wait before retrying a 500 error?
Start with 1 second, then double the delay on each subsequent retry: 1s, 2s, 4s, 8s. Add ±25% random jitter. After 3–5 failed retries, give up and alert your operations team. Most transient 500 errors resolve within the first two retries.
Where can I check if UniLink is experiencing an outage?
Check the UniLink status page at status.unilink.us for real-time infrastructure status and incident history. Sustained 5xx errors across multiple endpoints typically correlate with a reported incident there.
- All UniLink API errors return JSON with
error(code),message(text), and optionaldetails. - 4xx errors are client-side problems — fix the request. 5xx errors are server-side — retry with backoff.
- Never auto-retry 4xx errors — they will fail every time until the request itself is corrected.
- Use the
errorcode field (not just the HTTP status) to drive precise error handling and user-facing messages. - 401 means bad/missing auth; 403 means wrong scope; 429 means rate limited — each requires a different fix.
Start building robust integrations on UniLink — generate your API key at app.unilink.us under Settings → API and explore the endpoint reference.
Create Your Free Link-in-Bio Page
Join thousands of creators using UniLink. 40+ blocks, analytics, e-commerce, and AI tools — all free.
Get Started Free