Skip to content
LinkProfit

Quickstart

Create your first short link through the API in two minutes with curl, JavaScript or Python.

Updated August 13, 2026

Two minutes from zero to a working short link. You need a workspace API key with the links:write scope — create one in your dashboard under Settings → API keys (the full value is shown once).

The snippets read the base URL and the key from environment variables, so the same commands work against production and a local instance:

export LINKPROFIT_API_BASE="https://api.linkprofit.com/v1"
export LINKPROFIT_API_KEY="lp_live_…your key…"
curl -s -X POST "$LINKPROFIT_API_BASE/links" \
  -H "Authorization: Bearer $LINKPROFIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/summer-sale", "title": "Summer sale"}'

The response is the full link object:

{
  "data": {
    "id": "lnk_2f8k1mVq3xZcW9yTb4Nda",
    "short_url": "https://go.your-brand.com/x7f2q1z",
    "domain": "go.your-brand.com",
    "slug": "x7f2q1z",
    "url": "https://example.com/summer-sale",
    "title": "Summer sale",
    "has_password": false,
    "public_stats": false,
    "created_at": "2026-08-13T10:00:00.000Z"
  }
}

Without domain_id the link lands on your default domain; without slug a free code is generated. Every option of the link model — targeting, A/B split, expiry, password, UTM, pixels — is accepted in the same request; see the reference.

curl -s "$LINKPROFIT_API_BASE/links?limit=10" \
  -H "Authorization: Bearer $LINKPROFIT_API_KEY"

Lists are cursor-paginated: follow pagination.next_cursor until it is null.

3. Read the summary

curl -s "$LINKPROFIT_API_BASE/analytics/summary" \
  -H "Authorization: Bearer $LINKPROFIT_API_KEY"

Requires the analytics:read scope. Without dates the last 30 days are shown.

The same in JavaScript

const base = process.env.LINKPROFIT_API_BASE;
const key = process.env.LINKPROFIT_API_KEY;

const response = await fetch(`${base}/links`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${key}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com/summer-sale" }),
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.code}: ${error.message}`);
}

const { data } = await response.json();
console.log(data.short_url);

The same in Python

import os
import requests

base = os.environ["LINKPROFIT_API_BASE"]
key = os.environ["LINKPROFIT_API_KEY"]

response = requests.post(
    f"{base}/links",
    headers={"Authorization": f"Bearer {key}"},
    json={"url": "https://example.com/summer-sale"},
    timeout=10,
)
response.raise_for_status()
print(response.json()["data"]["short_url"])

Retry-safe creation

Pass an Idempotency-Key header on any mutation. Repeating the request with the same key returns the stored response instead of creating a second link — safe to retry after a network timeout:

curl -s -X POST "$LINKPROFIT_API_BASE/links" \
  -H "Authorization: Bearer $LINKPROFIT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-42-launch" \
  -d '{"url": "https://example.com/launch"}'

Keys are stored for 24 hours; the same key with a different body answers 409 conflict.