Every API request needs a Bearer token in the Authorization header. This page covers key types, permissions, test mode, and security.

Key Formats

API Keys page

cStar uses four key prefixes:

Prefix Type Environment
sk_live_ Secret Production
sk_test_ Secret Test/Sandbox
pk_live_ Publishable Production
pk_test_ Publishable Test/Sandbox

Keys are 32 random base64url characters after the prefix (so the alphabet includes A-Z, a-z, 0-9, -, and _). Example: sk_live_a1B2c3D4e5F6g7H8i9J0k-L2m3N4o5P6.

Secret Keys (Server-Side)

  • Full CRUD access: read, create, update, delete
  • 1,000 requests/hour rate limit
  • Server-side only: never expose in client code, bundle output, or Git repos
curl https://www.cstar.help/api/v1/teams/{teamId}/tickets \
  -H "Authorization: Bearer sk_live_your_secret_key" \
  -H "Content-Type: application/json"

Publishable Keys (Client-Side)

  • No team API access: team endpoints answer 403, reads included (publishable_key_forbidden for reads, publishable_key_write for writes)
  • 100 requests/hour rate limit
  • Safe for browsers and mobile apps

If you try to create or update a resource with a publishable key, the error tells you exactly what to do:

{
  "error": {
    "type": "authentication_error",
    "code": "publishable_key_write",
    "message": "Publishable keys are for public customer SDKs and cannot change staff data. Use a secret key (sk_live_ or sk_test_) for write operations."
  }
}

Public Library API (No Key)

Library endpoints require no authentication at all:

GET  /api/library/{team_slug_or_id}/articles
GET  /api/library/{team_slug_or_id}/articles/{slug}
GET  /api/library/{team_slug_or_id}/categories
GET  /api/library/{team_slug_or_id}/search?q={query}
POST /api/library/{team_slug_or_id}/articles/{slug}/view
POST /api/library/{team_slug_or_id}/articles/{slug}/feedback

These accept your team UUID or slug. Views are deduped per visitor and article for an hour, and each visitor gets one feedback vote per article. Reads have no app-level rate limit.

Test Mode

Test keys (sk_test_, pk_test_) work in the same team and database as live keys. Tickets, customers, and articles carry a test or live flag and stay separate between modes, while members, team settings, SLA settings, and custom field definitions are shared.

Use test mode during development so you never touch real customer data.

Making Authenticated Requests

const response = await fetch(
  'https://www.cstar.help/api/v1/teams/{teamId}/tickets',
  {
    headers: {
      'Authorization': 'Bearer sk_live_your_secret_key',
      'Content-Type': 'application/json'
    }
  }
);

const { success, data, error } = await response.json();

Authentication Errors

Code Status Meaning
authentication_required 401 Missing or malformed Authorization header
invalid_api_key 401 Key is invalid, revoked, or expired
invalid_key_format 401 Key doesn't start with a recognized prefix
publishable_key_forbidden 403 Publishable key used on a team endpoint, even for a read
insufficient_permissions 403 A test key tried to create a live key, or a key tried to change or remove the team owner
publishable_key_write 403 Tried to write with a publishable key
team_access_denied 403 Key doesn't belong to this team, its scope lacks the permission, or a member rule blocks it
feature_disabled 403 The team turned that feature off in Settings (Tickets, Community and so on). details.feature names it and details.enable_url links to the switch
team_paused 402 The team has no active subscription. Reads still work, so you can export data and revoke keys; writes resume when the owner subscribes

Every error includes a doc_url pointing to the relevant error docs.

Widget Authentication

In Custom Mode, the CStarChat widget SDK handles customer authentication separately (the default floating widget has no signup, login or isIdentified):

// Sign up a new customer (they confirm by email before they're signed in)
await CStarChat.signup({
  email: 'customer@example.com',
  name: 'Jane Doe',
  password: 'securepass123'
});

// Login an existing customer
await CStarChat.login({
  email: 'customer@example.com',
  password: 'securepass123'
});

// Sessions persist in localStorage
if (CStarChat.isIdentified()) {
  const customer = CStarChat.getCustomer();
}

For passing your own auth system's identity to the widget, see Customer Identity Verification.

Security Checklist

  • Store secret keys in environment variables, not source code
  • Use the public Library API in client-side code (publishable keys can't call the team API)
  • Rotate keys if a team member with access leaves
  • All API endpoints require HTTPS
  • Monitor usage in Settings → Team → API Keys

Related