Create a policy
POST https://{{host}}/script-management/v1/properties/:propertyId/hostnames/:hostname/network/:network/policies
Creates a new policy for the specified propertyId, hostname, and network. The policy request needs to include the spofConfig object or scriptConfig array item, but it can contain both. Only one policy can exist per hostname. A change to the spofConfig or scriptConfig overwrites the existing policy. If a policy already exists with the same spofConfig and scriptConfig, the API responds with a 409 error and displays the existing policy.
Request Params
| Key | Datatype | Required | Description |
|---|---|---|---|
accountSwitchKey | string | (Optional) For customers who manage more than one account, this runs the operation from another account. The Identity and Access Management API provides a list of available account switch keys. |
Request Body
{"policyNote"=>"First version for testing", "scriptConfig"=>[{"action"=>"BLOCK", "item"=>"https://www.example.com/main.min.js", "type"=>"URL"}, {"action"=>"DEFER", "item"=>"https://www.example.com/analytics.js", "type"=>"URL"}], "spofConfig"=>{"advancedSettings"=>{"maxSpofTimeoutInSecs"=>20, "minSpofTimeoutInSecs"=>6}, "spofEnabled"=>true}}
HEADERS
| Key | Datatype | Required | Description |
|---|---|---|---|
Content-Type | string | ||
Accept | string |
RESPONSES
status: Created
{"activationTime":"2022-02-19T09:45:00.000Z","policyNote":"First version for testing","scriptConfig":[{"action":"BLOCK","item":"https://www.example.com/main.min.js","type":"URL"},{"action":"DEFER","item":"https://www.example.com/analytics.js","type":"URL"}],"spofConfig":{"advancedSettings":{"maxSpofTimeoutInSecs":20,"minSpofTimeoutInSecs":6},"spofEnabled":true},"versionId":"1"}