Represents a set of permissions that’s used to grant additional access to one or more users without changing their profile or reassigning profiles. You can use permission sets to grant access, but not to deny access. This object is available in API version 22.0 and later.
Use the PermissionSet object to query existing permission sets.
For example, to search for all permission sets that contain the “Modify All Data” permission:
SELECT Name, PermissionsModifyAllData FROM PermissionSet WHERE PermissionsModifyAllData=true
When combined with the PermissionSetAssignment object, you can create a nested query that returns all users assigned to a particular permission like “Modify All Data”:
SELECT Name, (SELECT AssigneeId FROM Assignments) FROM PermissionSet WHERE PermissionsModifyAllData=true
You can also create a permission set, or delete a permission set if it isn't assigned to a user.
Every permission set is associated with a user license. You can only assign permission sets to users who have the same user license that’s associated with the permission set. If you want to assign similar permissions to users with different licenses, create multiple permission sets with the same permissions, but with different licenses.
When using the API, think of each permission set or related set of access controls as starting as an empty container that you fill with permission records.

In these child objects, access is stored in a record, while the absence of a record indicates no access. In order to return a record in a SOQL query, a minimum permission is required for each child object.
| Child Object | Minimum Permission Required to Return a Record |
|---|---|
| ObjectPermissions | Read |
| FieldPermissions | Read |
Because permissions are stored in a number of related sObjects, it’s important to understand what questions to ask when using SOQL. For example, you may want to know which permission sets have “Delete” on an object or have the right to approve a return merchandise authorization (where the approval checkbox is controlled with field permissions). Asking the right questions when using SOQL with permission sets will ensure that you get the information you need to make an informed decision, such as whether to migrate permissions or assign a permission set to a user.
For example, the following will return all permission sets where the “Read” permission is enabled for the Merchandise__c object.
SELECT SobjectType, ParentId, PermissionsRead FROM ObjectPermissions WHERE PermissionsRead = True AND SobjectType = 'Merchandise__c'
You can query for all permission sets that have “Read” on an object. However, you can’t query for permission sets that have no access on an object, because no records exist for that object. For example, the following will return no records because the object must have at least “Read” to return any records.
SELECT SobjectType, ParentId, PermissionsRead FROM ObjectPermissions WHERE PermissionsRead = False AND SobjectType = 'Merchandise__c'
If you have at least the “Read” permission on an object, you can create a conditional query on other permissions in the same object. For example, the following will return any records where the object has at least the “Read” permission but not the “Edit” permission.
SELECT ParentId, PermissionsRead, PermissionsEdit FROM ObjectPermissions WHERE PermissionsEdit = False AND SobjectType = 'Merchandise__c'
To set an object or field permission to no access, just delete the record that contains the permission. For example, to disable all object permissions in the Merchandise__c object for a particular permission set, first query to retrieve the ID of the object permission record.
SELECT Id FROM ObjectPermissions WHERE SobjectType = 'Merchandise__c'
Then delete the IDs returned from the query.
You can build on the PermissionSet object using child relationships that show all of the permissions in a single permission set. For example, the following will return all permission sets and display the “Transfer Leads” permission as well as any “Read” permissions on any objects and fields.
SELECT Label, PermissionsTransferAnyLead, (SELECT SobjectType, PermissionsRead from ObjectPerms), (SELECT SobjectType, Field, PermissionsRead from FieldPerms) FROM PermissionSet