How can I make a custom field visible with the REST API (NOT THE WEB UI)? Preferably when I create the custom field.

Currently I create a field like this,

curl --request POST \
  --url https://[company]-ed.my.salesforce.com/services/data/v52.0/tooling/sobjects/CustomField \
  --header 'Authorization: Bearer [token]' \
  --header 'Content-Type: application/json' \
  --data '{ 
     "FullName": "Account.Class__c",     
   "Metadata": { 
         "label": "Class",
      "description": "Class Field", 
      "required": false, 
      "externalId": false, 
      "type": "Text", 
      "length": 32 

However I am unable to use this field in other API calls until it is "visible", that is until it has the PermissionsEdit and PermissionsRead entries set to true for each profile in the FieldPermissions table.

SELECT Field, Id, ParentId, PermissionsEdit, PermissionsRead, SobjectType, SystemModstamp FROM FieldPermissions WHERE Field = 'Account.Class__c'

How can I make this happen with the REST API? What is the ParentId in this table? Seems like I need to make entries here.

  • Metadata API = SOAP. There's a popular Apex wrapper: github.com/financialforcedev/apex-mdapi
    – identigral
    Commented Nov 19, 2021 at 18:59
  • That is really not helpful, I'm looking for a response like, POST this XML to this endpoint...
    – avantassel
    Commented Dec 1, 2021 at 19:58
  • Turns out setting required to true will set the visibility also, so this kinda works but just need to make sure when updating an count you always post this field.
    – avantassel
    Commented Dec 2, 2021 at 17:53


Browse other questions tagged .