How to authenticate your API requests with 301LINK

Authentication

The 301LINK API uses an access code to authenticate requests. The access code is generated when you create a new account and acts as both your account identifier and secret.

ACCESS CODE = FULL ACCOUNT PERMS. DO NOT SHARE IT. DO NOT LOSE IT.

Getting an Access Code

Call /v1/new_account to generate a new account and receive your access code:

curl https://api.301link.com/v1/new_account

Response:

{
  "uid": "550e8400-e29b-41d4-a716-446655440000"
}

Authenticating Requests

Three endpoints require authentication:

Endpoint Method
/v1/links GET
/v1/link GET (create)
/v1/link DELETE (delete)

You may provide your access code in one of two ways:

Via Query Parameter

Append auth=<access_code> to the request URL:

curl "https://api.301link.com/v1/links?auth=550e8400-e29b-41d4-a716-446655440000"

Via Authorization Header

Include an Authorization header. Both formats are accepted:

# Bearer token format (recommended)
curl -H "Authorization: Bearer 550e8400-e29b-41d4-a716-446655440000" \
  https://api.301link.com/v1/links

# Bare token format
curl -H "Authorization: 550e8400-e29b-41d4-a716-446655440000" \
  https://api.301link.com/v1/links

Public Endpoints

The following endpoints do not require authentication:

  • GET /v1/get/:shortcode — Resolve a short link (the public redirect endpoint)
  • GET /v1/new_account — Create a new account

Error Responses

If authentication fails or the access code is invalid, the API responds with plaintext a la:

HTTP/1.1 401 Unauthorized
Content-Type: text/plain

Unable to [perform requested operation]

Pay close attention to the error message!