Skip to content

Manage personal access tokens🔗

Lightrun personal access tokens (PATs) provide a secure, reusable way to authenticate Lightrun MCP clients and Public API requests as your Lightrun user without an interactive browser sign-in. A PAT preserves your current role-based permissions and Agent Pool access, so clients can perform only the actions that you are authorized to perform.

Version availability

Personal access tokens are available starting with Lightrun version 1.93.1. They are supported for SaaS, Single-Tenant, and On-Premises deployments. Starting with version 1.98, a PAT can authenticate Lightrun Public API requests. Managing personal access tokens through the REST API is available starting with version 1.98, and on the 1.96 quarterly support release.

Supported authentication

PATs authenticate Lightrun MCP connections and, starting with version 1.98, Lightrun Public API requests. They do not authenticate IDE plugins or other Lightrun APIs.

Before you begin🔗

Ensure that:

  • Role-Based Access Control (RBAC) is enabled for your organization.
  • To use a PAT with the Public API, your role includes the permissions required by the endpoints you want to access and access to the relevant Agent Pools.
  • To use a PAT with Lightrun MCP: - Your role includes access to Lightrun MCP. - A Company Admin has enabled MCP access in Service Configuration. - You know your deployment's MCP endpoint URL. SaaS users connect to https://app.lightrun.com/mcp. For Single-Tenant and On-Premises deployments, find the URL under Platform > Lightrun MCP in the Management Portal.

Personal access tokens and system API keys🔗

PATs and system API keys both use a Bearer token, but they represent different identities and use cases.

Personal access token System API key
Identity The user who generated the token An organization-level system identity
Best suited for User-owned MCP and Public API clients when browser-based OAuth is unavailable or impractical Shared services, unattended automation, and Public API clients
Authorization The user's current RBAC permissions and Agent Pool access The key's API scopes and Agent Pool Access configuration
Supported authentication Lightrun MCP and, starting with version 1.98, Public API Lightrun MCP, Public API, and supported integrations
Who can generate it Any eligible user, for themselves An administrator

Changes to your role or Agent Pool assignments take effect immediately for existing PATs. A PAT never grants permissions beyond those assigned to its owner.

Generate a personal access token🔗

  1. Log in to the Lightrun Management Portal.
  2. Click Settings in the upper-right corner.
  3. Under Security, select Personal Access Tokens.

    The Personal Access Tokens page opens. Depending on your role, the table displays your tokens or all tokens in the organization.

  4. Click Generate PAT.

    The Generate PAT panel opens.

  5. In Token label, enter a label that identifies the client or device that will use the token.

    A label is optional. If you leave it blank, Lightrun assigns a label based on the token's last three characters.

  6. Under Expiration period, select 30 days, 60 days, 90 days, or Custom. The default is 90 days.

    For a custom expiration, select a date from tomorrow through two years from the current date.

  7. Click Generate.

    Lightrun generates the PAT and displays it once.

  8. Copy the token and store it in a secure secret manager.

Generate a personal access token and copy it from the success panel
Generate a personal access token and copy it before closing the success panel.

Copy the token before closing the panel

Lightrun stores only a hash of the PAT and cannot display the token again. If you lose it, revoke the token and generate a replacement. PATs begin with lr_pat_, which helps you identify them as Lightrun secrets.

Connect to Lightrun MCP with a PAT🔗

Configure your MCP client to send the PAT in the HTTP Authorization header:

Authorization: Bearer <PERSONAL_ACCESS_TOKEN>

For clients that use an mcp.json configuration file, add the MCP endpoint and header:

"Lightrun": {
  "url": "https://your-lightrun-server-domain/mcp",
  "headers": {
    "Authorization": "Bearer <PERSONAL_ACCESS_TOKEN>"
  }
}

Replace the URL when your deployment does not use Lightrun SaaS. Replace <PERSONAL_ACCESS_TOKEN> with the value that starts with lr_pat_.

Protect your PAT

Treat a PAT like a password. Do not commit it to source control or include it in logs, prompts, or support requests. Prefer a client-supported secret store or environment variable when available.

For client-specific connection instructions and an initial MCP test, see the Lightrun MCP quickstart.

Authenticate Public API requests with a PAT🔗

Starting with Lightrun version 1.98, send the PAT as a Bearer token in the HTTP Authorization header:

curl --header "Authorization: Bearer <PERSONAL_ACCESS_TOKEN>" \
  "https://<your-lightrun-server-domain>/api/v1/agent-pools"

Replace <PERSONAL_ACCESS_TOKEN> with the value that starts with lr_pat_. Lightrun authorizes the request using the token owner's current RBAC permissions and Agent Pool access. If the user does not have the permission required by the endpoint or access to the target Agent Pool, Lightrun returns 403 Forbidden.

Use a PAT when the API client should act as a specific Lightrun user. For shared services and organization-level automation that must remain independent of an individual user, use a system API key.

For available endpoints and request parameters, see the Lightrun API Reference.

Edit a token label🔗

You can change a token's label without changing its value or expiration date:

  1. On the Personal Access Tokens page, select the token.
  2. In the Token panel, update Token label.
  3. Click Save.

Revoke and delete a personal access token🔗

Revoke a PAT immediately when it is exposed, no longer required, or belongs to a client that should no longer connect.

  1. On the Personal Access Tokens page, click Revoke and Delete for the token.
  2. In the confirmation dialog, click Revoke and delete.

    Lightrun immediately rejects subsequent authentication attempts with the token. This action cannot be undone.

PAT management permissions🔗

Visibility and management of existing PATs depend on the user's role:

Role View PATs Edit labels or revoke PATs
Company Admin All PATs in the organization All PATs in the organization
Company Viewer or Operations All PATs in the organization Own PATs only
Other roles Own PATs only Own PATs only

Regardless of who can view or manage a PAT, MCP and Public API requests always use the current permissions and Agent Pool access of the token owner.

In the Management Portal, users generate PATs only for themselves. With the REST API, a Company Admin, or a system API key with the Company scope, can create a PAT for another active user in the organization.

Manage personal access tokens with the REST API🔗

Starting with Lightrun version 1.98, and on the 1.96 quarterly support release, you can list, create, and revoke personal access tokens with the Lightrun REST API. Call these endpoints with a system API key.

The same operations are available on both of these paths:

  • /api/v1/pat
  • /api/v1/personal-access-token

For the request and response fields, see Personal access tokens in the API reference.

List personal access tokens🔗

GET /api/v1/pat returns the active tokens the caller is allowed to see.

  • labelFilter is optional. It matches the token label with a case-insensitive partial match. Leave it empty to return every visible token.
  • Results are paged with page and size. The first page is 0, and the default page size is 20.
  • Sort by createdDate. The default sort is newest first: createdDate,desc.

A Company Admin, a Company Viewer, an Operations user, or a system API key with the Company scope receives every active token in the organization. Other roles receive only their own tokens.

For the operation contract, see Get personal access tokens.

Get a personal access token🔗

GET /api/v1/pat/{id} returns one active token.

Lightrun returns 404 when the token does not exist or the caller cannot view it. Lightrun returns 403 when the caller is not allowed to use the endpoint.

For the operation contract, see Get a personal access token.

Create a personal access token🔗

POST /api/v1/pat creates a token. The request body requires expirationDays, from 1 through 730. label is optional and can contain up to 255 characters. If you omit the label, Lightrun assigns one from the last three characters of the token.

Omit userId to create the token for the authenticated user. Set userId to create the token for another active user in the same company. Creating a token for another user requires a Company Admin or a system API key with the Company scope. A system API key creates a token for a user by setting userId.

curl -X POST "https://<your-domain>/api/v1/pat" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expirationDays": 90, "label": "cursor-laptop", "userId": "<user-id>"}'

Lightrun returns 201 and the token value in the token field. Lightrun returns the secret only in this response. Copy it and store it in a secure secret manager. Later list and get responses do not include the token secret. Lightrun returns 404 when userId is not a user in the company, and 409 when that user is inactive.

For the operation contract, see Create a personal access token.

Revoke a personal access token🔗

DELETE /api/v1/pat/{id} revokes one active token and returns 204. Lightrun immediately rejects later authentication attempts with that token. This action cannot be undone.

A Company Admin, or a system API key with the Company scope, can revoke any token in the organization. Other roles can revoke their own tokens. Lightrun returns 404 when the token does not exist or the caller cannot manage it, and 403 when the caller is not allowed to use the endpoint.

For the operation contract, see Revoke a personal access token.

Revoke all personal access tokens🔗

DELETE /api/v1/pat revokes every active personal access token in the company and returns 204.

This revokes every token in the company

Revoking all tokens immediately disconnects every MCP client that authenticates with a personal access token in the organization. Only a Company Admin, or a system API key with the Company scope, can call this endpoint. Other callers receive 403.

For the operation contract, see Revoke all personal access tokens.


Last update: November 24, 2026