# Create build

URL: https://docs.hanzo.ai/docs/openapi/tool/post-tool-plugins-build

> Builds and stores one plugin for the caller's org.

`POST /v1/tool/plugins/build`

> [Tool →](https://docs.hanzo.ai/docs/openapi/tool) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                              |
| ------------- | -------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/tool/plugins/build` |
| **Method**    | `POST`                                       |
| **Operation** | `post_tool_plugins_build`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`       |

Builds and stores one plugin for the caller's org. The 201 carries
the bundle's size, whether a model wrote the source, and the plugin as stored.

Post `source` to build TypeScript as-is, or `spec` — an OpenAPI document or
plain prose describing the endpoints — to have one generated; the generated
source comes back in the answer, so a caller reads what will run before it
runs. Exactly one of the two, and `name` must be one lowercase path segment;
both or neither is 400.

COMPILING IS THE GATE. The source goes through the same pipeline the committed
connectors do — esbuild to one CommonJS program, then compiled in the goja
runtime that will actually execute it — and anything that fails is rejected and
NEVER stored. So a plugin in the store is one this deployment has already
loaded once, not one a model claimed was fine. A failed build answers 422
carrying the diagnostics a caller needs to fix it: the bundler's error
(`detail`), the source that failed, and whether the model wrote it.

CREDENTIALS ARE NOT PART OF A PLUGIN. A plugin names the connectors `provider`
it needs and reads that credential from `ctx.auth` at run time, under KMS
custody. Source that carries something key-shaped is REFUSED rather than
silently persisted — a scrubbed key looks like it worked.

## Request

4 fields, body `application/json` (required).

| Field      | In   | Type   | Required | Description                                                                                                                |
| ---------- | ---- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `name`     | body | string | —        | Name is the plugin's name: one lowercase path segment (a-z0-9, \_ or -), and the id the runtime loads it by.               |
| `provider` | body | string | —        | Provider is the connectors provider whose credential the plugin reads at run time.                                         |
| `source`   | body | string | —        | Source is TypeScript to build as-is.                                                                                       |
| `spec`     | body | string | —        | Spec is API documentation — an OpenAPI document, or prose describing the endpoints — that the generator turns into Source. |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `201`     | tool.buildOut   | created |
| `default` | problem-details | refused |

`201` body — 9 fields.

| Field              | In   | Type                | Always | Description                                                                                                  |
| ------------------ | ---- | ------------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| `bytes`            | body | integer (int64)     | —      | Bytes is the size of the bundled CommonJS the runtime will execute.                                          |
| `generated`        | body | boolean             | —      | Generated is whether a model wrote the source from a spec, rather than the caller posting the source itself. |
| `plugin`           | body | tool.AuthoredPlugin | —      |                                                                                                              |
| `plugin.createdAt` | body | integer (int64)     | —      | CreatedAt is when the plugin was last built, Unix seconds.                                                   |
| `plugin.id`        | body | string              | —      | ID is the plugin's id within the org, and the id a delete addresses.                                         |
| `plugin.name`      | body | string              | —      | Name is the plugin's name: one lowercase path segment, the id it runs by.                                    |
| `plugin.org`       | body | string              | —      | Org is the org that built the plugin — the validated caller's.                                               |
| `plugin.provider`  | body | string              | —      | Provider is the connectors provider whose credential this plugin uses at run time.                           |
| `plugin.source`    | body | string              | —      | Source is the TypeScript as authored (or as generated from a spec).                                          |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo tool plugins build
```

**SDK**

**.ts**

```ts
import { Configuration, ToolApi } from 'hanzoai';

const api = new ToolApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postToolPluginsBuild({ name: "<name>", provider: "<provider>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import ToolApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ToolApi(client).post_tool_plugins_build(name="<name>", provider="<provider>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.ToolAPI.PostToolPluginsBuild(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, tool_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = tool_api::post_tool_plugins_build(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ToolApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new ToolApi(client).postToolPluginsBuild();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/tool/plugins/build \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "name": "<name>",
       "provider": "<provider>"
     }'
```

**MCP**

MCP reaches **tool** through the `tool` tool, which names its 17 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_tools"
         }
       }
     }'
```

---

[Tool API](https://docs.hanzo.ai/docs/openapi/tool) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
