This article explains how to remove permission set assignments using Data Loader or Workbench when UI access is unavailable — for example, when an admin has accidentally assigned themselves the API Only permission and can no longer log in to the Salesforce interface.
Note: The below article link may help the user to understand how to ensure 'API Only User' permission is not enabled to avoid getting into the similar scenario in the future. Error 'Insufficient Privileges' when administrators login from the user interface
Using an API enabled product such as Data Loader, query the PermissionSetAssignment object. Identify the ID of the record matching the User and Permission Set that is affecting the access.
With this file, you can identify the permission set assignment that you want to delete by searching for the ID of the impacted user(s). Remove all other non-impacted users from the CSV file, copy the "Id" column into a new .csv file, and save that new file. We recommend keeping a copy of the original file in a safe location for backup purposes.
Delete the PermissionSetAssignment viaWorkbench
Based on this solution, you can also mass add permission set via Dataloader
000385772

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.