# create()

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/brand/create/
Language: zh

`api.brand.create({ name, description?, logos?, palette?, identity?, platform?, assets? }) → Promise<Brand>`

创建品牌。只有名称是必填项；其余内容都可以之后逐个模块补充。

Status: POST /api/brand · free · colors from the logo

```javascript
const brand = await api.brand.create({
  name: "Qahwa Lab",
  description: "Specialty coffee roasted in Tunis",
  logos: [
    { name: "logo.svg", content: svgText, main: true },   // SVG text, bytes, a Blob or base64
    { path: "./icon.png", role: "icon" },                // Node.js only
  ],
  palette: ["#6B3E26", "#D9A441"],                        // optional
  identity: { tagline: "Roasted every morning" },
  assets: [{ cloud: "Brand/storefront.jpg", role: "hero" }],
});
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `name` | string | required | 品牌名称。 |
| `description` | string |  | 一句话，最多 500 个字符。详细描述应放在 `identity.longDescription` 中。 |
| `logos` | array |  | `{ name, content }` 或 `{ path }`，可选 `role`（primary、secondary、icon、monogram、other）和 `main`。最多 12 个，每个 5 MB；支持 SVG、PNG、JPEG 或 WebP，根据字节识别，而非文件名。 |
| `palette` | array | object |  | 颜色列表（`"#6B3E26"` 或 `{ hex, role, name }`），或 `{ colors, typography }`。不提供时，颜色从主标志中提取。 |
| `identity` | object |  | 标语、详细描述、行业、语言、创立年份、域名、社交账号。 |
| `platform` | object |  | 使命、愿景、价值观、定位、承诺、受众、原型、语气、信息。 |
| `assets` | array |  | 照片、视频或插图——参见 [assets](/zh/sdk/ref/brand-object/assets)。 |

## 被拒绝的资源不会取消品牌 {#assets}

先创建品牌，再添加其资源。失败的资源会列在 `brand.assetErrors` 中——包括索引、代码和消息——其余资源照常保留。

## 错误 {#errors}

| 代码 | 状态 | 触发条件 |
| --- | --- | --- |
| invalid_name | 400 | 没有名称，或名称为空。 |
| invalid_field | 400 | identity 或 platform 中的未知字段，或类型错误的值。 |
| unsupported_logo | 400 | 字节不是 SVG、PNG、JPEG 或 WebP 图片。 |
| unsafe_svg | 400 | SVG 含有脚本、事件处理器、内嵌 HTML 或外部链接。 |
| too_many_logos | 400 | 超过 12 个标志。 |
| logo_too_large | 413 | 标志超过 5 MB。 |
| invalid_color | 400 | 颜色不是十六进制值，或角色未知。 |
| too_many_brands | 403 | 账户已有 50 个品牌。 |

- [Brand](/zh/sdk/ref/brand-object): 品牌包含什么，以及如何修改它。
- [logos](/zh/sdk/ref/brand-object/logos): 添加标志，选择主标志。
- [palette](/zh/sdk/ref/brand-object/palette): 颜色、角色和字体。

```python
brand = api.brand.create(
    name="Qahwa Lab",
    description="Specialty coffee roasted in Tunis",
    logos=[
        {"name": "logo.svg", "content": svg_text, "main": True},   # SVG text, bytes or base64
        {"path": "icon.png", "role": "icon"},
    ],
    palette=["#6B3E26", "#D9A441"],                              # optional
    identity={"tagline": "Roasted every morning"},
    assets=[{"cloud": "Brand/storefront.jpg", "role": "hero"}],
)
brand.asset_errors   # None, or [{"index", "code", "message"}]
```
