Skip to main content

Permissions

Permissions are assigned to Policies, and control data access throughout the platform.

The permissions Object

Field NameTypeDescription
idintegerPrimary key of the permission rule.
policyobjectPolicy this permission applies to. Many-to-one relationship to policies.
collectionstringCollection this permission rule applies to.
actionstringCRUD operation this permission rule applies to. One of create, read, update, delete.
permissionsobjectCustom permission rules the item must pass before users with the policy can operate on it. Follows the Filter Rules spec.
validationobjectRules the provided values must pass before users with the policy can submit them for insertion/update. Follows the Filter Rules spec.
presetsobjectAdditional default values for the item that are applied by users with the policy.
fieldsobjectArray of fields the user is allowed to alter.

List Permissions

List all permissions that exist in TrackVision.

Request

GET /permissions

SEARCH /permissions

If using SEARCH you can provide a query object as the body of your request.

Learn more about SEARCH ->

Query Parameters

Supports all global query parameters.

Response

An array of up to limit permission objects. If no items are available, data will be an empty array.

Example

GET /permissions

SEARCH /permissions

Retrieve a Permission

List an existing permission by primary key.

Request

GET /permissions/:id

Query Parameters

Supports all global query parameters.

Response

Returns the requested permission object.

Example

GET /permissions/34

Create a Permission Rule

Create a new permission rule

Request

POST /permissions

Provide a permission object as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

A partial permissions object. action and collection are required.

Response

Returns the permission object for the created permission.

Example

POST /permissions

{
"collection": "pages",
"action": "read",
"policy": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
"fields": ["id", "title"]
}

Create Multiple Permission Rules

Create multiple new permission rules

Request

POST /permissions

Provide an array of permission objects as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

An array of partial permissions objects. action and collection are required.

Response

Returns the permission objects for the created permissions.

Example

POST /permissions

[
{
"collection": "pages",
"action": "read",
"policy": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
"fields": ["id", "title"]
},
{
"collection": "pages",
"action": "create",
"policy": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
"fields": ["id", "title"]
}
]

Update Permissions

Update an existing permissions rule.

Request

PATCH /permissions/:id

Provide a partial permissions object as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

A partial permissions object.

Response

Returns the permission object for the updated permission.

Example

PATCH /permissions/34

{
"fields": ["id", "title", "body"]
}

Update Multiple Permissions

Update multiple existing permissions rules.

Request

PATCH /permissions

{
"keys": permission_id_array,
"data": partial_permission_object
}

Query Parameters

Supports all global query parameters.

Request Body

keys Required
Array of primary keys of the permissions you'd like to update.

data Required
Any of the permission object's properties.

Returns

Returns the permission object for the updated permissions.

Example

PATCH /permissions

{
"keys": [34, 65],
"data": {
"fields": ["id", "title", "body"]
}
}

Delete Permissions

Delete an existing permissions rule

Request

DELETE /permissions/:id

Response

Empty body.

Example

DELETE /permissions/34

Delete Multiple Permissions

Delete multiple existing permissions rules

Request

DELETE /permissions

Provide an array of permissions IDs as the body of your request.

Request Body

An array of permission primary keys

Response

Empty body.

Example

DELETE /permissions

[34, 64]

Get Current User Permissions

Check the current user's permissions across all collections.

Request

GET /permissions/me

Response

The response is an object that contains one entry for every collection with at least one permission. Each collection has entries corresponding to the actions the user is able to perform on the collection.

The access property indicates the level of access the user has for an action for a collection. "none" means the user has no access, "partial" means the user has access to some items, but may not have access to all items, and "full" means the user has access to all items.

{
"data": {
"<collection>": {
"create": {
"access": "none" | "partial" | "full",
"fields": permission_fields,
"presets": permission_presets
},
"read": {
"access": "none" | "partial" | "full",
"full_access": boolean,
"fields": permission_fields,
},
"update": {
"access": "none" | "partial" | "full",
"full_access": boolean,
"fields": permission_fields,
"presets": permission_presets
},
"delete": {
"access": "none" | "partial" | "full",
"full_access": boolean
},
"share": {
"access": "none" | "partial" | "full",
"full_access": boolean
}
}
}
}

Example

GET /permissions/me

{
"data": {
"articles": {
"create": {
"access": "full",
"fields": [
"*"
],
"presets": {
"title": "New Article"
}
},
"read": {
"access": "partial",
"fields": [
"*"
]
},
"update": {
"access": "full",
"fields": [
"*"
],
"presets": {}
},
"delete": {
"access": "full"
},
"share": {
"access": "none"
}
}
}
}

Check Permissions for a Specific Item

Check the current user's permissions on a specific item.

Request

GET /permissions/me/:collection/:id?

Response

{
"data": {
"update": {
"access": boolean
},
"delete": {
"access": boolean
},
"share": {
"access": boolean
}
}
}

For a Singleton where update access is given, the presets and fields properties from the corresponding update permission are additionally returned:

{
"data": {
"update": {
"access": true,
"presets": permission_presets,
"fields": permission_fields
},
"delete": {
"access": boolean
},
"share": {
"access": boolean
}
}
}
Non-existing Collection / Item

The response structure is maintained in any case, even if the collection or item does not exist. To check for the existence of an item, use the filtering endpoint instead.

Example

GET /permissions/me/articles/15

{
"data": {
"update": {
"access": true
},
"delete": {
"access": false
},
"share": {
"access": false
}
}
}

GET /permissions/me/about

{
"data": {
"update": {
"access": true,
"presets": {},
"fields": ["*"]
},
"delete": {
"access": false
},
"share": {
"access": false
}
}
}