Error Reference

HTTP status codes and machine-readable error codes

All AWSYS.CO API errors return a consistent JSON body with a human-readable message and a machine-readable code your application can switch on:

{
  "error": "Human-readable message",
  "code": "MACHINE_READABLE_CODE"
}

HTTP Status Codes

Code Meaning When it occurs
200 OK Request succeeded
201 Created Resource created successfully (e.g. new short link)
204 No Content Successful deletion — response body is empty
400 Bad Request Invalid parameters or missing required fields in the request body
401 Unauthorized Missing or invalid API key in the Authorization header
403 Forbidden Valid API key but the key lacks permission for this operation
404 Not Found The requested resource does not exist
409 Conflict Custom slug already taken by another link
422 Unprocessable Validation failed — the request is well-formed but semantically invalid (e.g. invalid URL, unrecognized event name)
429 Too Many Requests Rate limit exceeded — check Retry-After header and implement backoff
500 Internal Server Error Unexpected server error — if persistent, contact support

Error Code Reference

Code HTTP Description
INVALID_TOKEN 401 API key is missing, malformed, or has been revoked
UNAUTHORIZED 403 API key is valid but lacks permission for this operation (e.g. Free plan calling a Pro endpoint)
NOT_FOUND 404 The link or resource does not exist or has been deleted
SLUG_TAKEN 409 The requested custom slug is already in use by another link
INVALID_URL 422 The destination URL is not a valid URL (e.g. missing scheme, malformed host)
INVALID_EVENTS 422 One or more webhook event names are not recognized. Use full prefixed names such as link.click.
RATE_LIMITED 429 Request rate exceeded for your plan in the current time window
DAILY_LIMIT_REACHED 429 Daily link creation limit has been reached. Resets at midnight UTC.
INTERNAL_ERROR 500 An unexpected server error occurred

Handling Errors in Code

const res = await fetch('https://awsys.co/api/createShort', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.AWSYS_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ long: btoa('https://example.com') }),
});

if (!res.ok) {
  const err = await res.json();
  switch (err.code) {
    case 'INVALID_TOKEN':
      console.error('Check your API key in Settings → API');
      break;
    case 'DAILY_LIMIT_REACHED':
      console.error('Daily link limit reached — upgrade to Pro for more');
      break;
    case 'SLUG_TAKEN':
      console.error('Choose a different custom slug');
      break;
    case 'RATE_LIMITED':
      const retryAfter = res.headers.get('Retry-After') || 60;
      console.error(`Rate limited — retry in ${retryAfter}s`);
      break;
    default:
      console.error(`API error ${res.status}: ${err.error}`);
  }
  throw new Error(err.code);
}

const data = await res.json();
console.log('Short link created:', data.url);

Common Mistakes

Symptom Likely cause Fix
Always getting INVALID_TOKEN Missing Bearer prefix or wrong key format Header must be exactly Authorization: Bearer awsys_live_...
Getting INVALID_URL despite a valid URL Destination URL not Base64-encoded in the long field Encode with btoa(url) (JS) or base64.b64encode(url.encode()).decode() (Python)
Webhook creation returns INVALID_EVENTS Using short event names like click Use full prefixed names: link.click, link.created, etc.
Unexpected DAILY_LIMIT_REACHED Free plan's 25-link/day limit exhausted by automated tests or scripts Upgrade to Pro, or wait for midnight UTC reset