Claude Platform Docs

移除用户

client.Organization.Users.Remove(ctx, userID) (*OrganizationUserRemoveResponse, error)
DELETE/v1/organizations/users/{user_id}

将成员从组织中移除。

Parameters
userID string⁠Path parameter

ID of the User.

Returns
type OrganizationUserRemoveResponse struct { Type: "user_deleted"; ID }
Type UserDeleted

Deleted object type.

For Users, this is always "user_deleted".

defaultuser_deleted
ID string

ID of the User.

Errors

Any method can also return the general HTTP errors.

ErrorCodeCannotRemoveLastMemberHTTP status 400error code cannot_remove_last_member

The user is the organization's only member. Add another member before removing this one.

ErrorCodeAPIKeyRequesterUnconfirmedHTTP status 403error code api_key_requester_unconfirmed

The API could not confirm that this request came from your organization, so it refused a change to an API key. If you were updating an API key, the key did not change. If you were archiving a service account, it is archived, but some of its API keys are not. If you were removing a user, they are still a member, but they may be signed out and some of their API keys may be turned off. It is safe to send the same request again. If the error continues, contact Anthropic support and give them the request_id from this response.

ErrorCodeSandboxEgressRestrictedHTTP status 403error code sandbox_egress_restricted

The request came from a Claude sandbox with restricted network access, which is not allowed to make this request. Send it from outside the sandbox, or from a sandbox with unrestricted network access.

ErrorCodeConcurrentMembershipChangeHTTP status 409error code concurrent_membership_change

Another change to the organization's members is in progress. Retry the request once it completes.

移除用户
package main

import (
	"context"
	"fmt"

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

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"),
	)
	user, err := client.Organization.Users.Remove(context.TODO(), "user_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", user.ID)
}
Returns Examples
Response 200
{
  "id": "user_01WxYzAbCdEfGhJkMnPqRsTu",
  "type": "user_deleted"
}