Snippets

  • Delete snippet

  • Retrieve snippet

  • Upsert snippet

Development
  • Guides
  • API Reference
  • API Explorer
  • SDKs
  • Sample apps
  • System status
Support
  • Developer forums
  • Developer blog
  • YouTube
  • X
More
  • Square Home
  • Square Developer
  • App Marketplace
  • Partner with Square
  • Solutions Partner Program
  • Pricing
  • Sales

© 2026 Square, Inc.

  • Developer terms of service
  • Developer Integration and Marketing Agreement
  • Privacy policy
  • Partnerships
  • Sign In
  • Sign In

<- Snippets API

Snippets API

All versions ->

Upsert snippet

POST

 /v2/sites/{site_id}/snippet

Adds a snippet to a Square Online site or updates the existing snippet on the site.

The snippet code is appended to the end of the head element on every page of the site, except checkout pages. A snippet application can add one snippet to a given site.

You can call ListSites to get the IDs of the sites that belong to a seller.

Note: Square Online APIs are publicly available as part of an early access program. For more information, see Early access program for Square Online APIs.

Permissions:ONLINE_STORE_SNIPPETS_WRITE

Guide

Add or update a snippet

Try in API Explorer
Link to section

Path parameters

Example code

Link to section

site_id

string

Required

The ID of the site where you want to add or update the snippet.

Link to section

Request body

Link to section

snippet

Required

The snippet for the site.

Link to section

Response fields

Link to section

errors

Any errors that occurred during the request.

Link to section

snippet

The new or updated snippet.

Link to section

Examples

All versions ->

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

Response JSON

{ "snippet": { "id": "snippet_5d178150-a6c0-11eb-a9f1-437e6a2881e7", "site_id": "site_278075276488921835", "content": "<script>var js = 1;</script>", "created_at": "2021-03-11T25:40:09.000000Z", "updated_at": "2021-03-11T25:40:09.000000Z" } }