Ask Inkeep
08/06/2025, 7:35 AMAsk Inkeep
08/06/2025, 7:35 AMpermit.check() function to determine if a user has permission to perform a specific action on a resource instance (1) (2) (3) (4) . This is the core authorization check endpoint.
The check function evaluates whether a particular action by a user on a resource should be allowed or denied (5) . It accepts:
• *User*: The user ID
• *Action*: The operation being attempted
• *Resource*: The resource type or specific instance ID
• *Context*: Optional additional data for evaluation
Here are examples of how to use it:
*Node.js SDK:*
const permitted = await permit.check(user, action, resource) ;
(3)
*With resource instance:*
const permitted = await permit.check(userId, action, `Resource:${resourceId}`) ;
(4)
*API endpoint example:*
const permitted = await permit.check(user, action, resourceObj) ;
(3)
*With context:*
const check = await permit.check(
body.user,
body.action,
body.resource,
body.context
) ;
(4)
The function returns a boolean indicating whether the user is permitted to perform the requested action (2) (3) .
While permit.check() tells you if a specific action is allowed, if you need to know _all_ actions a user can perform on a resource instance, you would need to check multiple actions individually or use bulk checking functionality (3) .Ask Inkeep
08/06/2025, 7:36 AMOr Weis
08/06/2025, 7:40 AMAsk Inkeep
08/06/2025, 7:40 AMAsk Inkeep
08/06/2025, 7:40 AMcurl -X POST <http://localhost:7766/v1/actions> \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"subject": {"type": "user", "id": "<mailto:alice@example.com|alice@example.com>"},
"resource": {
"type": "document",
"id": "doc123",
"properties": {"tenant": "default"}
},
}'
This returns: {"actions": [{"name": "read"}, {"name": "write"}]}
The PDP runs as a microservice in your infrastructure (as a sidecar, cluster, or centralized deployment) and evaluates authorization queries using policies and contextual data . It's separate from the control plane which manages the policy configuration (2) .
You can also use the standard /allowed endpoint to check specific actions, or /allowed/bulk for multiple checks at once (1) .Ask Inkeep
08/06/2025, 7:40 AMOmer Zuarets
08/06/2025, 7:44 AMx do action y on resources of type z ( this means on all resource instances of this type )
◦ via permit.check(x,y,z) ( api ref, sdk ref )
• Can user x do action y on resource z:z-instance
◦ via permit.check(x,y,z:z-instance) ( api ref, sdk ref )
• What permissions does user x has with filters
◦ via permit.get_user_permissions(x,tenants={optional tenant filter},resources={optional resources filter},resource_types={options resource types filter}) ( api ref, sdk ref )
• Which users can perform action y on resources of type z
◦ via permit.get_authorized_users(y,z) ( api ref, sdk ref )
• Which users can perform action y on resource `z:z-instance`( this means on all resource instances of this type )
◦ via permit.get_authorized_users(y,z:z-instance) ( api ref, sdk ref )
There are few others that are good for more specific use-casesMichał Wójcik
08/06/2025, 12:11 PMcurl --location '<http://localhost:7766/authorized_users>' \
--header 'Content-Type: application/json' \
--header 'Authorization: {{auth}}' \
--data '{
"action": "distribute",
"resource": {
"type": "market_order",
"tenant":"default"
},
"context": {
"enable_abac_authorized_users": true
}
}
}'
Result:
HTTP/1.1 200 OK
content-type: application/json
content-length: 59
connection: close
date: Wed, 06 Aug 2025 11:51:53 GMT
{
"resource": "market_order:*",
"tenant": "default",
"users": {}
}Omer Zuarets
08/06/2025, 12:55 PMdistribute on all resources of type market_order in tenant default ?”Michał Wójcik
08/06/2025, 2:19 PMOmer Zuarets
08/06/2025, 2:29 PMMichał Wójcik
08/07/2025, 6:20 AMcurl --location '<http://localhost:7766/allowed>' \
--header 'Content-Type: application/json' \
--header 'Authorization: {{auth}}' \
--data '{
"user": {
"key": "<mailto:michal@clarksons.com|michal@clarksons.com>"
},
"action": "distribute",
"resource": {
"type": "market_order",
"key": "m01",
"tenant": "default"
},
"context": {}
}'
Response:
HTTP/1.1 200 OK
content-type: application/json
content-length: 1215
connection: close
date: Thu, 07 Aug 2025 06:19:05 GMT
{
"allow": true,
"debug": {
"abac": {
"allow": false,
"code": "no_matching_rules",
"matching_resourcesets": [
"__autogen_market_order"
],
"matching_usersets": [
"__autogen_market_order"
],
"reason": "user '<mailto:michal@clarksons.com|michal@clarksons.com>' does not match any rule that grants him the 'distribute' permission on the given resource of type 'market_order'",
"support_link": "<https://docs.permit.io/errors/no_matching_rules>"
},
"rebac": {
"allow": true,
"allowing_roles": [
{
"reason": "granted by 'market_order:m01#creator'",
"resource": "market_order:m01",
"role": "market_order#creator",
"sources": [
{
"type": "role_assignment"
}
]
}
],
"code": "allow",
"reason": "user '<mailto:michal@clarksons.com|michal@clarksons.com>' has the 'distribute' permission on resource 'market_order:m01' in tenant 'default', granted by 'market_order:m01#creator'"
},
"rbac": {
"allow": false,
"code": "no_user_roles",
"reason": "no roles assigned to user '<mailto:michal@clarksons.com|michal@clarksons.com>'",
"support_link": "<https://docs.permit.io/errors/no_user_roles>"
},
"request": {
"action": "distribute",
"resource": {
"attributes": {
"type": "market_order"
},
"type": "market_order"
},
"tenant": "default",
"user": {
"attributes": {
"email": "<mailto:michal@clarksons.com|michal@clarksons.com>",
"key": "<mailto:michal@clarksons.com|michal@clarksons.com>",
"roles": [],
"tenants": []
},
"key": "<mailto:michal@clarksons.com|michal@clarksons.com>",
"synced": true
}
}
},
"result": false
}Omer Zuarets
08/07/2025, 7:22 AMMichał Wójcik
08/11/2025, 8:46 AMAsk Inkeep
08/11/2025, 8:46 AMAsk Inkeep
08/11/2025, 8:46 AMawait permit.api.resource_relations.create(
"file",
{
"key": "parent",
"name": "Parent",
"subject_resource": "folder",
}
)
Creating Relationship Tuples
To establish that resources belong to each other, create relationship tuples (1) :
curl <https://api.permit.io/v2/facts/my_project/my_environment/relationship_tuples> \
--request POST \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"subject": "organization:permitio",
"relation": "owner",
"object": "repo:test",
"tenant": "public"
}'
The format is: <Subject> : <Relation> : <Object>
Querying Resource Instances
For finding resource instances owned by a user, you can use the getUserPermissions function (3) (4) :
const tenants = await permit.api.tenants.list({
perPage: 100,
}) ;
(4)
This returns tenants where a user has assigned roles .
For specific resource instances with relationships, you'd sync them with attributes (3) :
const resourceInstance = await permit.api.resourceInstances.create({
resource: "Transaction",
key: transaction.id,
tenant,
attributes: {
...transaction,
},
}) ;
Note that Permit.io's PDP focuses on authorization checks rather than resource discovery. The getUserPermissions endpoint can show what permissions a user has, but for full resource hierarchy queries (like "all deliveries belonging to an order") , you'd typically maintain that relationship data in your application database and use Permit.Ask Inkeep
08/11/2025, 8:46 AMMichał Wójcik
08/11/2025, 8:56 AMThe getUserPermissions endpoint can show what permissions a user has, but for full resource hierarchy queries (like "all deliveries belonging to an order") , you'd typically maintain that relationship data in your application database and use <http://Permit.io|Permit.io> to authorize access to those resources.Or Weis
08/11/2025, 9:21 AMOr Weis
08/11/2025, 9:22 AMOmer Zuarets
08/11/2025, 9:24 AM