Code samples for creating sandboxes

Flexible options for creating your sandbox.

Version

Create a sandbox based on a specific property version.
{
    "property":{
        "propertyName":"www.example.com",
        "propertyVersion":23
    },
    "name":"dev1_sandbox"        
}

Clonable

Create a sandbox based on a particular property version that can be cloned by other developers.
{
    "property":{
        "propertyName":"www.example.com",
        "propertyVersion":23
    },
    "name":"dev1_sandbox",
    "isClonable":true
}

Rules

Create a sandbox based on a property and override the rules.
{  
    "property":{  
        "propertyName":"www.example.com",
        "propertyVersion":23,
        "rules":{  
            "name":"default",
            "children":[  ],
            "behaviors":[  
                {  
                    "name":"origin",
                    "options":{  
                        "cacheKeyHostname":"ORIGIN_HOSTNAME",
                        "compress":true,
                        "enableTrueClientIp":false,
                        "forwardHostHeader":"REQUEST_HOST_HEADER",
                        "httpPort":80,
                        "httpsPort":443,
                        "originSni":true,
                        "originType":"CUSTOMER",
                        "verificationMode":"PLATFORM_SETTINGS",
                        "hostname":"my-origin.example.com",
                        "originCertificate":"",
                        "ports":""
                    }
                },
                {  
                    "name":"cpCode",
                    "options":{  
                        "value":{  
                            "id":1090207,
                            "description":"my cpcode",
                            "products":[  
                                "SPM"
                            ],
                            "createdDate":1251013390000,
                            "name":"my cpcode"
                        }
                    }
                },
                {  
                    "name":"caching",
                    "options":{  
                        "behavior":"MAX_AGE",
                        "mustRevalidate":false,
                        "ttl":"3m"
                    }
                }
            ],
            "options":{  
                "is_secure":false
            },
            "variables":[ ]
        }
    },
    "name":"dev1_sandbox",
    "isClonable":true
}
If you have a specific rule tree that you want to base your sandbox testing on, use the createFromRules format for the JSON POST body.
{ 
    "createFromProperty":{ 
        "propertyName":"www.example.com",
        "propertyVersion":23
    },
    "name":"dev1_sandbox",
    "isClonable":true,
    "createFromRules":{ 
        "rules":{ 
            "name":"default",
            "children":[ ],
            "behaviors":[ 
                { 
                    "name":"origin",
                    "options":{ 
                        "cacheKeyHostname":"ORIGIN_HOSTNAME",
                        "compress":true,
                        "enableTrueClientIp":false,
                        "forwardHostHeader":"REQUEST_HOST_HEADER",
                        "httpPort":80,
                        "httpsPort":443,
                        "originSni":true,
                        "originType":"CUSTOMER",
                        "verificationMode":"PLATFORM_SETTINGS",
                        "hostname":"my-origin.example.com",
                        "originCertificate":"",
                        "ports":""
                    }
                },
                { 
                    "name":"cpCode",
                    "options":{ 
                        "value":{ 
                            "id":1090207,
                            "description":"my cpcode",
                            "products":[ 
                                "SPM"
                            ],
                            "createdDate":1251013390000,
                            "name":"my cpcode"
                        }
                    }
                },
                { 
                    "name":"caching",
                    "options":{ 
                        "behavior":"MAX_AGE",
                        "mustRevalidate":false,
                        "ttl":"3m"
                    }
                }
            ],
            "options":{ 
                "is_secure":false
            },
            "variables":[ 

            ]
        }
    }
}

Request hostnames

Create a sandbox based on a property and override the request hostnames.
{  
    "property":{  
        "propertyName":"www.example.com",
        "requestHostnames":[  
            "store.example.com",
            "portal.example.com"
        ],
        "propertyVersion":23
    },
    "name":"dev1_sandbox",
    "isClonable":true
}