Skip to main content

Introduction

  • This guide assumes you have an approved bot on top.gg and are using either Node.js or Python for your project.
  • Next, you will need to create an account on Square Cloud, which can be done through the sign up page. You can use your email to create an account.
  • Finally, you need to have an active plan on your account. Compare the available plans and choose one according to your needs.

Setting up the environment

  1. Before you begin, make sure you have Node.js and npm installed on your system. If you don’t have them yet, you can download them from the official Node.js website.
  2. Start a new Node.js project and enable the import syntax with the following commands:
Terminal
These commands create a package.json file in the current directory.
  1. Install Express:
Terminal

Setting up the project

1. Get your webhook secret:
  • Choose the subdomain your application will use on Square Cloud (the SUBDOMAIN field of your configuration file), for example mysite. Your webhook URL will then be https://mysite.squareweb.app/topgg.
  • On Top.gg, open your project’s dashboard and go to Webhooks.
  • Paste the webhook URL and save. Top.gg then generates a webhook secret that starts with whs_: copy it and keep it private. Your code reads it from the TOPGG_WEBHOOK_SECRET environment variable.
Top.gg signs every request with the x-topgg-signature header, in the format t=<timestamp>,v1=<signature>, where the signature is an HMAC SHA-256 of <timestamp>.<raw body> made with your secret. The code below recomputes it and rejects any request that doesn’t match, so nobody else can send fake votes to your URL. See the Top.gg webhook documentation for details.
This guide uses Top.gg v1 webhooks. The legacy v0 webhook, which sends a password in the Authorization header with a different payload, is not covered here.
2. Implement the webhook listener: The following sections provide code examples for both JavaScript and Python:
The example verifies the signature with Node’s built-in crypto module, so no Top.gg package is needed. The Webhook class of @top-gg/sdk 4.0.0 is not used: in our tests, its listener answered valid deliveries with a timeout error, which makes Top.gg retry them.
index.js

Creating the squarecloud config file

Create a squarecloud.app file in your project folder. Set SUBDOMAIN to the subdomain you chose in step 1:
SUBDOMAIN publishes the listener at https://mysite.squareweb.app, and web applications need at least MEMORY=512. The code listens on the port in the PORT environment variable, which Square Cloud sets to 80, and on host 0.0.0.0.

Learn about: how to make the configuration file for Square Cloud.

The squarecloud.app file is a configuration file that will be used to configure your application; it will be used to define the name, description, version, main file, among other things.

Uploading your application to Square Cloud

After following all the steps, your project folder should contain your code, its dependency file (package.json or requirements.txt) and the configuration file. To upload from the dashboard, put them into a .zip file. If your application is a Node.js project, take a look at our article on Node.js. If your application is a Python project, take a look at our article on Python.

Via dashboard

1

Access the Upload Page

Access the upload page and upload your project zip file.
2

Configure Your Environment

After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.
If you are uploading a web project, make sure to select “Web Publication” and set a subdomain to your project.
3

Deploy Your Project

Finally, click on the “Deploy” button to host your project on Square Cloud.
After deployment, you can monitor your project’s status and logs from the dashboard.
Uploading application to Square Cloud
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. In the dashboard, wait for your application status to show as running and check the logs for any startup errors.
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Via CLI

To use this method, your project needs a configuration file named squarecloud.app at its root. It tells Square Cloud how to run your application.

Configuration file guide

Learn how to create the squarecloud.app configuration file that defines your application’s environment.
1

Install the CLI

Install the Square Cloud CLI. If you already have it, run the same command to update it:
2

Log In

Run the command below. It opens your browser: approve the login there and the CLI is ready. There is no API key to copy. For scripts and CI, see CLI authentication.
3

Upload Your Project

From your project folder, run the command below. The CLI zips the current folder, leaving out what squarecloud.ignore lists, and uploads it:
To upload a zip you created yourself, pass it with --file:
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. Check your application status and logs directly from the terminal:
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Setting the webhook secret

Add your whs_ secret as the TOPGG_WEBHOOK_SECRET environment variable of your application, in one of these ways:
  • Dashboard: on the upload page, open Advanced configuration and add the variable before you deploy. For an application that is already deployed, add it on its Environment Variables page.
  • CLI: from your project folder, set it with squarecloud app env set and restart the application:
The application reads environment variables when it starts, so restart it after every change. Until the secret is set, the code rejects every request with 401 Unauthorized. See Environment variables for the other ways to manage them.

Starting tests

If you have done everything correctly, open https://mysite.squareweb.app/topgg in your browser (replace mysite with your subdomain). If “Cannot GET /topgg” (Node.js) or “Method Not Allowed” (Python) appears, everything is okay: the route only accepts the POST requests Top.gg sends.
  • For the JavaScript code we created with app.post("/topgg", ...), the route that will receive the votes is “/topgg”. So, if your website is mysite.squareweb.app, the Webhook URL is https://mysite.squareweb.app/topgg.
  • For the Python code we created with @app.route("/topgg", methods=["POST"]), the route that will receive the votes is also “/topgg”. So, the Webhook URL is the same https://mysite.squareweb.app/topgg.
Finally, go back to your project’s Webhooks page on Top.gg and click on the “Send Test” button. After that, check your application’s logs. If everything went well, the message you defined in console.log or print should appear in the logs.
Top.gg webhook send test example
And with that, if everything has been configured correctly, your webhook will be ready to send notifications when your bot receives a vote on top.gg.

Troubleshooting

Custom domain

To use a custom domain (e.g., mysite.com) instead of the default URL mysite.squareweb.app, you need the Standard plan or higher. The default URL comes from the SUBDOMAIN field in the configuration file. To connect your domain, follow how to set up your own domain.

Minimum RAM requirements

Minimum: 512MB RAM for websites and APIs, enough for a static build on the static runtime. For apps that render pages on a server (Next.js, Nuxt, Angular SSR and similar), we recommend at least 1GB RAM. For larger applications, allocate more RAM to prevent the application from running out of memory and crashing.

Could not find this site.

Check if the subdomain/domain matches what’s configured in the SUBDOMAIN field or in the custom domain settings. If you just uploaded the site, wait up to 60 seconds for Square to enable first access.

Site took too long to respond…

Your server must listen on port 80 and host 0.0.0.0. Square Cloud sets the PORT (80) and HOST (0.0.0.0) environment variables in your application: read them in your code instead of hardcoding other values. A server that listens only on localhost or 127.0.0.1 never receives requests.

Next steps

Discord bot

Host the bot that receives the votes.

Environment variables

Manage your webhook secret and other secrets.

App won't start

Fix port conflicts, missing modules and other startup failures.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.