---
title: "Update API Key Sharing Groups"
method: PATCH
path: "/api_keys/{api_key_id}/sharing-groups"
tags: ["API Keys"]
---

# Update API Key Sharing Groups

`PATCH /api_keys/{api_key_id}/sharing-groups`

Update default sharing groups for resources created by an API key.

## Path parameters

- `api_key_id` string, required

## Request body

- ApiKeySharingGroupsUpdateRequest — Request model for updating API key sharing groups.
  - `sharing_group_ids` string[], required — Replacement sharing groups (future creations only).

## Response `200`

Successful Response

- ApiKeyResponse — Response model for API key (excludes sensitive data).
  - `created_at` string, date-time, nullable — When the key was created.
  - `created_by` string, required — member_id of the creator.
  - `description` string, nullable — Optional description.
  - `id` string, required — The unique identifier of the API key.
  - `key_prefix` string, required — Display prefix (e.g., 'sk_tu_abc...').
  - `last_used_at` string, date-time, nullable — When the key was last used.
  - `name` string, required — Human-readable name for the API key.
  - `org_id` string, required — WorkOS organization ID.
  - `revoked_at` string, date-time, nullable — When the key was revoked (soft delete).
  - `scopes` ApiKeyScope[] — List of resource scopes for this API key.
    - `resource_id` string, required — ID of the resource.
    - `resource_type` string, required — Type of resource (namespace, project, agent).
    - `role` 'discoverer' | 'viewer' | 'editor' | 'admin' | 'owner' | 'member' | 'executor', required — Role that can be assigned to an API key for a scoped resource.
  - `sharing_group_ids` string[] — Groups that receive default admin grants on resources created by this key.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/terminaluse/apis/sb0-api.md) · [All operations](https://skmtc.net/terminaluse/apis/sb0-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/terminaluse/sb0-api/revisions/f24a474dc415/schema)
