API Reference
POST
upload-varnish-vclUpload Varnish VCL
Upload Varnish VCL is a POST request to https://api.sharkcluster.com/upload-varnish-vcl in the Server Management section of the SharkCluster API. Uploads a custom VCL file. Includes an automatic syntax check and rollback mechanism; if the new VCL is invalid, it restores the previous backup. It takes 3 parameters, 2 required (server_id and vcl_content).
Request URL
POST
https://api.sharkcluster.com/upload-varnish-vclHow do you call Upload Varnish VCL?
- 1Get a token from the login endpoint (POST /login) and send it as Authorization: Bearer <token>. See Login.
- 2Send a POST request to https://api.sharkcluster.com/upload-varnish-vcl.
- 3Include the required parameters: server_id and vcl_content.
- 4Add the optional parameter only if you need it: config.
Request parameters
| Parameter | Type | Description |
|---|---|---|
server_idRequired | string | The unique identifier or Instance ID of the server. |
config | object | Optional metadata about the configuration (ports, status, etc.). |
vcl_contentRequired | string | The full VCL code content to be uploaded to /etc/varnish/default.vcl. |
What does Upload Varnish VCL return?
A failed call explains the problem in the body, for example "VCL syntax error: /etc/varnish/default.vcl line 12...".
Request sample
const axios = require('axios');
async function uploadVarnishVcl(serverId, vclContent, token) {
try {
const payload = {
server_id: serverId,
vcl_content: vclContent, // Full VCL content string
config: {
status: "Stopped",
vcl_path: "/etc/varnish/default.vcl",
admin_port: "6082",
cache_size: "256m",
backend_host: "127.0.0.1",
backend_port: "8080",
listen_port: "6081",
purge_acl_enabled: "false",
server_type: "nginx"
}
};
const response = await axios.post('https://api.sharkcluster.com/upload-varnish-vcl', payload, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
console.log('Success:', response.data.message);
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
// Example usage
const myVclContent = `vcl 4.0;
backend default {
.host = "127.0.0.1";
.port = "8080";
}`;
uploadVarnishVcl('00000000-0000-4000-8000-000000000008', myVclContent, 'your_auth_token');
Related Server Management endpoints
- POST
get-varnish-vclGet Varnish VCL - POST
configure-varnishConfigure Varnish - POST
varnish-logsGet Varnish Logs - GET
get_server_monitoring_settings/:serverIdGet Server Monitoring Settings - PUT
update_server_monitoring_settings/:serverIdUpdate Server Monitoring Settings - GET
get_server_other_services_config/:serverIdGet Server Other Services Config
Stuck on an integration?
Raise a ticket from the panel with the endpoint and the response you got back — it reaches an engineer with your server already attached.