# Accounts ## List Accounts `client.Accounts.List(ctx, query) (*V4PagePaginationArray[Account], error)` **get** `/accounts` List all accounts you have ownership or verified access to. ### Parameters - `query AccountListParams` - `Direction param.Field[AccountListParamsDirection]` Direction to order results. - `const AccountListParamsDirectionAsc AccountListParamsDirection = "asc"` - `const AccountListParamsDirectionDesc AccountListParamsDirection = "desc"` - `Name param.Field[string]` Name of the account. - `Page param.Field[float64]` Page number of paginated results. - `PerPage param.Field[float64]` Maximum number of results per page. ### Returns - `type Account struct{…}` - `ID string` Identifier - `Name string` Account name - `Type AccountType` - `const AccountTypeStandard AccountType = "standard"` - `const AccountTypeEnterprise AccountType = "enterprise"` - `CreatedOn Time` Timestamp for the creation of the account - `ManagedBy AccountManagedBy` Parent container details - `ParentOrgID string` ID of the parent Organization, if one exists - `ParentOrgName string` Name of the parent Organization, if one exists - `Settings AccountSettings` 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 ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "023e105f4ecef8ad9ca31a8372d0c353", "name": "Demo Account", "type": "standard", "created_on": "2014-03-01T12:21:02.0000Z", "managed_by": { "parent_org_id": "4536bcfad5faccb111b47003c79917fa", "parent_org_name": "Demo Parent Organization" }, "settings": { "abuse_contact_email": "abuse_contact_email", "enforce_twofactor": true } } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Account Details `client.Accounts.Get(ctx, query) (*Account, error)` **get** `/accounts/{account_id}` Get information about a specific account that you are a member of. ### Parameters - `query AccountGetParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type Account struct{…}` - `ID string` Identifier - `Name string` Account name - `Type AccountType` - `const AccountTypeStandard AccountType = "standard"` - `const AccountTypeEnterprise AccountType = "enterprise"` - `CreatedOn Time` Timestamp for the creation of the account - `ManagedBy AccountManagedBy` Parent container details - `ParentOrgID string` ID of the parent Organization, if one exists - `ParentOrgName string` Name of the parent Organization, if one exists - `Settings AccountSettings` 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 ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) account, err := client.Accounts.Get(context.TODO(), accounts.AccountGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", account.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "name": "Demo Account", "type": "standard", "created_on": "2014-03-01T12:21:02.0000Z", "managed_by": { "parent_org_id": "4536bcfad5faccb111b47003c79917fa", "parent_org_name": "Demo Parent Organization" }, "settings": { "abuse_contact_email": "abuse_contact_email", "enforce_twofactor": true } } } ``` ## Create an account `client.Accounts.New(ctx, body) (*Account, error)` **post** `/accounts` Create an account (only available for tenant admins at this time) ### Parameters - `body AccountNewParams` - `Name param.Field[string]` Account name - `Type param.Field[AccountNewParamsType]` - `const AccountNewParamsTypeStandard AccountNewParamsType = "standard"` - `const AccountNewParamsTypeEnterprise AccountNewParamsType = "enterprise"` - `Unit param.Field[AccountNewParamsUnit]` information related to the tenant unit, and optionally, an id of the unit to create the account on. see https://developers.cloudflare.com/tenant/how-to/manage-accounts/ - `ID string` Tenant unit ID ### Returns - `type Account struct{…}` - `ID string` Identifier - `Name string` Account name - `Type AccountType` - `const AccountTypeStandard AccountType = "standard"` - `const AccountTypeEnterprise AccountType = "enterprise"` - `CreatedOn Time` Timestamp for the creation of the account - `ManagedBy AccountManagedBy` Parent container details - `ParentOrgID string` ID of the parent Organization, if one exists - `ParentOrgName string` Name of the parent Organization, if one exists - `Settings AccountSettings` 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 ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) account, err := client.Accounts.New(context.TODO(), accounts.AccountNewParams{ Name: cloudflare.F("name"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", account.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "name": "Demo Account", "type": "standard", "created_on": "2014-03-01T12:21:02.0000Z", "managed_by": { "parent_org_id": "4536bcfad5faccb111b47003c79917fa", "parent_org_name": "Demo Parent Organization" }, "settings": { "abuse_contact_email": "abuse_contact_email", "enforce_twofactor": true } } } ``` ## Update Account `client.Accounts.Update(ctx, params) (*Account, error)` **put** `/accounts/{account_id}` Update an existing account. ### Parameters - `params AccountUpdateParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Account param.Field[Account]` Body param ### Returns - `type Account struct{…}` - `ID string` Identifier - `Name string` Account name - `Type AccountType` - `const AccountTypeStandard AccountType = "standard"` - `const AccountTypeEnterprise AccountType = "enterprise"` - `CreatedOn Time` Timestamp for the creation of the account - `ManagedBy AccountManagedBy` Parent container details - `ParentOrgID string` ID of the parent Organization, if one exists - `ParentOrgName string` Name of the parent Organization, if one exists - `Settings AccountSettings` 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 ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) account, err := client.Accounts.Update(context.TODO(), accounts.AccountUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Account: accounts.AccountParam{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Demo Account"), Type: cloudflare.F(accounts.AccountTypeStandard), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", account.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "name": "Demo Account", "type": "standard", "created_on": "2014-03-01T12:21:02.0000Z", "managed_by": { "parent_org_id": "4536bcfad5faccb111b47003c79917fa", "parent_org_name": "Demo Parent Organization" }, "settings": { "abuse_contact_email": "abuse_contact_email", "enforce_twofactor": true } } } ``` ## Delete a specific account `client.Accounts.Delete(ctx, body) (*AccountDeleteResponse, error)` **delete** `/accounts/{account_id}` Delete a specific account (only available for tenant admins at this time). This is a permanent operation that will delete any zones or other resources under the account ### Parameters - `body AccountDeleteParams` - `AccountID param.Field[string]` The account ID of the account to be deleted ### Returns - `type AccountDeleteResponse struct{…}` - `ID string` Identifier ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) account, err := client.Accounts.Delete(context.TODO(), accounts.AccountDeleteParams{ AccountID: cloudflare.F("account_id"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", account.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` ## Domain Types ### Account - `type Account struct{…}` - `ID string` Identifier - `Name string` Account name - `Type AccountType` - `const AccountTypeStandard AccountType = "standard"` - `const AccountTypeEnterprise AccountType = "enterprise"` - `CreatedOn Time` Timestamp for the creation of the account - `ManagedBy AccountManagedBy` Parent container details - `ParentOrgID string` ID of the parent Organization, if one exists - `ParentOrgName string` Name of the parent Organization, if one exists - `Settings AccountSettings` 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 # Account Organizations ## Move account `client.Accounts.AccountOrganizations.New(ctx, params) (*AccountOrganizationNewResponse, error)` **post** `/accounts/{account_id}/move` Move an account within an organization hierarchy or an account outside an organization. (Currently in Closed Beta - see https://developers.cloudflare.com/fundamentals/organizations/) ### Parameters - `params AccountOrganizationNewParams` - `AccountID param.Field[string]` Path param - `DestinationOrganizationID param.Field[string]` Body param ### Returns - `type AccountOrganizationNewResponse struct{…}` - `AccountID string` - `DestinationOrganizationID string` - `SourceOrganizationID string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) accountOrganization, err := client.Accounts.AccountOrganizations.New(context.TODO(), accounts.AccountOrganizationNewParams{ AccountID: cloudflare.F("account_id"), DestinationOrganizationID: cloudflare.F("destination_organization_id"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", accountOrganization.AccountID) } ``` #### Response ```json { "errors": [], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "account_id": "account_id", "destination_organization_id": "destination_organization_id", "source_organization_id": "source_organization_id" }, "success": true } ``` # Account Profile ## Get account profile `client.Accounts.AccountProfile.Get(ctx, query) (*AccountProfile, error)` **get** `/accounts/{account_id}/profile` Retrieves the profile information for a specific Cloudflare account, including organization details, settings, and metadata. This endpoint is commonly used to verify account access and retrieve account-level configuration. ### Parameters - `query AccountProfileGetParams` - `AccountID param.Field[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/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) accountProfile, err := client.Accounts.AccountProfile.Get(context.TODO(), accounts.AccountProfileGetParams{ AccountID: cloudflare.F("account_id"), }) 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 account profile `client.Accounts.AccountProfile.Update(ctx, params) error` **put** `/accounts/{account_id}/profile` Updates the profile information for a Cloudflare account. Allows modification of account-level settings and organizational details. Requires Account Settings Write permission. ### Parameters - `params AccountProfileUpdateParams` - `AccountID param.Field[string]` Path param - `AccountProfile param.Field[AccountProfile]` Body param ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) err := client.Accounts.AccountProfile.Update(context.TODO(), accounts.AccountProfileUpdateParams{ AccountID: cloudflare.F("account_id"), 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 ### Account Profile - `type AccountProfile struct{…}` - `BusinessAddress string` - `BusinessEmail string` - `BusinessName string` - `BusinessPhone string` - `ExternalMetadata string` # Members ## List Members `client.Accounts.Members.List(ctx, params) (*V4PagePaginationArray[Member], error)` **get** `/accounts/{account_id}/members` List all members of an account. ### Parameters - `params MemberListParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Direction param.Field[MemberListParamsDirection]` Query param: Direction to order results. - `const MemberListParamsDirectionAsc MemberListParamsDirection = "asc"` - `const MemberListParamsDirectionDesc MemberListParamsDirection = "desc"` - `Order param.Field[MemberListParamsOrder]` Query param: Field to order results by. - `const MemberListParamsOrderUserFirstName MemberListParamsOrder = "user.first_name"` - `const MemberListParamsOrderUserLastName MemberListParamsOrder = "user.last_name"` - `const MemberListParamsOrderUserEmail MemberListParamsOrder = "user.email"` - `const MemberListParamsOrderStatus MemberListParamsOrder = "status"` - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Maximum number of results per page. - `Status param.Field[MemberListParamsStatus]` Query param: A member's status in the account. - `const MemberListParamsStatusAccepted MemberListParamsStatus = "accepted"` - `const MemberListParamsStatusPending MemberListParamsStatus = "pending"` - `const MemberListParamsStatusRejected MemberListParamsStatus = "rejected"` ### Returns - `type Member struct{…}` - `ID string` Membership identifier tag. - `Email string` The contact email address of the user. - `Policies []MemberPolicy` Access policy for the membership - `ID string` Policy identifier. - `Access MemberPoliciesAccess` Allow or deny operations against the resources. - `const MemberPoliciesAccessAllow MemberPoliciesAccess = "allow"` - `const MemberPoliciesAccessDeny MemberPoliciesAccess = "deny"` - `PermissionGroups []MemberPoliciesPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta MemberPoliciesPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `ResourceGroups []MemberPoliciesResourceGroup` A list of resource groups that the policy applies to. - `ID string` Identifier of the resource group. - `Scope []MemberPoliciesResourceGroupsScope` The scope associated to the resource group - `Key string` This is a combination of pre-defined resource name and identifier (like Account ID etc.) - `Objects []MemberPoliciesResourceGroupsScopeObject` A list of scope objects for additional context. - `Key string` This is a combination of pre-defined resource name and identifier (like Zone ID etc.) - `Meta MemberPoliciesResourceGroupsMeta` Attributes associated to the resource group. - `Key string` - `Value string` - `Name string` Name of the resource group. - `Roles []Role` Roles assigned to this Member. - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` - `Status MemberStatus` A member's status in the account. - `const MemberStatusAccepted MemberStatus = "accepted"` - `const MemberStatusPending MemberStatus = "pending"` - `User MemberUser` Details of the user associated to the membership. - `Email string` The contact email address of the user. - `ID string` Identifier - `FirstName string` User's first name - `LastName string` User's last name - `TwoFactorAuthenticationEnabled bool` Indicates whether two-factor authentication is enabled for the user account. Does not apply to API authentication. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Accounts.Members.List(context.TODO(), accounts.MemberListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "4536bcfad5faccb111b47003c79917fa", "email": "user@example.com", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "access": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resource_groups": [ { "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1", "scope": [ { "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", "objects": [ { "key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5" } ] } ], "meta": { "key": "key", "value": "value" }, "name": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4" } ] } ], "roles": [ { "id": "3536bcfad5faccb999b47003c79917fb", "description": "Administrative access to the entire Account", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "billing": { "read": true, "write": false }, "cache_purge": { "read": true, "write": false }, "dns": { "read": true, "write": false }, "dns_records": { "read": true, "write": false }, "lb": { "read": true, "write": false }, "logs": { "read": true, "write": false }, "organization": { "read": true, "write": false }, "ssl": { "read": true, "write": false }, "waf": { "read": true, "write": false }, "zone_settings": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } ], "status": "accepted", "user": { "email": "user@example.com", "id": "023e105f4ecef8ad9ca31a8372d0c353", "first_name": "John", "last_name": "Appleseed", "two_factor_authentication_enabled": true } } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Member Details `client.Accounts.Members.Get(ctx, memberID, query) (*Member, error)` **get** `/accounts/{account_id}/members/{member_id}` Get information about a specific member of an account. ### Parameters - `memberID string` Membership identifier tag. - `query MemberGetParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type Member struct{…}` - `ID string` Membership identifier tag. - `Email string` The contact email address of the user. - `Policies []MemberPolicy` Access policy for the membership - `ID string` Policy identifier. - `Access MemberPoliciesAccess` Allow or deny operations against the resources. - `const MemberPoliciesAccessAllow MemberPoliciesAccess = "allow"` - `const MemberPoliciesAccessDeny MemberPoliciesAccess = "deny"` - `PermissionGroups []MemberPoliciesPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta MemberPoliciesPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `ResourceGroups []MemberPoliciesResourceGroup` A list of resource groups that the policy applies to. - `ID string` Identifier of the resource group. - `Scope []MemberPoliciesResourceGroupsScope` The scope associated to the resource group - `Key string` This is a combination of pre-defined resource name and identifier (like Account ID etc.) - `Objects []MemberPoliciesResourceGroupsScopeObject` A list of scope objects for additional context. - `Key string` This is a combination of pre-defined resource name and identifier (like Zone ID etc.) - `Meta MemberPoliciesResourceGroupsMeta` Attributes associated to the resource group. - `Key string` - `Value string` - `Name string` Name of the resource group. - `Roles []Role` Roles assigned to this Member. - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` - `Status MemberStatus` A member's status in the account. - `const MemberStatusAccepted MemberStatus = "accepted"` - `const MemberStatusPending MemberStatus = "pending"` - `User MemberUser` Details of the user associated to the membership. - `Email string` The contact email address of the user. - `ID string` Identifier - `FirstName string` User's first name - `LastName string` User's last name - `TwoFactorAuthenticationEnabled bool` Indicates whether two-factor authentication is enabled for the user account. Does not apply to API authentication. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) member, err := client.Accounts.Members.Get( context.TODO(), "4536bcfad5faccb111b47003c79917fa", accounts.MemberGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", member.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "4536bcfad5faccb111b47003c79917fa", "email": "user@example.com", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "access": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resource_groups": [ { "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1", "scope": [ { "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", "objects": [ { "key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5" } ] } ], "meta": { "key": "key", "value": "value" }, "name": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4" } ] } ], "roles": [ { "id": "3536bcfad5faccb999b47003c79917fb", "description": "Administrative access to the entire Account", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "billing": { "read": true, "write": false }, "cache_purge": { "read": true, "write": false }, "dns": { "read": true, "write": false }, "dns_records": { "read": true, "write": false }, "lb": { "read": true, "write": false }, "logs": { "read": true, "write": false }, "organization": { "read": true, "write": false }, "ssl": { "read": true, "write": false }, "waf": { "read": true, "write": false }, "zone_settings": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } ], "status": "accepted", "user": { "email": "user@example.com", "id": "023e105f4ecef8ad9ca31a8372d0c353", "first_name": "John", "last_name": "Appleseed", "two_factor_authentication_enabled": true } } } ``` ## Add Member `client.Accounts.Members.New(ctx, params) (*Member, error)` **post** `/accounts/{account_id}/members` Add a user to the list of members for this account. ### Parameters - `params MemberNewParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Email param.Field[string]` Body param: The contact email address of the user. - `Roles param.Field[[]string]` Body param: Array of roles associated with this member. - `Status param.Field[MemberNewParamsIAMCreateMemberWithRolesStatus]` Body param: Status of the member invitation. If not provided during creation, defaults to 'pending'. Changing from 'accepted' back to 'pending' will trigger a replacement of the member resource in Terraform. - `const MemberNewParamsIAMCreateMemberWithRolesStatusAccepted MemberNewParamsIAMCreateMemberWithRolesStatus = "accepted"` - `const MemberNewParamsIAMCreateMemberWithRolesStatusPending MemberNewParamsIAMCreateMemberWithRolesStatus = "pending"` ### Returns - `type Member struct{…}` - `ID string` Membership identifier tag. - `Email string` The contact email address of the user. - `Policies []MemberPolicy` Access policy for the membership - `ID string` Policy identifier. - `Access MemberPoliciesAccess` Allow or deny operations against the resources. - `const MemberPoliciesAccessAllow MemberPoliciesAccess = "allow"` - `const MemberPoliciesAccessDeny MemberPoliciesAccess = "deny"` - `PermissionGroups []MemberPoliciesPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta MemberPoliciesPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `ResourceGroups []MemberPoliciesResourceGroup` A list of resource groups that the policy applies to. - `ID string` Identifier of the resource group. - `Scope []MemberPoliciesResourceGroupsScope` The scope associated to the resource group - `Key string` This is a combination of pre-defined resource name and identifier (like Account ID etc.) - `Objects []MemberPoliciesResourceGroupsScopeObject` A list of scope objects for additional context. - `Key string` This is a combination of pre-defined resource name and identifier (like Zone ID etc.) - `Meta MemberPoliciesResourceGroupsMeta` Attributes associated to the resource group. - `Key string` - `Value string` - `Name string` Name of the resource group. - `Roles []Role` Roles assigned to this Member. - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` - `Status MemberStatus` A member's status in the account. - `const MemberStatusAccepted MemberStatus = "accepted"` - `const MemberStatusPending MemberStatus = "pending"` - `User MemberUser` Details of the user associated to the membership. - `Email string` The contact email address of the user. - `ID string` Identifier - `FirstName string` User's first name - `LastName string` User's last name - `TwoFactorAuthenticationEnabled bool` Indicates whether two-factor authentication is enabled for the user account. Does not apply to API authentication. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) member, err := client.Accounts.Members.New(context.TODO(), accounts.MemberNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: accounts.MemberNewParamsBodyIAMCreateMemberWithRoles{ Email: cloudflare.F("user@example.com"), Roles: cloudflare.F([]string{"3536bcfad5faccb999b47003c79917fb"}), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", member.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "4536bcfad5faccb111b47003c79917fa", "email": "user@example.com", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "access": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resource_groups": [ { "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1", "scope": [ { "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", "objects": [ { "key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5" } ] } ], "meta": { "key": "key", "value": "value" }, "name": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4" } ] } ], "roles": [ { "id": "3536bcfad5faccb999b47003c79917fb", "description": "Administrative access to the entire Account", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "billing": { "read": true, "write": false }, "cache_purge": { "read": true, "write": false }, "dns": { "read": true, "write": false }, "dns_records": { "read": true, "write": false }, "lb": { "read": true, "write": false }, "logs": { "read": true, "write": false }, "organization": { "read": true, "write": false }, "ssl": { "read": true, "write": false }, "waf": { "read": true, "write": false }, "zone_settings": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } ], "status": "accepted", "user": { "email": "user@example.com", "id": "023e105f4ecef8ad9ca31a8372d0c353", "first_name": "John", "last_name": "Appleseed", "two_factor_authentication_enabled": true } } } ``` ## Update Member `client.Accounts.Members.Update(ctx, memberID, params) (*Member, error)` **put** `/accounts/{account_id}/members/{member_id}` Modify an account member. ### Parameters - `memberID string` Membership identifier tag. - `params MemberUpdateParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Roles param.Field[[]Role]` Body param: Roles assigned to this member. - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` ### Returns - `type Member struct{…}` - `ID string` Membership identifier tag. - `Email string` The contact email address of the user. - `Policies []MemberPolicy` Access policy for the membership - `ID string` Policy identifier. - `Access MemberPoliciesAccess` Allow or deny operations against the resources. - `const MemberPoliciesAccessAllow MemberPoliciesAccess = "allow"` - `const MemberPoliciesAccessDeny MemberPoliciesAccess = "deny"` - `PermissionGroups []MemberPoliciesPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta MemberPoliciesPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `ResourceGroups []MemberPoliciesResourceGroup` A list of resource groups that the policy applies to. - `ID string` Identifier of the resource group. - `Scope []MemberPoliciesResourceGroupsScope` The scope associated to the resource group - `Key string` This is a combination of pre-defined resource name and identifier (like Account ID etc.) - `Objects []MemberPoliciesResourceGroupsScopeObject` A list of scope objects for additional context. - `Key string` This is a combination of pre-defined resource name and identifier (like Zone ID etc.) - `Meta MemberPoliciesResourceGroupsMeta` Attributes associated to the resource group. - `Key string` - `Value string` - `Name string` Name of the resource group. - `Roles []Role` Roles assigned to this Member. - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` - `Status MemberStatus` A member's status in the account. - `const MemberStatusAccepted MemberStatus = "accepted"` - `const MemberStatusPending MemberStatus = "pending"` - `User MemberUser` Details of the user associated to the membership. - `Email string` The contact email address of the user. - `ID string` Identifier - `FirstName string` User's first name - `LastName string` User's last name - `TwoFactorAuthenticationEnabled bool` Indicates whether two-factor authentication is enabled for the user account. Does not apply to API authentication. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) member, err := client.Accounts.Members.Update( context.TODO(), "4536bcfad5faccb111b47003c79917fa", accounts.MemberUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: accounts.MemberUpdateParamsBodyIAMUpdateMemberWithRoles{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", member.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "4536bcfad5faccb111b47003c79917fa", "email": "user@example.com", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "access": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resource_groups": [ { "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1", "scope": [ { "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", "objects": [ { "key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5" } ] } ], "meta": { "key": "key", "value": "value" }, "name": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4" } ] } ], "roles": [ { "id": "3536bcfad5faccb999b47003c79917fb", "description": "Administrative access to the entire Account", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "billing": { "read": true, "write": false }, "cache_purge": { "read": true, "write": false }, "dns": { "read": true, "write": false }, "dns_records": { "read": true, "write": false }, "lb": { "read": true, "write": false }, "logs": { "read": true, "write": false }, "organization": { "read": true, "write": false }, "ssl": { "read": true, "write": false }, "waf": { "read": true, "write": false }, "zone_settings": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } ], "status": "accepted", "user": { "email": "user@example.com", "id": "023e105f4ecef8ad9ca31a8372d0c353", "first_name": "John", "last_name": "Appleseed", "two_factor_authentication_enabled": true } } } ``` ## Remove Member `client.Accounts.Members.Delete(ctx, memberID, body) (*MemberDeleteResponse, error)` **delete** `/accounts/{account_id}/members/{member_id}` Remove a member from an account. ### Parameters - `memberID string` Membership identifier tag. - `body MemberDeleteParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type MemberDeleteResponse struct{…}` - `ID string` Identifier ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) member, err := client.Accounts.Members.Delete( context.TODO(), "4536bcfad5faccb111b47003c79917fa", accounts.MemberDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", member.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` ## Domain Types ### Status - `type Status string` Whether the user is a member of the organization or has an invitation pending. - `const StatusMember Status = "member"` - `const StatusInvited Status = "invited"` # Roles ## List Roles `client.Accounts.Roles.List(ctx, params) (*V4PagePaginationArray[Role], error)` **get** `/accounts/{account_id}/roles` Get all available roles for an account. ### Parameters - `params RoleListParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of roles per page. ### Returns - `type Role struct{…}` - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Accounts.Roles.List(context.TODO(), accounts.RoleListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "3536bcfad5faccb999b47003c79917fb", "description": "Administrative access to the entire Account", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "billing": { "read": true, "write": false }, "cache_purge": { "read": true, "write": false }, "dns": { "read": true, "write": false }, "dns_records": { "read": true, "write": false }, "lb": { "read": true, "write": false }, "logs": { "read": true, "write": false }, "organization": { "read": true, "write": false }, "ssl": { "read": true, "write": false }, "waf": { "read": true, "write": false }, "zone_settings": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Role Details `client.Accounts.Roles.Get(ctx, roleID, query) (*Role, error)` **get** `/accounts/{account_id}/roles/{role_id}` Get information about a specific role for an account. ### Parameters - `roleID string` Role identifier tag. - `query RoleGetParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type Role struct{…}` - `ID string` Role identifier tag. - `Description string` Description of role's permissions. - `Name string` Role name. - `Permissions RolePermissions` - `Analytics PermissionGrant` - `Read bool` - `Write bool` - `Billing PermissionGrant` - `CachePurge PermissionGrant` - `DNS PermissionGrant` - `DNSRecords PermissionGrant` - `LB PermissionGrant` - `Logs PermissionGrant` - `Organization PermissionGrant` - `SSL PermissionGrant` - `WAF PermissionGrant` - `ZoneSettings PermissionGrant` - `Zones PermissionGrant` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) role, err := client.Accounts.Roles.Get( context.TODO(), "3536bcfad5faccb999b47003c79917fb", accounts.RoleGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", role.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "3536bcfad5faccb999b47003c79917fb", "description": "Administrative access to the entire Account", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "billing": { "read": true, "write": false }, "cache_purge": { "read": true, "write": false }, "dns": { "read": true, "write": false }, "dns_records": { "read": true, "write": false }, "lb": { "read": true, "write": false }, "logs": { "read": true, "write": false }, "organization": { "read": true, "write": false }, "ssl": { "read": true, "write": false }, "waf": { "read": true, "write": false }, "zone_settings": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } } ``` # Subscriptions ## List Subscriptions `client.Accounts.Subscriptions.Get(ctx, query) (*SinglePage[Subscription], error)` **get** `/accounts/{account_id}/subscriptions` Lists all of an account's subscriptions. ### Parameters - `query SubscriptionGetParams` - `AccountID param.Field[string]` Identifier ### Returns - `type Subscription struct{…}` - `ID string` Subscription identifier tag. - `Currency string` The monetary unit in which pricing information is displayed. - `CurrentPeriodEnd Time` The end of the current period and also when the next billing is due. - `CurrentPeriodStart Time` When the current billing period started. May match initial_period_start if this is the first period. - `Frequency SubscriptionFrequency` How often the subscription is renewed automatically. - `const SubscriptionFrequencyWeekly SubscriptionFrequency = "weekly"` - `const SubscriptionFrequencyMonthly SubscriptionFrequency = "monthly"` - `const SubscriptionFrequencyQuarterly SubscriptionFrequency = "quarterly"` - `const SubscriptionFrequencyYearly SubscriptionFrequency = "yearly"` - `Price float64` The price of the subscription that will be billed, in US dollars. - `RatePlan RatePlan` The rate plan applied to the subscription. - `ID RatePlanID` The ID of the rate plan. - `const RatePlanIDFree RatePlanID = "free"` - `const RatePlanIDLite RatePlanID = "lite"` - `const RatePlanIDPro RatePlanID = "pro"` - `const RatePlanIDProPlus RatePlanID = "pro_plus"` - `const RatePlanIDBusiness RatePlanID = "business"` - `const RatePlanIDEnterprise RatePlanID = "enterprise"` - `const RatePlanIDPartnersFree RatePlanID = "partners_free"` - `const RatePlanIDPartnersPro RatePlanID = "partners_pro"` - `const RatePlanIDPartnersBusiness RatePlanID = "partners_business"` - `const RatePlanIDPartnersEnterprise RatePlanID = "partners_enterprise"` - `Currency string` The currency applied to the rate plan subscription. - `ExternallyManaged bool` Whether this rate plan is managed externally from Cloudflare. - `IsContract bool` Whether a rate plan is enterprise-based (or newly adopted term contract). - `PublicName string` The full name of the rate plan. - `Scope string` The scope that this rate plan applies to. - `Sets []string` The list of sets this rate plan applies to. Returns array of strings. - `State SubscriptionState` The state that the subscription is in. - `const SubscriptionStateTrial SubscriptionState = "Trial"` - `const SubscriptionStateProvisioned SubscriptionState = "Provisioned"` - `const SubscriptionStatePaid SubscriptionState = "Paid"` - `const SubscriptionStateAwaitingPayment SubscriptionState = "AwaitingPayment"` - `const SubscriptionStateCancelled SubscriptionState = "Cancelled"` - `const SubscriptionStateFailed SubscriptionState = "Failed"` - `const SubscriptionStateExpired SubscriptionState = "Expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Accounts.Subscriptions.Get(context.TODO(), accounts.SubscriptionGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "506e3185e9c882d175a2d0cb0093d9f2", "currency": "USD", "current_period_end": "2014-03-31T12:20:00Z", "current_period_start": "2014-05-11T12:20:00Z", "frequency": "monthly", "price": 20, "rate_plan": { "id": "free", "currency": "USD", "externally_managed": false, "is_contract": false, "public_name": "Business Plan", "scope": "zone", "sets": [ "string" ] }, "state": "Paid" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Create Subscription `client.Accounts.Subscriptions.New(ctx, params) (*Subscription, error)` **post** `/accounts/{account_id}/subscriptions` Creates an account subscription. ### Parameters - `params SubscriptionNewParams` - `AccountID param.Field[string]` Path param: Identifier - `Subscription param.Field[Subscription]` Body param ### Returns - `type Subscription struct{…}` - `ID string` Subscription identifier tag. - `Currency string` The monetary unit in which pricing information is displayed. - `CurrentPeriodEnd Time` The end of the current period and also when the next billing is due. - `CurrentPeriodStart Time` When the current billing period started. May match initial_period_start if this is the first period. - `Frequency SubscriptionFrequency` How often the subscription is renewed automatically. - `const SubscriptionFrequencyWeekly SubscriptionFrequency = "weekly"` - `const SubscriptionFrequencyMonthly SubscriptionFrequency = "monthly"` - `const SubscriptionFrequencyQuarterly SubscriptionFrequency = "quarterly"` - `const SubscriptionFrequencyYearly SubscriptionFrequency = "yearly"` - `Price float64` The price of the subscription that will be billed, in US dollars. - `RatePlan RatePlan` The rate plan applied to the subscription. - `ID RatePlanID` The ID of the rate plan. - `const RatePlanIDFree RatePlanID = "free"` - `const RatePlanIDLite RatePlanID = "lite"` - `const RatePlanIDPro RatePlanID = "pro"` - `const RatePlanIDProPlus RatePlanID = "pro_plus"` - `const RatePlanIDBusiness RatePlanID = "business"` - `const RatePlanIDEnterprise RatePlanID = "enterprise"` - `const RatePlanIDPartnersFree RatePlanID = "partners_free"` - `const RatePlanIDPartnersPro RatePlanID = "partners_pro"` - `const RatePlanIDPartnersBusiness RatePlanID = "partners_business"` - `const RatePlanIDPartnersEnterprise RatePlanID = "partners_enterprise"` - `Currency string` The currency applied to the rate plan subscription. - `ExternallyManaged bool` Whether this rate plan is managed externally from Cloudflare. - `IsContract bool` Whether a rate plan is enterprise-based (or newly adopted term contract). - `PublicName string` The full name of the rate plan. - `Scope string` The scope that this rate plan applies to. - `Sets []string` The list of sets this rate plan applies to. Returns array of strings. - `State SubscriptionState` The state that the subscription is in. - `const SubscriptionStateTrial SubscriptionState = "Trial"` - `const SubscriptionStateProvisioned SubscriptionState = "Provisioned"` - `const SubscriptionStatePaid SubscriptionState = "Paid"` - `const SubscriptionStateAwaitingPayment SubscriptionState = "AwaitingPayment"` - `const SubscriptionStateCancelled SubscriptionState = "Cancelled"` - `const SubscriptionStateFailed SubscriptionState = "Failed"` - `const SubscriptionStateExpired SubscriptionState = "Expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/shared" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subscription, err := client.Accounts.Subscriptions.New(context.TODO(), accounts.SubscriptionNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Subscription: shared.SubscriptionParam{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subscription.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "506e3185e9c882d175a2d0cb0093d9f2", "currency": "USD", "current_period_end": "2014-03-31T12:20:00Z", "current_period_start": "2014-05-11T12:20:00Z", "frequency": "monthly", "price": 20, "rate_plan": { "id": "free", "currency": "USD", "externally_managed": false, "is_contract": false, "public_name": "Business Plan", "scope": "zone", "sets": [ "string" ] }, "state": "Paid" }, "success": true } ``` ## Update Subscription `client.Accounts.Subscriptions.Update(ctx, subscriptionIdentifier, params) (*Subscription, error)` **put** `/accounts/{account_id}/subscriptions/{subscription_identifier}` Updates an account subscription. ### Parameters - `subscriptionIdentifier string` Subscription identifier tag. - `params SubscriptionUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `Subscription param.Field[Subscription]` Body param ### Returns - `type Subscription struct{…}` - `ID string` Subscription identifier tag. - `Currency string` The monetary unit in which pricing information is displayed. - `CurrentPeriodEnd Time` The end of the current period and also when the next billing is due. - `CurrentPeriodStart Time` When the current billing period started. May match initial_period_start if this is the first period. - `Frequency SubscriptionFrequency` How often the subscription is renewed automatically. - `const SubscriptionFrequencyWeekly SubscriptionFrequency = "weekly"` - `const SubscriptionFrequencyMonthly SubscriptionFrequency = "monthly"` - `const SubscriptionFrequencyQuarterly SubscriptionFrequency = "quarterly"` - `const SubscriptionFrequencyYearly SubscriptionFrequency = "yearly"` - `Price float64` The price of the subscription that will be billed, in US dollars. - `RatePlan RatePlan` The rate plan applied to the subscription. - `ID RatePlanID` The ID of the rate plan. - `const RatePlanIDFree RatePlanID = "free"` - `const RatePlanIDLite RatePlanID = "lite"` - `const RatePlanIDPro RatePlanID = "pro"` - `const RatePlanIDProPlus RatePlanID = "pro_plus"` - `const RatePlanIDBusiness RatePlanID = "business"` - `const RatePlanIDEnterprise RatePlanID = "enterprise"` - `const RatePlanIDPartnersFree RatePlanID = "partners_free"` - `const RatePlanIDPartnersPro RatePlanID = "partners_pro"` - `const RatePlanIDPartnersBusiness RatePlanID = "partners_business"` - `const RatePlanIDPartnersEnterprise RatePlanID = "partners_enterprise"` - `Currency string` The currency applied to the rate plan subscription. - `ExternallyManaged bool` Whether this rate plan is managed externally from Cloudflare. - `IsContract bool` Whether a rate plan is enterprise-based (or newly adopted term contract). - `PublicName string` The full name of the rate plan. - `Scope string` The scope that this rate plan applies to. - `Sets []string` The list of sets this rate plan applies to. Returns array of strings. - `State SubscriptionState` The state that the subscription is in. - `const SubscriptionStateTrial SubscriptionState = "Trial"` - `const SubscriptionStateProvisioned SubscriptionState = "Provisioned"` - `const SubscriptionStatePaid SubscriptionState = "Paid"` - `const SubscriptionStateAwaitingPayment SubscriptionState = "AwaitingPayment"` - `const SubscriptionStateCancelled SubscriptionState = "Cancelled"` - `const SubscriptionStateFailed SubscriptionState = "Failed"` - `const SubscriptionStateExpired SubscriptionState = "Expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/shared" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subscription, err := client.Accounts.Subscriptions.Update( context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2", accounts.SubscriptionUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Subscription: shared.SubscriptionParam{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subscription.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "506e3185e9c882d175a2d0cb0093d9f2", "currency": "USD", "current_period_end": "2014-03-31T12:20:00Z", "current_period_start": "2014-05-11T12:20:00Z", "frequency": "monthly", "price": 20, "rate_plan": { "id": "free", "currency": "USD", "externally_managed": false, "is_contract": false, "public_name": "Business Plan", "scope": "zone", "sets": [ "string" ] }, "state": "Paid" }, "success": true } ``` ## Delete Subscription `client.Accounts.Subscriptions.Delete(ctx, subscriptionIdentifier, body) (*SubscriptionDeleteResponse, error)` **delete** `/accounts/{account_id}/subscriptions/{subscription_identifier}` Deletes an account's subscription. ### Parameters - `subscriptionIdentifier string` Subscription identifier tag. - `body SubscriptionDeleteParams` - `AccountID param.Field[string]` Identifier ### Returns - `type SubscriptionDeleteResponse struct{…}` - `SubscriptionID string` Subscription identifier tag. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subscription, err := client.Accounts.Subscriptions.Delete( context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2", accounts.SubscriptionDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subscription.SubscriptionID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "subscription_id": "506e3185e9c882d175a2d0cb0093d9f2" }, "success": true } ``` # Tokens ## List Tokens `client.Accounts.Tokens.List(ctx, params) (*V4PagePaginationArray[Token], error)` **get** `/accounts/{account_id}/tokens` List all Account Owned API tokens created for this account. ### Parameters - `params TokenListParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Direction param.Field[TokenListParamsDirection]` Query param: Direction to order results. - `const TokenListParamsDirectionAsc TokenListParamsDirection = "asc"` - `const TokenListParamsDirectionDesc TokenListParamsDirection = "desc"` - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Maximum number of results per page. ### Returns - `type Token struct{…}` - `ID string` Token identifier tag. - `Condition TokenCondition` - `RequestIP TokenConditionRequestIP` Client IP restrictions. - `In []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `NotIn []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `ExpiresOn Time` The expiration time on or after which the JWT MUST NOT be accepted for processing. - `IssuedOn Time` The time on which the token was created. - `LastUsedOn Time` Last time the token was used. - `ModifiedOn Time` Last time the token was modified. - `Name string` Token name. - `NotBefore Time` The time before which the token MUST NOT be accepted for processing. - `Policies []TokenPolicy` List of access policies assigned to the token. - `ID string` Policy identifier. - `Effect TokenPolicyEffect` Allow or deny operations against the resources. - `const TokenPolicyEffectAllow TokenPolicyEffect = "allow"` - `const TokenPolicyEffectDeny TokenPolicyEffect = "deny"` - `PermissionGroups []TokenPolicyPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta TokenPolicyPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `Resources TokenPolicyResourcesUnion` A list of resource names that the policy applies to. - `type TokenPolicyResourcesIAMResourcesTypeObjectString map[string, string]` Map of simple string resource permissions - `type TokenPolicyResourcesIAMResourcesTypeObjectNested map[string, map[string, string]]` Map of nested resource permissions - `Status TokenStatus` Status of the token. - `const TokenStatusActive TokenStatus = "active"` - `const TokenStatusDisabled TokenStatus = "disabled"` - `const TokenStatusExpired TokenStatus = "expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Accounts.Tokens.List(context.TODO(), accounts.TokenListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "ed17574386854bf78a67040be0a770b0", "condition": { "request_ip": { "in": [ "123.123.123.0/24", "2606:4700::/32" ], "not_in": [ "123.123.123.100/24", "2606:4700:4700::/48" ] } }, "expires_on": "2020-01-01T00:00:00Z", "issued_on": "2018-07-01T05:20:00Z", "last_used_on": "2020-01-02T12:34:00Z", "modified_on": "2018-07-02T05:20:00Z", "name": "readonly token", "not_before": "2018-07-01T05:20:00Z", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "effect": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resources": { "foo": "string" } } ], "status": "active" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Token Details `client.Accounts.Tokens.Get(ctx, tokenID, query) (*Token, error)` **get** `/accounts/{account_id}/tokens/{token_id}` Get information about a specific Account Owned API token. ### Parameters - `tokenID string` Token identifier tag. - `query TokenGetParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type Token struct{…}` - `ID string` Token identifier tag. - `Condition TokenCondition` - `RequestIP TokenConditionRequestIP` Client IP restrictions. - `In []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `NotIn []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `ExpiresOn Time` The expiration time on or after which the JWT MUST NOT be accepted for processing. - `IssuedOn Time` The time on which the token was created. - `LastUsedOn Time` Last time the token was used. - `ModifiedOn Time` Last time the token was modified. - `Name string` Token name. - `NotBefore Time` The time before which the token MUST NOT be accepted for processing. - `Policies []TokenPolicy` List of access policies assigned to the token. - `ID string` Policy identifier. - `Effect TokenPolicyEffect` Allow or deny operations against the resources. - `const TokenPolicyEffectAllow TokenPolicyEffect = "allow"` - `const TokenPolicyEffectDeny TokenPolicyEffect = "deny"` - `PermissionGroups []TokenPolicyPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta TokenPolicyPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `Resources TokenPolicyResourcesUnion` A list of resource names that the policy applies to. - `type TokenPolicyResourcesIAMResourcesTypeObjectString map[string, string]` Map of simple string resource permissions - `type TokenPolicyResourcesIAMResourcesTypeObjectNested map[string, map[string, string]]` Map of nested resource permissions - `Status TokenStatus` Status of the token. - `const TokenStatusActive TokenStatus = "active"` - `const TokenStatusDisabled TokenStatus = "disabled"` - `const TokenStatusExpired TokenStatus = "expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) token, err := client.Accounts.Tokens.Get( context.TODO(), "ed17574386854bf78a67040be0a770b0", accounts.TokenGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", token.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "ed17574386854bf78a67040be0a770b0", "condition": { "request_ip": { "in": [ "123.123.123.0/24", "2606:4700::/32" ], "not_in": [ "123.123.123.100/24", "2606:4700:4700::/48" ] } }, "expires_on": "2020-01-01T00:00:00Z", "issued_on": "2018-07-01T05:20:00Z", "last_used_on": "2020-01-02T12:34:00Z", "modified_on": "2018-07-02T05:20:00Z", "name": "readonly token", "not_before": "2018-07-01T05:20:00Z", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "effect": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resources": { "foo": "string" } } ], "status": "active" } } ``` ## Create Token `client.Accounts.Tokens.New(ctx, params) (*TokenNewResponse, error)` **post** `/accounts/{account_id}/tokens` Create a new Account Owned API token. ### Parameters - `params TokenNewParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Name param.Field[string]` Body param: Token name. - `Policies param.Field[[]TokenPolicy]` Body param: List of access policies assigned to the token. - `ID string` Policy identifier. - `Effect TokenPolicyEffect` Allow or deny operations against the resources. - `const TokenPolicyEffectAllow TokenPolicyEffect = "allow"` - `const TokenPolicyEffectDeny TokenPolicyEffect = "deny"` - `PermissionGroups []TokenPolicyPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta TokenPolicyPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `Resources TokenPolicyResourcesUnion` A list of resource names that the policy applies to. - `type TokenPolicyResourcesIAMResourcesTypeObjectString map[string, string]` Map of simple string resource permissions - `type TokenPolicyResourcesIAMResourcesTypeObjectNested map[string, map[string, string]]` Map of nested resource permissions - `Condition param.Field[TokenNewParamsCondition]` Body param - `RequestIP TokenNewParamsConditionRequestIP` Client IP restrictions. - `In []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `NotIn []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `ExpiresOn param.Field[Time]` Body param: The expiration time on or after which the JWT MUST NOT be accepted for processing. - `NotBefore param.Field[Time]` Body param: The time before which the token MUST NOT be accepted for processing. ### Returns - `type TokenNewResponse struct{…}` - `ID string` Token identifier tag. - `Condition TokenNewResponseCondition` - `RequestIP TokenNewResponseConditionRequestIP` Client IP restrictions. - `In []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `NotIn []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `ExpiresOn Time` The expiration time on or after which the JWT MUST NOT be accepted for processing. - `IssuedOn Time` The time on which the token was created. - `LastUsedOn Time` Last time the token was used. - `ModifiedOn Time` Last time the token was modified. - `Name string` Token name. - `NotBefore Time` The time before which the token MUST NOT be accepted for processing. - `Policies []TokenPolicy` List of access policies assigned to the token. - `ID string` Policy identifier. - `Effect TokenPolicyEffect` Allow or deny operations against the resources. - `const TokenPolicyEffectAllow TokenPolicyEffect = "allow"` - `const TokenPolicyEffectDeny TokenPolicyEffect = "deny"` - `PermissionGroups []TokenPolicyPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta TokenPolicyPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `Resources TokenPolicyResourcesUnion` A list of resource names that the policy applies to. - `type TokenPolicyResourcesIAMResourcesTypeObjectString map[string, string]` Map of simple string resource permissions - `type TokenPolicyResourcesIAMResourcesTypeObjectNested map[string, map[string, string]]` Map of nested resource permissions - `Status TokenNewResponseStatus` Status of the token. - `const TokenNewResponseStatusActive TokenNewResponseStatus = "active"` - `const TokenNewResponseStatusDisabled TokenNewResponseStatus = "disabled"` - `const TokenNewResponseStatusExpired TokenNewResponseStatus = "expired"` - `Value TokenValue` The token value. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/shared" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) token, err := client.Accounts.Tokens.New(context.TODO(), accounts.TokenNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("readonly token"), Policies: cloudflare.F([]shared.TokenPolicyParam{shared.TokenPolicyParam{ Effect: cloudflare.F(shared.TokenPolicyEffectAllow), PermissionGroups: cloudflare.F([]shared.TokenPolicyPermissionGroupParam{shared.TokenPolicyPermissionGroupParam{ ID: cloudflare.F("c8fed203ed3043cba015a93ad1616f1f"), }, shared.TokenPolicyPermissionGroupParam{ ID: cloudflare.F("82e64a83756745bbbb1c9c2701bf816b"), }}), Resources: cloudflare.F[shared.TokenPolicyResourcesUnionParam](shared.TokenPolicyResourcesIAMResourcesTypeObjectStringParam(map[string]string{ "foo": "string", })), }}), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", token.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "ed17574386854bf78a67040be0a770b0", "condition": { "request_ip": { "in": [ "123.123.123.0/24", "2606:4700::/32" ], "not_in": [ "123.123.123.100/24", "2606:4700:4700::/48" ] } }, "expires_on": "2020-01-01T00:00:00Z", "issued_on": "2018-07-01T05:20:00Z", "last_used_on": "2020-01-02T12:34:00Z", "modified_on": "2018-07-02T05:20:00Z", "name": "readonly token", "not_before": "2018-07-01T05:20:00Z", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "effect": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resources": { "foo": "string" } } ], "status": "active", "value": "8M7wS6hCpXVc-DoRnPPY_UCWPgy8aea4Wy6kCe5T" } } ``` ## Update Token `client.Accounts.Tokens.Update(ctx, tokenID, params) (*Token, error)` **put** `/accounts/{account_id}/tokens/{token_id}` Update an existing token. ### Parameters - `tokenID string` Token identifier tag. - `params TokenUpdateParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Token param.Field[Token]` Body param ### Returns - `type Token struct{…}` - `ID string` Token identifier tag. - `Condition TokenCondition` - `RequestIP TokenConditionRequestIP` Client IP restrictions. - `In []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `NotIn []TokenConditionCIDRList` List of IPv4/IPv6 CIDR addresses. - `ExpiresOn Time` The expiration time on or after which the JWT MUST NOT be accepted for processing. - `IssuedOn Time` The time on which the token was created. - `LastUsedOn Time` Last time the token was used. - `ModifiedOn Time` Last time the token was modified. - `Name string` Token name. - `NotBefore Time` The time before which the token MUST NOT be accepted for processing. - `Policies []TokenPolicy` List of access policies assigned to the token. - `ID string` Policy identifier. - `Effect TokenPolicyEffect` Allow or deny operations against the resources. - `const TokenPolicyEffectAllow TokenPolicyEffect = "allow"` - `const TokenPolicyEffectDeny TokenPolicyEffect = "deny"` - `PermissionGroups []TokenPolicyPermissionGroup` A set of permission groups that are specified to the policy. - `ID string` Identifier of the permission group. - `Meta TokenPolicyPermissionGroupsMeta` Attributes associated to the permission group. - `Key string` - `Value string` - `Name string` Name of the permission group. - `Resources TokenPolicyResourcesUnion` A list of resource names that the policy applies to. - `type TokenPolicyResourcesIAMResourcesTypeObjectString map[string, string]` Map of simple string resource permissions - `type TokenPolicyResourcesIAMResourcesTypeObjectNested map[string, map[string, string]]` Map of nested resource permissions - `Status TokenStatus` Status of the token. - `const TokenStatusActive TokenStatus = "active"` - `const TokenStatusDisabled TokenStatus = "disabled"` - `const TokenStatusExpired TokenStatus = "expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/shared" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) token, err := client.Accounts.Tokens.Update( context.TODO(), "ed17574386854bf78a67040be0a770b0", accounts.TokenUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Token: shared.TokenParam{ Name: cloudflare.F("readonly token"), Policies: cloudflare.F([]shared.TokenPolicyParam{shared.TokenPolicyParam{ Effect: cloudflare.F(shared.TokenPolicyEffectAllow), PermissionGroups: cloudflare.F([]shared.TokenPolicyPermissionGroupParam{shared.TokenPolicyPermissionGroupParam{ ID: cloudflare.F("c8fed203ed3043cba015a93ad1616f1f"), }, shared.TokenPolicyPermissionGroupParam{ ID: cloudflare.F("82e64a83756745bbbb1c9c2701bf816b"), }}), Resources: cloudflare.F[shared.TokenPolicyResourcesUnionParam](shared.TokenPolicyResourcesIAMResourcesTypeObjectStringParam(map[string]string{ "foo": "string", })), }}), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", token.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "ed17574386854bf78a67040be0a770b0", "condition": { "request_ip": { "in": [ "123.123.123.0/24", "2606:4700::/32" ], "not_in": [ "123.123.123.100/24", "2606:4700:4700::/48" ] } }, "expires_on": "2020-01-01T00:00:00Z", "issued_on": "2018-07-01T05:20:00Z", "last_used_on": "2020-01-02T12:34:00Z", "modified_on": "2018-07-02T05:20:00Z", "name": "readonly token", "not_before": "2018-07-01T05:20:00Z", "policies": [ { "id": "f267e341f3dd4697bd3b9f71dd96247f", "effect": "allow", "permission_groups": [ { "id": "c8fed203ed3043cba015a93ad1616f1f", "meta": { "key": "key", "value": "value" }, "name": "Zone Read" }, { "id": "82e64a83756745bbbb1c9c2701bf816b", "meta": { "key": "key", "value": "value" }, "name": "Magic Network Monitoring" } ], "resources": { "foo": "string" } } ], "status": "active" } } ``` ## Delete Token `client.Accounts.Tokens.Delete(ctx, tokenID, body) (*TokenDeleteResponse, error)` **delete** `/accounts/{account_id}/tokens/{token_id}` Destroy an Account Owned API token. ### Parameters - `tokenID string` Token identifier tag. - `body TokenDeleteParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type TokenDeleteResponse struct{…}` - `ID string` Identifier ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) token, err := client.Accounts.Tokens.Delete( context.TODO(), "ed17574386854bf78a67040be0a770b0", accounts.TokenDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", token.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` ## Verify Token `client.Accounts.Tokens.Verify(ctx, query) (*TokenVerifyResponse, error)` **get** `/accounts/{account_id}/tokens/verify` Test whether a token works. ### Parameters - `query TokenVerifyParams` - `AccountID param.Field[string]` Account identifier tag. ### Returns - `type TokenVerifyResponse struct{…}` - `ID string` Token identifier tag. - `Status TokenVerifyResponseStatus` Status of the token. - `const TokenVerifyResponseStatusActive TokenVerifyResponseStatus = "active"` - `const TokenVerifyResponseStatusDisabled TokenVerifyResponseStatus = "disabled"` - `const TokenVerifyResponseStatusExpired TokenVerifyResponseStatus = "expired"` - `ExpiresOn Time` The expiration time on or after which the JWT MUST NOT be accepted for processing. - `NotBefore Time` The time before which the token MUST NOT be accepted for processing. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Accounts.Tokens.Verify(context.TODO(), accounts.TokenVerifyParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "ed17574386854bf78a67040be0a770b0", "status": "active", "expires_on": "2020-01-01T00:00:00Z", "not_before": "2018-07-01T05:20:00Z" } } ``` # Permission Groups ## List Permission Groups `client.Accounts.Tokens.PermissionGroups.List(ctx, params) (*SinglePage[TokenPermissionGroupListResponse], error)` **get** `/accounts/{account_id}/tokens/permission_groups` Find all available permission groups for Account Owned API Tokens ### Parameters - `params TokenPermissionGroupListParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Name param.Field[string]` Query param: Filter by the name of the permission group. The value must be URL-encoded. - `Scope param.Field[string]` Query param: Filter by the scope of the permission group. The value must be URL-encoded. ### Returns - `type TokenPermissionGroupListResponse struct{…}` - `ID string` Public ID. - `Name string` Permission Group Name - `Scopes []TokenPermissionGroupListResponseScope` Resources to which the Permission Group is scoped - `const TokenPermissionGroupListResponseScopeComCloudflareAPIAccount TokenPermissionGroupListResponseScope = "com.cloudflare.api.account"` - `const TokenPermissionGroupListResponseScopeComCloudflareAPIAccountZone TokenPermissionGroupListResponseScope = "com.cloudflare.api.account.zone"` - `const TokenPermissionGroupListResponseScopeComCloudflareAPIUser TokenPermissionGroupListResponseScope = "com.cloudflare.api.user"` - `const TokenPermissionGroupListResponseScopeComCloudflareEdgeR2Bucket TokenPermissionGroupListResponseScope = "com.cloudflare.edge.r2.bucket"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Accounts.Tokens.PermissionGroups.List(context.TODO(), accounts.TokenPermissionGroupListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "7cf72faf220841aabcfdfab81c43c4f6", "name": "Billing Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "9d24387c6e8544e2bc4024a03991339f", "name": "Load Balancing: Monitors and Pools Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "d2a1802cc9a34e30852f8b33869b2f3c", "name": "Load Balancing: Monitors and Pools Write", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "8b47d2786a534c08a1f94ee8f9f599ef", "name": "Workers KV Storage Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "f7f0eda5697f475c90846e879bab8666", "name": "Workers KV Storage Write", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "1a71c399035b4950a1bd1466bbe4f420", "name": "Workers Scripts Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "e086da7e2179491d91ee5f35b3ca210a", "name": "Workers Scripts Write", "scopes": [ "com.cloudflare.api.account" ] } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## List Permission Groups `client.Accounts.Tokens.PermissionGroups.Get(ctx, params) (*[]TokenPermissionGroupGetResponse, error)` **get** `/accounts/{account_id}/tokens/permission_groups` Find all available permission groups for Account Owned API Tokens ### Parameters - `params TokenPermissionGroupGetParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Name param.Field[string]` Query param: Filter by the name of the permission group. The value must be URL-encoded. - `Scope param.Field[string]` Query param: Filter by the scope of the permission group. The value must be URL-encoded. ### Returns - `type TokenPermissionGroupGetResponseEnvelopeResult []TokenPermissionGroupGetResponse` - `ID string` Public ID. - `Name string` Permission Group Name - `Scopes []TokenPermissionGroupGetResponseScope` Resources to which the Permission Group is scoped - `const TokenPermissionGroupGetResponseScopeComCloudflareAPIAccount TokenPermissionGroupGetResponseScope = "com.cloudflare.api.account"` - `const TokenPermissionGroupGetResponseScopeComCloudflareAPIAccountZone TokenPermissionGroupGetResponseScope = "com.cloudflare.api.account.zone"` - `const TokenPermissionGroupGetResponseScopeComCloudflareAPIUser TokenPermissionGroupGetResponseScope = "com.cloudflare.api.user"` - `const TokenPermissionGroupGetResponseScopeComCloudflareEdgeR2Bucket TokenPermissionGroupGetResponseScope = "com.cloudflare.edge.r2.bucket"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) permissionGroups, err := client.Accounts.Tokens.PermissionGroups.Get(context.TODO(), accounts.TokenPermissionGroupGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", permissionGroups) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "7cf72faf220841aabcfdfab81c43c4f6", "name": "Billing Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "9d24387c6e8544e2bc4024a03991339f", "name": "Load Balancing: Monitors and Pools Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "d2a1802cc9a34e30852f8b33869b2f3c", "name": "Load Balancing: Monitors and Pools Write", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "8b47d2786a534c08a1f94ee8f9f599ef", "name": "Workers KV Storage Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "f7f0eda5697f475c90846e879bab8666", "name": "Workers KV Storage Write", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "1a71c399035b4950a1bd1466bbe4f420", "name": "Workers Scripts Read", "scopes": [ "com.cloudflare.api.account" ] }, { "id": "e086da7e2179491d91ee5f35b3ca210a", "name": "Workers Scripts Write", "scopes": [ "com.cloudflare.api.account" ] } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` # Value ## Roll Token `client.Accounts.Tokens.Value.Update(ctx, tokenID, params) (*TokenValue, error)` **put** `/accounts/{account_id}/tokens/{token_id}/value` Roll the Account Owned API token secret. ### Parameters - `tokenID string` Token identifier tag. - `params TokenValueUpdateParams` - `AccountID param.Field[string]` Path param: Account identifier tag. - `Body param.Field[unknown]` Body param ### Returns - `type TokenValue string` The token value. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) tokenValue, err := client.Accounts.Tokens.Value.Update( context.TODO(), "ed17574386854bf78a67040be0a770b0", accounts.TokenValueUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: map[string]interface{}{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", tokenValue) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "8M7wS6hCpXVc-DoRnPPY_UCWPgy8aea4Wy6kCe5T" } ``` # Logs # Audit ## Get account audit logs (Version 2) `client.Accounts.Logs.Audit.List(ctx, params) (*CursorPaginationAfter[LogAuditListResponse], error)` **get** `/accounts/{account_id}/logs/audit` Gets a list of audit logs for an account. ### Parameters - `params LogAuditListParams` - `AccountID param.Field[string]` Path param: The unique id that identifies the account. - `Before param.Field[Time]` Query param: 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]` Query param: 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]` Query param - `Not []string` Filters out audit logs by their IDs. - `AccountName param.Field[LogAuditListParamsAccountName]` Query param - `Not []string` Filters out audit logs by the account name. - `ActionResult param.Field[LogAuditListParamsActionResult]` Query param - `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]` Query param - `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]` Query param - `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]` Query param - `Not []string` Filters out audit logs by the actor's email address. - `ActorID param.Field[LogAuditListParamsActorID]` Query param - `Not []string` Filters out audit logs by the actor ID. This can be either the Account ID or User ID. - `ActorIPAddress param.Field[LogAuditListParamsActorIPAddress]` Query param - `Not []string` Filters out audit logs IP address where the action was initiated. - `ActorTokenID param.Field[LogAuditListParamsActorTokenID]` Query param - `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]` Query param - `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]` Query param - `Not []LogAuditListParamsActorTypeNot` Filters out audit logs by the actor type. - `const LogAuditListParamsActorTypeNotAccount LogAuditListParamsActorTypeNot = "account"` - `const LogAuditListParamsActorTypeNotCloudflareAdmin LogAuditListParamsActorTypeNot = "cloudflare_admin"` - `const LogAuditListParamsActorTypeNotSystem LogAuditListParamsActorTypeNot = "system"` - `const LogAuditListParamsActorTypeNotUser LogAuditListParamsActorTypeNot = "user"` - `AuditLogID param.Field[LogAuditListParamsAuditLogID]` Query param - `Not []string` Filters out audit logs by their IDs. - `Cursor param.Field[string]` Query param: 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]` Query param: Sets sorting order. - `const LogAuditListParamsDirectionDesc LogAuditListParamsDirection = "desc"` - `const LogAuditListParamsDirectionAsc LogAuditListParamsDirection = "asc"` - `Limit param.Field[float64]` Query param: 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]` Query param - `Not []string` Filters out audit logs by the response CF Ray ID. - `RawMethod param.Field[LogAuditListParamsRawMethod]` Query param - `Not []string` Filters out audit logs by the HTTP method for the API call. - `RawStatusCode param.Field[LogAuditListParamsRawStatusCode]` Query param - `Not []int64` Filters out audit logs by the response status code that was returned. - `RawURI param.Field[LogAuditListParamsRawURI]` Query param - `Not []string` Filters out audit logs by the request URI. - `ResourceID param.Field[LogAuditListParamsResourceID]` Query param - `Not []string` Filters out audit logs by the resource ID. - `ResourceProduct param.Field[LogAuditListParamsResourceProduct]` Query param - `Not []string` Filters out audit logs by the Cloudflare product associated with the changed resource. - `ResourceScope param.Field[LogAuditListParamsResourceScope]` Query param - `Not []LogAuditListParamsResourceScopeNot` Filters out audit logs by the resource scope, specifying whether the resource is associated with an user, an account, a zone, or a membership. - `const LogAuditListParamsResourceScopeNotAccounts LogAuditListParamsResourceScopeNot = "accounts"` - `const LogAuditListParamsResourceScopeNotUser LogAuditListParamsResourceScopeNot = "user"` - `const LogAuditListParamsResourceScopeNotZones LogAuditListParamsResourceScopeNot = "zones"` - `const LogAuditListParamsResourceScopeNotMemberships LogAuditListParamsResourceScopeNot = "memberships"` - `ResourceType param.Field[LogAuditListParamsResourceType]` Query param - `Not []string` Filters out audit logs based on the unique type of resource changed by the action. - `ZoneID param.Field[LogAuditListParamsZoneID]` Query param - `Not []string` Filters out audit logs by the zone ID. - `ZoneName param.Field[LogAuditListParamsZoneName]` Query param - `Not []string` Filters out audit logs by the zone name associated with the change. ### Returns - `type LogAuditListResponse struct{…}` - `ID string` A unique identifier for the audit log entry. - `Account LogAuditListResponseAccount` Contains account related information. - `ID string` A unique identifier for the account. - `Name string` A string that identifies the account name. - `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 LogAuditListResponseActorTypeAccount LogAuditListResponseActorType = "account"` - `const LogAuditListResponseActorTypeCloudflareAdmin LogAuditListResponseActorType = "cloudflare_admin"` - `const LogAuditListResponseActorTypeSystem LogAuditListResponseActorType = "system"` - `const LogAuditListResponseActorTypeUser LogAuditListResponseActorType = "user"` - `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. - `Zone LogAuditListResponseZone` Provides details about the zone affected by the action. - `ID string` A string that identifies the zone id. - `Name string` A string that identifies the zone name. ### Example ```go package main import ( "context" "fmt" "time" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Accounts.Logs.Audit.List(context.TODO(), accounts.LogAuditListParams{ AccountID: cloudflare.F("a67e14daa5f8dceeb91fe5449ba496ef"), 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", "account": { "id": "4bb334f7c94c4a29a045f03944f072e5", "name": "Example Account" }, "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" }, "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": "members", "request": {}, "response": {}, "scope": {}, "type": "type" }, "zone": { "id": "id", "name": "example.com" } } ], "result_info": { "count": "1", "cursor": "ASqdKd7dKgxh-aZ8bm0mZos1BtW4BdEqifCzNkEeGRzi_5SN_-362Y8sF-C1TRn60_6rd3z2dIajf9EAPyQ_NmIeAMkacmaJPXipqvP7PLU4t72wyqBeJfjmjdE=" }, "success": true } ```