How can I tell from REST api which of an object’s fields are required?

I am trying to create objects with the REST api, which works fine as long as I specify a value for each required field in the POST. The question is, how can I tell from the API which fields are required?

According to the API documentation, I should use Describe, like so:


When I do this, I get tons of metadata about the fields, but no indication as to which fields are required. I’ve compared required fields to optional fields and none of the metadata seems to indicated that the field is required.

Another SO thread suggested that “nillable” was equivalent to required, but that appears to be untrue. For example, Account.Name has nillable=true. I’ve also looked at custom objects with custom required fields, they can be nillable too. What am I missing here?


The way you are getting the field description is Ok:


If you check in the official doc you’ll see

nillable boolean Indicates whether the field is nillable (true) or not
(false). A nillable field can have empty content. A non-nillable field
must have a value in order for the object to be created or saved.

I’ve checked Account.Name and nillable seems to be Ok:

"name" : "Account",
  "fields" : [ {
   "name" : "Name",
   "nillable" : false,

Also, I’ve tried two custom fields an the result are Ok:

   "name" : "TestReq__c",
   "nillable" : false,

   "name" : "TestNoReq__c",
   "nillable" : true,

Are you sure that your API response are getting the wrong value? Are you working with PersonAccounts?


In addition (By reading Jonathan answer) I notice, you could also check if the pageLayout using the same REST API:


You will get there the layouts for that object where will find the layoutItem object which contains the require attr.

However, I think that you are trying to insert/update data through API and hence those security controls are expected to be omitted

Source : Link , Question Author : DevOfZot , Answer Author : Martin Borthiry

Leave a Comment