Create policy
POST/metalakes/:metalake/policies
Create policy
Request
Path Parameters
The name of the metalake
- application/json
Body
- CustomPolicyCreateRequest
oneOf
A request to create a policy with a custom content structure.
The name of the policy
A comment for the policy
The type of the policy
Default value: true
Whether the policy is enabled
content
object
required
Content for a custom policy type.
Possible values: [CATALOG
, SCHEMA
, TABLE
, FILESET
, TOPIC
, MODEL
], >= 1
The types of metadata objects this policy content can be applied to.
properties
object
A map of string-to-string properties for the policy content.
A map of custom rules where the key is the rule name and the value can be of any type.
Responses
- 200
- 409
- 5xx
Returns the created policy object
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- PolicyResponse
Schema
- CustomPolicy
Possible values: [0
]
Status code of the response
policy
object
A basic policy without content
oneOf
A policy with custom content
The name of the policy
A comment about the policy
The type of the policy
Whether the policy is enabled
audit
object
required
Audit information for a Gravitino resource.
The user who created the resource
The time the resource was created
The user who last modified the resource
The time the resource was last modified
Whether the policy is inherited from the parent metadata object
content
object
required
Content for a custom policy type.
Possible values: [CATALOG
, SCHEMA
, TABLE
, FILESET
, TOPIC
, MODEL
], >= 1
The types of metadata objects this policy content can be applied to.
properties
object
A map of string-to-string properties for the policy content.
A map of custom rules where the key is the rule name and the value can be of any type.
{
"code": 0
}
{
"code": 0,
"policy": {
"name": "my_policy1",
"comment": "This is a test policy",
"policyType": "custom",
"enabled": false,
"content": {
"customRules": {
"rule1": 123
},
"supportedObjectTypes": [
"SCHEMA",
"TABLE",
"MODEL",
"TOPIC",
"FILESET",
"CATALOG"
],
"properties": {
"key1": "value1"
}
},
"inherited": null,
"audit": {
"creator": "anonymous",
"createTime": "2025-08-04T10:29:23.463Z"
}
}
}
Conflict - The target policy already exists in the specified metalake
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- PolicyAlreadyExistsException
Schema
Possible values: >= 1000
and <= 1100
HTTP response code
Internal type definition of the error
A human-readable message
{
"code": 1002,
"type": "string",
"message": "string",
"stack": [
"string"
]
}
{
"code": 1004,
"type": "PolicyAlreadyExistsException",
"message": "Failed to operate policy(s) [my_policy] operation [CREATE], reason [PolicyAlreadyExistsException]",
"stack": [
"org.apache.gravitino.exceptions.PolicyAlreadyExistsException: Gag my_policy already exists",
"..."
]
}
A server-side problem that might not be addressable from the client side. Used for server 5xx errors without more specific documentation in individual routes.
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- Example
Schema
Possible values: >= 1000
and <= 1100
HTTP response code
Internal type definition of the error
A human-readable message
{
"code": 1002,
"type": "string",
"message": "string",
"stack": [
"string"
]
}
{
"code": 1002,
"type": "RuntimeException",
"message": "Internal Server Error",
"stack": [
"java.lang.RuntimeException: Internal Server Error"
]
}