#### Admin API

# Organization API

The Organization API lets you perform actions that apply across teams linked to an organization, such as moving users between those teams, reporting on pooled usage across teams, managing organization groups, reading or updating model access, and managing members' Grok Bot computers. It uses an **Organization API key** and the same HTTP patterns as the [team Admin API](/build/agents-window/account/teams/admin-api).

* The Organization API uses [Basic Authentication](/build/agents-window/api#basic-authentication) with your API key as the username.
* For details on creating API keys, authentication methods, rate limits, and best practices, see the [API Overview](/build/agents-window/api).

## Organization API keys vs Team API keys

Organization API keys are organization-scoped credentials. Team API keys are team-scoped credentials.

Use an **Organization API key** when calling organization-level endpoints like `/organizations/team-memberships/sync`, `/organizations/pooled-usage`, and `/organizations/groups`.

Use a **Team API key** when calling endpoints under `/teams/*` (for example, `/teams/members` and `/teams/spend`).

### Key differences

* **Scope**: Organization API keys can act across teams linked to the same organization. Team API keys can only act within one team.
* **Endpoint compatibility**: Organization endpoints require Organization API keys. Team endpoints require Team API keys.
* **Key scopes**: Each route requires a specific scope on the key. Read-only membership routes accept **`members:read`**; membership and group write routes need **`members:*`**; usage routes need **`usage:*`**. Keys with **`admin:*`** work everywhere because admin implies the other scopes. Grok Bot computer operations accept only **`admin:*`**.
* **Authorization failures**: If the key scope does not match the endpoint scope, requests fail with authentication or authorization errors (typically `401` or `403`).

### Scopes

Every Organization API key carries exactly one scope. A route runs only when the key's scope covers it, and broader scopes include everything narrower scopes allow.

| Scope | Access | Example routes |
|-------|--------|----------------|
| `members:read` | Read-only access to organization membership. | `GET /organizations/members` |
| `members:*` | Read and write access to membership, groups, and member sessions. Includes everything `members:read` allows. | `GET /organizations/members`, `POST /organizations/team-memberships/sync`, all `/organizations/groups` routes, all `/organizations/members/:userId/sessions` routes |
| `usage:*` | Read access to pooled usage and reporting. | `POST /organizations/pooled-usage`, `POST /organizations/filtered-usage-events`, `POST /organizations/daily-usage-data`, `POST /organizations/spend` |
| `models:read` | Read-only access to model-access configuration and provider inventories. | `GET /organizations/teams/model-access/configuration`, `GET /organizations/teams/{teamId}/model-access/configuration`, `GET /organizations/teams/{teamId}/model-access/providers` |
| `models:*` | Read and write access to model access. Includes everything `models:read` allows. | All model-access routes, including bulk provider/model toggles and bulk configuration |
| `auditlogs:read` | Read-only access to the organization audit log feed. | `GET /organizations/audit-logs` |
| `admin:*` | Full access to every organization route. The only scope that can run [Grok Bot computer operations](#grok-bot-computers). | All of the above, plus every `/organizations/teams/{teamId}/grok-bot/operations` route |

Pick the narrowest scope for the job. Use `members:read` for read-only integrations that list members but never change membership. Use `models:read` or `models:*` for model-access automation without granting full admin. You can select these scopes when you create an Organization API key in the dashboard.

### How should I pass an Organization API key?

Pass it the same way as other Grok Build API keys: Basic authentication with the key as the username and an empty password.

```bash
curl -X POST https://api.cursor.com/organizations/team-memberships/sync \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "users": [
      { "userId": 12345, "destinationTeamId": 7 }
    ]
  }'
```

## Members

Read organization membership, move members between the teams linked to your organization, and manage members' sign-in sessions.

> [!NOTE]
>
> * **Availability**: Enterprise only
> * **Authentication**: Organization API key (Basic auth). Reading members accepts the read-only **`members:read`** scope; moving members requires **`members:*`**. Keys with **`admin:*`** work for both. For member session routes, see [Member sessions](#member-sessions).
> * **Scope**: `GET /organizations/members` is organization-scoped and paginated, returning each member's organization role plus every linked-team assignment in one response.
> * **Pagination**: `GET /organizations/members` accepts `page` and `pageSize`. `pageSize` is capped at 200; larger values are clamped to 200.

### List organization members

`GET /organizations/members`

Retrieve members of the organization attached to your API key, along with each member's organization role and their assignments across linked teams. Results are paginated.

#### Query parameters

`page` (number): Page number (1-indexed). Defaults to the first page.

`pageSize` (number): Number of members per page. Capped at 200; values above 200 are clamped to 200.

`teamId` (number): Return only members of this team. A team that isn't linked to the organization returns an empty page.

`userId` (number | string): Return only this user. Accepts the numeric user ID (for example `12345`) or the encoded `user_…` ID that [`GET /teams/members`](/build/agents-window/account/teams/admin-api#get-team-members) returns.

#### Response fields

`members` (array): Array of organization member objects, each containing:

* `id` (number) - Numeric user ID of the member, such as `12345`. The team [`GET /teams/members`](/build/agents-window/account/teams/admin-api#get-team-members) endpoint returns the same user as an encoded `user_…` ID, so the two values don't match as strings. To join the two lists, pass either form to the `userId` filter, or match on `email`.
* `email` (string) - Email address of the member
* `name` (string) - Display name of the member
* `organizationRole` (string) - Organization-level role, either `admin` or `member`. This is distinct from each team assignment's `teamRole`: a user can be an org `admin` while holding a `member` role on a specific team, or vice versa.
* `teams` (array) - The member's assignments across teams linked to the organization. Each object contains:
  * `teamId` (number) - Integer ID of a linked team the member belongs to
  * `teamRole` (string) - Role within that team (e.g., `member`, `owner`)

`pagination` (object): Pagination metadata: `page`, `pageSize`, `totalCount`, `totalPages`, `hasNextPage`, and `hasPreviousPage`.

```bash
curl -X GET "https://api.cursor.com/organizations/members?page=1&pageSize=50" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "members": [
    {
      "id": 12345,
      "email": "developer@company.com",
      "name": "Alex",
      "organizationRole": "member",
      "teams": [
        { "teamId": 7, "teamRole": "member" },
        { "teamId": 8, "teamRole": "owner" }
      ]
    },
    {
      "id": 12346,
      "email": "admin@company.com",
      "name": "Sam",
      "organizationRole": "admin",
      "teams": [
        { "teamId": 7, "teamRole": "owner" }
      ]
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 50,
    "totalCount": 2,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  }
}
```

### Sync organization team memberships

`POST /organizations/team-memberships/sync`

Set the teams that one or more users belong to within your organization. This matches the bulk style of the CSV import API: you send an array of users and receive a result row for each one.

Each entry must use exactly one of `teamIds` or `destinationTeamId`:

* `teamIds` is the **complete set** of team IDs the user should belong to. The endpoint reconciles the user's memberships to exactly that set. It adds any listed teams the user is not on yet and removes any teams that are not listed. To keep a user on their current team while adding another during a migration, list both (for example `[oldTeamId, newTeamId]`).
* `destinationTeamId` puts the user on a **single** team. They are placed on the specified team and removed from every other team. Setting `destinationTeamId: NNN` is functionally equivalent to `teamIds: [NNN]`.

#### Request body

`organizationId` (string, required): Public organization ID (for example `org_abc123`). Must match the organization for the Organization API key used to call the endpoint.

`users` (array, required): Non-empty list of entries (at most 500 per request). Each element is an object with a user ID and exactly one team field (`teamIds` or `destinationTeamId`):

* `userId` (number | string): ID of the user to sync. Accepts either the numeric user ID as a JSON integer (for example `12345`) or the encoded `user_…` ID as a string (for example `"user_abc123"`).
* `teamIds` (number\[]): The complete set of org-linked team IDs the user should belong to after the sync. Memberships are reconciled to exactly this set. Any team not listed is removed. Include the user's current teams to keep them (for example `[7, 8]`). At most 100 teams per entry.
* `destinationTeamId` (number): Field for syncing to a single team. Setting `destinationTeamId: NNN` is the same as sending `teamIds: [NNN]`. The user's teams are set to exactly that one team. Must be a team linked to the organization.

Provide exactly one of `teamIds` or `destinationTeamId` per entry.

#### Success response (HTTP 200)

`results` (array): One entry per requested sync, in order. Each object includes `userId`, the resolved `teamIds` for that entry, and either `status: &quot;success&quot;` or `status: &quot;error&quot;` with `errorMessage` when that row failed. Entries sent with `destinationTeamId` also echo `destinationTeamId` (the first team in `teamIds`).

`successCount` (number): Number of rows with `status: &quot;success&quot;`.

`errorCount` (number): Number of rows with `status: &quot;error&quot;`.

> [!NOTE]
>
> * **Availability**: Enterprise only
> * **Authentication**: Organization API key (Basic auth). The key must include the **`members:*`** scope for this route; keys with **`admin:*`** also work because admin implies members.
> * **Organization match**: The `organizationId` in the body must be the same organization as the API key; otherwise the request is rejected.
> * **Team set**: `teamIds` is the exact set of teams the user should belong to after the call. The user will be removed from any team NOT listed, so include the user's existing teams in the set to retain them.
> * **One team field per entry**: Provide exactly one of `teamIds` or `destinationTeamId` for each entry.
> * **Per-entry team cap**: An entry's `teamIds` may list at most 100 teams.
> * The target user must already be a member of the organization for a sync to succeed.
> * Every team in the entry must be linked to the organization for the sync to succeed.
> * If one entry in `users` fails, others can still succeed; check each `results` entry's `status` and `errorMessage`.
> * **Batch size**: A single request may include up to 500 entries. Send additional batches in separate requests if needed.

```bash
curl -X POST https://api.cursor.com/organizations/team-memberships/sync \
  -u YOUR_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "users": [
      { "userId": 12345, "teamIds": [7, 8] },
      { "userId": "user_abc123", "destinationTeamId": 8 }
    ]
  }'
```

The first entry links user `12345` to exactly teams `7` and `8` (adding either team the user isn't already on, and removing any other linked team). The second entry uses `destinationTeamId`, which is the same as sending `teamIds: [8]`.

**Response:**

```json
{
  "results": [
    {
      "userId": 12345,
      "teamIds": [7, 8],
      "status": "success"
    },
    {
      "userId": "user_abc123",
      "teamIds": [8],
      "destinationTeamId": 8,
      "status": "success"
    }
  ],
  "successCount": 2,
  "errorCount": 0
}
```

**Error responses:**

Most thrown API errors use HTTP **401**, **403**, or **400** and a JSON body shaped like:

```json
{
  "code": "error",
  "message": "…"
}
```

**404: organization not found** (this route uses a different field name for the message):

```json
{
  "error": "Organization not found"
}
```

**401: invalid Organization API key** (wrong or missing key):

```json
{
  "code": "error",
  "message": "Invalid Organization API Key"
}
```

**401: missing required scope** (key is valid but does not include `members:*` or `admin:*`):

```json
{
  "code": "error",
  "message": "Organization API key missing required scope: members:*"
}
```

**403: organization does not match the key** (`organizationId` in the body is not the organization for this API key):

```json
{
  "code": "error",
  "message": "Not authorized"
}
```

**400: invalid request body** (examples; only one applies per failed request):

```json
{
  "code": "error",
  "message": "Request body is required"
}
```

```json
{
  "code": "error",
  "message": "organizationId is required"
}
```

```json
{
  "code": "error",
  "message": "users must be a non-empty array"
}
```

```json
{
  "code": "error",
  "message": "users must not contain more than 500 moves"
}
```

**Per-row failures (HTTP 200)**: Validation or business rules for a single entry are returned in `results` with `status: "error"` and `errorMessage`. The examples below use `destinationTeamId`, so the rows echo `destinationTeamId`; entries sent with `teamIds` echo `teamIds` instead. Invalid `userId` / `destinationTeamId` types use `0` for the invalid field in the row:

```json
{
  "results": [
    {
      "userId": 0,
      "destinationTeamId": 7,
      "status": "error",
      "errorMessage": "Invalid userId"
    }
  ],
  "successCount": 0,
  "errorCount": 1
}
```

```json
{
  "results": [
    {
      "userId": 12345,
      "destinationTeamId": 0,
      "status": "error",
      "errorMessage": "Invalid destinationTeamId"
    }
  ],
  "successCount": 0,
  "errorCount": 1
}
```

```json
{
  "results": [
    {
      "userId": 0,
      "destinationTeamId": 0,
      "status": "error",
      "errorMessage": "Invalid userId. Invalid destinationTeamId"
    }
  ],
  "successCount": 0,
  "errorCount": 1
}
```

**Per-row failures (HTTP 200)**: From the sync logic when inputs are well-typed but the change cannot be applied:

```json
{
  "results": [
    {
      "userId": 12345,
      "destinationTeamId": 999,
      "status": "error",
      "errorMessage": "Team is not linked to this organization"
    }
  ],
  "successCount": 0,
  "errorCount": 1
}
```

```json
{
  "results": [
    {
      "userId": 12345,
      "destinationTeamId": 7,
      "status": "error",
      "errorMessage": "User is not a member of this organization"
    }
  ],
  "successCount": 0,
  "errorCount": 1
}
```

```json
{
  "results": [
    {
      "userId": 12345,
      "destinationTeamId": 7,
      "status": "error",
      "errorMessage": "User not found"
    }
  ],
  "successCount": 0,
  "errorCount": 1
}
```

### Member sessions

List an organization member's active sign-in sessions and sign them out. These routes match the team [member sessions](/build/agents-window/account/teams/admin-api#member-sessions) API, scoped to your organization.

> [!NOTE]
>
> * **Authentication**: Organization API key (Basic auth). Listing needs the **View member sign-ins** permission. Revoking needs **Sign members out**. A legacy key needs the **`members:*`** scope for both routes, and **`admin:*`** also works. A key without the permission or scope, such as a `members:read` key, returns `401`. See [API key permissions](/build/agents-window/security/api-keys#permissions).
> * **Member IDs**: `:userId` takes the numeric user ID that [`GET /organizations/members`](#list-organization-members) returns, such as `12345`. The encoded `user_…` ID from the team [`GET /teams/members`](/build/agents-window/account/teams/admin-api#get-team-members) endpoint also works. The user must be a current member of the organization attached to your API key.
> * **Pagination**: The list route is cursor-based. Pass the `nextCursor` value from one response as `cursor` on the next request. The last page returns `nextCursor: null`.
> * **Rate limit**: Each route allows 20 requests per minute per organization. See [rate limits and best practices](/build/agents-window/api#rate-limits).
> * **Audit log**: Every revoke is recorded in your organization's [audit log](#audit-logs), with your API key's name as the actor.

Member session routes share these error responses. Error bodies use the shape `{ "code": "error", "message": "…" }`.

| Status | When |
|--------|------|
| `400` | Malformed `userId`, `limit`, `cursor`, or request body |
| `401` | Invalid API key, or the key is missing the permission or scope the route needs |
| `404` | The user isn't a current member of your organization (`Organization member not found`), or the session to revoke doesn't exist or has already ended (`Session not found`) |
| `429` | Rate limit exceeded. The response includes a `Retry-After: 60` header |

### List member sessions

`GET /organizations/members/:userId/sessions`

Retrieve an organization member's active sign-in sessions, newest first. A member who has never signed in returns an empty list.

#### Parameters

`userId` (number | string, required): Numeric user ID of the member (for example `12345`), or their encoded `user_…` ID.

#### Query parameters

`limit` (number): Number of sessions per page, from 1 to 100. Defaults to `50`. Values outside that range return `400`.

`cursor` (string): The `nextCursor` value from the previous page. Omit it to start from the newest session. An invalid cursor returns `400`.

#### Response fields

`sessions` (array): Array of session objects, each containing:

* `sessionId` (string) - Session identifier. Pass it with `type` to [revoke this session](#revoke-member-sessions).
* `type` (string) - Where the session signs in: `client`, `web`, `mobile`, or `grok_bot_mobile`. `unknown` means Grok Build couldn't classify the session.
* `createdAt` (string) - When the session started, in ISO 8601 format
* `expiresAt` (string) - When the session expires, in ISO 8601 format
* `lastActiveAt` (string) - When the session was last used, in ISO 8601 format. Omitted, along with `lastIp`, `lastLocation`, and `clientType`, when Grok Build has no recorded activity for the session.
* `lastIp` (string) - IP address the session was last used from. Omitted when unknown.
* `lastLocation` (string) - Country the session was last used from. Omitted when unknown.
* `clientType` (string) - The client that last used the session, such as `Web`, `Desktop IDE`, `Desktop app`, `TUI`, `Mobile app`, or `Grok Bot`.

`nextCursor` (string | null): Pass this value as `cursor` to fetch the next page. `null` when there are no more sessions.

```bash
curl -X GET "https://api.cursor.com/organizations/members/12345/sessions?limit=50" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "sessions": [
    {
      "sessionId": "sess_web_8f2c41",
      "type": "web",
      "createdAt": "2026-11-02T16:45:00.000Z",
      "expiresAt": "2026-12-02T16:45:00.000Z",
      "lastActiveAt": "2026-11-20T08:30:00.000Z",
      "lastIp": "203.0.113.10",
      "clientType": "Web"
    },
    {
      "sessionId": "sess_client_3a9d07",
      "type": "client",
      "createdAt": "2026-10-28T09:12:00.000Z",
      "expiresAt": "2026-11-27T09:12:00.000Z"
    }
  ],
  "nextCursor": null
}
```

### Revoke member sessions

`POST /organizations/members/:userId/sessions/revoke`

Sign an organization member out of one session, or out of every session at once.

#### Parameters

`userId` (number | string, required): Numeric user ID of the member (for example `12345`), or their encoded `user_…` ID.

#### Request body

Send one of two forms: `sessionId` with `type` to revoke one session, or `allSessions: true` to revoke every session. Mixing the two forms, adding other fields, or sending `allSessions: false` returns `400`.

`sessionId` (string): The session to revoke, from [List member sessions](#list-member-sessions). Required with `type`.

`type` (string): The session's `type` from the list: `client`, `web`, `mobile`, or `grok_bot_mobile`. Required with `sessionId`. A session ID that doesn't match an active session of this type for this member returns `404`.

`allSessions` (boolean): Set to `true` to revoke every session the member has. Send it on its own.

> [!NOTE]
>
> Revoking all sessions signs the member out everywhere. It applies to their whole Grok Build account, not only your organization: it ends their sessions for every team and organization they belong to and for personal use. The member keeps their organization membership and can sign in again.

#### Response fields

`revokedCount` (number): Number of sessions revoked. A single-session revoke returns `1`, or `0` if the session ended before the revoke completed. Revoking all sessions returns how many sessions the member had, or `0` if they had none.

**Revoke one session:**

```bash
curl -X POST https://api.cursor.com/organizations/members/12345/sessions/revoke \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "sessionId": "sess_web_8f2c41",
    "type": "web"
  }'
```

**Response:**

```json
{
  "revokedCount": 1
}
```

**Revoke all sessions (signs the member out everywhere):**

```bash
curl -X POST https://api.cursor.com/organizations/members/12345/sessions/revoke \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "allSessions": true
  }'
```

**Response:**

```json
{
  "revokedCount": 4
}
```

**Error responses:**

```json
{
  "code": "error",
  "message": "Organization member not found"
}
```

## Usage

Report on usage across every team linked to your organization. These endpoints aggregate data from all teams in the [organization pool](/build/agents-window/enterprise/pooled-usage), so you don't need a separate Team API key per team. For single-team reporting, use the team [Admin API](/build/agents-window/account/teams/admin-api) usage endpoints instead.

> [!NOTE]
>
> * **Availability**: Enterprise only
> * **Authentication**: Organization API key (Basic auth). The key must include the **`usage:*`** scope for these routes; keys with **`admin:*`** also work because admin implies usage.
> * **Organization match**: The `organizationId` in the body must be the same organization as the API key; otherwise the request is rejected.
> * **Team containment**: Every entry in `teamIds` must belong to the organization. Requests that reference a team outside the organization are rejected.
> * **Polling**: Usage data is aggregated at the hourly level. Poll these endpoints at most once per hour. Rate limited to 20 requests per minute. See [rate limits and best practices](/build/agents-window/api#rate-limits).

### Get pooled usage

`POST /organizations/pooled-usage`

Retrieve organization-pooled usage: the pool's spend limit, total usage across the organization, and a per-team breakdown. This powers the pooled-usage section of the dashboard. All monetary fields are in cents.

> [!NOTE]
>
> This endpoint doesn't split usage by product. To see Grok Bot and Grok Build usage separately, use the `product` filter on [`/organizations/filtered-usage-events`](#get-usage-events).

#### Request body

`organizationId` (string, required): Public organization ID (for example `org_abc123`). Must match the organization for the Organization API key used to call the endpoint.

#### Response fields

`pool` (object): Pool-level totals for the current contract period:

* `limitCents` (number) - Pooled spend limit for the organization, in cents
* `usedCents` (number) - Total pooled usage consumed so far, in cents
* `remainingCents` (number) - Remaining pooled budget (`limitCents` minus `usedCents`), in cents
* `contractStartDate` (string | null) - ISO 8601 timestamp marking the start of the current contract period, or `null` when no contract dates are set
* `contractEndDate` (string | null) - ISO 8601 timestamp marking the end of the current contract period, or `null` when no contract dates are set

`teams` (array): Per-team usage breakdown. The sum of every `usedCents` equals `pool.usedCents`. Each object contains:

* `teamId` (number) - Integer ID of a team linked to the organization
* `usedCents` (number) - Usage consumed by this team during the current contract period, in cents
* `budgetLimitCents` (number | undefined) - Per-team budget cap in cents. Present only when a budget is configured for the team.

```bash
curl -X POST https://api.cursor.com/organizations/pooled-usage \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123"
  }'
```

**Response:**

```json
{
  "pool": {
    "limitCents": 5000000,
    "usedCents": 1862340,
    "remainingCents": 3137660,
    "contractStartDate": "2026-01-01T00:00:00.000Z",
    "contractEndDate": "2026-12-31T23:59:59.999Z"
  },
  "teams": [
    {
      "teamId": 7,
      "usedCents": 1440100,
      "budgetLimitCents": 2000000
    },
    {
      "teamId": 8,
      "usedCents": 422240
    }
  ]
}
```

### Get usage events

`POST /organizations/filtered-usage-events`

Retrieve detailed usage events across the teams linked to your organization. This is the organization-wide counterpart to the team [`/teams/filtered-usage-events`](/build/agents-window/account/teams/admin-api#get-usage-events-data) endpoint: it returns the same event shape, with each event tagged by its owning `teamId`.

> [!NOTE]
>
> By default, events from **all** teams in the organization pool are returned. Pass `teamIds` to restrict the response to specific teams.

> [!NOTE]
>
> **Cost Calculation**: Sum the `chargedCents` field across events to reconcile event-level costs with the per-team `usedCents` breakdown from [`/organizations/pooled-usage`](#get-pooled-usage). This field includes both the model cost and the Grok Build Token Rate when a request is eligible for the rate.

> [!NOTE]
>
> The `cursorTokenFee` field represents the Grok Build Token Rate and is only present when the rate applies to a third-party model request. This includes when Auto routes to a third-party model. First-party models such as Grok and Composer, and request-based enterprise accounts do not include this fee. See [Grok Build Token Rate](/x-subscription/cursor-token-rate).

> [!NOTE]
>
> **Grok Bot Spend**: Every event includes `product`, set to `grok-bot` or `cursor`. To get Grok Bot spend, pass `product: "grok-bot"` and sum `chargedCents`. Usage paid from a credit grant has `kind` set to `Credit` and `chargedCents` set to `0`, so this sum leaves it out. Work that Grok Bot delegates to [Cloud Agents](/build/agents-window/cloud-agent) is billed as Grok Build usage and returns `cursor`. Events before 2026-07-19 have no stored product and return `cursor`, including Grok Bot usage from that period.

#### Request body

`organizationId` (string, required): Public organization ID (for example `org_abc123`). Must match the organization for the Organization API key used to call the endpoint.

`teamIds` (number\[]): Optional set of integer team IDs to include. Each must belong to the organization. When omitted, all teams in the organization pool are included.

`startDate` (number): Start date in epoch milliseconds. This bound is inclusive.

`endDate` (number): End date in epoch milliseconds. This bound is inclusive.

`userId` (number): Filter by specific user ID.

`email` (string): Filter by user email address.

`serviceAccountId` (string): Filter by service account ID.

`product` (string): Filter by the product that generated the event. When omitted or `null`, events from every product are returned. Accepted values:

* `grok-bot` - Grok Bot usage
* `cursor` - all other usage, including events with no stored product

> [!NOTE]
>
> An unrecognized `product` value returns a `400` error rather than an empty result. Field names are case-sensitive: the endpoint ignores `Product`. A request with `product` set to `grok-bot` or `cursor` never returns unfiltered events. If the events can't be read, the request fails with a `503` or `500` error. If a `503` repeats, use a shorter date range.

`page` (number): Page number (1-indexed). Default: `1`

`pageSize` (number): Number of results per page. Default: `10`

#### Response fields

Each object in `usageEvents` contains the same fields as the team endpoint, plus an owning-team tag:

* `teamId` (number) - Integer ID of the team that owns this event
* `timestamp` (string) - Event timestamp in epoch milliseconds (as a string)
* `userEmail` (string) - Email address of the user who made the request
* `serviceAccountId` (string | undefined) - ID of the service account that made the request. Omitted for human user events.
* `serviceAccountName` (string | undefined) - Display name of the service account that made the request. Omitted for human user events.
* `prAuthor` (string | undefined) - SCM username of the pull request author. Present on events from Bugbot reviews of pull requests. Omitted for other events.
* `repo` (string | undefined) - Repository the Bugbot review ran on, in `host/owner/repo` form, such as `github.com/your-org/your-repo`. Omitted for events outside Bugbot reviews of pull requests.
* `prNumber` (number | undefined) - Pull request or merge request number the Bugbot review ran on. Omitted for events outside Bugbot reviews of pull requests.
* `model` (string) - AI model used for the request
* `kind` (string) - Billing category (e.g., `Usage-based`, `Included in Business`)
* `maxMode` (boolean) - Whether the request used max mode
* `requestsCosts` (number) - Cost in request units
* `isTokenBasedCall` (boolean) - Whether the request was billed by token usage
* `isChargeable` (boolean) - Whether this event incurs a charge
* `isHeadless` (boolean) - Whether this request was made without a connected client (e.g., background agents)
* `tokenUsage` (object | undefined) - Token usage details (present when `isTokenBasedCall` is `true`):
  * `inputTokens` (number) - Input tokens consumed
  * `outputTokens` (number) - Output tokens generated
  * `cacheWriteTokens` (number) - Tokens written to cache
  * `cacheReadTokens` (number) - Tokens read from cache
  * `totalCents` (number) - Total model cost in cents
  * `discountPercentOff` (number | undefined) - Discount percentage applied, if any
* `chargedCents` (number) - Total amount charged in cents for this event. For third-party model requests subject to the Grok Build Token Rate, this includes model cost plus the Grok Build Token Rate.
* `cursorTokenFee` (number | undefined) - Grok Build Token Rate in cents. Present only when the rate applies to a third-party model request (including when Auto routes to a third-party model).
* `product` (string) - Product that generated the event: `grok-bot` for Grok Bot, `cursor` for all other usage. Older events have no stored product and return `cursor`, including Grok Bot usage. See the Grok Bot Spend note above for the date.

```bash
# Events across all teams in the organization pool
curl -X POST https://api.cursor.com/organizations/filtered-usage-events \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "startDate": 1748411762359,
    "endDate": 1751003762359,
    "page": 1,
    "pageSize": 25
  }'

# Events restricted to specific teams
curl -X POST https://api.cursor.com/organizations/filtered-usage-events \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "teamIds": [7, 8],
    "startDate": 1748411762359,
    "endDate": 1751003762359,
    "page": 1,
    "pageSize": 25
  }'
```

**Response:**

```json
{
  "totalUsageEventsCount": 113,
  "pagination": {
    "numPages": 12,
    "currentPage": 1,
    "pageSize": 10,
    "hasNextPage": true,
    "hasPreviousPage": false
  },
  "usageEvents": [
    {
      "teamId": 7,
      "timestamp": "1750979225854",
      "userEmail": "developer@company.com",
      "model": "claude-4.5-sonnet",
      "kind": "Usage-based",
      "maxMode": true,
      "requestsCosts": 5,
      "isTokenBasedCall": true,
      "isChargeable": true,
      "isHeadless": false,
      "tokenUsage": {
        "inputTokens": 126,
        "outputTokens": 450,
        "cacheWriteTokens": 6112,
        "cacheReadTokens": 11964,
        "totalCents": 20.18232
      },
      "chargedCents": 21.36232,
      "cursorTokenFee": 1.18,
      "product": "cursor"
    },
    {
      "teamId": 8,
      "timestamp": "1750978339901",
      "userEmail": "admin@company.com",
      "model": "claude-4-sonnet-thinking",
      "kind": "Included in Business",
      "maxMode": true,
      "requestsCosts": 1.4,
      "isTokenBasedCall": false,
      "isChargeable": false,
      "isHeadless": false,
      "chargedCents": 8,
      "product": "cursor"
    }
  ],
  "period": {
    "startDate": 1748411762359,
    "endDate": 1751003762359
  }
}
```

**Grok Bot spend example:**

```bash
curl -X POST https://api.cursor.com/organizations/filtered-usage-events \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "startDate": 1785542400000,
    "endDate": 1788220799999,
    "product": "grok-bot",
    "page": 1,
    "pageSize": 100
  }'
```

Each matching event has `product` set to `grok-bot`. Sum `chargedCents` across the events to calculate Grok Bot spend for the period. Group the events by `teamId` to split it by team.

### Get daily usage data

`POST /organizations/daily-usage-data`

Retrieve daily usage metrics for every member across the teams linked to your organization. This is the organization-wide counterpart to the team [`/teams/daily-usage-data`](/build/agents-window/account/teams/admin-api#get-daily-usage-data) endpoint, with each row tagged by its owning `teamId`. Results are paginated by user and return data for all members with a membership during the requested date range; use `page` and `pageSize` to page through them.

#### Request body

`organizationId` (string, required): Public organization ID (for example `org_abc123`). Must match the organization for the Organization API key used to call the endpoint.

`startDate` (number): Start date in epoch milliseconds. Defaults to 7 days ago.

`endDate` (number): End date in epoch milliseconds. Defaults to now.

`teamIds` (number\[]): Org-linked teams to report on. When omitted, all teams in the organization pool are included. At most 100 teams per request.

`page` (number): Page number (1-indexed). Default: `1`

`pageSize` (number): Number of users per page (1-1000). Default: `1000`

`userEmail` (string): Filter to one or more users by email. Accepts a single email or a comma-separated list. `userEmails` is accepted as an alias.

> [!NOTE]
>
> Date range cannot exceed 30 days. Make multiple requests for longer periods.

> [!NOTE]
>
> The fields `subscriptionIncludedReqs`, `usageBasedReqs`, and `apiKeyReqs` count raw usage events, not billable request units in older request-based pricing.

#### Response fields

Each object in the `data` array contains the same fields as the team [daily usage](/build/agents-window/account/teams/admin-api#get-daily-usage-data) endpoint, plus a `teamId`. Key fields:

* `userId` (string) - Encoded user ID with the `user_` prefix (e.g., `user_abc123`)
* `teamId` (number) - ID of the org-linked team this row belongs to
* `day` (string) - The date this record covers (ISO date, e.g., `2024-03-18`)
* `date` (number) - Date as epoch milliseconds
* `email` (string) - User's email address
* `isActive` (boolean) - Whether the user had activity on this day
* `totalLinesAdded` (number) - Total lines of code added
* `totalLinesDeleted` (number) - Total lines of code deleted
* `acceptedLinesAdded` (number) - AI-suggested lines added that were accepted
* `acceptedLinesDeleted` (number) - AI-suggested lines deleted that were accepted
* `totalApplies` (number) - Total AI code apply actions
* `totalAccepts` (number) - Total accepted AI suggestions
* `totalRejects` (number) - Total rejected AI suggestions
* `totalTabsShown` (number) - Total Tab completions shown to the user
* `totalTabsAccepted` (number) - Total Tab completions accepted by the user
* `composerRequests` (number) - Number of Composer requests made
* `chatRequests` (number) - Number of chat requests made
* `agentRequests` (number) - Number of Agent mode requests made
* `cmdkUsages` (number) - Number of Cmd+K inline edit usages
* `subscriptionIncludedReqs` (number) - Requests included in the subscription plan
* `apiKeyReqs` (number) - Requests made via API key
* `usageBasedReqs` (number) - Usage-based (overage) requests
* `bugbotUsages` (number) - Number of Bugbot usages
* `mostUsedModel` (string | null) - Most frequently used AI model for the day
* `applyMostUsedExtension` (string | null) - Most common file extension for apply actions
* `tabMostUsedExtension` (string | null) - Most common file extension for Tab completions
* `clientVersion` (string | null) - Agents Window version used

The response also includes a `pagination` object (`page`, `pageSize`, `totalUsers`, `totalPages`, `hasNextPage`, `hasPreviousPage`) and a `period` object (`startDate`, `endDate`).

```bash
curl -X POST https://api.cursor.com/organizations/daily-usage-data \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "startDate": 1710720000000,
    "endDate": 1710892800000,
    "page": 1,
    "pageSize": 1000
  }'
```

**Response:**

```json
{
  "data": [
    {
      "userId": "user_abc123",
      "teamId": 101,
      "day": "2024-03-18",
      "date": 1710720000000,
      "isActive": true,
      "totalLinesAdded": 1543,
      "totalLinesDeleted": 892,
      "acceptedLinesAdded": 1102,
      "acceptedLinesDeleted": 645,
      "totalApplies": 87,
      "totalAccepts": 73,
      "totalRejects": 14,
      "totalTabsShown": 342,
      "totalTabsAccepted": 289,
      "composerRequests": 45,
      "chatRequests": 128,
      "agentRequests": 12,
      "cmdkUsages": 67,
      "subscriptionIncludedReqs": 180,
      "apiKeyReqs": 0,
      "usageBasedReqs": 5,
      "bugbotUsages": 3,
      "mostUsedModel": "claude-sonnet-4.5",
      "applyMostUsedExtension": ".tsx",
      "tabMostUsedExtension": ".ts",
      "clientVersion": "0.25.1",
      "email": "developer@company.com"
    }
  ],
  "period": {
    "startDate": 1710720000000,
    "endDate": 1710892800000
  },
  "pagination": {
    "page": 1,
    "pageSize": 1000,
    "totalUsers": 150,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  }
}
```

### Get spending data

`POST /organizations/spend`

Retrieve per-member spend across the teams linked to your organization. This is the organization-wide counterpart to the team [`/teams/spend`](/build/agents-window/account/teams/admin-api#get-spending-data) endpoint, with each member tagged by its owning `teamId`. Unlike the team endpoint, spend is reported over the **organization contract window** (not per-team billing cycles) using the same included-spend definition as [`/organizations/pooled-usage`](#get-pooled-usage), so the numbers reconcile with the pool.

> [!NOTE]
>
> This endpoint doesn't split spend by product. To see Grok Bot and Grok Build usage separately, use the `product` filter on [`/organizations/filtered-usage-events`](#get-usage-events).

#### Request body

`organizationId` (string, required): Public organization ID (for example `org_abc123`). Must match the organization for the Organization API key used to call the endpoint.

`teamIds` (number\[]): Org-linked teams to report on. When omitted, all teams in the organization pool are included. At most 100 teams per request.

`sortBy` (string): Sort by: `email`, `name`, `spendCents`. Default: `email`

`sortDirection` (string): Sort direction: `asc`, `desc`. Default: `asc`

`page` (number): Page number (1-indexed). Default: `1`

`pageSize` (number): Results per page (1-1000). Default: `100`

> [!NOTE]
>
> Spend is reported across the organization's pooled teams, so the single-team fields `subscriptionCycleStart`, `overallSpendCents`, `fastPremiumRequests`, `hardLimitOverrideDollars`, and `monthlyLimitDollars` from `/teams/spend` are not included. The reporting window is returned in `period`.

#### Response fields

Each object in `teamMemberSpend` contains:

* `userId` (string) - Encoded user ID with the `user_` prefix (e.g., `user_abc123`)
* `teamId` (number) - ID of the org-linked team this member belongs to
* `name` (string) - Display name of the user
* `email` (string) - Email address of the user
* `role` (string) - Role in the team (e.g., `member`, `owner`)
* `spendCents` (number) - Included pool spend in cents attributed to this member over the organization contract window

The response also includes `totalMembers` (number), `totalPages` (number), and a `period` object (`startDate`, `endDate` in epoch milliseconds) describing the organization contract window.

```bash
curl -X POST https://api.cursor.com/organizations/spend \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "sortBy": "spendCents",
    "sortDirection": "desc",
    "page": 1,
    "pageSize": 25
  }'
```

**Response:**

```json
{
  "teamMemberSpend": [
    {
      "userId": "user_abc123",
      "teamId": 101,
      "name": "Alex",
      "email": "developer@company.com",
      "role": "member",
      "spendCents": 2450
    },
    {
      "userId": "user_def456",
      "teamId": 202,
      "name": "Sam",
      "email": "admin@company.com",
      "role": "owner",
      "spendCents": 1875
    }
  ],
  "totalMembers": 15,
  "totalPages": 1,
  "period": {
    "startDate": 1735689600000,
    "endDate": 1767225600000
  }
}
```

## Model access

> [!WARNING]
>
> Model access routes are in preview and may change. Paths, response fields, and error behavior can shift before general availability.

Read and update [model access](/build/agents-window/enterprise/model-and-integration-management#model-access-control) policy for teams linked to the organization. These routes match the team [model access](/build/agents-window/account/teams/admin-api#model-access) API, scoped to linked teams.

Use the list and per-team GETs to catch configuration drift. Align teams with configuration PUTs plus provider/model toggles (including per-model `parameters`). There is no org-level copy endpoint or policy fingerprint.

Enabling a model without parameter settings leaves it on the catalog defaults. Use the bulk model route when defaults such as Fast do not match your organization policy.

Numeric `teamId` values come from routes such as [`GET /organizations/members`](#list-organization-members).

> [!NOTE]
>
> * **Availability**: Enterprise organizations. Target teams must have model access control enabled.
> * **Authentication**: Organization API key (Basic auth). Reads require **`models:read`**. Writes require **`models:*`**. Keys with **`admin:*`** work for both. **`members:*`**, **`usage:*`**, and **`read:*`** keys cannot call these routes.
> * **Team containment**: Every `teamId` must be linked to the organization. On single-team routes, unknown or unlinked teams return **404**. On bulk routes, unlinked teams are HTTP 200 error rows.
> * **Configuration first**: Provider and model reads and writes return **409** while that team is still `unrestricted` (or `legacy`). Create a custom policy with `PUT /organizations/teams/{teamId}/model-access/configuration` first (or the bulk configuration route). The first defaults PUT seeds catalog defaults; it does not clone another team's on/off map.
> * **Return to unrestricted**: Send `{ "state": "unrestricted" }` on the per-team or bulk configuration PUT.
> * **Bulk partial success**: Bulk routes accept up to 100 `teamIds` and always return HTTP **200** when the batch is *processed*, even if some rows fail. Inspect `errorCount` and every `results[].status`. Successful rows are **not** rolled back. Operations are idempotent per team, so retry only the failed `teamId`s. A **4xx** or **5xx** response rejects the whole request and applies no changes. Response shape matches [`/organizations/team-memberships/sync`](#sync-organization-team-memberships).
> * **Rate limits**: 20 requests per minute. Writes appear in team audit logs as `team_settings` events. See [rate limits and best practices](/build/agents-window/api#rate-limits).

### List model access configuration

`GET /organizations/teams/model-access/configuration`

List model-access configuration for linked teams. Use this to find unrestricted vs custom policy drift. For on/off drift, `GET` each team's providers and compare.

If a linked team does not have model access control enabled, that row is still HTTP 200 and includes `errorMessage` instead of `state` / defaults. Per-team GET and write routes for that team return **403**.

#### Query parameters

`page` (number): Page number (1-indexed).

`pageSize` (number): Results per page.

`teamIds` (string): Optional comma-separated team IDs, for example `7,8,9`.

```bash
curl -X GET "https://api.cursor.com/organizations/teams/model-access/configuration?page=1&pageSize=50" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "teams": [
    {
      "teamId": 7,
      "teamName": "Platform",
      "state": "custom",
      "newProviderDefault": "disabled",
      "newModelDefault": "enabled"
    },
    {
      "teamId": 8,
      "teamName": "Mobile",
      "state": "custom",
      "newProviderDefault": "disabled",
      "newModelDefault": "enabled"
    },
    {
      "teamId": 9,
      "teamName": "Data",
      "state": "unrestricted",
      "newProviderDefault": null,
      "newModelDefault": null
    },
    {
      "teamId": 10,
      "teamName": "Research",
      "errorMessage": "Model access control is not available for this team"
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 50,
    "totalCount": 4,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  }
}
```

### Get team model access configuration

`GET /organizations/teams/:teamId/model-access/configuration`

Get configuration for one linked team.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

```bash
curl -X GET https://api.cursor.com/organizations/teams/7/model-access/configuration \
  -u YOUR_ORGANIZATION_API_KEY:
```

### Update team model access configuration

`PUT /organizations/teams/:teamId/model-access/configuration`

Create or update configuration for one linked team, or return that team to unrestricted. Same body and seeding behavior as the team route.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

#### Request body

`state` (string): Optional. Use `unrestricted` to clear policy. Omit when sending defaults.

`newProviderDefault` (string): `enabled` or `disabled`. Required when creating or updating a custom policy; omit when `state` is `unrestricted`.

`newModelDefault` (string): `enabled` or `disabled`. Required when creating or updating a custom policy; omit when `state` is `unrestricted`.

```bash
curl -X PUT https://api.cursor.com/organizations/teams/7/model-access/configuration \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "newProviderDefault": "disabled",
    "newModelDefault": "enabled"
  }'
```

Return one linked team to unrestricted:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/7/model-access/configuration \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{ "state": "unrestricted" }'
```

### Bulk update model access configuration

`PUT /organizations/teams/model-access/configuration`

Create or update configuration, or return teams to unrestricted, across many linked teams. Up to 100 `teamIds` per request.

HTTP **200** means the batch was processed, not that every row succeeded. Check `errorCount` and each `results[].status`. Successful teams keep their new configuration. The operation is idempotent per team, so retry only failed `teamId`s. A **4xx** or **5xx** response rejects the whole request and applies no changes.

#### Request body

`teamIds` (number\[], required): Linked team IDs to update. Maximum 100 per request.

`state` (string): Optional. Use `unrestricted` to clear policy on each team. Omit when sending defaults.

`newProviderDefault` (string): `enabled` or `disabled`. Required when creating or updating custom policies; omit when `state` is `unrestricted`.

`newModelDefault` (string): `enabled` or `disabled`. Required when creating or updating custom policies; omit when `state` is `unrestricted`.

Seed custom policy defaults on many teams:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/model-access/configuration \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "teamIds": [7, 8, 9],
    "newProviderDefault": "disabled",
    "newModelDefault": "enabled"
  }'
```

Return many teams to unrestricted:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/model-access/configuration \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "teamIds": [7, 8, 9],
    "state": "unrestricted"
  }'
```

**Response:**

```json
{
  "results": [
    { "teamId": 7, "status": "success" },
    { "teamId": 8, "status": "success" },
    {
      "teamId": 9,
      "status": "error",
      "errorMessage": "Team is not linked to this organization"
    }
  ],
  "successCount": 2,
  "errorCount": 1
}
```

### Get team model access providers

`GET /organizations/teams/:teamId/model-access/providers`

List providers and models for one linked team, including per-model `parameters` (same shape as the team [providers](/build/agents-window/account/teams/admin-api#list-model-access-providers) route). Returns **409** when the team does not have a custom policy.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

```bash
curl -X GET https://api.cursor.com/organizations/teams/7/model-access/providers \
  -u YOUR_ORGANIZATION_API_KEY:
```

### Update team model access provider

`PUT /organizations/teams/:teamId/model-access/providers/:provider`

Enable or disable a provider on one linked team. Returns **409** when the team does not have a custom policy.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

`provider` (string, required): Catalog provider id (for example `anthropic`).

#### Request body

`enabled` (boolean, required)

```bash
curl -X PUT https://api.cursor.com/organizations/teams/7/model-access/providers/anthropic \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{"enabled": false}'
```

### Update team model access model

`PUT /organizations/teams/:teamId/model-access/providers/:provider/models/:model`

Enable or disable a model on one linked team, and optionally set per-model `parameters` (same body as the team model route). Returns **409** when the team does not have a custom policy.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

`provider` (string, required): Catalog provider id (for example `anthropic`).

`model` (string, required): Catalog model id (for example `claude-opus-4-6`).

#### Request body

`enabled` (boolean, required): `parameters` (object): Optional map from parameter id to `{ allowedValues, defaultValue }`. Omitted fields are unchanged. `allowedValues: null` clears a restriction. `defaultValue: null` restores the catalog default. See the team [Update Model Access Model](/build/agents-window/account/teams/admin-api#update-model-access-model) docs.

Disable Fast on one linked team:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/7/model-access/providers/anthropic/models/claude-opus-4-6 \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "parameters": {
      "fast": { "allowedValues": ["false"] }
    }
  }'
```

Set the default effort:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/7/model-access/providers/anthropic/models/claude-opus-4-6 \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "parameters": {
      "effort": {
        "allowedValues": ["low", "medium", "high"],
        "defaultValue": "high"
      }
    }
  }'
```

### Bulk update model access provider

`PUT /organizations/teams/model-access/providers/:provider`

Enable or disable a provider on many linked teams. Up to 100 `teamIds` per request.

HTTP **200** means the batch was processed, not that every row succeeded. Inspect `errorCount` and every `results[].status`. Successful rows are not rolled back. The operation is idempotent per team, so retry only failed `teamId`s. A **4xx** or **5xx** response rejects the whole request and applies no changes.

#### Parameters

`provider` (string, required): Catalog provider id (for example `anthropic`).

#### Request body

`enabled` (boolean, required): `teamIds` (number\[], required): Linked team IDs to update. Maximum 100 per request.

```bash
curl -X PUT https://api.cursor.com/organizations/teams/model-access/providers/anthropic \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "teamIds": [7, 8, 9],
    "enabled": false
  }'
```

**Response:**

```json
{
  "results": [
    { "teamId": 7, "status": "success" },
    { "teamId": 8, "status": "success" },
    {
      "teamId": 9,
      "status": "error",
      "errorMessage": "Team has no model access policy. Create one with PUT /teams/model-access/configuration, or enable model access in Team Settings → Models."
    }
  ],
  "successCount": 2,
  "errorCount": 1
}
```

In this example HTTP status is still **200** because the batch completed. Teams 7 and 8 keep the provider disabled; only retry team 9 after creating its configuration.

### Bulk update model access model

`PUT /organizations/teams/model-access/providers/:provider/models/:model`

Enable or disable a model on many linked teams, optionally with the same `parameters` map as the single-team model PUT. Up to 100 `teamIds` per request.

HTTP **200** means the batch was processed, not that every row succeeded. Inspect `errorCount` and every `results[].status`. Successful rows are not rolled back. The operation is idempotent per team, so retry only failed `teamId`s. A **4xx** or **5xx** response rejects the whole request and applies no changes.

#### Parameters

`provider` (string, required): Catalog provider id (for example `anthropic`).

`model` (string, required): Catalog model id (for example `claude-opus-4-6`).

#### Request body

`enabled` (boolean, required): `teamIds` (number\[], required): Linked team IDs to update. Maximum 100 per request.

`parameters` (object): Optional. Same map as the single-team model PUT. `allowedValues: null` clears a restriction. `defaultValue: null` restores the catalog default.

Disable Fast across linked teams:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/model-access/providers/anthropic/models/claude-opus-4-6 \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "teamIds": [7, 8, 9],
    "enabled": true,
    "parameters": {
      "fast": { "allowedValues": ["false"] }
    }
  }'
```

Pin the default effort across linked teams:

```bash
curl -X PUT https://api.cursor.com/organizations/teams/model-access/providers/anthropic/models/claude-opus-4-6 \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "teamIds": [7, 8, 9],
    "enabled": true,
    "parameters": {
      "effort": {
        "allowedValues": ["low", "medium", "high"],
        "defaultValue": "high"
      }
    }
  }'
```

**Response:**

```json
{
  "results": [
    { "teamId": 7, "status": "success" },
    { "teamId": 8, "status": "success" },
    {
      "teamId": 9,
      "status": "error",
      "errorMessage": "Team has no model access policy. Create one with PUT /teams/model-access/configuration, or enable model access in Team Settings → Models."
    }
  ],
  "successCount": 2,
  "errorCount": 1
}
```

### Errors

Error bodies use:

```json
{ "code": "error", "message": "…" }
```

| Status | When |
|--------|------|
| `401` | Bad key, or missing `models:read` / `models:*` (or `admin:*`) |
| `403` | Model access control is not available for that team (single-team routes) |
| `404` | Team is not linked to the organization (single-team routes) |
| `409` | Provider or model read or single-team write while that team's `state` is `unrestricted` or `legacy` |
| `400` | Unknown provider, model, parameter id, or parameter value; invalid body; empty `allowedValues`; default outside `allowedValues`; settings that resolve to no valid model variant; or a Smart Auto required model would be blocked |

Bulk org routes (`PUT .../providers/:provider`, `PUT .../providers/:provider/models/:model`, and `PUT .../configuration` with `teamIds`) return HTTP **200** when the batch is processed, even if some rows fail. A non-zero `errorCount` is still a successful HTTP response. Unlinked teams and public errors such as missing configuration appear as `status: "error"` rows. Successful rows are not rolled back. Operations are idempotent per team, so retry only the failed `teamId`s. Any **4xx** or **5xx** response means the whole request was rejected and no changes were applied. The list route also returns HTTP 200 with an `errorMessage` row when a linked team cannot load configuration.

## Organization groups

Organization groups organize members across teams linked to the same organization. For dashboard setup and group-level controls, see [Organization Groups](/build/agents-window/enterprise/organization-groups). Team directory groups use the Team Admin API at [`/teams/directory-groups`](/build/agents-window/account/teams/admin-api#team-directory-groups) and `team_group_…` ids. Those routes do not accept Organization Group `id` (`g_`) values. Team directory groups also have a `publicId` with the `grp_` prefix, which their get and list-members routes accept.

> [!NOTE]
>
> * **Availability**: Enterprise only
> * **Authentication**: Organization API key (Basic auth). Every group route, read or write, requires the **`members:*`** scope. Keys with **`admin:*`** also work because admin implies members.
> * **Group IDs**: Each group has two IDs. `id` (`g_` prefix) is the Organization API group ID; use it wherever a route takes `:groupId`. `publicId` (`grp_` prefix) is the group's public ID. Origin [access grants](/build/agents-window/api/origin/grants-api) refer to groups by `publicId`. To list the members of a `grp_…` grantee, find the group whose `publicId` matches in [List Organization Groups](#list-organization-groups), then call [List Organization Group Members](#list-organization-group-members) with that group's `g_…` `id`.
> * **Name lookup**: To find a group's IDs from its name, call [List Organization Groups](#list-organization-groups) with the `name` query parameter. No route accepts a name in place of `:groupId`.
> * **Pagination**: List routes accept `page` and `pageSize`. Both values must be positive integers.
> * **Rate limit**: Each route allows 20 requests per minute per organization. See [rate limits and best practices](/build/agents-window/api#rate-limits).
> * **SCIM-synced groups**: Manage membership in your identity provider. Member add and remove requests return `400` for SCIM-synced groups.

Group routes share these error responses:

| Status | When |
|--------|------|
| `400` | Malformed group ID, pagination value, or request body |
| `401` | Invalid API key, or the key is missing the `members:*` (or `admin:*`) scope |
| `404` | Group does not exist in the organization |
| `429` | Rate limit exceeded. The response includes a `Retry-After: 60` header |

### List organization groups

`GET /organizations/groups`

Retrieve organization groups for the organization attached to your API key. Pass `name` to look up one group by its exact name.

#### Query parameters

`page` (number): Page number. Defaults to `1`.

`pageSize` (number): Number of groups per page. Defaults to `50`. Capped at 200; values above 200 are clamped to 200.

`name` (string): Exact name of one group, URL-encoded (for example `Platform%20Engineering`). Group names are unique within an organization, so the response is the normal list payload with one group or none. A name with no match returns `200` with an empty `groups` array, not `404`. Omit `name`, or send it blank, to list every group.

#### Response fields

Each object in `groups` contains:

* `id` (string) - Organization group ID with the `g_` prefix
* `publicId` (string) - Public group ID with the `grp_` prefix
* `name` (string) - Group name
* `memberCount` (number) - Number of members in the group
* `monthlySpendingLimitDollars` (number | null) - Monthly spending limit in whole dollars for each group member. `null` means the group has no limit.
* `createdAt` (string) - Creation time in ISO 8601 format
* `updatedAt` (string) - Last update time in ISO 8601 format

`pagination` (object): Pagination metadata: `page`, `pageSize`, `totalCount`, `totalPages`, `hasNextPage`, and `hasPreviousPage`.

```bash
curl -X GET "https://api.cursor.com/organizations/groups?page=1&pageSize=50" \
  -u YOUR_ORGANIZATION_API_KEY:
```

Look up one group by name:

```bash
curl -X GET "https://api.cursor.com/organizations/groups?name=Engineering" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "groups": [
    {
      "id": "g_PDSPmvukpYgZEDXsoNirw3CFhy",
      "publicId": "grp_01k2ja2000e0080000000000n2",
      "name": "Engineering",
      "memberCount": 12,
      "monthlySpendingLimitDollars": 500,
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-20T14:22:00.000Z"
    },
    {
      "id": "g_kljUvI0ASZORvSEXf9hV0ydcso",
      "publicId": "grp_01k2jb4000e0080000000000p7",
      "name": "Design",
      "memberCount": 8,
      "monthlySpendingLimitDollars": null,
      "createdAt": "2026-01-16T09:00:00.000Z",
      "updatedAt": "2026-01-16T09:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 50,
    "totalCount": 2,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  }
}
```

**Response (name lookup):**

```json
{
  "groups": [
    {
      "id": "g_PDSPmvukpYgZEDXsoNirw3CFhy",
      "publicId": "grp_01k2ja2000e0080000000000n2",
      "name": "Engineering",
      "memberCount": 12,
      "monthlySpendingLimitDollars": 500,
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-20T14:22:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 50,
    "totalCount": 1,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  }
}
```

### Get organization group

`GET /organizations/groups/:groupId`

Retrieve one organization group.

#### Parameters

`groupId` (string, required): Organization group ID with the `g_` prefix.

#### Response fields

The `group` object contains `id`, `publicId`, `name`, `memberCount`, `monthlySpendingLimitDollars`, `createdAt`, and `updatedAt`. These fields match the [List Organization Groups](#list-organization-groups) response.

```bash
curl -X GET https://api.cursor.com/organizations/groups/g_PDSPmvukpYgZEDXsoNirw3CFhy \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "group": {
    "id": "g_PDSPmvukpYgZEDXsoNirw3CFhy",
    "publicId": "grp_01k2ja2000e0080000000000n2",
    "name": "Engineering",
    "memberCount": 12,
    "monthlySpendingLimitDollars": 500,
    "createdAt": "2026-01-15T10:30:00.000Z",
    "updatedAt": "2026-01-20T14:22:00.000Z"
  }
}
```

### Create organization group

`POST /organizations/groups`

Create an organization group with manually managed membership. To create a SCIM-synced group, sync it from your identity provider in the [dashboard](/build/agents-window/enterprise/organization-groups#set-up-scim-synced-groups) instead.

#### Request body

`name` (string, required): Group name. Must be unique among the organization's active groups. Grok Build removes leading and trailing whitespace.

#### Response fields

Returns `201 Created` with the new `group` object. The object contains `id`, `publicId`, `name`, `memberCount`, `monthlySpendingLimitDollars`, `createdAt`, and `updatedAt`.

#### Errors

* `400` - The group name is missing, empty, or already used by another active group.

```bash
curl -X POST https://api.cursor.com/organizations/groups \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Engineering"
  }'
```

**Response:**

```json
{
  "group": {
    "id": "g_PDSPmvukpYgZEDXsoNirw3CFhy",
    "publicId": "grp_01k2ja2000e0080000000000n2",
    "name": "Engineering",
    "memberCount": 0,
    "monthlySpendingLimitDollars": null,
    "createdAt": "2026-01-15T10:30:00.000Z",
    "updatedAt": "2026-01-15T10:30:00.000Z"
  }
}
```

### Update organization group

`PATCH /organizations/groups/:groupId`

Update a group's name or monthly spending limit. Updates are partial: include at least one field, and any field you omit keeps its current value.

#### Parameters

`groupId` (string, required): Organization group ID with the `g_` prefix.

#### Request body

`name` (string): New group name. Must be unique among the organization's active groups. Grok Build removes leading and trailing whitespace.

`monthlySpendingLimitDollars` (number): Monthly spending limit in whole dollars for each group member, between `0` and `2147483647`.

`clearMonthlySpendingLimitDollars` (boolean): Set to `true` to remove the group spending limit. Do not include `monthlySpendingLimitDollars` in the same request.

#### Response fields

Returns the updated `group` object with `id`, `publicId`, `name`, `memberCount`, `monthlySpendingLimitDollars`, `createdAt`, and `updatedAt`.

#### Errors

* `400` - The request has no update fields, contains an invalid value, uses another active group's name, or sets and clears the spending limit in the same request.

```bash
curl -X PATCH https://api.cursor.com/organizations/groups/g_PDSPmvukpYgZEDXsoNirw3CFhy \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Platform Engineering",
    "monthlySpendingLimitDollars": 500
  }'
```

**Response:**

```json
{
  "group": {
    "id": "g_PDSPmvukpYgZEDXsoNirw3CFhy",
    "publicId": "grp_01k2ja2000e0080000000000n2",
    "name": "Platform Engineering",
    "memberCount": 12,
    "monthlySpendingLimitDollars": 500,
    "createdAt": "2026-01-15T10:30:00.000Z",
    "updatedAt": "2026-01-20T14:22:00.000Z"
  }
}
```

### Delete organization group

`DELETE /organizations/groups/:groupId`

Delete an organization group. The group must be empty: remove every member before deleting it.

#### Parameters

`groupId` (string, required): Organization group ID with the `g_` prefix.

#### Response

Returns `204 No Content` after deleting the group.

#### Errors

* `400` - The group still has members, or the group has an active SCIM mapping.

> [!NOTE]
>
> You can't delete a group with an active SCIM mapping through this endpoint.
> Remove the mapping in the dashboard, remove every member, then delete the
> group.

```bash
curl -X DELETE https://api.cursor.com/organizations/groups/g_PDSPmvukpYgZEDXsoNirw3CFhy \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:** `204 No Content`

### List organization group members

`GET /organizations/groups/:groupId/members`

Retrieve members in an organization group.

#### Parameters

`groupId` (string, required): Organization group ID with the `g_` prefix.

#### Query parameters

`page` (number): Page number. Defaults to `1`.

`pageSize` (number): Number of members per page. Defaults to `50`. Capped at 200; values above 200 are clamped to 200.

#### Response fields

Each object in `members` contains:

* `userId` (string) - Public user ID with the `user_` prefix
* `name` (string) - Display name of the member
* `email` (string) - Email address of the member
* `joinedAt` (string) - Time the member was added to the group in ISO 8601 format

`pagination` (object): Pagination metadata: `page`, `pageSize`, `totalCount`, `totalPages`, `hasNextPage`, and `hasPreviousPage`.

```bash
curl -X GET "https://api.cursor.com/organizations/groups/g_PDSPmvukpYgZEDXsoNirw3CFhy/members?page=1&pageSize=50" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "members": [
    {
      "userId": "user_abc123",
      "name": "Alex Developer",
      "email": "alex@company.com",
      "joinedAt": "2026-01-15T10:30:00.000Z"
    },
    {
      "userId": "user_def456",
      "name": "Sam Engineer",
      "email": "sam@company.com",
      "joinedAt": "2026-01-16T09:15:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 50,
    "totalCount": 2,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  }
}
```

### Add organization group members

`POST /organizations/groups/:groupId/members/bulk-add`

Add members to a manual organization group.

#### Parameters

`groupId` (string, required): Organization group ID with the `g_` prefix.

#### Request body

`userIds` (string\[], required): Array of public user IDs with the `user_` prefix. A single request may include up to 100 users.

#### Response fields

`addedCount` (number): Number of memberships this request created. Grok Build ignores users outside the organization and users who already belong to the group, so they don't count toward this total.

> [!NOTE]
>
> SCIM-synced groups reject manual membership changes with a `400` response.
> Manage their membership in your identity provider.

```bash
curl -X POST https://api.cursor.com/organizations/groups/g_PDSPmvukpYgZEDXsoNirw3CFhy/members/bulk-add \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "userIds": ["user_abc123", "user_def456"]
  }'
```

**Response:**

```json
{
  "addedCount": 2
}
```

### Remove organization group members

`POST /organizations/groups/:groupId/members/bulk-remove`

Remove members from a manual organization group.

#### Parameters

`groupId` (string, required): Organization group ID with the `g_` prefix.

#### Request body

`userIds` (string\[], required): Array of public user IDs with the `user_` prefix. A single request may include up to 100 users.

#### Response fields

`removedCount` (number): Number of memberships this request removed. Grok Build ignores users who don't belong to the group, so they don't count toward this total.

> [!NOTE]
>
> SCIM-synced groups reject manual membership changes with a `400` response.
> Manage their membership in your identity provider.

```bash
curl -X POST https://api.cursor.com/organizations/groups/g_PDSPmvukpYgZEDXsoNirw3CFhy/members/bulk-remove \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "userIds": ["user_def456"]
  }'
```

**Response:**

```json
{
  "removedCount": 1
}
```

## Audit logs

The organization audit feed returns the same events as the team [`GET /teams/audit-logs`](/build/agents-window/account/teams/admin-api#get-audit-logs) endpoint, across every team linked to the organization, plus organization-level events that have no team. Event types and `event_data` fields are listed in [Compliance and Monitoring](/build/agents-window/enterprise/compliance-and-monitoring#event-types).

> [!NOTE]
>
> * **Availability**: Enterprise only
> * **Authentication**: Organization API key (Basic auth) with the **`auditlogs:read`** scope. Keys with **`admin:*`** also work.
> * **Rate limit**: 20 requests per minute per organization. See [rate limits](/build/agents-window/api#rate-limits).

### Get audit logs

`GET /organizations/audit-logs`

Retrieve audit log events for the organization attached to your API key. Pass `teamId` to narrow the feed to one linked team. Query parameters, defaults, and the response shape mirror the team endpoint, with one addition: each event carries `team_id`.

#### Query parameters

`startTime` (string | number): Start time (defaults to 7 days ago). Accepts the same [date formats](/build/agents-window/account/teams/admin-api#date-formats) as the team endpoint.

`endTime` (string | number): End time (defaults to now).

`eventTypes` (string): Comma-separated `event_type` values to filter by.

`search` (string): Case-insensitive substring match against `user_email`, `event_type`, and `event_id`. It does not search `event_data`.

`users` (string): Comma-separated email addresses, numeric user IDs, or `user_` public IDs. Up to 100 values. Every user must be a member of the organization. Email values match `user_email` exactly and are case-sensitive.

`teamId` (number): Restrict the feed to one team. The team must be linked to the organization; otherwise the request returns `403`.

`page` (number): Page number (1-indexed). Default: `1`

`pageSize` (number): Results per page (1-500). Default: `100`

> [!NOTE]
>
> Date range cannot exceed 30 days. Make multiple requests for longer periods. Events are returned oldest first.

#### Response fields

`events` (array): Audit events, each containing:

* `event_id` (string) - UUID of the event
* `timestamp` (string) - ISO 8601 timestamp
* `team_id` (string) - Numeric ID of the team the event belongs to, the same value as `teams[].teamId` in [List Organization Members](#list-organization-members). Empty for organization-level events such as `organization_group` and `xai_credit_transfer`
* `ip_address` (string) - Client IP of the request
* `user_email` (string) - Actor, as recorded when the event was written. See the [log format](/build/agents-window/enterprise/compliance-and-monitoring#log-format) for `Api Key:`, `Bot:`, and `System` values, and for why this isn't a stable user key
* `user_id` (string) - On Origin events, the actor's public `user_…` ID. Empty for non-user actors and on rows written before the field existed. See the [log format](/build/agents-window/enterprise/compliance-and-monitoring#log-format)
* `event_type` (string) - Event type
* `application_type` (string) - `cursor`, `grok_bot`, or empty when unknown
* `event_data` (object) - Event-specific fields. `old_value` and `new_value` are parsed into JSON when the stored value is valid JSON

`pagination` (object): Pagination metadata: `page`, `pageSize`, `totalCount`, `totalPages`, `hasNextPage`, and `hasPreviousPage`.

`params` (object): Echo of the resolved query: `organizationId`, `teamId`, `startDate`, `endDate`, `eventTypes`, `search`, and `users`.

```bash
curl -X GET "https://api.cursor.com/organizations/audit-logs?startTime=7d&endTime=now&eventTypes=organization_group,add_user" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "events": [
    {
      "event_id": "c2d4e6f8-1a3b-4c5d-8e9f-0a1b2c3d4e5f",
      "timestamp": "2026-09-14T09:02:11.000Z",
      "team_id": "",
      "ip_address": "203.0.113.42",
      "user_email": "admin@company.com",
      "event_type": "organization_group",
      "application_type": "cursor",
      "event_data": {
        "action": "create",
        "organization_group_id": "grp_7Hq2mKp9vRt4xLw1",
        "organization_group_name": "Platform Engineering"
      }
    },
    {
      "event_id": "8a1f0f0e-0d1b-4c7e-9b3a-2f6e1c9d4a55",
      "timestamp": "2026-09-14T18:30:45.123Z",
      "team_id": "12345",
      "ip_address": "203.0.113.42",
      "user_email": "alice@company.com",
      "event_type": "add_user",
      "application_type": "cursor",
      "event_data": {
        "user_email": "bob@company.com",
        "role": "member",
        "source": "domain_join",
        "team_id": "12345",
        "invited_by_email": "",
        "invited_by_user_id": "0",
        "invite_id": ""
      }
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 100,
    "totalCount": 2,
    "totalPages": 1,
    "hasNextPage": false,
    "hasPreviousPage": false
  },
  "params": {
    "organizationId": "org_abc123",
    "startDate": 1757232131000,
    "endDate": 1757836931000,
    "eventTypes": "organization_group,add_user"
  }
}
```

## Grok Bot computers

Recreate, terminate, or delete the hosted computers that run Grok Bot for a team's members, or delete all of their Grok Bot data, then follow the operation until every member has a result. These routes run the same operations as **Manage Member Computers and Data** in the dashboard. See [Manage Grok Bot computers](/grok-bot/computers) for what each action does to a member's computer and what the member sees.

> [!NOTE]
>
> * **Availability**: Enterprise only.
> * **Authentication**: Organization API key (Basic auth) with the **`admin:*`** scope. Keys with any other scope return `401`. These routes take an Organization API key rather than a Team API key because one computer serves every team a member belongs to.
> * **Team**: `teamId` in the path must be a team linked to your organization. Any other team returns `404`.
> * **One operation per team**: A team runs one operation at a time. Starting another while one runs returns `409` with the running operation's ID.
> * **Rate limits**: Starting an operation allows 20 requests per minute per organization. Each status route allows 120 requests per minute per organization, so you can poll while an operation runs. See [rate limits](/build/agents-window/api#rate-limits).

Operation routes share these error responses:

| Status | When |
|--------|------|
| `400` | Malformed body or query, an unknown body field, a `userId` that isn't a current member of the team, or too many members |
| `401` | Invalid API key, or the key is missing the `admin:*` scope |
| `404` | The team isn't linked to your organization, or the operation doesn't exist or is no longer available |
| `409` | Another operation is running for the team (start only) |
| `429` | Rate limit exceeded. The response includes a `Retry-After: 60` header |
| `503` | Operations are temporarily unavailable. Retry the same request |

### Start Grok Bot computer operation

`POST /organizations/teams/:teamId/grok-bot/operations`

Start a recreate, terminate, or delete across members of one team. The request returns `202 Accepted` once the operation is queued, and Grok Build works through the members in batches from there. Poll [Get Grok Bot Computer Operation](#get-grok-bot-computer-operation) to follow progress.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

#### Request body

`action` (string, required): What to do to each member's computer:

* `recreate_vm` - Build a replacement computer on the latest image and run Team Setup. Bots, files, and logins carry over, and a Bot that is mid-turn pauses and resumes on the new computer.
* `terminate_vm` - Delete the member's current computer and keep the durable disk. The member's next message starts a fresh computer.
* `delete_vm_and_data` - Delete the computer and its durable data, so the member starts from empty. This can't be undone.
* `delete_grok_bot_data` - Delete all of the member's [Grok Bot data](/grok-bot/computers#delete-all-grok-bot-data). This can't be undone.

`userIds` (number\[], required): Numeric user IDs of the members to change. To collect them, call [List Organization Members](#list-organization-members) with `teamId`. Send at least 1 and at most 25,000 IDs, at most 1,000 for `delete_vm_and_data`, or at most 100 for `delete_grok_bot_data`. Duplicates are ignored. Every ID must belong to a current member of the team who has signed in to Grok Build; if one doesn't, the request returns `400` and nothing starts. Members without a computer are skipped for recreate and terminate. `delete_vm_and_data` and `delete_grok_bot_data` still delete the member's data.

`operationId` (string, required): A UUID you generate for this operation. If a request times out or fails, send it again with the same `operationId`. Grok Build returns `202` for the existing operation instead of starting a second one, even while that operation is still running. Grok Build doesn't compare the rest of the body on a retry, so generate a new UUID for every new operation.

#### Response fields

Returns `202 Accepted` with:

* `operationId` (string) - The operation's ID in lowercase. Use it with [Get Grok Bot Computer Operation](#get-grok-bot-computer-operation).

When another operation is running for the team, the route returns `409` with `code: "conflict"`, a `message`, and `runningOperationId`, the ID of the running operation. `runningOperationId` is `null` when Grok Build can't identify it; call [Get Latest Grok Bot Computer Operation](#get-latest-grok-bot-computer-operation) instead.

```bash
curl -X POST https://api.cursor.com/organizations/teams/7/grok-bot/operations \
  -u YOUR_ORGANIZATION_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "action": "recreate_vm",
    "userIds": [12345, 12346, 12347],
    "operationId": "3f2a9c1e-8b4d-4e6f-a1c2-5d7e9f0b1a2c"
  }'
```

**Response:**

```json
{
  "operationId": "3f2a9c1e-8b4d-4e6f-a1c2-5d7e9f0b1a2c"
}
```

**Error responses:**

**409: another operation is running for the team:**

```json
{
  "code": "conflict",
  "message": "Another Grok Bot computer operation is already running for this team. Wait for it to finish, then try again.",
  "runningOperationId": "b81c4e27-6a90-4f3d-9e15-2c8d7a4f6b03"
}
```

**400: a user isn't a current member of the team:**

```json
{
  "code": "error",
  "message": "Every userId must be a current member of the team."
}
```

### Get Grok Bot computer operation

`GET /organizations/teams/:teamId/grok-bot/operations/:operationId`

Retrieve an operation's progress: counts across all members, plus a page of per-member results. Poll this route until `state` is no longer `running`.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

`operationId` (string, required): The UUID sent to [Start Grok Bot Computer Operation](#start-grok-bot-computer-operation).

#### Query parameters

`limit` (number): Per-member results per page (1-1000). Default: `100`

`cursor` (string): The `nextCursor` value from the previous page. Omit it for the first page.

#### Response fields

`operationId` (string): The operation's ID.

`action` (string): `recreate_vm`, `terminate_vm`, `delete_vm_and_data`, or `delete_grok_bot_data`.

`state` (string): `running` until every member has a result. A finished operation is `succeeded` when no member failed, `partially_succeeded` when some members failed and others succeeded or were skipped, and `failed` when every member failed.

`counts` (object): Member counts across the whole operation: `total`, `queued`, `running`, `succeeded`, `skipped`, and `failed`. `noVmSkipped` is the part of `skipped` made up of members who had no computer. It's always `0` for `delete_vm_and_data` and `delete_grok_bot_data`, which delete the member's data whether or not a computer is running.

`items` (array | null): Per-member results for this page, each containing:

* `userId` (number) - Numeric user ID of the member
* `state` (string) - `queued`, `running`, `succeeded`, `skipped`, or `failed`
* `reason` (string | null) - Why the member was skipped or failed. `null` otherwise

`items` is `null` for operations of more than 1,000 members. Those report `counts` only.

`itemsTruncated` (boolean): `true` when the operation has more than 1,000 members and per-member results aren't kept.

`nextCursor` (string | null): Pass as `cursor` to get the next page of `items`. `null` on the last page.

The `reason` values you're most likely to see:

| `reason` | `state` | Meaning |
|----------|---------|---------|
| `no-box` | `skipped` | The member had no running or hibernated computer. Recreate and terminate only |
| `team-member-not-found` | `skipped` | The member left the team while the operation was queued |
| `member-identity-changed` | `skipped` | The member's account changed while the operation was queued |
| `recreate-already-in-progress` | `failed` | The member's computer was already being recreated. Start a new operation for this member once it finishes |
| `delete-already-in-progress` | `failed` | The member's Grok Bot data was already being deleted |
| `delete-failed` | `failed` | The deletion didn't finish |
| `authorization-revoked` | `failed` | The API key that started the operation was revoked, expired, or lost `admin:*` before Grok Build reached this member |

Any other `reason` on a failed member means the action didn't finish. Start a new operation for those members. See [Skipped and failed members](/grok-bot/computers#skipped-and-failed-members) for what to do next.

A `404` with `Operation not found.` means the operation never started or has aged out. A `404` with `This operation finished, and its status is no longer available.` means the operation completed, but Grok Build no longer holds its results.

```bash
curl -X GET "https://api.cursor.com/organizations/teams/7/grok-bot/operations/3f2a9c1e-8b4d-4e6f-a1c2-5d7e9f0b1a2c?limit=100" \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "operationId": "3f2a9c1e-8b4d-4e6f-a1c2-5d7e9f0b1a2c",
  "action": "recreate_vm",
  "state": "partially_succeeded",
  "counts": {
    "total": 3,
    "queued": 0,
    "running": 0,
    "succeeded": 1,
    "skipped": 1,
    "failed": 1,
    "noVmSkipped": 1
  },
  "items": [
    { "userId": 12345, "state": "succeeded", "reason": null },
    { "userId": 12346, "state": "skipped", "reason": "no-box" },
    { "userId": 12347, "state": "failed", "reason": "recreate-already-in-progress" }
  ],
  "itemsTruncated": false,
  "nextCursor": null
}
```

### Get latest Grok Bot computer operation

`GET /organizations/teams/:teamId/grok-bot/operations/latest`

Retrieve the team's running operation, or its most recent one when none is running. Use it to find out what's blocking a `409`, or to pick an operation back up when you no longer have its ID. The team has no latest operation until one has run, and until then the route returns `404`.

#### Parameters

`teamId` (number, required): Integer ID of a team linked to the organization.

#### Query parameters

Accepts the same `limit` and `cursor` parameters as [Get Grok Bot Computer Operation](#get-grok-bot-computer-operation).

#### Response fields

Same fields as [Get Grok Bot Computer Operation](#get-grok-bot-computer-operation).

```bash
curl -X GET https://api.cursor.com/organizations/teams/7/grok-bot/operations/latest \
  -u YOUR_ORGANIZATION_API_KEY:
```

**Response:**

```json
{
  "operationId": "b81c4e27-6a90-4f3d-9e15-2c8d7a4f6b03",
  "action": "terminate_vm",
  "state": "running",
  "counts": {
    "total": 2400,
    "queued": 2340,
    "running": 20,
    "succeeded": 38,
    "skipped": 2,
    "failed": 0,
    "noVmSkipped": 2
  },
  "items": null,
  "itemsTruncated": true,
  "nextCursor": null
}
```
