Skip to contentSkip to page list

Docs

API Keys

Create and manage API keys in LangWatch. Use personal keys for development and AI assistants, or service keys for CI/CD and automation.

On this page

Ingestion keys and API keys

LangWatch has two kinds of credentials. An ingestion key starts with ik-lw- and can only write traces. An API key starts with sk-lw- and can read and change whatever its scope and permissions allow. Both are managed at Settings > API Keys.

Ingestion keyAPI key
What it doesWrites traces. It cannot read, update or deleteReads and manages everything its permissions allow
Permissionstraces:create onlyThe permission categories you pick, capped by the owner's permissions on a personal key
ScopeExactly one projectOne or more projects, teams, or the whole organization
Use it forAgent environments, CLIs and OTLP exporters that only push telemetrySDK setup, MCP, CI/CD, dashboards and automation
If it leaksThe holder can create traces in one project, and cannot read or delete anythingThe holder gets whatever the key grants. Treat it like a password

An ingestion template mints an ingestion key and writes it into the tool's OTEL_EXPORTER_OTLP_HEADERS; the langwatch <tool> CLI does the same. An ingestion key can reference the template so the receiver shapes the trace into the gen_ai.* attributes. The rest of this page covers API keys.

Key types

Personal keyService key
OwnerOne userNone; it belongs to the organization
Use it forLocal development, AI assistants over MCP, personal scriptsCI/CD pipelines, automation, service-to-service calls
PermissionsNever more than the owner holds at the time of the requestThe scope and the permission mode you set
Who can create itAny memberOrganization admins
When the owner leavesRemoving the owner from the organization revokes their bindings, so the key can no longer do anything. A deactivated owner's key is rejectedKeeps working

The Project API Key shown on the project setup page, and in the Legacy row of Settings > API Keys, still works and is not going away. It carries its project, so it does not need LANGWATCH_PROJECT_ID. Rotate it from that row. Create keys from Settings > API Keys when you need scoped permissions.

Create a personal key

  1. Open Settings > API Keys

    Go to Settings > API Keys and click Create new secret key.

  2. Fill in the drawer

    • Key type: shown to organization admins only, with a picker for the member who owns a personal key. Other members always create a personal key for themselves
    • Name: for example Local dev or MCP key
    • Scope: the projects, teams or the organization the key can access. The current project is picked for you
    • Expiration: No expiration by default, or 7, 30, 60 or 90 days, or Custom

    That is all a first key needs: it gets all of its owner's permissions on that scope. The owner is you, or the member an admin picked, and the key never holds more than they do. Open Advanced to change the rest:

    • Description: optional
    • Permissions: All gives the key its owner's permissions on each scope. Restricted lets you pick read or write per permission category
  3. Copy the key

    Click Create secret key. The key is shown once, as sk-lw-<id>_<secret>, with ready-made .env, HTTP header, terminal and MCP snippets whose copy buttons carry the real key. Copy it now; the table never shows it again.

    The Token created dialog with the new key, .env values and code assistant snippets

Use a personal key

Set the key and the project id in the environment. The SDKs and the MCP server read both.

.envBash
LANGWATCH_API_KEY="sk-lw-..."LANGWATCH_PROJECT_ID="your-project-id"

The project id is in Settings > Projects and in the project URL. A key scoped to exactly one project resolves that project on its own; a key that reaches more than one project needs LANGWATCH_PROJECT_ID.

Organization admins can also create a personal key for another member: the drawer shows a member picker, and the key is capped by that member's permissions.

Create a service key

Service keys are for automated systems: CI/CD pipelines, production services and scripts that span projects. They have no owner, so they keep working when people leave.

Only organization admins create service keys.
  1. Open Settings > API Keys

    Go to Settings > API Keys and click Create new secret key.

  2. Fill in the drawer

    • Key type: Service
    • Name
    • Scope: the projects, teams or the organization the key can access
    • Expiration
    • Under Advanced:
      • Description: optional
      • Permissions: All gives Admin on every scope you picked. Restricted gives only the categories you tick
    Warning

    A service key scoped to the organization with All permissions is an organization-wide Admin. Scope service keys to the projects they serve.

  3. Copy the key

    Click Create secret key and store the key. It is shown once.

Use a service key

Set LANGWATCH_API_KEY and LANGWATCH_PROJECT_ID as for a personal key. Endpoints that work on the organization, for example the spend events and webhook endpoints of the LangWatch AI Gateway, accept an organization-scoped key without a project id.

.envBash
LANGWATCH_API_KEY="sk-lw-..."LANGWATCH_PROJECT_ID="your-project-id"

Permission categories

A Restricted key holds read or write access per category. Read grants the view action on the resources in the category. Write grants every action on them.

CategoryReadWrite
TracesView traces and spansCreate, update and share traces
CostView cost analyticsRead only
ScenariosView scenarios and runsCreate and manage scenarios
AnnotationsView annotationsCreate and manage annotations
AnalyticsView analytics dashboardsCreate and manage dashboards
EvaluationsView evaluationsCreate and manage evaluations
LangyView Langy conversationsStart and manage Langy conversations
DatasetsView datasetsCreate and manage datasets
TriggersView triggersCreate and manage triggers
WorkflowsView workflowsCreate and manage workflows
ExperimentsView experimentsCreate and manage experiments
PromptsView promptsCreate and manage prompts
PlaygroundView the playgroundRun the playground
SecretsList secretsCreate and manage secrets
Agent CacheView the agent cacheManage the agent cache
Audit LogView the audit logRead only
TeamView team membersManage team membership
ProjectView project settingsCreate, update and delete projects
OrganizationView the organizationManage the organization
GatewayView virtual keys, budgets, providers, routing policies, guardrails, usage, cache rules, spend and webhook endpointsManage all of them
GovernanceView governance, ingestion sources, anomaly rules, compliance exports, the activity monitor and AI toolsManage all of them

Also check: Access Control (RBAC) for the actions each resource accepts.

Connect an AI assistant over MCP

The LangWatch MCP Server is hosted at https://app.langwatch.ai/mcp. Most AI clients connect to it with OAuth: you sign in and approve a project, and no key is involved. See the MCP setup guide.

A client that cannot sign in can send a personal key as a header instead. The key gives the MCP server access to traces, analytics, prompts and the other features your key allows:

example.shBash
claude mcp add --transport http langwatch https://app.langwatch.ai/mcp --header "Authorization: Bearer sk-lw-..."

To run the MCP server on your machine instead, give it both LANGWATCH_API_KEY and LANGWATCH_PROJECT_ID:

example.shBash
claude mcp add langwatch --env LANGWATCH_API_KEY=sk-lw-... --env LANGWATCH_PROJECT_ID=your-project-id -- npx -y @langwatch/mcp-server

The dialog that shows a new key prints these commands with the key and the project id filled in. See the MCP setup guide for the other editors.

The langwatch login key

langwatch login in the CLI opens a browser page where you approve the scopes, then creates a personal Restricted key named CLI login - <device> and stores it in ~/.langwatch/config.json as cli_api_key. The default selection holds every permission category except managing or deleting the organization and managing teams, at organization scope for organization admins and on your teams otherwise.

One key exists per device: a new login replaces the previous key and langwatch logout revokes it. The key appears in Settings > API Keys as a personal key with the Restricted badge, and you can revoke it there too.

How permissions are resolved

A personal key never exceeds its owner. On every request LangWatch intersects the key's permissions with what the owner holds at that moment, so a demoted owner's key loses access at the same time.

A service key has no owner. Its permissions come from its scope and permission mode alone.

Manage keys

Settings > API Keys lists every key with Name, Status, Secret Key (the prefix only), Created, Last Used, Type (the owner's email, or Service), Scope and Permissions. A scope filter above the table narrows the list to one project, team or the organization.

Click a key to open its details: owner, scope, permissions, expiry, creation date and last use. The secret is never shown again after it is created.

The key's owner and organization admins can:

  • Edit the name, description, permission mode, categories and scope
  • Rotate the key to get a new secret with the same settings. After you confirm, the new secret is shown once and the old secret is refused at once; there is no overlap period. The key keeps its name, owner, scope, permissions, expiry and usage history. An expired or revoked key cannot be rotated
  • Revoke the key. A revoked key is refused at once and cannot be restored

The Ingestion keys table on the same page lists ingestion keys; organization admins revoke them.

Set an expiration on keys made for a short task, and revoke keys that show no Last Used date for a while.

Documentation