Claude Platform Docs

更新合規設定

client.Organization.ComplianceSettings.Update(ctx, body) (*OrganizationComplianceSettings, error)
POST/v1/organizations/compliance_settings

更新您組織的合規設定。

將 state 設為 enabled 會開啟 Compliance API 並開始擷取組織活動事件。將其設為 disabled 則會同時關閉兩者。Access Transparency 事件是例外:即使 Compliance API 已停用,這些事件仍會被擷取,並在 Compliance API 重新啟用後由其活動摘要傳回。state 反映 Compliance API 是否已啟用。

將 state 設為其目前值的請求會成功,且資源保持不變。disabled 請求會持續生效,直到後續的 enabled 請求,或組織下一次啟用 Access Transparency 的佈建動作為止:啟用 Access Transparency 也會啟用提供其活動事件的 Compliance API,因此此類佈建(包括重新執行)即使在 disabled 請求之後也會重新啟用 Compliance API。自動化佈建絕不會停用合規設定。

Parameters
body OrganizationComplianceSettingUpdateParams

Desired state. Accepts the string shorthand "enabled" or "disabled" in place of the object form; the response always returns the canonical object form.

Returns
type OrganizationComplianceSettings struct { Type: "compliance_settings"; State }
Type ComplianceSettings
defaultcompliance_settings

Whether the Compliance API is enabled for this organization.

One of the following:
type ComplianceSettingsStateEnabled struct { Type: "enabled" }
Type Enabled
defaultenabled
type ComplianceSettingsStateDisabled struct { Type: "disabled" }
Type Disabled
defaultdisabled
Errors

Any method can also return the general HTTP errors.

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"),
	)
	organizationComplianceSettings, err := client.Organization.ComplianceSettings.Update(context.TODO(), anthropic.OrganizationComplianceSettingUpdateParams{
		State: anthropic.ComplianceSettingsStateParamUnion{
			OfEnabled: &anthropic.ComplianceSettingsStateEnabledParam{},
		},
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", organizationComplianceSettings.State)
}
Returns Examples
Response 200
{
  "state": {
    "type": "enabled"
  },
  "type": "compliance_settings"
}