Grant APIs
This feature is only available in paid plans. Please visit our pricing page to learn more.
Overview
This page contains the APIs for granting and revoking permissions to Entities.
This API has been available since 1.26.0
Grant a User or Entity Permissions to an Entity
This API is used to grant permissions to an Entity for a User or another Entity.
This is an upsert operation. If the grant to this Entity for the specified User or recipient Entity exists, it will be updated. Otherwise it will be created.
Request
URI
{entityId}
/grantRequest Parameters
The Id of the Entity to which access is granted.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
An object that can hold any information about the Grant that should be persisted. Please review the limits on data field types as you plan for and build your custom data schema.
The set of permissions of this Grant.
The Entity Id for which access is granted.
If recipientEntityId is not provided, then the userId will be required.
The User Id for which access is granted.
If userId is not provided, then the recipientEntityId will be required.
Example User Grant Request JSON
{
"grant": {
"data": {
"expiresAt": 1695361142909
},
"permissions": [
"read",
"write",
"sue"
],
"userId": "7174f72f-5ecd-4eae-8de8-7fef597b3473"
}
}
Example Grant Request JSON
{
"grant": {
"data": {
"foo": "bar"
},
"permissions": [
"read",
"write",
"sue"
],
"recipientEntityId": "5174f72f-5ecd-4eae-8de8-7fef597b3473"
}
}
URI
{entityId}
/grantRequest Parameters
The Id of the Entity to which access is granted.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
An object that can hold any information about the Grant that should be persisted. Please review the limits on data field types as you plan for and build your custom data schema.
The set of permissions of this Grant.
The Entity Id for which access is granted.
If recipientEntityId is not provided, then the userId will be required.
The User Id for which access is granted.
If userId is not provided, then the recipientEntityId will be required.
Example User Grant Request JSON
{
"grant": {
"data": {
"expiresAt": 1695361142909
},
"permissions": [
"read",
"write",
"sue"
],
"userId": "7174f72f-5ecd-4eae-8de8-7fef597b3473"
}
}
Example Grant Request JSON
{
"grant": {
"data": {
"foo": "bar"
},
"permissions": [
"read",
"write",
"sue"
],
"recipientEntityId": "5174f72f-5ecd-4eae-8de8-7fef597b3473"
}
}
Response
This API does not return a JSON response body.
Response CodesCode | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Retrieve Grants
This API is used to retrieve Grants. Specifying only an entityId on the URI will retrieve all Grants for a single Entity.
Adding a parameter of userId or recipientEntityId filters the returned Grants. It limits them to those made to the User or recipient Entity, respectively.
Request
URI
{entityId}
/grantRequest Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
URI
{entityId}
/grant?userId={userId}
Request Parameters
The Id of the Entity to which access is granted.
The Id of the User which has been granted access.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
URI
{entityId}
/grant?recipientEntityId={recipientEntityId}
Request Parameters
The Id of the Entity to which access is granted.
The Id of the Entity which has been granted access.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
This API is used to retrieve one or all of the Grants made to this Entity. Specifying only an entityId on the URI will retrieve all Grants. Adding a parameter of userId or recipientEntityId will retrieve a single Grant made to the User or Entity, respectively.
Response CodesCode | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
An object that can hold any information about the Grant that should be persisted.
The Entity to which access is granted. See the Entity API for property definitions and example JSON.
The unique Id of the Grant.
The instant that the Grant was added to the FusionAuth database.
The instant that the Grant was last updated in the FusionAuth database.
The set of permissions of this Grant.
The Entity Id for which access is granted.
The User Id for which access is granted.
The total number of results for the search. This can be used for pagination.
Example Response JSON for a Single Grant
{
"grant": {
"data": {
"foo": "bar"
},
"entity": {
"clientId": "092dbded-30af-4149-9c61-b578f2c72f59",
"clientSecret": "+fcXet9Iu2kQi61yWD9Tu4ReZ113P6yEAkr32v6WKOQ=",
"data": {
"companyType": "Legal"
},
"id": "8174f72f-5ecd-4eae-8de8-7fef597b3473",
"insertInstant": 1595361142909,
"lastUpdateInstant": 1595361143101,
"name": "Raviga",
"tenantId": "30663132-6464-6665-3032-326466613934",
"type": {
"id": "4838d96a-4e7b-42c6-a4a1-ebc64952e1c8",
"insertInstant": 1518962408732,
"jwtConfiguration": {
"enabled": false,
"timeToLiveInSeconds": 60
},
"lastUpdateInstant": 1518962408732,
"name": "Customers"
}
},
"id": "8174f72f-5ecd-4eae-8de8-6fef597b3473",
"insertInstant": 1595361142929,
"lastUpdateInstant": 1595361143121,
"permissions": [
"read",
"write",
"sue"
],
"userId": "7174f72f-5ecd-4eae-8de8-7fef597b3473"
}
}
Response Body
The list of Grant objects.
An object that can hold any information about the Grant that should be persisted.
The Entity to which access is granted. See the Entity API for property definitions and example JSON.
The unique Id of the Grant.
The instant that the Grant was added to the FusionAuth database.
The instant that the Grant was last updated in the FusionAuth database.
The set of permissions of this Grant.
The Entity Id for which access is granted.
The User Id for which access is granted.
The total number of results for the search. This can be used for pagination.
Example Response JSON for Multiple Grants
{
"grants": [
{
"data": {
"foo": "bar"
},
"entity": {
"clientId": "092dbded-30af-4149-9c61-b578f2c72f59",
"clientSecret": "+fcXet9Iu2kQi61yWD9Tu4ReZ113P6yEAkr32v6WKOQ=",
"data": {
"companyType": "Legal"
},
"id": "8174f72f-5ecd-4eae-8de8-7fef597b3473",
"insertInstant": 1595361142909,
"lastUpdateInstant": 1595361143101,
"name": "Raviga",
"tenantId": "30663132-6464-6665-3032-326466613934",
"type": {
"id": "4838d96a-4e7b-42c6-a4a1-ebc64952e1c8",
"insertInstant": 1518962408732,
"jwtConfiguration": {
"enabled": false,
"timeToLiveInSeconds": 60
},
"lastUpdateInstant": 1518962408732,
"name": "Customers"
}
},
"id": "8174f72f-5ecd-4eae-8de8-6fef597b3473",
"insertInstant": 1595361142929,
"lastUpdateInstant": 1595361143121,
"permissions": [
"read",
"write",
"sue"
],
"userId": "7174f72f-5ecd-4eae-8de8-7fef597b3473"
}
]
}
Delete a Grant
This API is used to delete a Grant from an Entity. This is also known as revoking the Grant.
Request
URI
{entityId}
/grant?userId={userId}
Request Parameters
The Id of the Entity which is the target of the Grant.
The Id of the User who received the Grant.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
URI
{entityId}
/grant?recipientEntityId={recipientEntityId}
Request Parameters
The Id of the Entity which is the target of the Grant.
The Id of the Entity which received the Grant.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
This API does not return a JSON response body.
Code | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 | The object you requested doesn't exist. The response will be empty. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Search for Grants
This API is used to search for Entity Grants. This API may be called using the GET
or POST
HTTP methods. Examples of each are provided below. The POST
method is provided to allow for a richer request object without worrying about exceeding the maximum length of a URL. Calling this API with either the GET
or POST
HTTP method will provide the same search results given the same query parameters.
Request
URI
?entityId={uuid}
URI
?name={string}
URI
?userId={uuid}
Request Parameters
An Entity Id to search for Grants on.
The name of the Entity that the Grants are for. For example, if you want the Grants for “Jane’s Thermostat”, you can specify that as the name parameter to receive the Grants for that Entity.
It is recommended that you use this parameter in conjunction with the entityId or the userId parameter. This will help reduce the set of Grants to be queried in the database and dramatically reduce the overhead of the search.
The number of search results to return. Used for pagination.
The start row within the search results to return. Used for pagination.
The database column to order the search results on plus the order direction.
The possible values are:
insertInstant
- the instant when the Entity Grant was createdname
- the name of the Entity the Grant is for
For example, to order the results by the insert instant in a descending order, the value would be provided as insertInstant DESC
. The final string is optional can be set to ASC
or DESC
.
A User Id to search for Grants on.
URI
Request Body
An Entity Id to search for Grants on.
The name of the Entity that the Grants are for. For example, if you want the Grants for “Jane’s Thermostat”, you can specify that as the name parameter to receive the Grants for that Entity.
It is recommended that you use this parameter in conjunction with the entityId or the userId parameter. This will help reduce the set of Grants to be queried in the database and dramatically reduce the overhead of the search.
The number of search results to return. Used for pagination.
The start row within the search results to return. Used for pagination.
The database column to order the search results on plus the order direction.
The possible values are:
insertInstant
- the instant when the Entity Grant was createdname
- the name of the Entity the Grant is for
For example, to order the results by the insert instant in a descending order, the value would be provided as insertInstant DESC
. The final string is optional can be set to ASC
or DESC
.
A User Id to search for Grants on.
Request Body Examples
Example Request JSON
{
"search": {
"entityId": "e4b44fdc-cee6-46f2-8b31-93c4d91d92b3",
"numberOfResults": 25,
"name": "Jane's Thermostat",
"orderBy": "name DESC",
"startRow": 0,
"userId": "dc7f68e9-2731-484d-a5be-cd1fd73b8763"
}
}
Response
The response contains the Entity Grant objects that were found as part of the lookup or search.
Code | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 | The object you requested doesn't exist. The response will be empty. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
The list of Grant objects.
An object that can hold any information about the Grant that should be persisted.
The Entity to which access is granted. See the Entity API for property definitions and example JSON.
The unique Id of the Grant.
The instant that the Grant was added to the FusionAuth database.
The instant that the Grant was last updated in the FusionAuth database.
The set of permissions of this Grant.
The Entity Id for which access is granted.
The User Id for which access is granted.
The total number of results for the search. This can be used for pagination.
Example Response JSON for Multiple Grants
{
"grants": [
{
"data": {
"foo": "bar"
},
"entity": {
"clientId": "092dbded-30af-4149-9c61-b578f2c72f59",
"clientSecret": "+fcXet9Iu2kQi61yWD9Tu4ReZ113P6yEAkr32v6WKOQ=",
"data": {
"companyType": "Legal"
},
"id": "8174f72f-5ecd-4eae-8de8-7fef597b3473",
"insertInstant": 1595361142909,
"lastUpdateInstant": 1595361143101,
"name": "Raviga",
"tenantId": "30663132-6464-6665-3032-326466613934",
"type": {
"id": "4838d96a-4e7b-42c6-a4a1-ebc64952e1c8",
"insertInstant": 1518962408732,
"jwtConfiguration": {
"enabled": false,
"timeToLiveInSeconds": 60
},
"lastUpdateInstant": 1518962408732,
"name": "Customers"
}
},
"id": "8174f72f-5ecd-4eae-8de8-6fef597b3473",
"insertInstant": 1595361142929,
"lastUpdateInstant": 1595361143121,
"permissions": [
"read",
"write",
"sue"
],
"userId": "7174f72f-5ecd-4eae-8de8-7fef597b3473"
}
]
}