コンテンツにスキップ
言語の選択:日本語
テーマの選択

加工部品API

加工部品の一覧、作成、更新、削除、検索。

更新日:

ベースパス:/v1/organizations/:organization_id/parts

メソッド パス 説明
GET /parts すべての加工部品の一覧
GET /parts/:id 加工部品を取得
POST /parts 加工部品を作成
PATCH /parts/:id 加工部品を更新
DELETE /parts/:id 加工部品を削除
GET /parts/search 部品番号、説明、またはその両方で検索

{
"id": 5,
"number": "P-0042",
"description": "Cylinder Block",
"customer_number": "CB-100",
"created_at": "2025-03-01T08:00:00Z",
"updated_at": "2025-06-01T10:00:00Z",
"material": {
"id": 2,
"name": "42CrMo4",
"iso_code": "P20",
"vdi_code": "1.7225"
},
"created_by": { "id": 7, "email": "user@example.com" }
}

パラメータ 型 説明
number string 部品番号。作成時に空の場合は、組織の加工部品の採番設定から自動生成します。
description string 加工部品の説明
customer_number string 顧客側の参照番号
material_id integer 材料ライブラリの材料ID。組織自身の材料か共有の材料です。別の組織の材料には422を返します
organization_id integer URLだけでなく、作成時は本文にも必須です。:organization_idのパス要素は権限を確認しますが、それだけで新しい加工部品を組織に関連付けるわけではありません。本文でも指定してください。
user_id integer 権限によるアクセス範囲のため、特定のユーザーに関連付けます。認証を参照してください。必要と分かっている場合以外は指定しません。
picture string Base64エンコードしたPNGの加工部品の写真
drawing string Base64エンコードしたDXFの2D図面
model string Base64エンコードしたSTEPの3Dモデル

パラメータ 型 説明
number string 部品番号の完全一致
description string 大文字・小文字を区別しない説明の完全一致

両方のパラメータを組み合わせて絞り込めます。

写真、図面、STEPモデルは、JSON本文内のBase64エンコード文字列でアップロードします。ファイルはオブジェクトストレージに保存され、保存後に加工部品のレコードに関連付けられます。

{
"number": "P-0042",
"description": "Cylinder Block",
"model": "<base64-encoded-step-content>"
}

# Search by part number
curl "https://api.toolingmetrics.com/v1/organizations/12/parts/search?number=P-0042" \
-H "Authorization: Bearer YOUR_TOKEN"
# Create a part — organization_id is required in the body, not just the URL
curl -X POST "https://api.toolingmetrics.com/v1/organizations/12/parts" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"number": "P-0042", "description": "Cylinder Block", "material_id": 2, "organization_id": 12}'
import requests
import base64
BASE = "https://api.toolingmetrics.com/v1"
HEADERS = {"Authorization": "Bearer YOUR_TOKEN"}
# Create a part with a STEP model attached
with open("cylinder_block.stp", "rb") as f:
model_b64 = base64.b64encode(f.read()).decode()
response = requests.post(
f"{BASE}/organizations/12/parts",
headers={**HEADERS, "Content-Type": "application/json"},
json={
"number": "P-0042",
"description": "Cylinder Block",
"material_id": 2,
"organization_id": 12,
"model": model_b64,
},
)
response.raise_for_status()
part = response.json()
print(f"Created part #{part['id']}: {part['number']}")