Create an Access reusable policy
Creates a new Access reusable policy.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYYAPI Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
X-Auth-Email: user@example.comThe previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194Accepted Permissions (at least one required)
Access: Apps and Policies WriteParametersExpand Collapse
params AccessPolicyNewParams
Body param: The action Access will take if a user matches this policy. Infrastructure application policies can only use the Allow action.
Include param.Field[[]AccessRule]Body param: Rules evaluated with an OR logical operator. A user needs to meet only one of the Include rules.
Body param: Rules evaluated with an OR logical operator. A user needs to meet only one of the Include rules.
type AccessRuleAccessAuthContextRule struct{…}Matches an Azure Authentication Context.
Requires an Azure identity provider.
Matches an Azure Authentication Context. Requires an Azure identity provider.
type AuthenticationMethodRule struct{…}Enforce different MFA options
Enforce different MFA options
AuthMethod AuthenticationMethodRuleAuthMethod
The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176#section-2.
type ExternalEvaluationRule struct{…}Create Allow or Block policies which evaluate the user based on custom criteria.
Create Allow or Block policies which evaluate the user based on custom criteria.
type GitHubOrganizationRule struct{…}Matches a Github organization.
Requires a Github identity provider.
Matches a Github organization. Requires a Github identity provider.
type GSuiteGroupRule struct{…}Matches a group in Google Workspace.
Requires a Google Workspace identity provider.
Matches a group in Google Workspace. Requires a Google Workspace identity provider.
type AccessRuleAccessOIDCClaimRule struct{…}Matches an OIDC claim.
Requires an OIDC identity provider.
Matches an OIDC claim. Requires an OIDC identity provider.
type AccessRuleAccessLinkedAppTokenRule struct{…}Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
type AccessRuleAccessUserRiskScoreRule struct{…}Matches a user’s risk score.
Matches a user’s risk score.
UserRiskScore AccessRuleAccessUserRiskScoreRuleUserRiskScore
UserRiskScore []AccessRuleAccessUserRiskScoreRuleUserRiskScoreUserRiskScoreA list of risk score levels to match. Values can be low, medium, high, or unscored.
A list of risk score levels to match. Values can be low, medium, high, or unscored.
Body param: Requires the user to request access from an administrator at the start of each session.
Body param: The rules that define how users may connect to targets secured by your application.
Body param: The rules that define how users may connect to targets secured by your application.
RDP AccessPolicyNewParamsConnectionRulesRDPoptionalThe RDP-specific rules that define clipboard behavior for RDP connections.
The RDP-specific rules that define clipboard behavior for RDP connections.
Body param: Rules evaluated with a NOT logical operator. To match the policy, a user cannot meet any of the Exclude rules.
Body param: Rules evaluated with a NOT logical operator. To match the policy, a user cannot meet any of the Exclude rules.
type AccessRuleAccessAuthContextRule struct{…}Matches an Azure Authentication Context.
Requires an Azure identity provider.
Matches an Azure Authentication Context. Requires an Azure identity provider.
type AuthenticationMethodRule struct{…}Enforce different MFA options
Enforce different MFA options
AuthMethod AuthenticationMethodRuleAuthMethod
The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176#section-2.
type ExternalEvaluationRule struct{…}Create Allow or Block policies which evaluate the user based on custom criteria.
Create Allow or Block policies which evaluate the user based on custom criteria.
type GitHubOrganizationRule struct{…}Matches a Github organization.
Requires a Github identity provider.
Matches a Github organization. Requires a Github identity provider.
type GSuiteGroupRule struct{…}Matches a group in Google Workspace.
Requires a Google Workspace identity provider.
Matches a group in Google Workspace. Requires a Google Workspace identity provider.
type AccessRuleAccessOIDCClaimRule struct{…}Matches an OIDC claim.
Requires an OIDC identity provider.
Matches an OIDC claim. Requires an OIDC identity provider.
type AccessRuleAccessLinkedAppTokenRule struct{…}Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
type AccessRuleAccessUserRiskScoreRule struct{…}Matches a user’s risk score.
Matches a user’s risk score.
UserRiskScore AccessRuleAccessUserRiskScoreRuleUserRiskScore
UserRiskScore []AccessRuleAccessUserRiskScoreRuleUserRiskScoreUserRiskScoreA list of risk score levels to match. Values can be low, medium, high, or unscored.
A list of risk score levels to match. Values can be low, medium, high, or unscored.
Body param: Require this application to be served in an isolated browser for users matching this policy. ‘Client Web Isolation’ must be on for the account in order to use this feature.
Body param: Configures multi-factor authentication (MFA) settings.
Body param: Configures multi-factor authentication (MFA) settings.
AllowedAuthenticators []AccessPolicyNewParamsMfaConfigAllowedAuthenticatoroptionalLists the MFA methods that users can authenticate with.
Lists the MFA methods that users can authenticate with.
Body param: A custom message that will appear on the purpose justification screen.
Body param: Require users to enter a justification when they log in to the application.
Body param: Rules evaluated with an AND logical operator. To match the policy, a user must meet all of the Require rules.
Body param: Rules evaluated with an AND logical operator. To match the policy, a user must meet all of the Require rules.
type AccessRuleAccessAuthContextRule struct{…}Matches an Azure Authentication Context.
Requires an Azure identity provider.
Matches an Azure Authentication Context. Requires an Azure identity provider.
type AuthenticationMethodRule struct{…}Enforce different MFA options
Enforce different MFA options
AuthMethod AuthenticationMethodRuleAuthMethod
The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176#section-2.
type ExternalEvaluationRule struct{…}Create Allow or Block policies which evaluate the user based on custom criteria.
Create Allow or Block policies which evaluate the user based on custom criteria.
type GitHubOrganizationRule struct{…}Matches a Github organization.
Requires a Github identity provider.
Matches a Github organization. Requires a Github identity provider.
type GSuiteGroupRule struct{…}Matches a group in Google Workspace.
Requires a Google Workspace identity provider.
Matches a group in Google Workspace. Requires a Google Workspace identity provider.
type AccessRuleAccessOIDCClaimRule struct{…}Matches an OIDC claim.
Requires an OIDC identity provider.
Matches an OIDC claim. Requires an OIDC identity provider.
type AccessRuleAccessLinkedAppTokenRule struct{…}Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
type AccessRuleAccessUserRiskScoreRule struct{…}Matches a user’s risk score.
Matches a user’s risk score.
UserRiskScore AccessRuleAccessUserRiskScoreRuleUserRiskScore
UserRiskScore []AccessRuleAccessUserRiskScoreRuleUserRiskScoreUserRiskScoreA list of risk score levels to match. Values can be low, medium, high, or unscored.
A list of risk score levels to match. Values can be low, medium, high, or unscored.
ReturnsExpand Collapse
type AccessPolicyNewResponse struct{…}
Requires the user to request access from an administrator at the start of each session.
ConnectionRules AccessPolicyNewResponseConnectionRulesoptionalThe rules that define how users may connect to targets secured by your application.
The rules that define how users may connect to targets secured by your application.
RDP AccessPolicyNewResponseConnectionRulesRDPoptionalThe RDP-specific rules that define clipboard behavior for RDP connections.
The RDP-specific rules that define clipboard behavior for RDP connections.
The action Access will take if a user matches this policy. Infrastructure application policies can only use the Allow action.
The action Access will take if a user matches this policy. Infrastructure application policies can only use the Allow action.
Rules evaluated with a NOT logical operator. To match the policy, a user cannot meet any of the Exclude rules.
Rules evaluated with a NOT logical operator. To match the policy, a user cannot meet any of the Exclude rules.
type AccessRuleAccessAuthContextRule struct{…}Matches an Azure Authentication Context.
Requires an Azure identity provider.
Matches an Azure Authentication Context. Requires an Azure identity provider.
type AuthenticationMethodRule struct{…}Enforce different MFA options
Enforce different MFA options
AuthMethod AuthenticationMethodRuleAuthMethod
The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176#section-2.
type ExternalEvaluationRule struct{…}Create Allow or Block policies which evaluate the user based on custom criteria.
Create Allow or Block policies which evaluate the user based on custom criteria.
type GitHubOrganizationRule struct{…}Matches a Github organization.
Requires a Github identity provider.
Matches a Github organization. Requires a Github identity provider.
type GSuiteGroupRule struct{…}Matches a group in Google Workspace.
Requires a Google Workspace identity provider.
Matches a group in Google Workspace. Requires a Google Workspace identity provider.
type AccessRuleAccessOIDCClaimRule struct{…}Matches an OIDC claim.
Requires an OIDC identity provider.
Matches an OIDC claim. Requires an OIDC identity provider.
type AccessRuleAccessLinkedAppTokenRule struct{…}Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
type AccessRuleAccessUserRiskScoreRule struct{…}Matches a user’s risk score.
Matches a user’s risk score.
UserRiskScore AccessRuleAccessUserRiskScoreRuleUserRiskScore
UserRiskScore []AccessRuleAccessUserRiskScoreRuleUserRiskScoreUserRiskScoreA list of risk score levels to match. Values can be low, medium, high, or unscored.
A list of risk score levels to match. Values can be low, medium, high, or unscored.
Rules evaluated with an OR logical operator. A user needs to meet only one of the Include rules.
Rules evaluated with an OR logical operator. A user needs to meet only one of the Include rules.
type AccessRuleAccessAuthContextRule struct{…}Matches an Azure Authentication Context.
Requires an Azure identity provider.
Matches an Azure Authentication Context. Requires an Azure identity provider.
type AuthenticationMethodRule struct{…}Enforce different MFA options
Enforce different MFA options
AuthMethod AuthenticationMethodRuleAuthMethod
The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176#section-2.
type ExternalEvaluationRule struct{…}Create Allow or Block policies which evaluate the user based on custom criteria.
Create Allow or Block policies which evaluate the user based on custom criteria.
type GitHubOrganizationRule struct{…}Matches a Github organization.
Requires a Github identity provider.
Matches a Github organization. Requires a Github identity provider.
type GSuiteGroupRule struct{…}Matches a group in Google Workspace.
Requires a Google Workspace identity provider.
Matches a group in Google Workspace. Requires a Google Workspace identity provider.
type AccessRuleAccessOIDCClaimRule struct{…}Matches an OIDC claim.
Requires an OIDC identity provider.
Matches an OIDC claim. Requires an OIDC identity provider.
type AccessRuleAccessLinkedAppTokenRule struct{…}Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
type AccessRuleAccessUserRiskScoreRule struct{…}Matches a user’s risk score.
Matches a user’s risk score.
UserRiskScore AccessRuleAccessUserRiskScoreRuleUserRiskScore
UserRiskScore []AccessRuleAccessUserRiskScoreRuleUserRiskScoreUserRiskScoreA list of risk score levels to match. Values can be low, medium, high, or unscored.
A list of risk score levels to match. Values can be low, medium, high, or unscored.
Require this application to be served in an isolated browser for users matching this policy. ‘Client Web Isolation’ must be on for the account in order to use this feature.
MfaConfig AccessPolicyNewResponseMfaConfigoptionalConfigures multi-factor authentication (MFA) settings.
Configures multi-factor authentication (MFA) settings.
AllowedAuthenticators []AccessPolicyNewResponseMfaConfigAllowedAuthenticatoroptionalLists the MFA methods that users can authenticate with.
Lists the MFA methods that users can authenticate with.
A custom message that will appear on the purpose justification screen.
Require users to enter a justification when they log in to the application.
Rules evaluated with an AND logical operator. To match the policy, a user must meet all of the Require rules.
Rules evaluated with an AND logical operator. To match the policy, a user must meet all of the Require rules.
type AccessRuleAccessAuthContextRule struct{…}Matches an Azure Authentication Context.
Requires an Azure identity provider.
Matches an Azure Authentication Context. Requires an Azure identity provider.
type AuthenticationMethodRule struct{…}Enforce different MFA options
Enforce different MFA options
AuthMethod AuthenticationMethodRuleAuthMethod
The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176#section-2.
type ExternalEvaluationRule struct{…}Create Allow or Block policies which evaluate the user based on custom criteria.
Create Allow or Block policies which evaluate the user based on custom criteria.
type GitHubOrganizationRule struct{…}Matches a Github organization.
Requires a Github identity provider.
Matches a Github organization. Requires a Github identity provider.
type GSuiteGroupRule struct{…}Matches a group in Google Workspace.
Requires a Google Workspace identity provider.
Matches a group in Google Workspace. Requires a Google Workspace identity provider.
type AccessRuleAccessOIDCClaimRule struct{…}Matches an OIDC claim.
Requires an OIDC identity provider.
Matches an OIDC claim. Requires an OIDC identity provider.
type AccessRuleAccessLinkedAppTokenRule struct{…}Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
Matches OAuth 2.0 access tokens issued by the specified Access OIDC SaaS application. Only compatible with non_identity and bypass decisions.
type AccessRuleAccessUserRiskScoreRule struct{…}Matches a user’s risk score.
Matches a user’s risk score.
UserRiskScore AccessRuleAccessUserRiskScoreRuleUserRiskScore
UserRiskScore []AccessRuleAccessUserRiskScoreRuleUserRiskScoreUserRiskScoreA list of risk score levels to match. Values can be low, medium, high, or unscored.
A list of risk score levels to match. Values can be low, medium, high, or unscored.
Create an Access reusable policy
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/zero_trust"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
policy, err := client.ZeroTrust.Access.Policies.New(context.TODO(), zero_trust.AccessPolicyNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Decision: cloudflare.F(zero_trust.DecisionAllow),
Include: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.GroupRuleParam{
Group: cloudflare.F(zero_trust.GroupRuleGroupParam{
ID: cloudflare.F("aa0a4aab-672b-4bdb-bc33-a59f1130a11f"),
}),
}}),
Name: cloudflare.F("Allow devs"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", policy.ID)
}
{
"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": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
"app_count": 2,
"approval_groups": [
{
"approvals_needed": 1,
"email_addresses": [
"test1@cloudflare.com",
"test2@cloudflare.com"
],
"email_list_uuid": "email_list_uuid"
},
{
"approvals_needed": 3,
"email_addresses": [
"test@cloudflare.com",
"test2@cloudflare.com"
],
"email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34"
}
],
"approval_required": true,
"connection_rules": {
"rdp": {
"allowed_clipboard_local_to_remote_formats": [
"text"
],
"allowed_clipboard_remote_to_local_formats": [
"text"
]
}
},
"created_at": "2014-01-01T05:20:00.12345Z",
"decision": "allow",
"exclude": [
{
"group": {
"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"
}
}
],
"include": [
{
"group": {
"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"
}
}
],
"isolation_required": false,
"mfa_config": {
"allowed_authenticators": [
"totp",
"biometrics",
"security_key"
],
"mfa_disabled": false,
"session_duration": "24h"
},
"name": "Allow devs",
"purpose_justification_prompt": "Please enter a justification for entering this protected domain.",
"purpose_justification_required": true,
"require": [
{
"group": {
"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"
}
}
],
"reusable": true,
"session_duration": "24h",
"updated_at": "2014-01-01T05:20:00.12345Z"
}
}Returns Examples
{
"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": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
"app_count": 2,
"approval_groups": [
{
"approvals_needed": 1,
"email_addresses": [
"test1@cloudflare.com",
"test2@cloudflare.com"
],
"email_list_uuid": "email_list_uuid"
},
{
"approvals_needed": 3,
"email_addresses": [
"test@cloudflare.com",
"test2@cloudflare.com"
],
"email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34"
}
],
"approval_required": true,
"connection_rules": {
"rdp": {
"allowed_clipboard_local_to_remote_formats": [
"text"
],
"allowed_clipboard_remote_to_local_formats": [
"text"
]
}
},
"created_at": "2014-01-01T05:20:00.12345Z",
"decision": "allow",
"exclude": [
{
"group": {
"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"
}
}
],
"include": [
{
"group": {
"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"
}
}
],
"isolation_required": false,
"mfa_config": {
"allowed_authenticators": [
"totp",
"biometrics",
"security_key"
],
"mfa_disabled": false,
"session_duration": "24h"
},
"name": "Allow devs",
"purpose_justification_prompt": "Please enter a justification for entering this protected domain.",
"purpose_justification_required": true,
"require": [
{
"group": {
"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"
}
}
],
"reusable": true,
"session_duration": "24h",
"updated_at": "2014-01-01T05:20:00.12345Z"
}
}