Skip to main content

apps_policies

Creates, updates, deletes, gets or lists an apps_policies resource.

Overview

Nameapps_policies
TypeResource
Idcloudflare.zero_trust.apps_policies

Fields

The following fields are returned by SELECT queries:

Get an Access policy response.

NameDatatypeDescription
idstringThe UUID of the policy (example: f174e90a-fafe-4643-bbbc-4a0ed4fc8415)
namestringThe name of the Access policy. (example: Allow devs)
approval_groupsarrayAdministrators who can approve a temporary authentication request. (x-stainless-collection-type: set)
approval_requiredbooleanRequires the user to request access from an administrator at the start of each session.
connection_rulesobjectThe rules that define how users may connect to targets secured by your application. (title: Connection Rules)
created_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)
decisionstringThe action Access will take if a user matches this policy. Infrastructure application policies can only use the Allow action. (allow, deny, non_identity, bypass) (example: allow)
excludearrayRules evaluated with a NOT logical operator. To match the policy, a user cannot meet any of the Exclude rules. (x-stainless-collection-type: set)
includearrayRules evaluated with an OR logical operator. A user needs to meet only one of the Include rules. (x-stainless-collection-type: set)
isolation_requiredbooleanRequire 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.
mfa_configobjectConfigures multi-factor authentication (MFA) settings.
precedenceintegerThe order of execution for this policy. Must be unique for each policy within an app.
purpose_justification_promptstringA custom message that will appear on the purpose justification screen. (example: Please enter a justification for entering this protected domain.)
purpose_justification_requiredbooleanRequire users to enter a justification when they log in to the application.
requirearrayRules evaluated with an AND logical operator. To match the policy, a user must meet all of the Require rules. (x-stainless-collection-type: set)
session_durationstringThe amount of time that tokens issued for the application will be valid. Must be in the format 300ms or 2h45m. Valid time units are: ns, us (or µs), ms, s, m, h. (default: 24h, example: 24h)
updated_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_by_accountselectapp_id, policy_id, account_idFetches a single Access policy configured for an application. Returns both exclusively owned and reusable policies used by the application.
get_by_zoneselectapp_id, policy_id, zone_idFetches a single Access policy configured for an application. Returns both exclusively owned and reusable policies used by the application.
list_by_accountselectapp_id, account_idpage, per_pageLists Access policies configured for an application. Returns both exclusively scoped and reusable policies used by the application.
list_by_zoneselectapp_id, zone_idpage, per_pageLists Access policies configured for an application. Returns both exclusively scoped and reusable policies used by the application.
create_by_accountinsertapp_id, account_idCreates a policy applying exclusive to a single application that defines the users or groups who can reach it. We recommend creating a reusable policy instead and subsequently referencing its ID in the application's 'policies' array.
create_by_zoneinsertapp_id, zone_idCreates a policy applying exclusive to a single application that defines the users or groups who can reach it. We recommend creating a reusable policy instead and subsequently referencing its ID in the application's 'policies' array.
update_by_accountreplaceapp_id, policy_id, account_idUpdates an Access policy specific to an application. To update a reusable policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint.
update_by_zonereplaceapp_id, policy_id, zone_idUpdates an Access policy specific to an application. To update a reusable policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint.
delete_by_accountdeleteapp_id, policy_id, account_idDeletes an Access policy specific to an application. To delete a reusable policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint.
delete_by_zonedeleteapp_id, policy_id, zone_idDeletes an Access policy specific to an application. To delete a reusable policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
app_idstringThe Access application ID.
policy_idstringThe Access policy ID.
zone_idstringThe Cloudflare zone ID.
pageinteger
per_pageinteger

SELECT examples

Fetches a single Access policy configured for an application. Returns both exclusively owned and reusable policies used by the application.

SELECT
id,
name,
approval_groups,
approval_required,
connection_rules,
created_at,
decision,
exclude,
include,
isolation_required,
mfa_config,
precedence,
purpose_justification_prompt,
purpose_justification_required,
require,
session_duration,
updated_at
FROM cloudflare.zero_trust.apps_policies
WHERE app_id = '{{ app_id }}' -- required
AND policy_id = '{{ policy_id }}' -- required
AND account_id = '{{ account_id }}' -- required
;

INSERT examples

Creates a policy applying exclusive to a single application that defines the users or groups who can reach it. We recommend creating a reusable policy instead and subsequently referencing its ID in the application's 'policies' array.

INSERT INTO cloudflare.zero_trust.apps_policies (
precedence,
approval_groups,
approval_required,
connection_rules,
isolation_required,
mfa_config,
purpose_justification_prompt,
purpose_justification_required,
session_duration,
app_id,
account_id
)
SELECT
{{ precedence }},
'{{ approval_groups }}',
{{ approval_required }},
'{{ connection_rules }}',
{{ isolation_required }},
'{{ mfa_config }}',
'{{ purpose_justification_prompt }}',
{{ purpose_justification_required }},
'{{ session_duration }}',
'{{ app_id }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

REPLACE examples

Updates an Access policy specific to an application. To update a reusable policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint.

REPLACE cloudflare.zero_trust.apps_policies
SET
precedence = {{ precedence }},
approval_groups = '{{ approval_groups }}',
approval_required = {{ approval_required }},
connection_rules = '{{ connection_rules }}',
isolation_required = {{ isolation_required }},
mfa_config = '{{ mfa_config }}',
purpose_justification_prompt = '{{ purpose_justification_prompt }}',
purpose_justification_required = {{ purpose_justification_required }},
session_duration = '{{ session_duration }}'
WHERE
app_id = '{{ app_id }}' --required
AND policy_id = '{{ policy_id }}' --required
AND account_id = '{{ account_id }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Deletes an Access policy specific to an application. To delete a reusable policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint.

DELETE FROM cloudflare.zero_trust.apps_policies
WHERE app_id = '{{ app_id }}' --required
AND policy_id = '{{ policy_id }}' --required
AND account_id = '{{ account_id }}' --required
;