What went wrong and how to fix it.
When something goes wrong, lyng responds with an HTTP status code that indicates the type of problem, plus a JSON object with an error field that describes it in plain English.
Status codes in the 400s mean the problem is on your side. Something about your request was wrong. Codes in the 500s mean the problem is on lyng's side.
{ "error": "url is required" }url is requiredYou forgot to include a URL in your request body.
How to fix: Add a "url" field to your JSON, e.g. {"url": "https://example.com"}
Invalid urlThe URL you sent is not a valid web address.
How to fix: Make sure it starts with http:// or https:// and is a real URL.
That slug is reservedThe custom slug you chose is a reserved word (e.g. "login", "dashboard").
How to fix: Choose a different slug.
Invalid or missing API keyYour API key is wrong, missing, or has been revoked.
How to fix: Check your Authorization header. Make sure you copied the full key and it starts with lk_.
Custom slugs require PremiumYou tried to set a custom slug but your account is on the free plan.
How to fix: Upgrade to Premium, or remove the slug field and let lyng generate one automatically.
Slug already takenSomeone else (or you) already has a link with that slug.
How to fix: Choose a different slug.
Link limit reachedYour free account has hit the 60-link limit.
How to fix: Delete some links from your dashboard, or upgrade to Premium for unlimited links.
Internal server errorSomething went wrong on lyng's end.
How to fix: Wait a moment and try again. If it keeps happening, contact support.
Always check whether your request succeeded before using the response data. A good way to do this is to check the HTTP status code. Anything below 400 is a success.
JavaScript example
const res = await fetch('https://lyng.my.id/api/v1/links', {
method: 'POST',
headers: {
'Authorization': 'Bearer lk_your_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({ url: 'https://example.com' }),
})
const data = await res.json()
if (!res.ok) {
// Something went wrong
console.error('Error:', data.error)
} else {
// Success!
console.log('Short link:', data.shortUrl)
}500 errors and retrying doesn't help, email us at hellolyng@gmail.com.