API Reference

Authentication

Secure your API requests with API keys

All ShortyLink API requests require authentication using an API key. This guide explains how to create and use API keys.


Creating an API Key

  1. Go to DashboardSettings API Keys
  2. Click Create New Key
  3. Give your key a descriptive name
  4. Select the permissions (scopes) the key needs
  5. Click Create
  6. Copy and securely store your key

Important

API keys are only shown once when created. If you lose a key, you'll need to create a new one.


Using Your API Key

Include your API key in the Authorization header of every request:

curl -X GET "https://api.shortylink.io/v1/links" \
  -H "Authorization: Bearer YOUR_API_KEY"

Header Format

Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxx

API Key Types

PrefixTypeUse Case
sk_live_ProductionReal data, live applications
sk_test_TestDevelopment, testing

Permission Scopes

API keys can be created with specific permissions:

ScopeDescription
links:readRead link data
links:writeCreate and update links
links:deleteDelete links
analytics:readRead analytics data
domains:readRead domain configuration
domains:writeManage domains

Authentication Errors

StatusErrorDescription
401unauthorizedMissing or invalid API key
403forbiddenKey lacks required scope
403key_revokedAPI key has been revoked
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key"
  }
}

Security Best Practices

  • Never expose keys in client-side code
  • Use environment variables for key storage
  • Create keys with minimum required scopes
  • Rotate keys periodically
  • Revoke keys immediately if compromised
  • Use different keys for different applications

Revoking API Keys

If a key is compromised or no longer needed:

  1. Go to SettingsAPI Keys
  2. Find the key to revoke
  3. Click Revoke
  4. Confirm the action

Revoked keys immediately stop working for all requests.