Skip to main content

How to Configure Row and Column Permissions with APIs

Get Security Filter Information on a Dataset

GET /api/data-source/{dsId}/security-filter

Parameters

NameLocationTypeMeaningRequiredRemarks
dsIdPathStringDataset idYes
tokenHeaderStringLogin TokenYesThe token must be obtained through the login API

Header Example

{
"token": "guanyuan token"
}

Response

{
"column":{
"enabled":true,
"rules":[]
},
"row":{
"enabled":false,
"rules":[],
"defaultRule":{
"ruleType":"HIDDEN"
}
},
"applyToOwner":false
}

Currently, ruleType supports three values:

  • COLUMN: Column-level permission, representing columns that cannot be viewed.
  • ADVANCED: Advanced row-level permission, similar to a Threshold formula.
  • FREEFORM: Custom row-level permission, where you write SQL yourself.

Enable or Disable Row/Column Security Filter on a Dataset, and Whether to Apply Security Filter to Owner and Administrators

POST api/data-source/{dsId}/security-filter/enable

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin TokenYesThe token must be obtained through the login API
dsIdPathStringDataset idYes
levelBodyStringLevelYesrow: row permission; column: column permission; applyToOwner: apply to administrators and Owner
enableBodyBooleanWhether to enableYestrue: enable; false: disable

POST Body Example

{
"level": "column",
"enable": true
}

Response

The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.

Row/Column Security Filter Rules on a Dataset

Create a Row/Column Security Filter Rule on a Dataset

Apply an existing permission rule to a dataset.

POST api/data-source/{dsId}/security-filter/rules

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin tokenYes
dsIdPathStringDataset idYes
ruleIdBodyStringRule idYes
userAndGroupsBodyJSONUsers and user groupsYes
ruleTypeBodyStringRule typeYesCOLUMN: column-level; ADVANCED: row-level; FREEFORM: custom
commentBodyStringComment
forbiddenColumnsBodyJSONInvisible fieldsRequired when adding column permissions
advancedBodyJSONRow permission ruleRequired when adding row permissions
freeformBodyStringCustom ruleRequired when adding custom permissions

POST Body Example

COLUMN column-level permission

{
"ruleId": "b4a956d66bd57464f8f050f4",
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
}
],
"ruleType": "COLUMN",
"comment":"testUser cannot read columns",
"forbiddenColumns": [
{
"fdId": "j9259851e2ac14152bd8e41d", /* fdId can be read from Network Preview when previewing the dataset */
"name": "city"
}
]
}

ADVANCED row-level permission

{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
}
],
"ruleType": "ADVANCED",
"comment":"testUser cannot read rows",
"advanced": [
{
"type": "condition",
"not": false,
"value": {
"name": "2009",
"fdType": "DOUBLE",
"fdId": "ea853c91",
"metaType": "METRIC",
"seqNo": 2,
"filterType": "GE",
"filterValue": [
"50",
""
],
"advFilter": null
}
}
]
}

FREEFORM custom permission

{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
}
],
"ruleType": "FREEFORM",
"comment": "testUser cannot read rows (freeform)",
"freeform": "[city] in 'hangzhou'"
}

Response

The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.

Modify a Row/Column Security Filter Rule on a Dataset

POST api/data-source/{dsId}/security-filter/rules/{ruleId}

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin tokenYes
dsIdPathStringDataset idYes
ruleIdPathStringPermission rule idYes
userAndGroupsBodyJSONUsers and user groupsYes
ruleTypeBodyStringRule typeYesCOLUMN: column-level; ADVANCED: row-level; FREEFORM: custom
commentBodyStringComment
forbiddenColumnsBodyJSONInvisible fieldsRequired when modifying column permissions
advancedBodyJSONRow permission ruleRequired when modifying row permissions
freeformBodyStringCustom ruleRequired when modifying custom permissions

POST Body Example (FREEFORM)

{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
},
{
"relId": "b1766b1ac99bf4679a1bd111",
"name": "User2",
"relType": "USER"
}
],
"ruleType": "FREEFORM",
"comment": "users cannot read rows (freeform)",
"freeform": "[city] in 'hangzhou'"
}

Response

The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.

Delete a Row/Column Security Filter Rule on a Dataset

DELETE api/data-source/{dsId}/security-filter/rules/{ruleId}

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin tokenYes
dsIdPathStringDataset idYes
ruleIdPathStringPermission rule idYes

Response

The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.

Modify the Default Rule on Dataset Columns

POST api/data-source/{dsId}/security-filter/rules/row-level-default-rule

Parameters

NameLocationTypeMeaningRequiredRemarks
dsIdPathStringDataset idYes

POST Body Example (FREEFORM)

{
"ruleType": "FREEFORM",
"comment": "default rule based on city",
"freeform": "[city] in 'hangzhou'"
}

Supported ruleType values are:

  • HIDDEN: Default rule. Other users cannot see the columns.
  • VISIBLE: All other users can see the columns. This is risky and requires a nearby prompt.
  • ADVANCED: Advanced column configuration. The extra field advanced needs to be read.
  • FREEFORM: Custom SQL mode. The extra field freeform needs to be read.

Response

The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.