Snippets API: The first API for Square Online

Snippets API: The first API for Square Online

Insert code directly into the <head> tag of a Square Online site

Thousands of sellers are signing up to create websites every day on Square Online. The transition to selling online and developing an omnichannel strategy is top of mind for most entrepreneurs. As they set up their sites and build their online presence, these business owners are looking for features to add on to their sites and increase sales.

We announced Snippets API, the first API for Square Online, at Unboxed. This API enables developers to add code directly to the <head> tag of a seller’s website. Whether Javascript, HTML, or CSS, developers can add on features such as popups, chatbots for support, or improve SEO.

How Snippets API works

Once a seller has completed the OAuth process, you will need to first call the Sites API to retrieve a list of available sites to install your app. Once you have the site that the app will be installed on, simply POST the snippet of code to their website.

curl -X POST \
  https://connect.squareup.com/v2/sites/{site_id}/snippet \
  -H 'Authorization: Bearer {ACCESS_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{
    "snippet": {
      "content": "<script type=\"text/javascript\">var js = 1;</script>"
    }
  }'

Early Access Program

We are releasing Snippets API as an early-access program. We want to work with developers to ensure we are able to quickly improve the developer experience as needed, since the needs of developers creating apps for Square Online may be different than other integrations.

Snippets API is available to all developers in the United States, Canada, United Kingdom, Australia, and Japan. You can start using the APIs today without an application process, and we encourage developers to share their feedback on the current feature set by posting on our Square Developer Forums or Slack. Check out the documentation to learn how to get started and access API reference docs.

To stay up to date with the rest of our content, be sure to follow us here, on Twitter, and sign up for our developer newsletter. We also have a developer community for connecting with and talking to other developers implementing Square APIs.

Table Of Contents
View More Articles ›