---
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/theme/create-theme'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/online-store/theme/create-theme.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.json
```

## Base URL

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

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

## Required Permissions

* `write_themes`

## Request

### 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

* `src`

  string

  主题资源链接

* `name`

  string

  主题名称

* `role`

  integer

  published：主题已发布； unpublished：主题待发布；development：开发状态主题

## 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

* `check_errors`

  array<object>

  校验错误结果

  * `type`

    string

    类型

  * `filename`

    string

    文件名

  * `message`

    array<string>

    错误信息

* `theme`

  object

  主题信息

  * `created_at`

    long

    创建时间（ISO 8601）

  * `id`

    string

    主题id

  * `name`

    string

    主题名称

  * `role`

    integer

    是否发布

  * `theme_store_id`

    string

    店铺id

  * `updated_at`

    long

    更新时间（ISO 8601）


#### 401

* `errors`

  string

  错误描述。


#### 429

* `errors`

  string

  错误描述。


## OpenAPI Definition

```json
{
  "description": "创建主题接口",
  "externalDocs": {
    "description": "接口使用的权限点: `write_themes` ，更多权限点使用信息，请参考:",
    "url": "ec20/3cv5d7wpfgr6a8z5/xabczf5442284vkq?lang=zh-hans-cn",
    "errorTableDescription": ""
  },
  "operationId": "EQoOTAOG",
  "parameters": [
    {
      "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": {
            "src": {
              "name": "src",
              "description": "主题资源链接",
              "type": "string",
              "example": "/theme.zip"
            },
            "name": {
              "name": "name",
              "description": "主题名称",
              "type": "string",
              "example": "demo_theme"
            },
            "role": {
              "name": "role",
              "description": "published：主题已发布； unpublished：主题待发布；development：开发状态主题",
              "type": "integer",
              "example": 0
            }
          },
          "required": [
            "name"
          ],
          "example": {
            "name": "demo_theme",
            "role": 0,
            "src": "/theme.zip"
          }
        }
      }
    },
    "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": {
              "check_errors": {
                "name": "check_errors",
                "description": "校验错误结果",
                "type": "array",
                "items": {
                  "name": "check_errors",
                  "description": "校验错误结果",
                  "type": "object",
                  "properties": {
                    "type": {
                      "name": "type",
                      "description": "类型",
                      "type": "string",
                      "example": ""
                    },
                    "filename": {
                      "name": "filename",
                      "description": "文件名",
                      "type": "string",
                      "example": ""
                    },
                    "message": {
                      "name": "message",
                      "description": "错误信息",
                      "type": "array",
                      "items": {
                        "name": "message",
                        "description": "错误信息",
                        "type": "string",
                        "example": ""
                      },
                      "example": [
                        ""
                      ]
                    }
                  },
                  "example": {
                    "filename": "",
                    "message": [
                      ""
                    ],
                    "type": ""
                  }
                },
                "example": [
                  {
                    "type": "",
                    "filename": "",
                    "message": [
                      ""
                    ]
                  }
                ]
              },
              "theme": {
                "name": "theme",
                "description": "主题信息",
                "type": "object",
                "properties": {
                  "created_at": {
                    "name": "created_at",
                    "description": "创建时间（ISO 8601）",
                    "type": "long",
                    "example": 0
                  },
                  "id": {
                    "name": "id",
                    "description": "主题id",
                    "type": "string",
                    "example": "627d1003d4baa549bf5b83f9"
                  },
                  "name": {
                    "name": "name",
                    "description": "主题名称",
                    "type": "string",
                    "example": "demo_theme"
                  },
                  "role": {
                    "name": "role",
                    "description": "是否发布",
                    "type": "integer",
                    "example": 0
                  },
                  "theme_store_id": {
                    "name": "theme_store_id",
                    "description": "店铺id",
                    "type": "string",
                    "example": "1631700219512"
                  },
                  "updated_at": {
                    "name": "updated_at",
                    "description": "更新时间（ISO 8601）",
                    "type": "long",
                    "example": 0
                  }
                },
                "example": {
                  "name": "demo_theme",
                  "role": 0,
                  "theme_store_id": "1631700219512",
                  "updated_at": 0,
                  "created_at": 0,
                  "id": "627d1003d4baa549bf5b83f9"
                }
              }
            },
            "example": {
              "check_errors": [
                {
                  "filename": "",
                  "message": [
                    ""
                  ],
                  "type": ""
                }
              ],
              "theme": {
                "created_at": 0,
                "id": "627d1003d4baa549bf5b83f9",
                "name": "demo_theme",
                "role": 0,
                "theme_store_id": "1631700219512",
                "updated_at": 0
              }
            }
          }
        }
      }
    },
    "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.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"
  ]
}
```