Create Site Page

POST /v2/sites/{site_id}/pages

Creates a page for a Square Online site. This operation creates a .json file under pages in the site directory of the site.

Permissions: ONLINE_STORE_CUSTOM_THEME_WRITE

Path parameters

Name Type Description
site_id string Required The ID of the site.

Request body

Name Type Description
idempotency_key string A unique identifier for this request, used to ensure idempotency. For more information, see Idempotency.
page SitePage Details about the page to create. The following fields are required: name, route, and properties.

Response fields

Name Type Description
errors Error [ ] Any errors that occurred during the request.
page SitePage The new page.

Example request

curl https://connect.squareup.com/v2/sites/site_id0/pages \
  -X POST \
  -H 'Square-Version: 2023-09-25' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "UNIQUE_STRING",
    "page": {
      "properties" : "{\"layout\": \"layouts/brisk\", \"template\": \"templates/pages/home\"}",
      "route" : "lightning-home",
      "name" : "Home"
    }
  }'

Example response

{
  "page": {
    "id": "site_page_7e4e68a8-fde2-11ee-be56-0242ac120002",
    "name": "Home",
    "route": "lightning-home",
    "properties": "{\"layout\": \"layouts/brisk\", \"template\": \"templates/pages/home\"}",
    "site_id": "site_278075276488921835",
    "created_at": "2023-11-06T10:01:42.000000Z",
    "updated_at": "2023-11-06T10:01:42.000000Z"
  }
}