Claude Platform Docs

Supprimer un compte de service membre d'un espace de travail

client.Organization.Workspaces.ServiceAccounts.Remove(ctx, serviceAccountID, body) (*OrganizationWorkspaceServiceAccountRemoveResponse, error)
DELETE/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}

Nécessite un jeton d'accès OAuth avec la portée org:admin, obtenu via ant auth login --scope org:admin ou une règle de fédération d'identité de charge de travail ; les clés API Admin ne sont pas acceptées. Consultez Gérer WIF avec l'API Admin.

Retire un compte de service d'un espace de travail.

Le retrait est idempotent (renvoie 200 même si l'appartenance a déjà été retirée). Un DELETE sur l'appartenance implicite à l'espace de travail par défaut renvoie 200 mais n'a aucun effet et l'appartenance persiste ; la suppression d'une ligne explicite d'espace de travail par défaut rétablit l'appartenance implicite workspace_user. Les espaces de travail archivés renvoient 400.

Parameters
serviceAccountID string⁠Path parameter

ID of the service account.

body OrganizationWorkspaceServiceAccountRemoveParams
WorkspaceID string⁠Path parameter

ID of the workspace.

Returns
type OrganizationWorkspaceServiceAccountRemoveResponse struct { Type: "service_account_workspace_member_deleted"; ServiceAccountID; WorkspaceID }
Type ServiceAccountWorkspaceMemberDeleted
defaultservice_account_workspace_member_deleted
ServiceAccountID string

Tagged service account ID (svac_...) named in the delete request. Removal is idempotent; see the endpoint description for the implicit-membership no-op.

WorkspaceID string

Tagged workspace ID (wrkspc_...) named in the delete request.

Supprimer un compte de service membre d'un espace de travail
package main

import (
	"context"
	"fmt"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"),
	)
	serviceAccount, err := client.Organization.Workspaces.ServiceAccounts.Remove(
		context.TODO(),
		"service_account_id",
		anthropic.OrganizationWorkspaceServiceAccountRemoveParams{
			WorkspaceID: "workspace_id",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", serviceAccount.ServiceAccountID)
}
Returns Examples
Response 200
{
  "service_account_id": "service_account_id",
  "type": "service_account_workspace_member_deleted",
  "workspace_id": "workspace_id"
}