## 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
```text
Salesforce license usage export failed: insufficient privileges
```

## Steps
1. Confirm the privilege gap: the error names insufficient privileges on the license objects. Expected: a permissions problem, not a data problem.
2. 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.
3. Test the export query in isolation (Workbench or the API) as the agent user. Expected: the query succeeds.
4. 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
