Code Cookbook

Create a Catalog Image

Upload an image file to use with catalog objects.

Catalog API

Before you start

  • The CreateCatalogImage endpoint does not have SDK support. It is REST only.
  • Your image must be in JPEG, PJPEG, PNG, or GIF format.

Create a catalog image

To create a catalog image, send a request to the CreateCatalogImage endpoint with the local path of the image file and a unique idempotency key.

Optionally, you can also add a caption to the image_data field and an object_id to identify the CatalogObject the image should be attached to. You can also create the image without specifying an object_id and attach it to a CatalogObject at a later time.

For example:

curl -v -X POST \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'Cache-Control: no-cache' \
-H 'Square-Version:  2019-03-27' \
-F 'file=@/local/path/to/Coffee.jpg' \
-F 'request=
{
    "idempotency_key":"{UNIQUE_STRING}",
    "object_id":"{ITEM_ID}",
    "image":{
        "id":"#TEMP_ID",
        "type":"IMAGE",
        "image_data":{
            "caption":"A picture of a cup of coffee"
        }
    }
}' \
'https://connect.squareupstaging.com/v2/catalog/images'

The CreateCatalogImage endpoint returns a CatalogImage object which includes the image, data on the image, and a URL to the image generated by Square.

Contact Developer Support, join our Slack channel, or ask for help on Stack Overflow