API Reference
POSTupload-varnish-vcl

Upload 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

POSThttps://api.sharkcluster.com/upload-varnish-vcl

How do you call Upload Varnish VCL?

  1. 1Get a token from the login endpoint (POST /login) and send it as Authorization: Bearer <token>. See Login.
  2. 2Send a POST request to https://api.sharkcluster.com/upload-varnish-vcl.
  3. 3Include the required parameters: server_id and vcl_content.
  4. 4Add the optional parameter only if you need it: config.

Request parameters

ParameterTypeDescription
server_id
Required
stringThe unique identifier or Instance ID of the server.
configobjectOptional metadata about the configuration (ports, status, etc.).
vcl_content
Required
stringThe 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');

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.

Contact us