> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Upsert Snippet

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

`square.upsertSnippet` adds a snippet to a Square Online site or updates the existing snippet on the site.

## Example

```ts automations/square-upsert-snippet.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Upsert Square Snippet", () => {
  onDashboardRun({ title: "Upsert Square Snippet" })

  square.upsertSnippet({
    siteId: "site_id",
    snippet: {
      content: "<script>var js = 1;</script>",
    },
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `ONLINE_STORE_SNIPPETS_WRITE`.

| Field     | Type             | Required | Default | Description                                                     |
| --------- | ---------------- | -------- | ------- | --------------------------------------------------------------- |
| `siteId`  | `string`         | Yes      | —       | The ID of the site where you want to add or update the snippet. |
| `snippet` | `Square.Snippet` | Yes      | —       | The snippet for the site.                                       |

Use the official [UpsertSnippet reference](https://developer.squareup.com/reference/square/snippets-api/upsert-snippet) for provider field semantics and limits.

## Output

Returns the official `Square.UpsertSnippetResponse` response as a codec-safe object. Square integer money amounts remain `bigint` values.
