# Organizations ## List organizations the user has access to `client.Organizations.List(ctx, query) (*SinglePage[Organization], error)` **get** `/organizations` Retrieve a list of organizations a particular user has access to. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `query OrganizationListParams` - `ID param.Field[[]string]` Only return organizations with the specified IDs (ex. id=foo&id=bar). Send multiple elements by repeating the query value. - `Containing param.Field[OrganizationListParamsContaining]` - `Account string` Filter the list of organizations to the ones that contain this particular account. - `Organization string` Filter the list of organizations to the ones that contain this particular organization. - `User string` Filter the list of organizations to the ones that contain this particular user. IMPORTANT: Just because an organization "contains" a user is not a representation of any authorization or privilege to manage any resources therein. An organization "containing" a user simply means the user is managed by that organization. - `Name param.Field[OrganizationListParamsName]` - `Contains string` (case-insensitive) Filter the list of organizations to where the name contains a particular string. - `EndsWith string` (case-insensitive) Filter the list of organizations to where the name ends with a particular string. - `StartsWith string` (case-insensitive) Filter the list of organizations to where the name starts with a particular string. - `PageSize param.Field[int64]` The amount of items to return. Defaults to 10. - `PageToken param.Field[string]` An opaque token returned from the last list response that when provided will retrieve the next page. Parameters used to filter the retrieved list must remain in subsequent requests with a page token. - `Parent param.Field[OrganizationListParamsParent]` - `ID OrganizationListParamsParentID` Filter the list of organizations to the ones that are a sub-organization of the specified organization. "null" is a valid value to provide for this parameter. It means "where an organization has no parent (i.e. it is a 'root' organization)." - `string` - `type OrganizationListParamsParentID string` Filter the list of organizations to the ones that are a sub-organization of the specified organization. "null" is a valid value to provide for this parameter. It means "where an organization has no parent (i.e. it is a 'root' organization)." - `const OrganizationListParamsParentIDNull OrganizationListParamsParentID = "null"` ### Returns - `type Organization struct{…}` References an Organization in the Cloudflare data model. - `ID string` - `CreateTime Time` - `Meta OrganizationMeta` - `Flags OrganizationMetaFlags` Enable features for Organizations. - `AccountCreation string` - `AccountDeletion string` - `AccountMigration string` - `AccountMobility string` - `SubOrgCreation string` - `ManagedBy string` - `Name string` - `Parent OrganizationParent` - `ID string` - `Name string` - `Profile AccountProfile` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Organizations.List(context.TODO(), organizations.OrganizationListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "flags": { "account_creation": "account_creation", "account_deletion": "account_deletion", "account_migration": "account_migration", "account_mobility": "account_mobility", "sub_org_creation": "sub_org_creation" }, "managed_by": "managed_by" }, "name": "name", "parent": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "name": "name" }, "profile": { "business_address": "business_address", "business_email": "business_email", "business_name": "business_name", "business_phone": "business_phone", "external_metadata": "external_metadata" } } ], "result_info": { "next_page_token": "next_page_token", "total_size": 0 }, "success": true } ``` ## Get organization `client.Organizations.Get(ctx, organizationID) (*Organization, error)` **get** `/organizations/{organization_id}` Retrieve the details of a certain organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` ### Returns - `type Organization struct{…}` References an Organization in the Cloudflare data model. - `ID string` - `CreateTime Time` - `Meta OrganizationMeta` - `Flags OrganizationMetaFlags` Enable features for Organizations. - `AccountCreation string` - `AccountDeletion string` - `AccountMigration string` - `AccountMobility string` - `SubOrgCreation string` - `ManagedBy string` - `Name string` - `Parent OrganizationParent` - `ID string` - `Name string` - `Profile AccountProfile` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organization, err := client.Organizations.Get(context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organization.ID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "flags": { "account_creation": "account_creation", "account_deletion": "account_deletion", "account_migration": "account_migration", "account_mobility": "account_mobility", "sub_org_creation": "sub_org_creation" }, "managed_by": "managed_by" }, "name": "name", "parent": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "name": "name" }, "profile": { "business_address": "business_address", "business_email": "business_email", "business_name": "business_name", "business_phone": "business_phone", "external_metadata": "external_metadata" } }, "success": true } ``` ## Create organization `client.Organizations.New(ctx, body) (*Organization, error)` **post** `/organizations` Create a new organization for a user. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `body OrganizationNewParams` - `Organization param.Field[Organization]` References an Organization in the Cloudflare data model. ### Returns - `type Organization struct{…}` References an Organization in the Cloudflare data model. - `ID string` - `CreateTime Time` - `Meta OrganizationMeta` - `Flags OrganizationMetaFlags` Enable features for Organizations. - `AccountCreation string` - `AccountDeletion string` - `AccountMigration string` - `AccountMobility string` - `SubOrgCreation string` - `ManagedBy string` - `Name string` - `Parent OrganizationParent` - `ID string` - `Name string` - `Profile AccountProfile` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organization, err := client.Organizations.New(context.TODO(), organizations.OrganizationNewParams{ Organization: organizations.OrganizationParam{ Name: cloudflare.F("name"), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organization.ID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "flags": { "account_creation": "account_creation", "account_deletion": "account_deletion", "account_migration": "account_migration", "account_mobility": "account_mobility", "sub_org_creation": "sub_org_creation" }, "managed_by": "managed_by" }, "name": "name", "parent": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "name": "name" }, "profile": { "business_address": "business_address", "business_email": "business_email", "business_name": "business_name", "business_phone": "business_phone", "external_metadata": "external_metadata" } }, "success": true } ``` ## Modify organization. `client.Organizations.Update(ctx, organizationID, body) (*Organization, error)` **put** `/organizations/{organization_id}` Modify organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `body OrganizationUpdateParams` - `Organization param.Field[Organization]` References an Organization in the Cloudflare data model. ### Returns - `type Organization struct{…}` References an Organization in the Cloudflare data model. - `ID string` - `CreateTime Time` - `Meta OrganizationMeta` - `Flags OrganizationMetaFlags` Enable features for Organizations. - `AccountCreation string` - `AccountDeletion string` - `AccountMigration string` - `AccountMobility string` - `SubOrgCreation string` - `ManagedBy string` - `Name string` - `Parent OrganizationParent` - `ID string` - `Name string` - `Profile AccountProfile` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organization, err := client.Organizations.Update( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", organizations.OrganizationUpdateParams{ Organization: organizations.OrganizationParam{ Name: cloudflare.F("name"), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organization.ID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "flags": { "account_creation": "account_creation", "account_deletion": "account_deletion", "account_migration": "account_migration", "account_mobility": "account_mobility", "sub_org_creation": "sub_org_creation" }, "managed_by": "managed_by" }, "name": "name", "parent": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "name": "name" }, "profile": { "business_address": "business_address", "business_email": "business_email", "business_name": "business_name", "business_phone": "business_phone", "external_metadata": "external_metadata" } }, "success": true } ``` ## Delete organization. `client.Organizations.Delete(ctx, organizationID) (*OrganizationDeleteResponse, error)` **delete** `/organizations/{organization_id}` Delete an organization. The organization MUST be empty before deleting. It must not contain any sub-organizations, accounts, members or users. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` ### Returns - `type OrganizationDeleteResponse struct{…}` - `ID string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organization, err := client.Organizations.Delete(context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organization.ID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "id" }, "success": true } ``` ## Domain Types ### Organization - `type Organization struct{…}` References an Organization in the Cloudflare data model. - `ID string` - `CreateTime Time` - `Meta OrganizationMeta` - `Flags OrganizationMetaFlags` Enable features for Organizations. - `AccountCreation string` - `AccountDeletion string` - `AccountMigration string` - `AccountMobility string` - `SubOrgCreation string` - `ManagedBy string` - `Name string` - `Parent OrganizationParent` - `ID string` - `Name string` - `Profile AccountProfile` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` # Organization Accounts ## Get organization accounts `client.Organizations.OrganizationAccounts.Get(ctx, organizationID, query) (*[]OrganizationAccountGetResponse, error)` **get** `/organizations/{organization_id}/accounts` Retrieve a list of accounts that belong to a specific organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `query OrganizationAccountGetParams` - `AccountPubname param.Field[OrganizationAccountGetParamsAccountPubname]` - `Contains string` (case-insensitive) Filter the list of accounts to where the account_pubname contains a particular string. - `EndsWith string` (case-insensitive) Filter the list of accounts to where the account_pubname ends with a particular string. - `StartsWith string` (case-insensitive) Filter the list of accounts to where the account_pubname starts with a particular string. - `Direction param.Field[OrganizationAccountGetParamsDirection]` Sort direction for the order_by field. Valid values: `asc`, `desc`. Defaults to `asc` when order_by is specified. - `const OrganizationAccountGetParamsDirectionAsc OrganizationAccountGetParamsDirection = "asc"` - `const OrganizationAccountGetParamsDirectionDesc OrganizationAccountGetParamsDirection = "desc"` - `Name param.Field[OrganizationAccountGetParamsName]` - `Contains string` (case-insensitive) Filter the list of accounts to where the name contains a particular string. - `EndsWith string` (case-insensitive) Filter the list of accounts to where the name ends with a particular string. - `StartsWith string` (case-insensitive) Filter the list of accounts to where the name starts with a particular string. - `OrderBy param.Field[OrganizationAccountGetParamsOrderBy]` Field to order results by. Currently supported values: `account_name`. When not specified, results are ordered by internal account ID. - `const OrganizationAccountGetParamsOrderByAccountName OrganizationAccountGetParamsOrderBy = "account_name"` - `PageSize param.Field[int64]` The amount of items to return. Defaults to 10. - `PageToken param.Field[string]` An opaque token returned from the last list response that when provided will retrieve the next page. Parameters used to filter the retrieved list must remain in subsequent requests with a page token. ### Returns - `type OrganizationAccountGetResponseEnvelopeResult []OrganizationAccountGetResponse` - `ID string` - `CreatedOn Time` - `Name string` - `Settings OrganizationAccountGetResponseSettings` - `AbuseContactEmail string` - `AccessApprovalExpiry Time` - `APIAccessEnabled bool` - `DefaultNameservers string` Use [DNS Settings](https://developers.cloudflare.com/api/operations/dns-settings-for-an-account-list-dns-settings) instead. Deprecated. - `EnforceTwofactor bool` - `UseAccountCustomNSByDefault bool` Use [DNS Settings](https://developers.cloudflare.com/api/operations/dns-settings-for-an-account-list-dns-settings) instead. Deprecated. - `Type OrganizationAccountGetResponseType` - `const OrganizationAccountGetResponseTypeStandard OrganizationAccountGetResponseType = "standard"` - `const OrganizationAccountGetResponseTypeEnterprise OrganizationAccountGetResponseType = "enterprise"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organizationAccounts, err := client.Organizations.OrganizationAccounts.Get( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", organizations.OrganizationAccountGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organizationAccounts) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "id", "created_on": "2019-12-27T18:11:19.117Z", "name": "name", "settings": { "abuse_contact_email": "abuse_contact_email", "access_approval_expiry": "2019-12-27T18:11:19.117Z", "api_access_enabled": true, "default_nameservers": "default_nameservers", "enforce_twofactor": true, "use_account_custom_ns_by_default": true }, "type": "standard" } ], "result_info": { "next_page_token": "next_page_token", "total_size": 0 }, "success": true } ``` ## Domain Types ### Organization Accounts - `type OrganizationAccounts struct{…}` - `ID string` Identifier - `Name string` Account name - `Type OrganizationAccountsType` - `const OrganizationAccountsTypeStandard OrganizationAccountsType = "standard"` - `const OrganizationAccountsTypeEnterprise OrganizationAccountsType = "enterprise"` - `CreatedOn Time` Timestamp for the creation of the account - `ManagedBy OrganizationAccountsManagedBy` Parent container details - `ParentOrgID string` ID of the parent Organization, if one exists - `ParentOrgName string` Name of the parent Organization, if one exists - `Settings OrganizationAccountsSettings` Account settings - `AbuseContactEmail string` Sets an abuse contact email to notify for abuse reports. - `EnforceTwofactor bool` Indicates whether membership in this account requires that Two-Factor Authentication is enabled # Organization Profile ## Get organization profile `client.Organizations.OrganizationProfile.Get(ctx, organizationID) (*AccountProfile, error)` **get** `/organizations/{organization_id}/profile` Get an organizations profile if it exists. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` ### Returns - `type AccountProfile struct{…}` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) accountProfile, err := client.Organizations.OrganizationProfile.Get(context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", accountProfile.BusinessAddress) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "business_address": "business_address", "business_email": "business_email", "business_name": "business_name", "business_phone": "business_phone", "external_metadata": "external_metadata" }, "success": true } ``` ## Modify organization profile. `client.Organizations.OrganizationProfile.Update(ctx, organizationID, body) error` **put** `/organizations/{organization_id}/profile` Modify organization profile. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `body OrganizationProfileUpdateParams` - `AccountProfile param.Field[AccountProfile]` ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) err := client.Organizations.OrganizationProfile.Update( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", organizations.OrganizationProfileUpdateParams{ AccountProfile: accounts.AccountProfileParam{ BusinessAddress: cloudflare.F("business_address"), BusinessEmail: cloudflare.F("business_email"), BusinessName: cloudflare.F("business_name"), BusinessPhone: cloudflare.F("business_phone"), ExternalMetadata: cloudflare.F("external_metadata"), }, }, ) if err != nil { panic(err.Error()) } } ``` ## Domain Types ### Organization Profile - `type OrganizationProfile struct{…}` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` # Members ## List organization members `client.Organizations.Members.List(ctx, organizationID, query) (*SinglePage[OrganizationMember], error)` **get** `/organizations/{organization_id}/members` List memberships for an Organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `query MemberListParams` - `PageSize param.Field[int64]` The amount of items to return. Defaults to 10. - `PageToken param.Field[string]` An opaque token returned from the last list response that when provided will retrieve the next page. Parameters used to filter the retrieved list must remain in subsequent requests with a page token. - `Status param.Field[[]MemberListParamsStatus]` Filter the list of memberships by membership status. - `const MemberListParamsStatusActive MemberListParamsStatus = "active"` - `const MemberListParamsStatusCanceled MemberListParamsStatus = "canceled"` - `User param.Field[MemberListParamsUser]` - `Email string` Filter the list of memberships for a specific email that ends with a substring. ### Returns - `type OrganizationMember struct{…}` - `ID string` Organization Member ID - `CreateTime Time` - `Meta map[string, unknown]` - `Status OrganizationMemberStatus` - `const OrganizationMemberStatusActive OrganizationMemberStatus = "active"` - `const OrganizationMemberStatusCanceled OrganizationMemberStatus = "canceled"` - `UpdateTime Time` - `User OrganizationMemberUser` - `ID string` - `Email string` - `Name string` - `TwoFactorAuthenticationEnabled bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Organizations.Members.List( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", organizations.MemberListParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "foo": {} }, "status": "active", "update_time": "2019-12-27T18:11:19.117Z", "user": { "id": "id", "email": "email", "name": "name", "two_factor_authentication_enabled": true } } ], "result_info": { "next_page_token": "next_page_token", "total_size": 0 }, "success": true } ``` ## Get organization member `client.Organizations.Members.Get(ctx, organizationID, memberID) (*OrganizationMember, error)` **get** `/organizations/{organization_id}/members/{member_id}` Retrieve a single membership from an Organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `memberID string` Organization Member ID ### Returns - `type OrganizationMember struct{…}` - `ID string` Organization Member ID - `CreateTime Time` - `Meta map[string, unknown]` - `Status OrganizationMemberStatus` - `const OrganizationMemberStatusActive OrganizationMemberStatus = "active"` - `const OrganizationMemberStatusCanceled OrganizationMemberStatus = "canceled"` - `UpdateTime Time` - `User OrganizationMemberUser` - `ID string` - `Email string` - `Name string` - `TwoFactorAuthenticationEnabled bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organizationMember, err := client.Organizations.Members.Get( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organizationMember.ID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "foo": {} }, "status": "active", "update_time": "2019-12-27T18:11:19.117Z", "user": { "id": "id", "email": "email", "name": "name", "two_factor_authentication_enabled": true } }, "success": true } ``` ## Create organization member `client.Organizations.Members.New(ctx, organizationID, body) (*OrganizationMember, error)` **post** `/organizations/{organization_id}/members` Create a membership that grants access to a specific Organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `body MemberNewParams` - `Member param.Field[MemberNewParamsMember]` - `User MemberNewParamsMemberUser` - `Email string` - `Status MemberNewParamsMemberStatus` - `const MemberNewParamsMemberStatusActive MemberNewParamsMemberStatus = "active"` - `const MemberNewParamsMemberStatusCanceled MemberNewParamsMemberStatus = "canceled"` ### Returns - `type OrganizationMember struct{…}` - `ID string` Organization Member ID - `CreateTime Time` - `Meta map[string, unknown]` - `Status OrganizationMemberStatus` - `const OrganizationMemberStatusActive OrganizationMemberStatus = "active"` - `const OrganizationMemberStatusCanceled OrganizationMemberStatus = "canceled"` - `UpdateTime Time` - `User OrganizationMemberUser` - `ID string` - `Email string` - `Name string` - `TwoFactorAuthenticationEnabled bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organizationMember, err := client.Organizations.Members.New( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", organizations.MemberNewParams{ Member: cloudflare.F(organizations.MemberNewParamsMember{ User: cloudflare.F(organizations.MemberNewParamsMemberUser{ Email: cloudflare.F("email"), }), }), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organizationMember.ID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "create_time": "2019-12-27T18:11:19.117Z", "meta": { "foo": {} }, "status": "active", "update_time": "2019-12-27T18:11:19.117Z", "user": { "id": "id", "email": "email", "name": "name", "two_factor_authentication_enabled": true } }, "success": true } ``` ## Delete organization member `client.Organizations.Members.Delete(ctx, organizationID, memberID) error` **delete** `/organizations/{organization_id}/members/{member_id}` Delete a membership to a particular Organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `organizationID string` - `memberID string` Organization Member ID ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) err := client.Organizations.Members.Delete( context.TODO(), "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", "a7b9c3d2e8f4g1h5i6j0k9l2m3n7o4p8", ) if err != nil { panic(err.Error()) } } ``` ## Domain Types ### Organization Member - `type OrganizationMember struct{…}` - `ID string` Organization Member ID - `CreateTime Time` - `Meta map[string, unknown]` - `Status OrganizationMemberStatus` - `const OrganizationMemberStatusActive OrganizationMemberStatus = "active"` - `const OrganizationMemberStatusCanceled OrganizationMemberStatus = "canceled"` - `UpdateTime Time` - `User OrganizationMemberUser` - `ID string` - `Email string` - `Name string` - `TwoFactorAuthenticationEnabled bool` # Logs # Audit ## Get organization audit logs (Version 2, Beta release) `client.Organizations.Logs.Audit.List(ctx, organizationID, query) (*CursorPaginationAfter[LogAuditListResponse], error)` **get** `/organizations/{organization_id}/logs/audit` Gets a list of audit logs for an organization. ### Parameters - `organizationID string` The unique id that identifies the organization. - `query LogAuditListParams` - `Before param.Field[Time]` Limits the returned results to logs older than the specified date. This can be a date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that conforms to RFC3339. - `Since param.Field[Time]` Limits the returned results to logs newer than the specified date. This can be a date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that conforms to RFC3339. - `ID param.Field[LogAuditListParamsID]` - `Not []string` Filters out audit logs by their IDs. - `ActionResult param.Field[LogAuditListParamsActionResult]` - `Not []LogAuditListParamsActionResultNot` Filters out audit logs by whether the action was successful or not. - `const LogAuditListParamsActionResultNotSuccess LogAuditListParamsActionResultNot = "success"` - `const LogAuditListParamsActionResultNotFailure LogAuditListParamsActionResultNot = "failure"` - `ActionType param.Field[LogAuditListParamsActionType]` - `Not []LogAuditListParamsActionTypeNot` Filters out audit logs by the action type. - `const LogAuditListParamsActionTypeNotCreate LogAuditListParamsActionTypeNot = "create"` - `const LogAuditListParamsActionTypeNotDelete LogAuditListParamsActionTypeNot = "delete"` - `const LogAuditListParamsActionTypeNotView LogAuditListParamsActionTypeNot = "view"` - `const LogAuditListParamsActionTypeNotUpdate LogAuditListParamsActionTypeNot = "update"` - `ActorContext param.Field[LogAuditListParamsActorContext]` - `Not []LogAuditListParamsActorContextNot` Filters out audit logs by the actor context. - `const LogAuditListParamsActorContextNotAPIKey LogAuditListParamsActorContextNot = "api_key"` - `const LogAuditListParamsActorContextNotAPIToken LogAuditListParamsActorContextNot = "api_token"` - `const LogAuditListParamsActorContextNotDash LogAuditListParamsActorContextNot = "dash"` - `const LogAuditListParamsActorContextNotOAuth LogAuditListParamsActorContextNot = "oauth"` - `const LogAuditListParamsActorContextNotOriginCAKey LogAuditListParamsActorContextNot = "origin_ca_key"` - `ActorEmail param.Field[LogAuditListParamsActorEmail]` - `Not []string` Filters out audit logs by the actor's email address. - `ActorID param.Field[LogAuditListParamsActorID]` - `Not []string` Filters out audit logs by the actor's user ID. - `ActorIPAddress param.Field[LogAuditListParamsActorIPAddress]` - `Not []string` Filters out audit logs IP address where the action was initiated. - `ActorTokenID param.Field[LogAuditListParamsActorTokenID]` - `Not []string` Filters out audit logs by the API token ID when the actor context is an api_token or oauth. - `ActorTokenName param.Field[LogAuditListParamsActorTokenName]` - `Not []string` Filters out audit logs by the API token name when the actor context is an api_token or oauth. - `ActorType param.Field[LogAuditListParamsActorType]` - `Not []LogAuditListParamsActorTypeNot` Filters out audit logs by the actor type. - `const LogAuditListParamsActorTypeNotCloudflareAdmin LogAuditListParamsActorTypeNot = "cloudflare_admin"` - `const LogAuditListParamsActorTypeNotSystem LogAuditListParamsActorTypeNot = "system"` - `const LogAuditListParamsActorTypeNotUser LogAuditListParamsActorTypeNot = "user"` - `Cursor param.Field[string]` The cursor is an opaque token used to paginate through large sets of records. It indicates the position from which to continue when requesting the next set of records. A valid cursor value can be obtained from the cursor object in the result_info structure of a previous response. - `Direction param.Field[LogAuditListParamsDirection]` Sets sorting order. - `const LogAuditListParamsDirectionDesc LogAuditListParamsDirection = "desc"` - `const LogAuditListParamsDirectionAsc LogAuditListParamsDirection = "asc"` - `Limit param.Field[float64]` The number limits the objects to return. The cursor attribute may be used to iterate over the next batch of objects if there are more than the limit. - `RawCfRayID param.Field[LogAuditListParamsRawCfRayID]` - `Not []string` Filters out audit logs by the response CF Ray ID. - `RawMethod param.Field[LogAuditListParamsRawMethod]` - `Not []string` Filters out audit logs by the HTTP method for the API call. - `RawStatusCode param.Field[LogAuditListParamsRawStatusCode]` - `Not []int64` Filters out audit logs by the response status code that was returned. - `RawURI param.Field[LogAuditListParamsRawURI]` - `Not []string` Filters out audit logs by the request URI. - `ResourceID param.Field[LogAuditListParamsResourceID]` - `Not []string` Filters out audit logs by the resource ID. - `ResourceProduct param.Field[LogAuditListParamsResourceProduct]` - `Not []string` Filters out audit logs by the Cloudflare product associated with the changed resource. - `ResourceScope param.Field[LogAuditListParamsResourceScope]` - `Not []LogAuditListParamsResourceScopeNot` Filters out audit logs by the resource scope, specifying whether the resource is associated with an organization. - `const LogAuditListParamsResourceScopeNotOrganizations LogAuditListParamsResourceScopeNot = "organizations"` - `ResourceType param.Field[LogAuditListParamsResourceType]` - `Not []string` Filters out audit logs based on the unique type of resource changed by the action. ### Returns - `type LogAuditListResponse struct{…}` - `ID string` A unique identifier for the audit log entry. - `Action LogAuditListResponseAction` Provides information about the action performed. - `Description string` A short description of the action performed. - `Result string` The result of the action, indicating success or failure. - `Time Time` A timestamp indicating when the action was logged. - `Type string` A short string that describes the action that was performed. - `Actor LogAuditListResponseActor` Provides details about the actor who performed the action. - `ID string` The ID of the actor who performed the action. If a user performed the action, this will be their User ID. - `Context LogAuditListResponseActorContext` - `const LogAuditListResponseActorContextAPIKey LogAuditListResponseActorContext = "api_key"` - `const LogAuditListResponseActorContextAPIToken LogAuditListResponseActorContext = "api_token"` - `const LogAuditListResponseActorContextDash LogAuditListResponseActorContext = "dash"` - `const LogAuditListResponseActorContextOAuth LogAuditListResponseActorContext = "oauth"` - `const LogAuditListResponseActorContextOriginCAKey LogAuditListResponseActorContext = "origin_ca_key"` - `Email string` The email of the actor who performed the action. - `IPAddress string` The IP address of the request that performed the action. - `TokenID string` The API token ID when the actor context is an api_token or oauth. - `TokenName string` The API token name when the actor context is an api_token or oauth. - `Type LogAuditListResponseActorType` The type of actor. - `const LogAuditListResponseActorTypeCloudflareAdmin LogAuditListResponseActorType = "cloudflare_admin"` - `const LogAuditListResponseActorTypeSystem LogAuditListResponseActorType = "system"` - `const LogAuditListResponseActorTypeUser LogAuditListResponseActorType = "user"` - `Organization LogAuditListResponseOrganization` Contains organization related information. - `ID string` A unique identifier for the organization. - `Raw LogAuditListResponseRaw` Provides raw information about the request and response. - `CfRayID string` The Cloudflare Ray ID for the request. - `Method string` The HTTP method of the request. - `StatusCode int64` The HTTP response status code returned by the API. - `URI string` The URI of the request. - `UserAgent string` The client's user agent string sent with the request. - `Resource LogAuditListResponseResource` Provides details about the affected resource. - `ID string` The unique identifier for the affected resource. - `Product string` The Cloudflare product associated with the resource. - `Request unknown` - `Response unknown` - `Scope unknown` The scope of the resource. - `Type string` The type of the resource. ### Example ```go package main import ( "context" "fmt" "time" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/organizations" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Organizations.Logs.Audit.List( context.TODO(), "a67e14daa5f8dceeb91fe5449ba496ef", organizations.LogAuditListParams{ Before: cloudflare.F(time.Now()), Since: cloudflare.F(time.Now()), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message" } ], "result": [ { "id": "023e105f4ecef8ad9ca31a8372d0c353", "action": { "description": "Add Member", "result": "success", "time": "2024-04-26T17:31:07Z", "type": "create" }, "actor": { "id": "f6b5de0326bb5182b8a4840ee01ec774", "context": "dash", "email": "alice@example.com", "ip_address": "198.41.129.166", "token_id": "token_id", "token_name": "token_name", "type": "user" }, "organization": { "id": "019c4f65e7607d8c9f6f6b58aa3aff50" }, "raw": { "cf_ray_id": "8e9b1c60ef9e1c9a", "method": "POST", "status_code": 200, "uri": "/accounts/4bb334f7c94c4a29a045f03944f072e5/members", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/605.1.15" }, "resource": { "id": "id", "product": "organizations", "request": {}, "response": {}, "scope": {}, "type": "type" } } ], "result_info": { "count": "1", "cursor": "ASqdKd7dKgxh-aZ8bm0mZos1BtW4BdEqifCzNkEeGRzi_5SN_-362Y8sF-C1TRn60_6rd3z2dIajf9EAPyQ_NmIeAMkacmaJPXipqvP7PLU4t72wyqBeJfjmjdE=" }, "success": true } ```