สร้าง Tool

สร้าง Tool

รองรับการสร้าง Tool ภายใต้องค์กรที่ระบุ และสามารถสร้าง actions โดยอัตโนมัติผ่าน OpenAPI Schema

คุณสามารถใช้อินเทอร์เฟซนี้เพื่อสร้าง Tool ภายใต้องค์กรที่ระบุ เมื่อส่ง api_schema มาด้วยจะสร้าง actions พร้อมกัน หากไม่ส่งมาจะสร้างเพียงโครง Tool เท่านั้น

วิธีการร้องขอ

POST

URL สำหรับร้องขอ

https://api.${endpoint}/v1/org/tool/create

การยืนยันตัวตนในการร้องขอ

ใช้การยืนยันตัวตนแบบ Basic ด้วย DevKey / DevSecret ระดับบัญชี และกำหนดให้บัญชีที่เรียกใช้ต้องมีสิทธิ์สร้าง Tool ขององค์กร

การร้องขอ

ตัวอย่างการร้องขอ

curl -X POST 'https://api.${endpoint}/v1/org/tool/create' \ -H 'Authorization: Basic ${BASIC_TOKEN}' \ -H 'Content-Type: application/json' \ -d '{ "org_id": "p-xxxx", "name": "weather", "display_name": "Weather Lookup", "description": "Query current weather by city name", "logo": "https://cdn.example.com/weather.png", "url": "https://api.example.com", "show_request": true, "api_schema": "{\"openapi\":\"3.0.0\",\"paths\":{}}" }'
                      
                      curl -X POST 'https://api.${endpoint}/v1/org/tool/create' \
  -H 'Authorization: Basic ${BASIC_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{
    "org_id": "p-xxxx",
    "name": "weather",
    "display_name": "Weather Lookup",
    "description": "Query current weather by city name",
    "logo": "https://cdn.example.com/weather.png",
    "url": "https://api.example.com",
    "show_request": true,
    "api_schema": "{\"openapi\":\"3.0.0\",\"paths\":{}}"
  }'

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

Header สำหรับร้องขอ

ฟิลด์ ประเภท คำอธิบาย
Authorization Basic ${BASIC_TOKEN} Basic Token ที่ได้จากการเข้ารหัส Base64 ของ DevKey:DevSecret
Content-Type application/json รูปแบบของเนื้อหาคำขอ

พารามิเตอร์การร้องขอ (Body Parameters)

พารามิเตอร์ ประเภท คำอธิบาย required
org_id String ID ขององค์กร true
name String ชื่อ Tool สูงสุด 20 อักขระ true
display_name String ชื่อที่แสดงของ Tool สูงสุด 50 อักขระ false
description String คำอธิบาย Tool สูงสุด 100 อักขระ true
logo String URL ไอคอนของ Tool true
url String URL พื้นฐานของ Tool ต้องเป็นที่อยู่ http/https บนอินเทอร์เน็ตสาธารณะ true
show_request Boolean จะแสดงเนื้อหาคำขอในระหว่างการเรียกใช้หรือไม่ true
api_schema String OpenAPI JSON Schema เมื่อส่งมาจะสร้าง actions และเมื่อสำเร็จ available=true หากไม่ส่งมา available=false false

การตอบกลับ

ตัวอย่างการตอบกลับ

{ "code": 0, "message": "OK", "data": { "tool_id": "tool-xxxx", "name": "weather", "available": true } }
                      
                      {
  "code": 0,
  "message": "OK",
  "data": {
    "tool_id": "tool-xxxx",
    "name": "weather",
    "available": true
  }
}

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

การตอบกลับเมื่อสำเร็จ

ฟิลด์ ประเภท คำอธิบาย
tool_id String ID ของ Tool ที่สร้างใหม่
name String ชื่อ Tool
available Boolean Tool ใช้งานได้หรือไม่

การตอบกลับเมื่อผิดพลาด

ฟิลด์ ประเภท คำอธิบาย
code Integer รหัสข้อผิดพลาด
message String รายละเอียดข้อผิดพลาด

รหัสสถานะ

รหัสสถานะ คำอธิบาย
200 สำเร็จ
400 พารามิเตอร์ไม่ถูกต้อง
401 ไม่ได้รับอนุญาต
403 สิทธิ์ไม่เพียงพอ
429 คำขอถี่เกินไป
500 ข้อผิดพลาดของเซิร์ฟเวอร์