API

Lock one visual style and its palette, then let your scripts, CI jobs and AI agents generate the on-style asset system — app icons, favicons, og-images, empty states, per-screen illustrations. One key, one URL, and every image is checked against the locked style before you get it, the same guarantee the app gives you.

1. Get a key

In the app, open Settings → API keys and generate one. The key is shown once; copy it then. It starts with sl_ and covers your account's projects. Revoke it any time from the same screen.

Send the key on every request in an Authorization: Bearer header.

2. Connect an AI agent

Agents that speak MCP — Claude Code, Cursor, Claude Desktop and others — connect to one URL with the key and get Stylelock as tools. Nothing to install.

Claude Code, one command:

claude mcp add --transport http stylelock https://app.stylelock.dev/api/mcp \
  --header "Authorization: Bearer sl_your_key"

Cursor, Claude Desktop and most others take the same thing as a config entry:

{
  "mcpServers": {
    "stylelock": {
      "url": "https://app.stylelock.dev/api/mcp",
      "headers": { "Authorization": "Bearer sl_your_key" }
    }
  }
}

Claude Desktop, claude.ai and ChatGPT take no key at all: add a custom connector with the URL https://app.stylelock.dev/api/mcp, sign in to Stylelock when asked, and approve. That approval creates a key named after the app under Settings → API keys; revoke it there to disconnect.

3. The tools

The connector's own instructions teach the assistant the routine, so you do not have to. In order:

Money. Exploring and generating are the paid steps; everything else is free. Each paid tool states its price in its own description, the first style explore on an account is free, and every paid result states the exact charge — so an agent can try, look, and try again, and it is told never to spend without you agreeing. Pass the same idempotencyKey on a retry and the same answer comes back, with nothing charged twice. When the balance is empty the call answers 402 and nothing is rendered; top up in the app under Credits.

4. Working inside a project

A project that uses Stylelock keeps .stylelock/stylelock.json, committed to the repo. It holds ids and what was locked — never a key:

{
  "version": 1,
  "family": { "version": 1 },
  "account": "app.stylelock.dev",
  "project": { "id": "…", "name": "Acme" },
  "palette": { "accent": "#2563EB", "secondary": "#0EA5E9", "bg": "#F8FAFC", "source": "stylelock" },
  "style": { "id": "…", "name": "flat-minimal", "source": "stylelock" }
}

When a call is refused

401 — no key, or a key we do not recognise

Check the header. A revoked or banned key answers 403.

404 — the project is not yours

Pass a project id from .stylelock/stylelock.json or list_projects.

400 — the brief names the artifact, not the artwork

Describe what should be drawn ("a running shoe mid-stride"), not "an app icon" or "a logo"; the result names the word to change.

409 — the style is already locked

A project locks one style. Create another project for a second look.

402 — out of credits

Top up under Credits and retry with the same idempotencyKey.

429 — this key is over its calls per minute

Wait the seconds given in Retry-After, then send the same request again.

What's new for agents