Claude Platform Docs

Удалить внешний ключ

client.Beta.Organization.ExternalKeys.Delete(ctx, externalKeyID) (*BetaOrganizationExternalKeyDeleteResponse, error)
DELETE/v1/organizations/external_keys/{external_key_id}

Удаляет конфигурацию внешнего ключа.

Запрос отклоняется, если на эту конфигурацию всё ещё ссылается какое-либо рабочее пространство.

Parameters
externalKeyID string⁠Path parameter

ID of the External Key.

maxLength2048
Returns
type BetaOrganizationExternalKeyDeleteResponse struct { Type: "external_key_deleted"; ID }
Type ExternalKeyDeleted
defaultexternal_key_deleted
ID string

ID of the deleted External Key.

Errors

Any method can also return the general HTTP errors.

ErrorCodeExternalKeyInWorkspacePolicyHTTP status 400error code external_key_in_workspace_policy

The External Key can't be deleted or reconfigured while the organization's Workspace Policy lists it as an allowed key.

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.

Удалить внешний ключ
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"),
	)
	externalKey, err := client.Beta.Organization.ExternalKeys.Delete(context.TODO(), "external_key_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", externalKey.ID)
}
Returns Examples
Response 200
{
  "id": "ekey_01AbCdEfGhIjKlMnOpQrStUv",
  "type": "external_key_deleted"
}