Claude Platform Docs

Create External Key

BetaExternalKey beta().organization().externalKeys().create(ExternalKeyCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/v1/organizations/external_keys

Create an external key config owned by the caller's organization.

Parameters
ExternalKeyCreateParams params
ProviderConfig providerConfig

KMS provider identity and auth coordinates.

class BetaAwsExternalKeyConfig:
String kmsArn

Full ARN of the AWS KMS key.

maxLength2048
JsonValue type "aws"constant
Optional<String> region

AWS region. Derived from kms_arn if omitted.

Optional<String> roleArnDeprecated

IAM role ARN. Deprecated — Anthropic reaches the KMS key via a managed intermediate role; this field is ignored.

class BetaGcpExternalKeyConfig:
String keyName

Full resource name of the Cloud KMS key.

JsonValue type "gcp"constant
class BetaAzureExternalKeyConfigParam:

Azure Key Vault provider configuration.

String keyName

Name of the key within the vault.

String tenantId

Azure AD tenant ID.

JsonValue type "azure"constant
String vaultUri

Key Vault data-plane URI — https://{vault-name}.vault.azure.net or https://{hsm-name}.managedhsm.azure.net.

Optional<String> clientId

Azure AD application (client) ID. Omit to use Anthropic's multitenant app. Provide only if using a single-tenant app registration in the customer's directory.

Optional<String> displayName

Human-friendly display name.

maxLength255
minLength1
Optional<Geo> geo

Data residency geo. Only us is supported.

US("us")
Returns
class BetaExternalKey:

CMEK external key config belonging to the caller's organization.

Configs are organization-scoped. Workspaces attach to a config; once any workspace references it, the provider fields become effectively immutable (existing encrypted data needs the config for decrypt).

Create External Key

package com.anthropic.example;

import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.beta.organization.externalkeys.BetaExternalKey;
import com.anthropic.models.beta.organization.externalkeys.ExternalKeyCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        AnthropicClient client = AnthropicOkHttpClient.fromEnv();

        ExternalKeyCreateParams params = ExternalKeyCreateParams.builder()
            .awsProviderConfig("arn:aws:kms:us-east-1:111122223333:key/abcd1234-5678-90ab-cdef-000011112222")
            .build();
        BetaExternalKey betaExternalKey = client.beta().organization().externalKeys().create(params);
    }
}
{
  "id": "ekey_01SDCCSbTxrXDpWc1phhtcfK",
  "attachment": {
    "type": "attached"
  },
  "created_at": "2024-10-30T23:58:27.427722Z",
  "display_name": "prod-us-key",
  "geo": "us",
  "provider_config": {
    "kms_arn": "arn:aws:kms:us-east-1:111122223333:key/abcd1234-5678-90ab-cdef-000011112222",
    "type": "aws",
    "region": "us-east-1",
    "role_arn": "arn:aws:iam::111122223333:role/anthropic-cmek"
  },
  "type": "external_key",
  "updated_at": "2024-10-30T23:58:27.427722Z"
}
Returns Examples
{
  "id": "ekey_01SDCCSbTxrXDpWc1phhtcfK",
  "attachment": {
    "type": "attached"
  },
  "created_at": "2024-10-30T23:58:27.427722Z",
  "display_name": "prod-us-key",
  "geo": "us",
  "provider_config": {
    "kms_arn": "arn:aws:kms:us-east-1:111122223333:key/abcd1234-5678-90ab-cdef-000011112222",
    "type": "aws",
    "region": "us-east-1",
    "role_arn": "arn:aws:iam::111122223333:role/anthropic-cmek"
  },
  "type": "external_key",
  "updated_at": "2024-10-30T23:58:27.427722Z"
}