CSP Generator
curl --request POST \
--url https://api.iotools.cloud/v1/tool/csp-generator \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ioDefaultSrc": "<string>",
"ioScriptSrc": "<string>",
"ioStyleSrc": "<string>",
"ioImgSrc": "<string>",
"ioFontSrc": "<string>",
"ioConnectSrc": "<string>",
"ioFrameSrc": "<string>",
"ioObjectSrc": "<string>",
"ioMediaSrc": "<string>",
"ioFrameAncestors": "<string>",
"ioBaseUri": "<string>",
"ioFormAction": "<string>",
"ioUpgradeInsecure": true
}
'import requests
url = "https://api.iotools.cloud/v1/tool/csp-generator"
payload = {
"ioDefaultSrc": "<string>",
"ioScriptSrc": "<string>",
"ioStyleSrc": "<string>",
"ioImgSrc": "<string>",
"ioFontSrc": "<string>",
"ioConnectSrc": "<string>",
"ioFrameSrc": "<string>",
"ioObjectSrc": "<string>",
"ioMediaSrc": "<string>",
"ioFrameAncestors": "<string>",
"ioBaseUri": "<string>",
"ioFormAction": "<string>",
"ioUpgradeInsecure": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ioDefaultSrc: '<string>',
ioScriptSrc: '<string>',
ioStyleSrc: '<string>',
ioImgSrc: '<string>',
ioFontSrc: '<string>',
ioConnectSrc: '<string>',
ioFrameSrc: '<string>',
ioObjectSrc: '<string>',
ioMediaSrc: '<string>',
ioFrameAncestors: '<string>',
ioBaseUri: '<string>',
ioFormAction: '<string>',
ioUpgradeInsecure: true
})
};
fetch('https://api.iotools.cloud/v1/tool/csp-generator', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.iotools.cloud/v1/tool/csp-generator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ioDefaultSrc' => '<string>',
'ioScriptSrc' => '<string>',
'ioStyleSrc' => '<string>',
'ioImgSrc' => '<string>',
'ioFontSrc' => '<string>',
'ioConnectSrc' => '<string>',
'ioFrameSrc' => '<string>',
'ioObjectSrc' => '<string>',
'ioMediaSrc' => '<string>',
'ioFrameAncestors' => '<string>',
'ioBaseUri' => '<string>',
'ioFormAction' => '<string>',
'ioUpgradeInsecure' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.iotools.cloud/v1/tool/csp-generator"
payload := strings.NewReader("{\n \"ioDefaultSrc\": \"<string>\",\n \"ioScriptSrc\": \"<string>\",\n \"ioStyleSrc\": \"<string>\",\n \"ioImgSrc\": \"<string>\",\n \"ioFontSrc\": \"<string>\",\n \"ioConnectSrc\": \"<string>\",\n \"ioFrameSrc\": \"<string>\",\n \"ioObjectSrc\": \"<string>\",\n \"ioMediaSrc\": \"<string>\",\n \"ioFrameAncestors\": \"<string>\",\n \"ioBaseUri\": \"<string>\",\n \"ioFormAction\": \"<string>\",\n \"ioUpgradeInsecure\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.iotools.cloud/v1/tool/csp-generator")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ioDefaultSrc\": \"<string>\",\n \"ioScriptSrc\": \"<string>\",\n \"ioStyleSrc\": \"<string>\",\n \"ioImgSrc\": \"<string>\",\n \"ioFontSrc\": \"<string>\",\n \"ioConnectSrc\": \"<string>\",\n \"ioFrameSrc\": \"<string>\",\n \"ioObjectSrc\": \"<string>\",\n \"ioMediaSrc\": \"<string>\",\n \"ioFrameAncestors\": \"<string>\",\n \"ioBaseUri\": \"<string>\",\n \"ioFormAction\": \"<string>\",\n \"ioUpgradeInsecure\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.iotools.cloud/v1/tool/csp-generator")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ioDefaultSrc\": \"<string>\",\n \"ioScriptSrc\": \"<string>\",\n \"ioStyleSrc\": \"<string>\",\n \"ioImgSrc\": \"<string>\",\n \"ioFontSrc\": \"<string>\",\n \"ioConnectSrc\": \"<string>\",\n \"ioFrameSrc\": \"<string>\",\n \"ioObjectSrc\": \"<string>\",\n \"ioMediaSrc\": \"<string>\",\n \"ioFrameAncestors\": \"<string>\",\n \"ioBaseUri\": \"<string>\",\n \"ioFormAction\": \"<string>\",\n \"ioUpgradeInsecure\": true\n}"
response = http.request(request)
puts response.read_body{
"tool": "<string>",
"tool_version": "<string>",
"outputs": {
"ioCspHeader": "<string>",
"ioMetaTag": "<string>"
},
"credits_used": 123,
"request_id": "<string>",
"credits_remaining": 123
}{
"type": "https://iotools.cloud/docs/errors/validation_error",
"title": "Invalid request",
"status": 400,
"code": "validation_error",
"detail": "One or more inputs are invalid — see `fields`.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/invalid_api_key",
"title": "Invalid API key",
"status": 401,
"code": "invalid_api_key",
"detail": "Provide 'Authorization: Bearer <key>'.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/insufficient_credits",
"title": "Insufficient credits",
"status": 402,
"code": "insufficient_credits",
"detail": "This call costs 1 credit and 0 remain in this month's allowance.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/tool_not_allowed",
"title": "Tool not available over the API",
"status": 403,
"code": "tool_not_allowed",
"detail": "\"Background Remover\" is available on iotools.cloud but has no API endpoint.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/tool_not_found",
"title": "Tool not found",
"status": 404,
"code": "tool_not_found",
"detail": "No tool with that slug. See GET /v1/tools.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/payload_too_large",
"title": "Payload too large",
"status": 413,
"code": "payload_too_large",
"detail": "Request body exceeds this tool's size limit.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/rate_limited",
"title": "Rate limit exceeded",
"status": 429,
"code": "rate_limited",
"detail": "Too many requests. Retry in 30s.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/processing_error",
"title": "Tool failed to run",
"status": 500,
"code": "processing_error",
"detail": "The tool failed to run. Please try again.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/tool_disabled",
"title": "Tool temporarily disabled",
"status": 503,
"code": "tool_disabled",
"detail": "This tool is temporarily unavailable. Try again shortly.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}Generators
CSP Generator
Build a Content-Security-Policy header value from structured directive fields (default-src, script-src, style-src, img-src and more) plus a ready-to-paste HTML meta tag.
POST
/
v1
/
tool
/
csp-generator
CSP Generator
curl --request POST \
--url https://api.iotools.cloud/v1/tool/csp-generator \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ioDefaultSrc": "<string>",
"ioScriptSrc": "<string>",
"ioStyleSrc": "<string>",
"ioImgSrc": "<string>",
"ioFontSrc": "<string>",
"ioConnectSrc": "<string>",
"ioFrameSrc": "<string>",
"ioObjectSrc": "<string>",
"ioMediaSrc": "<string>",
"ioFrameAncestors": "<string>",
"ioBaseUri": "<string>",
"ioFormAction": "<string>",
"ioUpgradeInsecure": true
}
'import requests
url = "https://api.iotools.cloud/v1/tool/csp-generator"
payload = {
"ioDefaultSrc": "<string>",
"ioScriptSrc": "<string>",
"ioStyleSrc": "<string>",
"ioImgSrc": "<string>",
"ioFontSrc": "<string>",
"ioConnectSrc": "<string>",
"ioFrameSrc": "<string>",
"ioObjectSrc": "<string>",
"ioMediaSrc": "<string>",
"ioFrameAncestors": "<string>",
"ioBaseUri": "<string>",
"ioFormAction": "<string>",
"ioUpgradeInsecure": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ioDefaultSrc: '<string>',
ioScriptSrc: '<string>',
ioStyleSrc: '<string>',
ioImgSrc: '<string>',
ioFontSrc: '<string>',
ioConnectSrc: '<string>',
ioFrameSrc: '<string>',
ioObjectSrc: '<string>',
ioMediaSrc: '<string>',
ioFrameAncestors: '<string>',
ioBaseUri: '<string>',
ioFormAction: '<string>',
ioUpgradeInsecure: true
})
};
fetch('https://api.iotools.cloud/v1/tool/csp-generator', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.iotools.cloud/v1/tool/csp-generator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ioDefaultSrc' => '<string>',
'ioScriptSrc' => '<string>',
'ioStyleSrc' => '<string>',
'ioImgSrc' => '<string>',
'ioFontSrc' => '<string>',
'ioConnectSrc' => '<string>',
'ioFrameSrc' => '<string>',
'ioObjectSrc' => '<string>',
'ioMediaSrc' => '<string>',
'ioFrameAncestors' => '<string>',
'ioBaseUri' => '<string>',
'ioFormAction' => '<string>',
'ioUpgradeInsecure' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.iotools.cloud/v1/tool/csp-generator"
payload := strings.NewReader("{\n \"ioDefaultSrc\": \"<string>\",\n \"ioScriptSrc\": \"<string>\",\n \"ioStyleSrc\": \"<string>\",\n \"ioImgSrc\": \"<string>\",\n \"ioFontSrc\": \"<string>\",\n \"ioConnectSrc\": \"<string>\",\n \"ioFrameSrc\": \"<string>\",\n \"ioObjectSrc\": \"<string>\",\n \"ioMediaSrc\": \"<string>\",\n \"ioFrameAncestors\": \"<string>\",\n \"ioBaseUri\": \"<string>\",\n \"ioFormAction\": \"<string>\",\n \"ioUpgradeInsecure\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.iotools.cloud/v1/tool/csp-generator")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ioDefaultSrc\": \"<string>\",\n \"ioScriptSrc\": \"<string>\",\n \"ioStyleSrc\": \"<string>\",\n \"ioImgSrc\": \"<string>\",\n \"ioFontSrc\": \"<string>\",\n \"ioConnectSrc\": \"<string>\",\n \"ioFrameSrc\": \"<string>\",\n \"ioObjectSrc\": \"<string>\",\n \"ioMediaSrc\": \"<string>\",\n \"ioFrameAncestors\": \"<string>\",\n \"ioBaseUri\": \"<string>\",\n \"ioFormAction\": \"<string>\",\n \"ioUpgradeInsecure\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.iotools.cloud/v1/tool/csp-generator")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ioDefaultSrc\": \"<string>\",\n \"ioScriptSrc\": \"<string>\",\n \"ioStyleSrc\": \"<string>\",\n \"ioImgSrc\": \"<string>\",\n \"ioFontSrc\": \"<string>\",\n \"ioConnectSrc\": \"<string>\",\n \"ioFrameSrc\": \"<string>\",\n \"ioObjectSrc\": \"<string>\",\n \"ioMediaSrc\": \"<string>\",\n \"ioFrameAncestors\": \"<string>\",\n \"ioBaseUri\": \"<string>\",\n \"ioFormAction\": \"<string>\",\n \"ioUpgradeInsecure\": true\n}"
response = http.request(request)
puts response.read_body{
"tool": "<string>",
"tool_version": "<string>",
"outputs": {
"ioCspHeader": "<string>",
"ioMetaTag": "<string>"
},
"credits_used": 123,
"request_id": "<string>",
"credits_remaining": 123
}{
"type": "https://iotools.cloud/docs/errors/validation_error",
"title": "Invalid request",
"status": 400,
"code": "validation_error",
"detail": "One or more inputs are invalid — see `fields`.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/invalid_api_key",
"title": "Invalid API key",
"status": 401,
"code": "invalid_api_key",
"detail": "Provide 'Authorization: Bearer <key>'.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/insufficient_credits",
"title": "Insufficient credits",
"status": 402,
"code": "insufficient_credits",
"detail": "This call costs 1 credit and 0 remain in this month's allowance.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/tool_not_allowed",
"title": "Tool not available over the API",
"status": 403,
"code": "tool_not_allowed",
"detail": "\"Background Remover\" is available on iotools.cloud but has no API endpoint.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/tool_not_found",
"title": "Tool not found",
"status": 404,
"code": "tool_not_found",
"detail": "No tool with that slug. See GET /v1/tools.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/payload_too_large",
"title": "Payload too large",
"status": 413,
"code": "payload_too_large",
"detail": "Request body exceeds this tool's size limit.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/rate_limited",
"title": "Rate limit exceeded",
"status": 429,
"code": "rate_limited",
"detail": "Too many requests. Retry in 30s.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/processing_error",
"title": "Tool failed to run",
"status": 500,
"code": "processing_error",
"detail": "The tool failed to run. Please try again.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}{
"type": "https://iotools.cloud/docs/errors/tool_disabled",
"title": "Tool temporarily disabled",
"status": 503,
"code": "tool_disabled",
"detail": "This tool is temporarily unavailable. Try again shortly.",
"request_id": "e4042b29-8f1e-4c7a-9b52-6f0d1a3c7e11"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
default-src
script-src
style-src
img-src
font-src
connect-src
frame-src
object-src
media-src
frame-ancestors
base-uri
form-action
upgrade-insecure-requests
Response
Tool output
Output-contract version for this tool. Currently "1" for all tools.
Show child attributes
Show child attributes
Credits this call consumed, after any settlement refund. 0 when metering is disabled.
Credits left in the current monthly allowance, or null when metering is disabled.
Was this page helpful?
⌘I