function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
samyak jain 45samyak jain 45 

How to create a connected app programatically ?

Can someone explain/share code snippet for creating a connected app programatically. Is there any library for using metadata api in javascript ?
NagendraNagendra (Salesforce Developers) 
Hi Samyak,

You can use the Salesforce Metadata API( to create a Connected App(, it provides the ConnectedApp metadata type for this purpose. You can either use the File Based method( or the CRUD method( (preferable for programmatic creation).

Represents a Connected App application. A connected app is an application that integrates with using APIs. Connected apps use standard SAML and OAuth protocols to authenticate, provide Single Sign-On, and provide tokens for use with Salesforce APIs. In addition to standard OAuth capabilities, connected apps allow administrators to set various security policies and have explicit control over who may use the applications. It extends the Metadata metadata type and inherits its fullName field.

ConnectedApp components have the suffix .connectedapp and are stored in the connected apps folder.

This API is available in any language supporting HTTP callouts using Web Services (Salesforce provides a WSDL to consume in your client app). If you're using a Java, there is a prebuilt client library available here( There is also an Apex wrapper( around the API if you're interested in doing this natively.

Hope this helps.

Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who encountering a similar issue.