Is it possible to know if a profile is custom via API?
Like an attribute “profile.isCustom”.
The short answer is no.
Neither the sObject API nor the Metadata API includes the ‘custom’ boolean value in their footprint. We’re discussing whether or not to include it in a future release, in fact, someone just asked me yesterday whether anyone actually uses this checkbox.
You could create a list view in the setup UI that filters based on the ‘custom’ checkbox and then use that list to enumerate your SOQL (where name <> “System Administrator”). But name is a difficult attribute to use for profiles in general to determine whether it’s custom since it’s possible for standard and custom profiles to have similar looking names (no __c to distinguish).
In the API, profile.name is actually the profile’s label and doesn’t follow normal API field behaviors. That label is used to generate the file name during a retrieve in the Metadata API but you’ll notice that by using Daniel’s package.xml definition to return all profiles, that the standard profiles are all predefined (e.g. System Administrator = Admin.profile) without any special ‘standard’ designation.
In the API, the profile Name attribute is also used to return the label of the profile. Unlike permission sets where we expose an API ‘Name’ attribute, profile only returns the equivalent of a label (SELECT Id,Label,Name, Profile.Name FROM PermissionSet WHERE isOwnedByProfile=true).