# create()

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

`api.hosts.create({ runtime, framework, label, slug? }) → Promise<Host>`

创建一个主机并保留地址。 子弹来自标签, 或者你强加它, 它永远不会被悄悄地纠正。

Status: POST /api/hosting · slug is the URL · reserved names refused

```javascript
const site = await api.hosts.create({ runtime: "static", framework: "vite", label: "Portfolio" });
// { id, runtime: "static", framework: "vite", slug: "portfolio", url: "https://portfolio.…", status: "empty" }
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `runtime` | string | 必填 | `site` · `app` · `function`. |
| `framework` | string |  | 一个人读的名字。 |
| `label` | string |  | 地址的第一部分,从标签上取出 |
| `slug` | string |  | The first part of the address. Derived from the label otherwise. |

## 子弹是地址 {#slug}

> **事后不能改变**
>
> 更改时会断开已经共享的链接、 连接它的自定义域名和为主机名签发的证书。 对于另一个地址, 创建另一个主机, 并更新( ) 仅更改标签 。

## 无效的弹壳被拒绝, 未被固定 {#never-corrected}

以你的名义改正的子弹 给出了一个地址 没有人问到, 后发现 在一个不起作用的链接。 `invalid_slug` 故你们在选择的时候,可以随意地说。

## 保留姓名 {#reserved}

无法提供一个平台的答案——用于邮寄、签字、账单、行政管理的答案——的名称,这就是阻止客户取一个答案;单级的每个方位地址是真正的保护,这就是腰带。

## 错误 {#errors}

| 代码 | 状态 | 触发条件 |
| --- | --- | --- |
| invalid_kind | 400 | 没有任何种类,或者平台不知道的种类。 |
| invalid_slug | 400 | 无法使用的子弹, 或保留的名称 。 |
| slug_taken | 400 | 有人有它。 |
| hosting_limit | 409 | 计划已经计算好了 |
| hosting_not_in_plan | 403 | 该计划根本没有主机。 |
| hosting_kind_unavailable | 403 | 那种东西还不能用 |
| hosting_kind_unavailable | 501 | That kind cannot serve yet. |

## 空空开始空空 {#empty}

`status: "empty"` 网上什么都没有 [(部署)](/zh/sdk/ref/host/deploy) 是什么把东西在那里。

- [deploy()](/zh/sdk/ref/host/deploy): 正在在线上公布文件 。
- [kinds()](/zh/sdk/ref/hosts/kinds): 选择一种之前
- [usage()](/zh/sdk/ref/hosts/usage): 创建之前。

```python
site = api.hosts.create(runtime="static", framework="vite", label="Portfolio")
# site.id, site.runtime == "static", site.framework == "vite", site.slug == "portfolio",
# site.url == "https://portfolio.…", site.status == "empty"
```
