Claude Platform Docs

Создать рабочее пространство

client.Organization.Workspaces.New(ctx, body) (*Workspace, error)
POST/v1/organizations/workspaces

Создать рабочее пространство

Parameters
body OrganizationWorkspaceNewParams
Name string

Name of the Workspace.

minLength1
maxLength255
DataResidency DataResidencyCreateConfigParam Optional

Data residency configuration for the workspace. If omitted, defaults to workspace_geo: "us", allowed_inference_geos: "unrestricted", and default_inference_geo: "global".

DisplayColor param.Opt[string] Optional

Hex color code representing the Workspace in the Anthropic Console.

maxLength7
pattern^#[0-9A-Fa-f]{6}$
ExternalKeyID param.Opt[string] Optional

ID of the customer-managed encryption key (CMEK) configuration to use for this Workspace. Setting this field requires CMEK to be enabled for your organization. When set, data stored for this Workspace is encrypted with the referenced key. Create key configurations with the External Keys API. On Claude Platform on AWS the value for an AWS KMS key is the key's ARN, and your organization's own key must be a single-Region key in the same Region as the Workspace. If that key is outside the Workspace's AWS account, it can be attached only by updating an active Workspace. On that platform the key is validated against this Workspace when it is attached, so a key-policy problem is reported as an error on this request. This field is write-once: once a key is attached to a Workspace it cannot be detached or replaced. To rotate key material, rotate the underlying key on your cloud KMS; the external_key_id stays the same.

Tags map[string]string Optional

User-defined tags as string key-value pairs. Keys may not begin with anthropic.

UserProfileID param.Opt[string] Optional

ID of a user profile to attach to the Workspace. Every inference request through the Workspace must then name this user profile; the API rejects a request that names none or a different one. The user profile can't be replaced or removed later; only deleting the user profile clears it.

Returns
type Workspace struct { Type: "workspace"; ID; ArchivedAt; /* 8 more */ }
Errors

Any method can also return the general HTTP errors.

ErrorCodeExternalKeyValidationFailedHTTP status 400error code external_key_validation_failed

The External Key failed Anthropic's validation, so the request was refused. The message gives the reason, if there is one.

ErrorCodeExternalKeyValidationTimedOutHTTP status 400error code external_key_validation_timed_out

Anthropic's validation of the External Key did not finish in time, so the request was refused. Wait a moment, then send the request again.

ErrorCodeKeyProfileMismatchHTTP status 400error code key_profile_mismatch

After this request, the External Key and the Workspace would not have the same user profile. A key and its Workspace must have the same user profile, or both have none.

ErrorCodeUserProfileNotFoundHTTP status 400error code user_profile_not_found

The request depends on a user profile that does not exist in the organization or is no longer active. The request either names this user profile by ID, or names a resource, such as an External Key, that is bound to it.

ErrorCodeWorkspacePolicyViolationHTTP status 400error code workspace_policy_violation

The request breaks the organization's Workspace Policy. The message says which rule it broke; an organization admin can see and change the policy in the Console.

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.

ErrorCodeExternalKeyChangedHTTP status 409error code external_key_changed

The external key changed while the request was validating it. Send the request again.

ErrorCodeWorkspaceCreatedIncompleteHTTP status 503error code workspace_created_incomplete

The Workspace was created, but some of what the request asked for did not take effect, or may not have. Don't send the create again. The error's message says what to do with the Workspace at workspace_id.

Создать рабочее пространство
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"),
	)
	workspace, err := client.Organization.Workspaces.New(context.TODO(), anthropic.OrganizationWorkspaceNewParams{
		Name: "Workspace Name",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", workspace.ID)
}
Returns Examples
Response 200
{
  "id": "wrkspc_01AbCdEfGhJkLmNpQrStUvWx",
  "archived_at": "2024-11-01T23:59:27.427722Z",
  "compartment_id": "f8a7b6c5-4d3e-4f1a-8b9c-0d1e2f3a4b5c",
  "created_at": "2024-10-30T23:58:27.427722Z",
  "data_residency": {
    "allowed_inference_geos": "unrestricted",
    "default_inference_geo": "global",
    "workspace_geo": "us"
  },
  "display_color": "#6C5BB9",
  "external_key_id": "ekey_01SDCCSbTxrXDpWc1phhtcfK",
  "name": "Workspace Name",
  "tags": {
    "env": "prod",
    "team": "platform"
  },
  "type": "workspace",
  "user_profile_id": "uprof_01SDCCSbTxrXDpWc1phhtcfK"
}