Beta

HitLink Links API

HitLink is now open. Create a free account to get started.

Docs home

What this is

The Links API creates short links and reads visit totals for one HitLink workspace. It is part of the Business plan. A Free, Starter, or Pro account does not have an API key that works. Calls go to https://links.hitlink.com, not to this docs site.

Create a key, and turn one off

Sign in at links.hitlink.com, then open Workspace. Only an owner or an admin can manage keys.

  1. Under API keys, type a name of up to 40 characters and press Create key.
  2. Copy the key immediately. HitLink shows it once. After that the page only shows the start of the key. HitLink stores a hash, not the key.
  3. To turn a key off, press Revoke next to it on that same page. A revoked key stops working at once.

Every example below uses the placeholder hlk_example_not_a_real_key. That is not a working key. Do not send a real key to anyone, and do not paste one into a public page.

Authentication

Send the key in the Authorization header:

Authorization: Bearer hlk_example_not_a_real_key

The value must start with hlk_. There is no CSRF header for an API key. A key that is missing, revoked, or not from a Business workspace is refused. Create then answers 403. Reading visit totals answers 401. The two messages are different today. Both mean the call was not accepted as an API key.

Base URL

https://links.hitlink.com

Rate limit

An API key can make 60 requests a minute. The count is for the whole workspace, so every key on that workspace shares it. It is a sliding minute, kept in memory on the app. A restart clears the count. HitLink does not send a Retry-After header or an X-RateLimit header.

The 429 body is JSON, with no extra headers beyond the usual JSON response:

{
  "error": "rate_limit",
  "message": "This API key has made too many requests. Wait a minute and try again."
}

Other limits

Requests

Send JSON, at most 16 KB. An unknown field is refused. The response is JSON, Content-Type: application/json; charset=utf-8, and it is not cached. An error body is {"error":"code","message":"what to do"}. A dangerous page also includes sources, a list of the lists that matched.

Create a short link

POST /v1/links. Checks the page, then creates one short link for the workspace that owns the key.

Fields:

Example:

curl -sS -X POST https://links.hitlink.com/v1/links \
  -H 'Authorization: Bearer hlk_example_not_a_real_key' \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://example.com/pricing","utm_source":"newsletter","utm_medium":"email","utm_campaign":"spring"}'

A successful call answers 201:

{
  "id": 1001,
  "slug": "abc1234",
  "domain": "htlk.link",
  "short_url": "https://htlk.link/abc1234",
  "destination": "https://example.com/pricing?utm_campaign=spring&utm_medium=email&utm_source=newsletter",
  "destination_stripped": "https://example.com/pricing",
  "redirect_code": 302,
  "safety_status": "unknown",
  "served": true
}

Read visit totals for one link

GET /v1/links/{id}/stats. Returns the campaign source, the campaign name, and the real-visit total for one link in this workspace.

id in the path is the number returned when the link was created. It has to belong to this workspace.

Example:

curl -sS https://links.hitlink.com/v1/links/1001/stats \
  -H 'Authorization: Bearer hlk_example_not_a_real_key'

A successful call answers 200:

{
  "id": 1001,
  "utm_source": "newsletter",
  "utm_campaign": "spring",
  "real_visits": 12
}

Errors

StatuserrorWhen
400bad_jsonThe body is not a JSON object, or it has a field the API does not know.
400bad_urlA campaign label could not be added to the address.
400invalid_slugThe ending is the wrong shape, or it uses a reserved word.
400invalid_redirectredirect_code is not 301 or 302.
400domain_not_foundThat short domain is not one this workspace can use.
400shortener_not_allowedThe page is another link shortener.
400invalid_urlThe address is missing, not a web address, or has too many query fields.
400unsupported_schemeThe address does not start with http:// or https://.
400credentials_not_allowedThe address contains a username or password.
400private_addressThe address is a private network or this computer.
400own_domainThe address is already a HitLink address.
400port_not_allowedThe address has a port number.
400url_too_longThe address is too long.
401unauthorizedReading visit totals without a usable key or a signed-in session.
403create_disabledCreating a link without a usable key. A bad key gets this, not 401.
403account_pausedThe workspace is paused. Signing in on the website turns it back on. An API call does not.
403domain_not_allowedThis plan cannot use that short domain.
403planVisit totals are not included in this plan.
404not_foundThat link number is not in this workspace.
409slug_takenThat ending is already used on that domain.
422destination_flaggedA safety list reports the page as dangerous. sources names the list.
422naming_ruleThe campaign labels do not follow the workspace rules.
429rate_limitThis workspace has made 60 API requests in the last minute.
429active_limitThe workspace is already at its link cap.
429daily_limitThe plan's daily create cap is used up. Business does not have one.
503unavailableHitLink could not finish the check. Try again.

Version

These paths start with /v1. HitLink will not change what an existing field means on /v1. A breaking change would be a new path, such as /v2. There is no separate version header.

Contact us · Report a link · Feedback · Terms of service · Privacy policy · Refund policy · Pricing · Free UTM builder · API docs