Create a custom field
sf_create_custom_fieldCreate a custom field on any Salesforce object using the Tooling API, with optional field-level security grants to profiles or permission sets.
Instructions
Create a custom field on an object via the Tooling API (POST /tooling/sobjects/CustomField), mirroring Inspector's Field Creator. Optionally grants field-level security to profiles/permission sets. Gated behind MC_NEXT_ALLOW_METADATA_CHANGES=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Field API name without the __c suffix, e.g. "Due_Date". | |
| type | Yes | Field type. | |
| label | Yes | Field label, e.g. "Due Date". | |
| scale | No | Decimal places for numeric types. | |
| length | No | Length for Text/LongTextArea/Html. | |
| sorted | No | Sort picklist values alphabetically. Default false. | |
| unique | No | Mark the field unique. Default false. | |
| grantTo | No | Field-level security grants, applied after the field is created. | |
| sobject | Yes | Object API name, e.g. "Account" or "Invoice__c". | |
| required | No | Mark the field required. Default false. | |
| precision | No | Total digits for numeric types. | |
| externalId | No | Mark the field as an external id. Default false. | |
| description | No | ||
| defaultValue | No | Default value (e.g. true for a Checkbox). | |
| visibleLines | No | Visible lines for long text areas. | |
| inlineHelpText | No | ||
| picklistValues | No | Picklist values, required for Picklist/MultiselectPicklist. | |
| firstValueDefault | No | Make the first picklist value the default. Default false. |