agent could not export Salesforce license usage: insufficient privileges, audit failed
Fixes license agents blocked from Salesforce license exports by insufficient privileges. Use when the export fails on permissions. Not for mapping or API errors.
TL;DR
Grant the agent's Salesforce user the permissions the export needs (View Setup and API access at minimum). The export reads setup objects that standard users cannot see.
Error
Salesforce license usage export failed: insufficient privilegesSteps
- Confirm the privilege gap: the error names insufficient privileges on the license objects. Expected: a permissions problem, not a data problem.
- Assign the needed permissions to the agent's user: View Setup and Configuration, API Enabled, and access to the UserLicense objects. Expected: the permission set updated.
- Test the export query in isolation (Workbench or the API) as the agent user. Expected: the query succeeds.
- Re-run the audit export. Expected: license data flows.
When to use
- Salesforce exports fail on insufficient privileges
- The agent user is new or recently changed
- The query works for an admin but not the agent
When not to use
- The query itself is wrong (a SOQL problem)
- The license mapping changed (a mapping problem)
- The org has API limits disabled for the user (a different setting)
Tool compatibility
Salesforce API and Setup permissions.
Variant phrasings
privileges granted but export still fails
Check profile versus permission set conflicts, and field-level security on the license fields.
want least privilege
Scope to the specific objects and fields the export reads; document the set.
Why it happens
License data lives in setup objects behind admin permissions. Agent service users are usually created with minimal rights, which excludes exactly the objects the audit needs.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_5NvJ7io6GVxAhM5HYCXMIQ