[SalesForce] Create a custom object via the API (define the object, similar to DDL)

I was looking through the Metadata API (and Partner) but can't find anywhere described how I can define via the API a custom object.

We have specific datasets which have to translate into Custom Objects in Salesforce via the API.

For instance a Home Repair dataset would include: Address, Estimate and Repair Date fields.
I want to translate this dataset into a Custom Object (named HomeRepair__c with those 3 custom fields) in Salesforce in our client's account via an API call.

Is this even possible?

Thanks.

Best Answer

Sure, you can use the Metadata API. You want the create() call. Here's the sample xml to define the custom object from the documentation:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <deploymentStatus>Deployed</deploymentStatus>
    <description>just a test object with one field for eclipse ide testing</description>
    <fields>
        <fullName>Comments__c</fullName>
        <description>add your comments about this object here</description>
        <inlineHelpText>This field contains comments made about this object</inlineHelpText>
        <label>Comments</label>
        <length>32000</length>
        <type>LongTextArea</type>
        <visibleLines>30</visibleLines>
    </fields>
    <label>MyFirstObject</label>
    <nameField>
        <label>MyFirstObject Name</label>
        <type>Text</type>
    </nameField>
    <pluralLabel>MyFirstObjects</pluralLabel>
    <sharingModel>ReadWrite</sharingModel>
</CustomObject>
Related Topic