---
title: "批量创建/修改资产内容"
description: "批量创建/修改资产内容接口"
doc_type: openapi
doc_category: openapi
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/online-store/asset/batch-create-modify-asset-content'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/online-store/asset/batch-create-modify-asset-content.md'
---
# 批量创建/修改资产内容

批量创建/修改资产内容接口

- **Base URL:** `https://{handle}.myshopline.com/admin/openapi`
- **Required Scopes:** `write_themes`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** RESTful

## Endpoint

```http
POST /themes/:theme_id/batch-assets.json
```

## Base URL

* `https://{handle}.myshopline.com/admin/openapi`

  * `{handle}`: `handle` ：店铺的唯一标识符，值为店铺域名的前缀。例如，域名为 `open001.myshopline.com` 的店铺，其 `handle` 是 `open001` 。

## Required Permissions

* `write_themes`

## Request

### Path Parameters

* `theme_id`

  string (required)

  主题id

### Request Headers

* `Content-Type`

  string (required)

  字段值固定为 `application/json; charset=utf-8`。

* `Authorization`

  string (required)

  资源的访问令牌。参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入。

### Request Body

* `assets`

  array<object>

  文件列表

  * `value`

    string

    文件内容（value、src、attachment、source_key四个字段只能传其中一个）

  * `attachment`

    string

    图片base64内容（value、src、attachment三个字段只能传其中一个）

  * `key`

    string

    文件名

  * `src`

    string

    资源链接（value、src、attachment、source_key四个字段只能传其中一个）

## Response

### Status Codes

* `200`

  更多状态码信息，参考 [HTTP 状态码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/http-status-code.md?lang=zh-hans-cn)。

* `401`

  

* `429`

  

### Response Headers

* `traceId`

  请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。

### Response Body

#### 200

* `assets`

  array<object>

  文件列表

  * `public_url`

    string

    资源url

  * `size`

    integer

    文件大小

  * `theme_id`

    string

    主题id

  * `updated_at`

    long

    更新时间

  * `checksum`

    string

    校验值

  * `content_type`

    string

    文件类型

  * `created_at`

    long

    创建时间

  * `key`

    string

    文件名


#### 401

* `errors`

  string

  错误描述。


#### 429

* `errors`

  string

  错误描述。


## OpenAPI Definition

```json
{
  "description": "批量创建/修改资产内容接口",
  "externalDocs": {
    "description": "接口使用的权限点: `write_themes` ，更多权限点使用信息，请参考:",
    "url": "ec20/3cv5d7wpfgr6a8z5/xabczf5442284vkq?lang=zh-hans-cn",
    "errorTableDescription": ""
  },
  "operationId": "uunEZSYT",
  "parameters": [
    {
      "name": "theme_id",
      "in": "path",
      "description": "主题id",
      "required": true,
      "style": "simple",
      "schema": {
        "name": "theme_id",
        "description": "主题id",
        "type": "string",
        "example": ""
      },
      "example": ""
    },
    {
      "name": "Content-Type",
      "in": "header",
      "description": "字段值固定为 `application/json; charset=utf-8`。",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Content-Type",
        "type": "string",
        "example": "application/json; charset=utf-8"
      }
    },
    {
      "name": "Authorization",
      "in": "header",
      "description": "资源的访问令牌。参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入。",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Authorization",
        "description": "资源的访问令牌。请参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入",
        "type": "string",
        "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
      },
      "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "assets": {
              "name": "assets",
              "description": "文件列表",
              "type": "array",
              "items": {
                "name": "assets",
                "description": "文件列表",
                "type": "object",
                "properties": {
                  "value": {
                    "name": "value",
                    "description": "文件内容（value、src、attachment、source_key四个字段只能传其中一个）",
                    "type": "string",
                    "example": "file_content"
                  },
                  "attachment": {
                    "name": "attachment",
                    "description": "图片base64内容（value、src、attachment三个字段只能传其中一个）",
                    "type": "string",
                    "example": "base64_content"
                  },
                  "key": {
                    "name": "key",
                    "description": "文件名",
                    "type": "string",
                    "example": "templates/index.test.json"
                  },
                  "src": {
                    "name": "src",
                    "description": "资源链接（value、src、attachment、source_key四个字段只能传其中一个）",
                    "type": "string",
                    "example": "https://cdn.myshopline.com/assets/blog.css"
                  }
                },
                "required": [
                  "key"
                ],
                "example": {
                  "attachment": "base64_content",
                  "key": "templates/index.test.json",
                  "src": "https://cdn.myshopline.com/assets/blog.css",
                  "value": "file_content"
                }
              },
              "example": [
                {
                  "attachment": "base64_content",
                  "key": "templates/index.test.json",
                  "src": "https://cdn.myshopline.com/assets/blog.css",
                  "value": "file_content"
                }
              ]
            }
          },
          "required": [
            "assets"
          ],
          "example": {
            "assets": [
              {
                "attachment": "base64_content",
                "key": "templates/index.test.json",
                "src": "https://cdn.myshopline.com/assets/blog.css",
                "value": "file_content"
              }
            ]
          }
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "更多状态码信息，参考 [HTTP 状态码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/http-status-code.md?lang=zh-hans-cn)。",
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "assets": {
                "name": "assets",
                "description": "文件列表",
                "type": "array",
                "items": {
                  "name": "assets",
                  "description": "文件列表",
                  "type": "object",
                  "properties": {
                    "public_url": {
                      "name": "public_url",
                      "description": "资源url",
                      "type": "string",
                      "example": "https://cdn.myshopline.com/assets/blog.css"
                    },
                    "size": {
                      "name": "size",
                      "description": "文件大小",
                      "type": "integer",
                      "example": 500
                    },
                    "theme_id": {
                      "name": "theme_id",
                      "description": "主题id",
                      "type": "string",
                      "example": "66012436ec4cd35a973324c4"
                    },
                    "updated_at": {
                      "name": "updated_at",
                      "description": "更新时间",
                      "type": "long",
                      "example": 1712043467793
                    },
                    "checksum": {
                      "name": "checksum",
                      "description": "校验值",
                      "type": "string",
                      "example": "660BB5CB379F2D68816F4050"
                    },
                    "content_type": {
                      "name": "content_type",
                      "description": "文件类型",
                      "type": "string",
                      "example": "text/css"
                    },
                    "created_at": {
                      "name": "created_at",
                      "description": "创建时间",
                      "type": "long",
                      "example": 1712043467793
                    },
                    "key": {
                      "name": "key",
                      "description": "文件名",
                      "type": "string",
                      "example": "assets/blog.css"
                    }
                  },
                  "example": {
                    "updated_at": 1712043467793,
                    "checksum": "660BB5CB379F2D68816F4050",
                    "content_type": "text/css",
                    "created_at": 1712043467793,
                    "key": "assets/blog.css",
                    "public_url": "https://cdn.myshopline.com/assets/blog.css",
                    "size": 500,
                    "theme_id": "66012436ec4cd35a973324c4"
                  }
                },
                "example": [
                  {
                    "public_url": "https://cdn.myshopline.com/assets/blog.css",
                    "size": 500,
                    "theme_id": "66012436ec4cd35a973324c4",
                    "updated_at": 1712043467793,
                    "checksum": "660BB5CB379F2D68816F4050",
                    "content_type": "text/css",
                    "created_at": 1712043467793,
                    "key": "assets/blog.css"
                  }
                ]
              }
            },
            "example": {
              "assets": [
                {
                  "key": "assets/blog.css",
                  "public_url": "https://cdn.myshopline.com/assets/blog.css",
                  "size": 500,
                  "theme_id": "66012436ec4cd35a973324c4",
                  "updated_at": 1712043467793,
                  "checksum": "660BB5CB379F2D68816F4050",
                  "content_type": "text/css",
                  "created_at": 1712043467793
                }
              ]
            }
          }
        }
      }
    },
    "401": {
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "错误描述。",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    },
    "429": {
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "错误描述。",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "method": "post",
  "path": "/themes/:theme_id/batch-assets.json",
  "servers": [
    {
      "url": "https://{handle}.myshopline.com/admin/openapi",
      "variables": {
        "handle": {
          "default": "openapiceshidianpu",
          "description": "`handle` ：店铺的唯一标识符，值为店铺域名的前缀。例如，域名为 `open001.myshopline.com` 的店铺，其 `handle` 是 `open001` 。"
        }
      }
    }
  ],
  "info": {
    "title": "批量创建/修改资产内容",
    "version": "v20270301"
  },
  "authIndexes": [
    "write_themes"
  ]
}
```