Asset

Assets are individual files that make up a shop's theme.

Asset

Assets can be any additional file; from images and stylesheets to extra snippets of code. Assets can be easily added, changed or removed from a shop's theme.

What can you do with Asset?

The Shopify API lets you do the following with the Asset resource. More detailed versions of these general actions may be available:

Asset Properties

attachment
{ "attachment" : "R0lGODlhAQABAPABAP///wAAACH5Ow==
" }

An asset attached to a store's theme.

content_type
{ "content_type" : "image/gif" }

MIME representation of the content, consisting of the type and subtype of the asset.

created_at
{ "created_at" : "2010-07-12T15:31:50-04:00" }

The date and time when the asset was created. The API returns this value in ISO 8601 format.

key
{ "key" : "assets/bg-body-green.gif" }

The path to the asset within a shop. For example, the asset bg-body-green.gif is located in the assets folder.

public_url
{ "public_url" : "http://static.shopify.com/assets/bg.gif?1" }

The public facing URL of the asset.

size
{ "size" : 1542 }

The asset size in bytes.

source_key
{ "source_key" : "layout/theme.liquid" }

The source key copies an asset.

src
{ "src" : "http://apple.com/new_bg.gif" }

Specifies the location of an asset.

theme_id
{ "theme_id" : 828155753 }

A unique numeric identifier for the theme.

updated_at
{ "updated_at" : "2010-07-12T15:31:50-04:00" }

The date and time when an asset was last updated. The API returns this value in ISO 8601 format.

value
{ "value" : "<img src='backsoon-postit.png'>" }

The asset that you are adding.

Endpoints

GET/admin/themes/828155753/assets.json

Listing theme assets only returns metadata about each asset. You need to request assets individually in order to get their contents.

fields

comma-separated list of fields to include in the response

Get a list of all theme assets

GET /admin/themes/#{id}/assets.json
View Response
HTTP/1.1 200 OK
{
  "assets": [
    {
      "key": "assets\/bg-body-green.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-body-green.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 1542,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-body-orange.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-body-orange.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 1548,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-body-pink.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-body-pink.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 1562,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-body.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-body.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 1571,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-content.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-content.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 134,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-footer.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-footer.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 1434,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-main.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-main.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 297,
      "theme_id": 828155753
    },
    {
      "key": "assets\/bg-sidebar.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-sidebar.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 124,
      "theme_id": 828155753
    },
    {
      "key": "assets\/shop.css",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/shop.css?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/css",
      "size": 14058,
      "theme_id": 828155753
    },
    {
      "key": "assets\/shop.css.liquid",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/shop.css.liquid?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 14675,
      "theme_id": 828155753
    },
    {
      "key": "assets\/shop.js",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/shop.js?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "application\/javascript",
      "size": 348,
      "theme_id": 828155753
    },
    {
      "key": "assets\/sidebar-devider.gif",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/sidebar-devider.gif?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/gif",
      "size": 1016,
      "theme_id": 828155753
    },
    {
      "key": "assets\/sidebar-menu.jpg",
      "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/sidebar-menu.jpg?12441496865301016029",
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "image\/jpeg",
      "size": 1609,
      "theme_id": 828155753
    },
    {
      "key": "config\/settings.html",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/html",
      "size": 4570,
      "theme_id": 828155753
    },
    {
      "key": "layout\/theme.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 3252,
      "theme_id": 828155753
    },
    {
      "key": "templates\/article.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 2486,
      "theme_id": 828155753
    },
    {
      "key": "templates\/blog.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 786,
      "theme_id": 828155753
    },
    {
      "key": "templates\/cart.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 2047,
      "theme_id": 828155753
    },
    {
      "key": "templates\/collection.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 946,
      "theme_id": 828155753
    },
    {
      "key": "templates\/index.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 1068,
      "theme_id": 828155753
    },
    {
      "key": "templates\/page.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 147,
      "theme_id": 828155753
    },
    {
      "key": "templates\/product.liquid",
      "public_url": null,
      "created_at": "2010-07-12T15:31:50-04:00",
      "updated_at": "2010-07-12T15:31:50-04:00",
      "content_type": "text\/x-liquid",
      "size": 2796,
      "theme_id": 828155753
    }
  ]
}
GET/admin/themes/828155753/assets.json

There are different buckets which hold different kinds of assets, each corresponding to one of the folders within a theme's zip file: layout, templates, and assets. The full key of an asset always starts with the bucket name, and the path separator is a forward slash, like layout/theme.liquid or assets/bg-body.gif.

fields

comma-separated list of fields to include in the response

Get a liquid template

GET /admin/themes/#{id}/assets.json?asset[key]=templates/index.liquid&theme_id=828155753
View Response
HTTP/1.1 200 OK
{
  "asset": {
    "key": "templates\/index.liquid",
    "public_url": null,
    "value": "<!-- LIST 3 PER ROW -->\n<h2>Featured Products<\/h2>\n<table id=\"products\" cellspacing=\"0\" cellpadding=\"0\">\n{% tablerow product in collections.frontpage.products cols:3  %}\n   <a href=\"{{product.url}}\">{{ product.featured_image | product_img_url: 'small' | img_tag }}<\/a>\n   <h3><a href=\"{{product.url}}\">{{product.title}}<\/a><\/h3>\n   <ul class=\"attributes\">\n     <li><span class=\"money\">{{product.price_min | money}}<\/span><\/li>\n   <\/ul>\n{% endtablerow %}\n<\/table>\n<!-- \/LIST 3 PER ROW  -->\n\n  <div id=\"articles\">\n  \t{% assign article = pages.frontpage %}\n\n    <div class=\"article\">\n    {% if article.content != \"\" %}\n\t\t  <h3>{{ article.title }}<\/h3>\n      <div class=\"article-body textile\">\n  \t\t  {{ article.content }}\n  \t\t<\/div>\n  \t{% else %}\n      <div class=\"article-body textile\">\n  \t  In <em>Admin &gt; Blogs &amp; Pages<\/em>, create a page with the handle <strong><code>frontpage<\/code><\/strong> and it will show up here.<br \/>\n  \t  {{ \"Learn more about handles\" | link_to \"http:\/\/wiki.shopify.com\/Handle\" }}\n      <\/div>\n  \t{% endif %}\n    <\/div>\n\n  <\/div>\n\n",
    "created_at": "2010-07-12T15:31:50-04:00",
    "updated_at": "2010-07-12T15:31:50-04:00",
    "content_type": "text\/x-liquid",
    "size": 1068,
    "theme_id": 828155753
  }
}

Get a theme image

GET /admin/themes/#{id}/assets.json?asset[key]=assets/bg-body.gif&theme_id=828155753
View Response
HTTP/1.1 200 OK
{
  "asset": {
    "key": "assets\/bg-body.gif",
    "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-body.gif?12339842436141157369",
    "attachment": "R0lGODlhBgCTAPcAAIzH6Xu423y53IO\/4pXP8CAgIJPN75HM7X263YvG6Hq3\n2nq325XP8X+835LM7pDL7YTA45TO8I3I6pLN7oG+4IfD5ZPO75DK7I7J64K+\n4YC94IbC5ITA4onF54rF54C834jD5o\/K7JDL7JHM7nq424XB45TP8JXQ8YC9\n34jE5onE5pTO74K\/4ZbQ8n+73u7u7iQkJDU1NYrF6FpaWsvLy+Xl5VNTU47K\n63y63YnE51dXVzw8PEJCQk5OTkhISITB49TU1CkpKS8vL5HL7X263JXQ8IG+\n4X+83o\/J64XB5Hy43Hy63IbB5IfD5obC5YvH6ZPN7n673Xu43IjD5Y\/K64fC\n5IPA4pbR8o3J6oG94Hu53Hu323273Xq42orG6IfC5X663ZfQ8pLN73663nu5\n25fQ8ZPO8IzI6ovF6Hy53YvH6I7I6o7J6nm32ny524O\/4Y3H6pbR8YzI6X+7\n34XC45fR8oPA44G934fD5H253Y3I63y424K+4Hm42o3I6X273ozG6Y7I64C8\n4IzH6oC734O\/45bQ8JLO7pHL7oS\/4obD5X253InF5pTP8YK94H6735XO8JDK\n7ZTN8JbP8Hm324jE54\/L7IXA44TB5JLM7YO+4YnG54zG6I7J7Hu32oK94YK\/\n4n673pbQ8QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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uecSsQQRRCCAQx44LIED\nETicK4C8eaSBgAD03rvIvWmkIcDABGvhhgBaDKyEGwEkrIQWSkjBsBJkkBGA\nFEoEsMceAQRgsRQkSBEACR13TPICWwSwxckoK9DxAguQEDPKMC\/gCQkKLNBF\nzgq00UcXXfisgAI470xJz0MrUMDSTM\/g9NM6RC21DVRX3cPVWPug9dY8dO31\nDmCHHcPYZAth9tlBpK02DGy3zTTTNMQtNxB0113D3Xi\/oPcD3gEBADs=\n",
    "created_at": "2010-07-12T15:31:50-04:00",
    "updated_at": "2010-07-12T15:31:50-04:00",
    "content_type": "image\/gif",
    "size": 1571,
    "theme_id": 828155753
  }
}
PUT/admin/themes/828155753/assets.json

PUT takes care of both creating new assets and updating existing ones

Change an existing liquid template's value

PUT /admin/themes/#{id}/assets.json
{
  "asset": {
    "key": "templates\/index.liquid",
    "value": "<img src='backsoon-postit.png'><p>We are busy updating the store for you and will be back within the hour.<\/p>"
  }
}
View Response
HTTP/1.1 200 OK
{
  "asset": {
    "key": "templates\/index.liquid",
    "public_url": null,
    "created_at": "2010-07-12T15:31:50-04:00",
    "updated_at": "2015-03-28T13:26:53-04:00",
    "content_type": "text\/x-liquid",
    "size": 110,
    "theme_id": 828155753
  }
}

Create a new image by providing a base64-encoded attachment

PUT /admin/themes/#{id}/assets.json
{
  "asset": {
    "key": "assets\/empty.gif",
    "attachment": "R0lGODlhAQABAPABAP\/\/\/wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"
  }
}
View Response
HTTP/1.1 200 OK
{
  "asset": {
    "key": "assets\/empty.gif",
    "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/empty.gif?4403551604110394662",
    "created_at": "2015-03-28T13:26:53-04:00",
    "updated_at": "2015-03-28T13:26:53-04:00",
    "content_type": "image\/gif",
    "size": 43,
    "theme_id": 828155753
  }
}

Update an image by providing a source URL from which to fetch the value

PUT /admin/themes/#{id}/assets.json
{
  "asset": {
    "key": "assets\/bg-body.gif",
    "src": "http:\/\/apple.com\/new_bg.gif"
  }
}
View Response
HTTP/1.1 200 OK
{
  "asset": {
    "key": "assets\/bg-body.gif",
    "public_url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/t\/1\/assets\/bg-body.gif?3530484542103056718",
    "created_at": "2010-07-12T15:31:50-04:00",
    "updated_at": "2015-03-28T13:26:54-04:00",
    "content_type": "image\/gif",
    "size": 43,
    "theme_id": 828155753
  }
}

Copy an asset by providing a source key

PUT /admin/themes/#{id}/assets.json
{
  "asset": {
    "key": "layout\/alternate.liquid",
    "source_key": "layout\/theme.liquid"
  }
}
View Response
HTTP/1.1 200 OK
{
  "asset": {
    "key": "layout\/alternate.liquid",
    "public_url": null,
    "created_at": "2015-03-28T13:26:54-04:00",
    "updated_at": "2015-03-28T13:26:54-04:00",
    "content_type": "text\/x-liquid",
    "size": 3174,
    "theme_id": 828155753
  }
}
DELETE/admin/themes/828155753/assets.json

Remove assets from your shop

Delete an image from your theme

DELETE /admin/themes/#{id}/assets.json?asset[key]=assets/bg-body.gif
View Response
HTTP/1.1 200 OK
{}

There are some files you cannot delete

DELETE /admin/themes/#{id}/assets.json?asset[key]=layout/theme.liquid
View Response
HTTP/1.1 403 Forbidden
{}

Ready to put what you've learned into action?

Build an online store with Shopify. Try it free.

Experience the future of retail now.

Shopify Point of Sale. Try it free.