All Guides

Your First API Call

Get your API key, make your first request to the Linksii API, and parse the response. From zero to working integration in under 5 minutes.

~5 min

Prerequisites

  • Active Linksii account on the Enterprise plan
  • At least one workspace created in your account
  • curl, Node.js 18+, or Python 3.8+ installed

API access is available on Enterprise plans only. If you're on Starter or Pro, upgrade from Settings → Billing or view pricing.


Get Your API Key

API keys are managed from Settings → API Keys. Each key starts with lnk_ and is shown only once — copy it immediately.

1

Navigate to API Keys

Go to Settings → API Keys in your Linksii dashboard, or use the API to create a key programmatically.

2

Create a new key

Click New API Key, give it a name (e.g. "My Integration"), and copy the key that appears.

curl -X POST https://www.linksii.com/api/v1/keys \
  -H "Authorization: Bearer lnk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"name": "My Integration"}'

Response

{
  "data": {
    "id": "key_01HXYZ",
    "name": "My Integration",
    "key": "lnk_a1b2c3d4e5f6g7h8i9j0",
    "created_at": "2025-06-01T10:00:00Z",
    "last_used_at": null
  }
}

Store your key in an environment variable — never hard-code it in source files. Use LINKSII_API_KEY=lnk_... in your .env file.


First Request

The simplest call is listing your workspaces. Every API request needs an Authorization header with your key as a Bearer token.

curl https://www.linksii.com/api/v1/workspaces \
  -H "Authorization: Bearer lnk_your_api_key_here"

Replace lnk_your_api_key_here with your actual key. In production, always load it from an environment variable.


Parse the Response

All Linksii API responses follow a consistent envelope: a data array for collections (or object for single resources) and a meta object with pagination info.

Workspaces response

{
  "data": [
    {
      "id": "ws_01HXYZ",
      "name": "Acme Corp",
      "slug": "acme-corp",
      "plan": "enterprise",
      "created_at": "2025-01-15T09:00:00Z"
    }
  ],
  "meta": {
    "total": 1,
    "limit": 20,
    "offset": 0
  }
}

Extracting the workspace ID

# Pipe through jq to extract the first workspace ID
curl https://www.linksii.com/api/v1/workspaces \
  -H "Authorization: Bearer lnk_your_api_key_here" \
  | jq -r '.data[0].id'

Save your workspaceId — most other endpoints accept it as a query parameter to scope results to a specific workspace.


Fetch Tracking Results

Once you have a workspace ID, fetch its AI tracking results — brand mentions detected across ChatGPT, Claude, Gemini, and Perplexity.

curl "https://www.linksii.com/api/v1/tracking?workspace_id=ws_01HXYZ&limit=5" \
  -H "Authorization: Bearer lnk_your_api_key_here"

Response

{
  "data": [
    {
      "id": "run_01HABC",
      "workspace_id": "ws_01HXYZ",
      "platform": "chatgpt",
      "score": 72,
      "mention_count": 14,
      "prompt_count": 8,
      "ran_at": "2025-06-01T08:00:00Z",
      "status": "complete"
    },
    {
      "id": "run_01HDEF",
      "workspace_id": "ws_01HXYZ",
      "platform": "claude",
      "score": 68,
      "mention_count": 11,
      "prompt_count": 8,
      "ran_at": "2025-06-01T08:00:00Z",
      "status": "complete"
    }
  ],
  "meta": {
    "total": 2,
    "limit": 5,
    "offset": 0
  }
}

Error Handling

The API uses standard HTTP status codes. Error responses always include an error field explaining what went wrong.

Error response shape

{
  "error": "Unauthorized — invalid or missing API key",
  "status": 401
}

Common status codes

CodeMeaning
400Bad Request — check your request body or query params
401Unauthorized — missing or invalid API key
403Forbidden — your plan does not include API access
404Not Found — resource does not exist
429Rate Limited — slow down and retry after the reset time
500Server Error — retry with exponential backoff

Handling errors in code

# Check HTTP status — non-2xx means an error
STATUS=$(curl -s -o /tmp/response.json -w "%{http_code}" \
  https://www.linksii.com/api/v1/workspaces \
  -H "Authorization: Bearer lnk_your_api_key_here")

if [ "$STATUS" -ne 200 ]; then
  echo "Error $STATUS: $(cat /tmp/response.json | jq -r '.error')"
  exit 1
fi

cat /tmp/response.json | jq '.data'

Next Steps

You've made your first API call. Here's what to explore next: