#### Enterprise

# Service accounts

> [!NOTE]
>
> Service accounts are available on the [Enterprise plan](/build/agents-window/enterprise).

Service accounts are non-human accounts that enable teams to securely automate Grok Build-powered workflows at scale. With service accounts, you can consume APIs, authenticate [self-hosted workers](#using-service-accounts-with-self-hosted-workers), and invoke [cloud agents](/build/agents-window/cloud-agent) without tying integrations to individual developers' personal accounts.

## Why use service accounts

As teams find new ways to automate coding tasks with Grok Build cloud agents, APIs, and CLI, the need for centralized, secure automation becomes critical. Service accounts address this by:

* **Decoupling from individuals**: Automations continue running even as people and roles change
* **Secure credential management**: Easily rotate API keys without disrupting workflows
* **Centralized access control**: Admins manage all service account permissions in one place
* **Attribution and auditability**: Tie cloud agent runs to the initiating service or system

## Key features

### No additional seat required

Service accounts are included with your Enterprise plan at no extra cost. They do not consume a seat license.

### Usage consumption

Service accounts consume usage from your team's usage pool, like human users. All usage is tracked and visible in your team's analytics and billing.

### Cloud Agent integration

Service accounts can initiate [cloud agent](/build/agents-window/cloud-agent) runs programmatically. This enables automation scenarios such as:

* A ticket created in Linear triggering a cloud agent to implement a feature
* An error in Sentry initiating a cloud agent to investigate and fix the issue
* Internal engineering services kicking off migrations or refactoring tasks

### Admin visibility

Cloud agent runs initiated by service accounts are accessible to all team admins. This ensures visibility and oversight of automated workflows across your organization.

### Repository access

Each service account API key has a repository scope: **All repositories from the team's connected Git providers** or **Specific repositories only**. A key can initiate cloud agent runs only on repositories in its scope that have been authorized via the [Cursor GitHub App](/build/agents-window/integrations/github).

> [!WARNING]
>
> The GitHub integration must be connected at the team level for service accounts to access repositories. If you have a personal GitHub integration but no team-level integration, service accounts will not be able to initiate cloud agent runs.

To connect GitHub at the team level:

1. Navigate to **Grok Dashboard** → **Settings** → **Integrations**
2. Connect the Cursor GitHub App to your organization
3. Authorize the repositories you want service accounts to access

Repository access is governed by the permissions configured for your team's GitHub app installation. To change a key's scope later, use **Edit repository access** on the service account.

## Creating a service account

Admins can create and manage service accounts from the [Grok Dashboard](https://grok.com/dashboard).

1. Navigate to **Grok Dashboard** → **Settings** → **API Keys** → **Service Accounts**
2. Click **New Service Account**
3. Enter a name and optional description for the service account
4. Click **Create**

Each service account API key has its own permissions and repository scope, which you choose when you create the key. Permissions cover areas such as members, usage and spend, audit logs, settings, repositories, Bugbot, security findings, and Cloud Agents. **Run Cloud Agents** is selected by default.

When you create a service account, an API key is generated. Copy this key immediately. It is shown only once and can't be retrieved later.

> [!NOTE]
>
> Store your API key securely. If you lose it, you'll need to rotate it to generate a new one.

## Managing API keys

Each service account can have API keys associated with it. You can:

* **View masked keys**: See the last few characters of each key for identification
* **Rotate keys**: Generate a new key and invalidate the old one
* **Edit permissions and repository access**: Change what a key can do and which repositories it can reach
* **Edit name and description**: Rename an active service account or update its description. Its existing API keys keep working
* **Set spend limits**: Cap how much a service account can spend per billing period
* **Suspend service accounts**: Stop all of a service account's API keys from working without revoking them, then resume it later
* **Archive service accounts**: Archive a service account and revoke all its API keys

### Rotating an API key

To rotate an API key:

1. Navigate to **Grok Dashboard** → **Settings** → **API Keys** → **Service Accounts**
2. Find the service account and click the rotate icon next to its API key
3. Copy the new key immediately

The old key is invalidated. Update any integrations using the old key.

## Spend limits

Admins can cap how much each service account spends per billing period.

1. Navigate to **Grok Dashboard** → **API keys** → **Service accounts**
2. Open the actions menu next to the service account and click **Edit monthly spend limit**
3. Choose **Limit spend each month** and enter an amount, or choose **No limit**
4. Click **Save**

The Service accounts table shows each account's current limit in the **Monthly spend limit** column. New service accounts have no limit by default.

When a service account reaches its limit, its requests are blocked with a "Service account spend limit reached" error for the rest of the billing period. A team admin can raise or remove the limit at any time to restore access immediately.

> [!NOTE]
>
> Spend limits do not apply to Bugbot: Bugbot usage is billed through your Bugbot subscription, so Bugbot service accounts are never blocked by a spend limit.

## Using service accounts with the API

Service accounts authenticate using their API key. Use the key in the `Authorization` header when making requests to the [Cloud Agents API](/build/agents-window/cloud-agent/api/endpoints):

```bash
curl -X POST https://api.cursor.com/agents \
  -H "Authorization: Bearer YOUR_SERVICE_ACCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "repo": "owner/repo",
    "prompt": "Implement the feature described in issue #123"
  }'
```

See the [Cloud Agents API documentation](/build/agents-window/cloud-agent/api/endpoints) for the full API reference.

## Using service accounts with self-hosted workers

Service accounts authenticate [pool workers](/build/agents-window/cloud-agent/self-hosted/pool#authenticate-workers): `cursor-agent worker --pool start` reads the key from `CURSOR_API_KEY`, so workers in CI, Kubernetes, and other non-interactive hosts start without a browser login. Personal and team API keys can't start pool workers.

```bash
curl https://cursor.com/install -fsS | bash
export CURSOR_API_KEY=your_service_account_api_key
cursor-agent worker --pool start
```

For headless agent runs in CI, use the Grok Build TUI's [headless mode](/build/cli/headless-scripting) with an `XAI_API_KEY`.

## Security best practices

* **Rotate keys regularly**: Establish a key rotation schedule for your service accounts
* **Use descriptive names**: Name service accounts after their purpose (e.g., "Linear Integration", "Sentry Auto-Fix")
* **Limit scope**: Create separate service accounts for different automation workflows
* **Monitor usage**: Review service account activity in your team's analytics dashboard
* **Revoke unused accounts**: Archive service accounts that are no longer in use

## Suspending a service account

Suspending a service account stops its API keys from working until you resume it. The keys are kept, so resuming restores access without rotating them.

To suspend a service account:

1. Navigate to **Grok Dashboard** → **Settings** → **API Keys** → **Service Accounts**
2. Click the pause icon next to the service account
3. Confirm the suspend action

Suspended accounts show a **Suspended** badge. To resume one, click the play icon next to it and confirm.

## Archiving a service account

Archiving a service account:

* Revokes all API keys associated with the account
* Breaks any integrations using those keys
* Preserves the account record for auditability

To archive a service account:

1. Navigate to **Grok Dashboard** → **Settings** → **API Keys** → **Service Accounts**
2. Click the archive icon next to the service account
3. Confirm the archive action

> [!NOTE]
>
> Archived accounts can be viewed by clicking **Show Archived** on the Service Accounts page. This helps maintain a complete audit trail of service accounts used by your team.
