Showing posts with label Tricks. Show all posts

How to Bulk Add DNS Records in Squarespace Using the Browser Console

Note: This article was heavily assisted by AI. The underlying technique, testing, and implementation were done by me; I used Claude to help refine the process and turn my notes into a cleaner write-up.

Squarespace’s DNS interface works well when you only need to add a few records. But when you have dozens of CNAME and MX records to enter, adding them one at a time through the UI becomes slow very quickly.

A much faster approach is to call the same internal DNS endpoint that Squarespace’s own interface uses, directly from the browser console. The request still runs through your authenticated Squarespace session, so you are not bypassing account permissions—you are simply avoiding the repetitive one-record-at-a-time UI.

How it works

First, log into Squarespace and open the DNS settings for the domain you want to update.

Open your browser’s DevTools and switch to the Network tab. Then manually add a single DNS record through the normal Squarespace interface.

Look for a request similar to this:

POST /api/account/1/domains/{DOMAIN_ID}/dns/v2/dns-bulk-changes

The important part is the {DOMAIN_ID} in the request URL. This ID is unique to the domain, so do not reuse one from another domain or account.

You will also need the CSRF token from the request headers. You can find it in the cookies using the Google Chrome Dev Tools, it may be called "crumb"



Once you have both values, you can use the following helper function from the DevTools Console:

const CSRF_TOKEN = "PASTE_YOUR_TOKEN_HERE";

async function addDnsRecords(records) {
    const res = await fetch(
        "https://account.squarespace.com/api/account/1/domains/{DOMAIN_ID}/dns/v2/dns-bulk-changes",
        {
            headers: {
                "accept": "application/json",
                "content-type": "application/json",
                "x-csrf-token": CSRF_TOKEN
            },
            body: JSON.stringify({
                recordsToAdd: records,
                recordsToRemove: [],
                presetsToAdd: [],
                presetsToRemove: []
            }),
            method: "POST",
            credentials: "include"
        }
    );

    const json = await res.json().catch(() => null);

    console.log({
        status: res.status,
        ok: res.ok,
        response: json
    });

    return {
        status: res.status,
        ok: res.ok,
        response: json
    };
}

Replace {DOMAIN_ID} with the actual domain ID you captured from the Network request.

Adding multiple DNS records

Once the helper function is loaded, you can submit multiple records in a single request:

await addDnsRecords([
    {
        type: "CNAME",
        domainName: "example.com",
        subdomain: "em1234.location",
        ttl: 14400,
        hostname: "example.sendgrid.net",
        priority: ""
    },
    {
        type: "MX",
        domainName: "example.com",
        subdomain: "location",
        ttl: 14400,
        hostname: "mx.sendgrid.net",
        priority: "10"
    }
]);

Also on Github Gists:

A few important details

The subdomain value should contain only the hostname portion before the main domain.

For example:

em1234.location.example.com

becomes:

em1234.location

For MX records, Squarespace expects the priority as a string:

priority: "10"

For CNAME records, the priority can remain empty:

priority: ""

The ttl value is specified in seconds. For example:

14400 = 4 hours
3600  = 1 hour
1800  = 30 minutes

Use smaller batches

Even though the endpoint can accept multiple records at once, I would not recommend pushing a very large DNS change in one request.

For larger jobs, batches of roughly 10–15 records work well. Smaller batches make it easier to verify each change and reduce the impact if there is a typo or an issue in the source data.

Also keep these arrays empty unless you specifically intend to modify or remove something:

recordsToRemove: [],
presetsToAdd: [],
presetsToRemove: []

That way, each request is limited to adding the records you explicitly provide.

Verify everything

Before making any changes, take a snapshot or export of the existing DNS records.

After each batch, inspect the API response and confirm that the records you submitted appear with the correct:

  • Record type
  • Subdomain
  • Target / hostname
  • MX priority
  • TTL

Once all batches are complete, compare the final DNS state against both your original spreadsheet and your pre-change DNS snapshot.

Why this is useful

I used this method on a project that required 92 DNS records across 23 locations.

Doing that through Squarespace’s standard Add Record interface would have meant repeating the same sequence 92 times. Using the bulk endpoint allowed the records to be normalized, reviewed, submitted in manageable batches, and verified after each request.

This approach does not bypass Squarespace authentication, permissions, or 2FA. The request runs using the browser session you are already authenticated with and calls the same backend endpoint used by Squarespace itself.

For large DNS migrations, SendGrid setups, email-authentication rollouts, or similar projects, this can turn a very repetitive task into a much more manageable workflow.

Trouble Adding AdSense Code for Page-Level Ads? Learn how to fix it.

In order to add the Page-Level ads functionality from AdSense on your Blogger blog you are required to place a code that AdSense provides which is :

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"/>

Unfortunately if you have tried placing the code in your theme you may have run into this error that states:

Error parsing XML, line n, column n: Attribute name "async" associated with an element type "script" must be followed by the ' = ' character.


Inviting All Friends to Facebook Page at Once JavaScript Snippet

Facebook is a great tool for connecting with the World but one of the problem is that the population on Facebook is very big and so sometimes we feel the need of a "do all" function in most places such as inviting your friends on your new page.

It can be a hefty job clicking on thousands of "Invite" buttons one after one since Facebook doesn't give you an "Invite all" button. Same used to be true for Group requests but fortunately it now does, but as for Facebook page invites you still have to do the manual way.

Fix Blogger Tracking Your Pageviews

Your blog's quick stats on the dashboard reflects the number of page views your blog received in a given time window, the stats can be inaccurate as it might also be counting your own pageviews.

Blogger does provide an option to stop tracking your pageview, though it doesn't work properly for many Blogger users.

Confirm Friend Request on Facebook All At Once

Popular on Facebook? So you have got 100s of friend requests pending on your Facebook profile, confirming them one by one can be a pain. This small block of JavaScript code can save you time and energy.

Easiest Way To Use WhatsApp on PC

Using WhatsApp on PC has been really a hot topic, one obvious answer is to use an Android emulator and then use WhatsApp, but it has its own difficulties. I will show an easy way to use WhatsApp on PC or even Mac.

Fun With The Developer Console: Styling Console Output

This post is for people who are familiar with the Webkit JavaScript console you find in Chrome and Safari browser. Did you know you can do a lot more with the console than just logging output ?

Encrypt Your Personal Details with JavaScript

When you have a lot of online accounts to handle and don't have enough time to memorize all the passwords it becomes an annoying problem. What if you could save your passwords and other details in a simple text file on your PC ?

Sinhala Font in Blogger

Bloggers in different country needs different fonts that supports their language, most of them are already in the computer but when you are talking about some forgotten languages then you hardly get it on computers, then you need to get a font for it on your web page and so in Blogger.

Speed up our blog by hosting CSS files externally

Nowadays, blogs and websites are ranked on basis of various factors and page load speed is also one of the factor on which your search rank depends.

Remove default share buttons from Dynamic Views Blogger

Dynamic views is now used by many people. But everyone don't want every feature of Dynamic views and e the share buttons are a feature that many Blogger users asked me how to remove it, this tutorial is specially for them.

Add 'Read Previous post' link at bottom of Posts in Blogger

If you have a well structured blog with links to right things at right places then your chances of getting more readers increases and that's what any blogger wants. This tutorial shows you how to add an good looking link to previous post at bottom of every post automatically.

Create Google like Scroll bar in blogger blog

If you look back at Google web pages back in mid 2011, they were simple just like a classic web page like other pages but 2012 seems to be a design year and that's why each and every big company painted their web pages with dynamic looks and features. One of the extraordinary thing about Google is it's scroll bars, they are just awesome and anyone wants to implement it, this tutorial will show you how to do that.

Embed Slideshow in blog post from Picasa

Many Blogger users wanted to use a slideshow technique in Blogger, but they don't have the idea to do it. This tutorial will tell you an easy and working way to put slideshow into post.

Hover effect on images in posts - Blogger

This is an easy trick but an amazing one too, bring the photos in your post to life with this hover effect trick.

Show/Hide effect for Gadgets in Blogger with JQuery

Don't you sometime feel like adding more dynamics to your blog and make it more user friendly, like giving them their own control like toggling show/hide of a gadget. You will learn how to do that in Blogger.

Adding any thing under every post

Bloggers with less experience with some advance feature of HTML and Blogger will always end up adding 'Thank for reading this post' under every blog they post, but there is much easier way to add any thing, from normal text to good looking HTML elements below the post.

Disable users from selecting text and images on blog/website

Bloggers using tricks to disable right click are benefited in ways. They may have surely get red of their content being copied.

Disable right click without using JavaScripts

Disabling right click on websites and blogs are very popular nowadays just to ensure that no one can copy content from their website.

Under line gadgets title in Blogger

You can see how i have underlined my gadget's title to make it look different from rest of the widget content and it is a good way to keep your blog user interface easy.