I have a salesforce app, and I'd like to use it to add fields to the Lead object in salesforce.

This can be achieved in Salesforce by going to Setup > Object Manager > Lead > FieldsAndRelationships > New and filling out the form there.

However, I would like to create this new field automatically using the REST api.

I cannot find any documentation on how to achieve this. The closest I've found is Retrieve Metadata for an Object which has documentation on how to fetch the object fields, but no information on how to add one.

The concept is, I'd like to add a field MyCustomField to the Lead object, then iterate over all the Leads to populate that column with app-specific data.

Is what I'm trying to achieve possible with the REST api?

Thanks for any input.

1 Answer 1


You'll need to use the Metadata API to add fields programmatically, and you'll also need to add field-level security for the user your REST API integration is connecting under before you're able to read and write to them.

Depending on how your application is structured (more information might be helpful), it may be a better solution to do a one-time metadata migration with the Force.com IDE or Ant migration tool, or to provide a package for installation in Salesforce that includes the field(s) and perhaps a permission set that can be assigned to your integration user to provide access.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .