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
Laurent Poulain 14Laurent Poulain 14 

Create custom object using Apex Metadata API


Is it possible to create a custom object using Apex Metadata API? I wasn't able to find any code example about this quite recent API.

Note that I am creating it right now by making a callout to the Metadata API, but am wondering if there is a better way.

PriyaPriya (Salesforce Developers) 

Hey Laurent,

Yes it is possible to create the custom object using Metadata API.

Refer this link ;-

If it helps, kindly mark it as the best answer.


Priya Ranjan

Laurent Poulain 14Laurent Poulain 14
Hi Priya,

This is using the callout to the Metadata API, which I am already using. I'm looking for a way to use the new Apex Metadata API.

Maciej Król 28Maciej Król 28
I can't find apropriate class in Metadata Namespace ( so I'd assume it's not achievable so far.