Beta
HitLink Links API
HitLink is now open. Create a free account to get started.
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.
- Under API keys, type a name of up to 40 characters and press Create key.
- 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.
- 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
- Creating a link counts toward the Business cap of 25,000 links at a time. Deleting a link frees a place. There is no daily create cap on Business.
- Links to other shorteners are refused on every plan, including Business.
- The new page is checked the same way as a link made on the website. A page listed as dangerous is not shortened. The response names the list that matched.
- If the workspace has naming rules, the campaign labels have to follow them.
- A custom short domain has to be one this workspace already verified, and the plan has to include it. Leave domain out to use htlk.link.
- Changing the page a link opens is not an API call. On the website that change is limited to 20 times an hour for the workspace. The API cannot make that change.
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:
url, required. The page to shorten. http or https.domain, optional. A short domain this workspace can use. Empty means htlk.link.slug, optional. The ending, 3 to 32 characters. Empty means HitLink chooses one.redirect_code, optional. 302, the usual choice, or 301. Empty means 302.utm_source,utm_medium,utm_campaign,utm_term,utm_content, all optional. If you send any of them, HitLink adds them to the page address.
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
| Status | error | When |
|---|---|---|
| 400 | bad_json | The body is not a JSON object, or it has a field the API does not know. |
| 400 | bad_url | A campaign label could not be added to the address. |
| 400 | invalid_slug | The ending is the wrong shape, or it uses a reserved word. |
| 400 | invalid_redirect | redirect_code is not 301 or 302. |
| 400 | domain_not_found | That short domain is not one this workspace can use. |
| 400 | shortener_not_allowed | The page is another link shortener. |
| 400 | invalid_url | The address is missing, not a web address, or has too many query fields. |
| 400 | unsupported_scheme | The address does not start with http:// or https://. |
| 400 | credentials_not_allowed | The address contains a username or password. |
| 400 | private_address | The address is a private network or this computer. |
| 400 | own_domain | The address is already a HitLink address. |
| 400 | port_not_allowed | The address has a port number. |
| 400 | url_too_long | The address is too long. |
| 401 | unauthorized | Reading visit totals without a usable key or a signed-in session. |
| 403 | create_disabled | Creating a link without a usable key. A bad key gets this, not 401. |
| 403 | account_paused | The workspace is paused. Signing in on the website turns it back on. An API call does not. |
| 403 | domain_not_allowed | This plan cannot use that short domain. |
| 403 | plan | Visit totals are not included in this plan. |
| 404 | not_found | That link number is not in this workspace. |
| 409 | slug_taken | That ending is already used on that domain. |
| 422 | destination_flagged | A safety list reports the page as dangerous. sources names the list. |
| 422 | naming_rule | The campaign labels do not follow the workspace rules. |
| 429 | rate_limit | This workspace has made 60 API requests in the last minute. |
| 429 | active_limit | The workspace is already at its link cap. |
| 429 | daily_limit | The plan's daily create cap is used up. Business does not have one. |
| 503 | unavailable | HitLink 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