# Site theme files

These endpoints lets you manage the files of a given installed theme.

# The file object

  • site_theme_id integer

    The ID of the theme that the file belongs to.

  • file string

    The path to the file within the theme.

  • content string

    The content of the file using Base64 encoding.

  • public_url string

    The public URL of a public asset file. A public asset is one that lives in the assets directory of a theme.

  • size integer

    The size of the file in bytes.

  • created_at string

    The timestamp when the theme was created.

  • updated_at string

    The timestamp when the theme was last updated.

# The file object

{
  "site_theme_id": 1,
  "file": "templates/home.twig",
  "content": "...",
  "public_url": "http://...",
  "size": 123,
  "created_at": "2019-06-01T16:12:25+00:00",
  "updated_at": "2019-06-01T16:12:25+00:00"
}

# Retrieve a file

# Sample request

curl https://www.yourdomain.com/api/v1/sites/1/themes/1/files/template/home.twig \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <access-token>" \
  -G

# Sample successful response

{
  "data": {
    "site_theme_id": 1,
    "file": "templates/home.twig",
    "content": "...",
    "public_url": "http://...",
    "size": 123,
    "created_at": "2019-06-01T16:12:25+00:00",
    "updated_at": "2019-06-01T16:12:25+00:00"
  }
}

# Create or update a file

Use this endpoint to create or update a given theme file.

  • content string required

    The content of the file using Base64 encoding.

# Sample request

curl https://www.yourdomain.com/api/v1/sites/1/themes/1/files/templates/home.twig \
  --request PUT \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <access-token>" \
  -d content="..."

# Sample successful response

{
  "data": {
    "site_theme_id": 1,
    "file": "templates/home.twig",
    "content": "...",
    "public_url": "http://...",
    "size": 123,
    "created_at": "2019-06-01T16:12:25+00:00",
    "updated_at": "2019-06-01T16:12:25+00:00"
  }
}

# Delete a file

# Sample request

curl https://www.yourdomain.com/api/v1/sites/1/themes/1/files/templates/home.twig \
  --request DELETE \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <access-token>" 

If successful, the above request will return an empty response with 204 HTTP status code.

# List all files

# Sample request

curl https://www.yourdomain.com/api/v1/sites/1/themes/1/files \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <access-token>" \
  -G

# Sample successful response

{
  "data": [
    {
      "site_theme_id": 1,
      "file": "templates/home.twig",
      "public_url": "http://...",
      "size": 123,
      "created_at": "2019-06-01T16:12:25+00:00",
      "updated_at": "2019-06-01T16:12:25+00:00"
    },
    {...}
  ]
}