Export Policy
  • 12 Dec 2023
  • 1 Minute to read
  • Dark
    Light
  • PDF

Export Policy

  • Dark
    Light
  • PDF

Article Summary

Get
/api/1.0/policies/{envId}/{policyId}

This API exports a policy from the Authorization Platform.

Notice

Accessing the Policy Management APIs is through a dedicated domain/URL according to your PlainID Tenant Location:

Notice

Accessing the Policy Management APIs is through a dedicated domain/URL according to your PlainID Tenant Location:
https://api.{REGION}.plainid.io

United States (US) - https://api.us1.plainid.io
Canada (US) - https://api.ca1.plainid.io
Europe (US) - https://api.eu1.plainid.io

Replace{REGION} with your PlainID Tenant region (e.g. us1, eu1, ca1, etc.).


Security
Http
Type bearer
For more details about Management API Authentication, check out the Management APIs Authentication Article
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: `Authorization: Bearer 123`
Path parameters
envId
stringRequired

The Environment ID can be found under the Details tab in the Environment Settings.

policyId
stringRequired

The Policy ID can be found on the Policy Details tab

Query parameters
language
stringRequired

The code language rego

Examplerego
Responses
200

Bad Request

Headers
x-request-id
string
Exported Policy
{
  "data": {
    "language": "rego",
    "policyCode": "# METADATA\n# custom:\n#   plainid:\n#     policyId: PaC1\n#     name: Manage consumers accounts in branch\n#     description: Tellers, Senior Tellers, Branch Managers can manage private consumer accounts in their own branch only during business hours\n#     accessType: Allow\npackage policy\nimport future.keywords\n\n# METADATA\n# custom:\n#   plainid:\n#     kind: DynamicGroup\n#     name: Teller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n#   plainid:\n#     kind: DynamicGroup\n#     name: SeniorTeller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"title\"] == \"Senior Teller\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n#   plainid:\n#     kind: DynamicGroup\n#     name: BranchManager\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"internal\"\n\tidentity[\"title\"] == \"branch manager\"\n}\n\n# METADATA\n# custom:\n#   plainid:\n#     kind: Ruleset\n#     name: Private consumer bank accounts managed in the user branch\nruleset(asset, identity){\n\tasset.template == \"Bank Accounts\"\n\tidentity.template == \"User\"\n\tasset[\"account_type\"] == \"private\"\n\tasset[\"account_branch\"] == identity[\"User_Branch\"]\n}\n\n# METADATA\n# custom:\n#   plainid:\n#     kind: Action\naction(asset){\n\tasset.template == \"Bank Accounts\"\n\tasset.action in [\"Manage\",\"View\"]\n}"
  }
}
Expand All
object
data
object
language
string
policyCode
string
401

Unauthorized

Headers
x-request-id
string
404

Not Found

Headers
x-request-id
string
Export Failed - Policy ID Does Not Exist
{
  "errors": [
    {
      "code": "PUA-033",
      "args": {
        "0": "Pa1",
        "1": "ed252aa5-9d0c-4193-8388-60bf20b13109"
      },
      "id": "EKULDR",
      "status": 404,
      "name": "PolicyNotFoundError",
      "message": "Policy Id doesn't exist in the environment"
    }
  ]
}
object
422

Validation Failed - Invalid UUID

Headers
x-request-id
string
Invalid ID Format
{
  "errors": [
    {
      "code": "V-032",
      "args": {
        "0": "ed252aa5-9d0c-4193-838-60bf20b13109",
        "1": "uuid"
      },
      "id": "EEJQMA",
      "status": 422,
      "name": "UnprocessableEntityError",
      "message": "$: ed252aa5-9d0c-4193-838-60bf20b13109 is an invalid uuid"
    }
  ]
}
Expand All
object
errors
Array of object
object
code
string
args
object
0
string
1
string
id
string
status
integer
name
string
message
string

Was this article helpful?