# 工具アセンブリAPI

工具アセンブリのモデルを一覧・取得し、ライブラリ全体をFusion 360パッケージとしてエクスポートします。

Source: https://support.toolingmetrics.com/ja/api/reference/tool-assemblies/
Updated: 2026-10-29

ベースパス：`/v1/organizations/:organization_id/tool_assemblies`

<a id="endpoints"></a>

## エンドポイント

| メソッド | パス | 説明 |
|---|---|---|
| `GET` | `/tool_assemblies` | エクスポート可能な工具アセンブリのモデルの一覧 |
| `GET` | `/tool_assemblies/:id` | 工具アセンブリのモデルを取得 |
| `GET` | `/tool_library/:vendor` | 指定したベンダー向けのパッケージとしてライブラリをエクスポート |

工具アセンブリはAPIでは読取り専用です。`POST`、`PATCH`、`DELETE`のルートはありません。アプリの**ライブラリ → 工具アセンブリ**で作成・管理してください。

<a id="tool-assembly-object"></a>

## 工具アセンブリオブジェクト

```json
{
  "id": 42,
  "name": "Face Mill Ø80 — ADKT",
  "designation": "TA-042",
  "status": "released",
  "created_at": "2025-01-10T08:00:00Z",
  "updated_at": "2025-06-01T10:00:00Z",
  "category": { "id": 3, "name": "Face Mills", "code": "FM" },
  "created_by": { "id": 7, "email": "user@example.com", "firstname": "Long", "lastname": "Han" },
  "cutting_data": [
    {
      "id": "b1e1f7a0-1c2d-4e3f-9a8b-7c6d5e4f3a2b",
      "material_id": 2,
      "name": "42CrMo4 — Face milling",
      "operation": "milling_face",
      "parameters": { "cutting_speed": 180, "feed_per_tooth": 0.12 },
      "unit_system": "metric",
      "created_at": "2025-01-10T08:00:00Z",
      "updated_at": "2025-01-10T08:00:00Z"
    }
  ]
}
```

識別項目は`number`ではなく`designation`です。`cutting_data[].parameters`は自由形式のJSONで、キーは`operation`によって変わり、スキーマで固定されません。安定した仕様としてではなく、中身の決まっていない切削パラメータの集まりとして扱ってください。

<a id="list-behavior"></a>

## 一覧の動作

`GET /tool_assemblies`は、次の条件を満たすものだけを返します。

- `status`が、組織で「工具ライブラリのエクスポート対象」に設定された状態に含まれていること。対象の状態は、**管理センター → 組織 → 設定**の**共通工具アセンブリライブラリ**のチェックボックス（下書き／リリース済み／稼働中／アーカイブ予定／アーカイブ済み）で選びます。これは組織単位の設定（`organizations.preferences["engineering"]["tool_library_exportable"]`）であり、固定の状態の一覧ではありません。工具アセンブリ自体のリリースの流れにおける`status`とは別の軸で、状態遷移上の「リリース済み」とは関係なく、何を「CAMで使用可能」とするかを組織が決めます。
- `assets_builded: true`であること。3D・STEPアセットの処理が完了している状態です。

画面に存在して見える工具アセンブリでも、いずれかを満たさなければ一覧に表示されません。

`GET /tool_assemblies/:id`には一覧エンドポイントのような絞り込みはなく、通常の権限によるアクセス範囲の中で、IDを指定した、その組織の任意の工具アセンブリを返します。[認証](https://support.toolingmetrics.com/ja/api/authentication/)を参照してください。

<a id="export-library"></a>

## ライブラリのエクスポート

```
GET /v1/organizations/:organization_id/tool_library/:vendor
```

`:vendor`は現在`fusion`のみ実装されています（Autodesk Fusion 360の工具ライブラリJSON形式で、一覧エンドポイントと同じ状態・アセットの条件で作成されます）。それ以外のベンダー値では、エラーではなく本文が`null`の`200 OK`が返ります。エラーステータスに頼らず、空またはnullのレスポンスかどうかを確認してください。Autodesk Fusionとの接続は、[ToolingMetrics CAM Connect for Autodesk Fusion](https://support.toolingmetrics.com/ja/integrations/cam-connect/autodesk-fusion/)を参照してください。

<a id="examples"></a>

## 使用例

```bash
# List all exportable tool assemblies
curl "https://api.toolingmetrics.com/v1/organizations/12/tool_assemblies" \
  -H "Authorization: Bearer YOUR_TOKEN"

# Get a specific tool assembly with cutting data
curl "https://api.toolingmetrics.com/v1/organizations/12/tool_assemblies/42" \
  -H "Authorization: Bearer YOUR_TOKEN"

# Export the full library as a Fusion 360 package
curl "https://api.toolingmetrics.com/v1/organizations/12/tool_library/fusion" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -o tool_library.json
```

```python
import requests
import json

BASE = "https://api.toolingmetrics.com/v1"
HEADERS = {"Authorization": "Bearer YOUR_TOKEN"}

# Fetch all exportable tool assemblies and index them by designation for lookup
assemblies = requests.get(
    f"{BASE}/organizations/12/tool_assemblies",
    headers=HEADERS,
).json()

by_designation = {a["designation"]: a for a in assemblies}
ta = by_designation.get("TA-042")
if ta:
    print(f"{ta['name']} — status: {ta['status']}")

# Download the Fusion 360 library package
fusion_pkg = requests.get(
    f"{BASE}/organizations/12/tool_library/fusion",
    headers=HEADERS,
).json()

if fusion_pkg:
    with open("tool_library.json", "w") as f:
        json.dump(fusion_pkg, f, indent=2)
    print("Fusion 360 library exported.")
else:
    print("Nothing exported — no exportable tool assemblies, or the vendor value isn't supported.")
```

<a id="common-errors"></a>

## よくあるエラー

| ステータス | 原因 |
|---|---|
| `401` | この組織の工具アセンブリを閲覧する権限がない、またはこのIDの組織が存在しない |
| `404` | `GET /tool_assemblies/:id`：この組織にこのIDの工具アセンブリが存在しない。本文は加工部品、プロジェクト、機械と同じく単数形の`error`キーを使います（[エラー](https://support.toolingmetrics.com/ja/api/errors/)を参照） |
| `422` | ライブラリのエクスポートのみ：組み立てられない工具アセンブリを除いてもエクスポートを組み立てられなかった（通常、そのような工具アセンブリはライブラリから除かれ、そのユーザーに通知されます）。理由は`errors`に入ります |
| `500` | ライブラリのエクスポートのみ：エクスポートが想定外の理由で失敗した。`errors`は`"The tool library export failed"`です |
