Skip to content

Execute MDL Script

This synchronous endpoint executes the given MDL script on a Vault. Note that some large operations require use of the asynchronous endpoint.

POST/api/mdl/execute
NameDescription
Content-Typeapplication/json or application/xml
Acceptapplication/json (default) or application/xml

The body of the request should contain the MDL script to execute. Enter the body as raw data. The body must start with one of the following values:

  • CREATE
  • RECREATE
  • RENAME
  • ALTER
  • DROP

Learn more in the MDL Commands documentation.

In this example, we update our picklists using the RECREATE command. If a picklist exists with the name color__c, Vault updates it to conform to the definition provided. If not, Vault creates a new picklist with the definition provided.

curl -X POST -H "Authorization: {SESSION_ID}" \
-H "Content-Type: application/json" \
--data-raw 'RECREATE Picklist color__c (
   label('Color'),
   active(true),
   Picklistentry red__c(
      value('Red'),
      order(1),
      active(true)
   ),
   Picklistentry blue__c(
      value('Blue'),
      order(2),
      active(true)
   ),
   Picklistentry green__c(
      value('Green'),
      order(3),
      active(true)
   )
);' \
https://myvault.veevavault.com/api/mdl/execute
{
    "responseStatus": "SUCCESS",
    "script_execution": {
        "code": "GEN-S-0",
        "message": "OK",
        "warnings": 0,
        "failures": 0,
        "exceptions": 0,
        "components_affected": 1,
        "execution_time": 0.028
    },
    "statement_execution": [
        {
            "vault": "myvault.veevavault.com",
            "statement": 1,
            "command": "RECREATE",
            "component": "Picklist.color__c",
            "message": "[SUCCESS] RECREATE Picklist color__c",
            "response": "SUCCESS"
        }
    ]
}

Request: RECREATE Java SDK Trigger

Section link for Request: RECREATE Java SDK Trigger
curl -X POST -H "Authorization: {SESSION_ID}" \
-H "Content-Type: application/json" \
--data-raw 'RECREATE Recordtrigger my_custom_trigger_name__c (
active (true),
source_code (<VeevaData>
...
</VeevaData>)
);' \
https://myvault.veevavault.com/api/mdl/execute

Response: RECREATE Java SDK Trigger

Section link for Response: RECREATE Java SDK Trigger
{
    "responseStatus": "SUCCESS",
    "script_execution": {
        "code": "GEN-S-0",
        "message": "OK",
        "warnings": 0,
        "failures": 0,
        "exceptions": 0,
        "components_affected": 1,
        "execution_time": 0.026
    },
    "statement_execution": [
        {
            "vault": "myvault.veevavault.com",
            "statement": 1,
            "command": "RECREATE",
            "component": "Recordtrigger.my_custom_trigger_name__c",
            "message": "[SUCCESS] RECREATE Recordtrigger my_custom_trigger_name__c",
            "response": "SUCCESS"
        }
    ]
}

On SUCCESS, the response contains details of the execute.