Guide

Create and read your shortlinks with the Rest API.

Connect your own app, script, or workflow to SafeLinkMe using a personal API key. This guide covers the general flow; your dashboard always shows the current details.

Getting started

  1. Generate your API key

    Open the Rest API tool in your dashboard and choose Generate API key. The key is shown only once, so copy it right away and store it somewhere safe.

  2. Send it with every request

    Add your key in the Authorization header as a Bearer token. Requests without a valid key are rejected.

  3. Read the response

    Responses are JSON. Successful creates return status 201, reads return 200, and failures return an error code you can match against the table below.

Endpoints

POST/api/v1/links

Create a shortlink. Send url (required, must start with http:// or https://) and an optional alias. Without an alias, a random code is generated.

Request
curl -X POST https://api.safelinkme.net/api/v1/links \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/page","alias":"my-code"}'
Response
{
  "id": 123,
  "code": "my-code",
  "customAlias": true,
  "destUrl": "https://example.com/page",
  "createdAt": 1790000000000
}

Your shortlink is https://safelinkme.net/ followed by the returned code.

GET/api/v1/links

List the links in your account, 50 per page. Use ?page=2 to move through pages.

Request
curl "https://api.safelinkme.net/api/v1/links?page=1" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response
{
  "links": [
    {
      "id": 123,
      "code": "my-code",
      "custom_alias": 1,
      "dest_url": "https://example.com/page",
      "status": "active",
      "views": 0,
      "earnings": 0,
      "created_at": 1790000000000
    }
  ],
  "page": 1,
  "pageSize": 50
}
GET/api/v1/links/:code

Get the details of one link you own, including views and earnings. Links that belong to other accounts or were deleted return NOT_FOUND.

Request
curl https://api.safelinkme.net/api/v1/links/my-code \
  -H "Authorization: Bearer YOUR_API_KEY"

Custom aliases

An alias must be 3 to 30 characters using lowercase letters, numbers, hyphens, and underscores. It cannot start or end with a hyphen or underscore, cannot contain two hyphens in a row, and cannot match a reserved word such as a page name on the site. Aliases are converted to lowercase and must be unique across the platform.

Error codes

CodeStatusWhat to do
UNAUTHORIZED401Check that the key is correct, active, and sent as a Bearer token.
INVALID_BODY400Send valid JSON with the Content-Type header set to application/json.
INVALID_DEST_URL400The url must be a full http:// or https:// address.
INVALID_ALIAS400Follow the alias rules above.
ALIAS_TAKEN409Choose a different alias.
NOT_FOUND404No link with that code exists in your account.
RATE_LIMITED429You reached a usage limit. Wait a while and try again.
MAINTENANCE-The Rest API is temporarily unavailable. Try again later.

Keeping your key safe

Never share it

Anyone with your key can create links in your account. Keep it out of public code, screenshots, and front-end scripts.

Regenerate if it leaks

Regenerating creates a new key and the old one stops working immediately. Update every app that used it.

Revoke what you no longer use

Revoking disables the key completely. You can generate a new one whenever you need it.

Ready to build with the API?

Generate your key and create your first link in minutes.