Meta · whoami

ตรวจสอบ API key และ scope

Meta · whoami

ใช้ตรวจว่า API key ที่ส่งมาผูกกับธุรกิจไหนและมี scope อะไรบ้าง — เหมาะกับการ debug ระหว่างพัฒนาหรือตอนเข้าเวร (on-call) รูปแบบ response ขึ้นกับ ระดับ ของ key (business หรือ account) ดูได้จากฟิลด์ level

GET /meta/whoami

ตรวจข้อมูลของ API key

curl https://phone.mcloud.co.th/api/v1/meta/whoami \
  -H "Authorization: Bearer crk_..."

Business key

Business key ผูกกับธุรกิจเดียว และตอบ scope ที่ key นั้นมีอยู่

{
  "level": "business",
  "business": {
    "id": "0192...",
    "name": "Acme Co",
    "slug": "acme"
  },
  "scopes": [
    "view_recording_all",
    "manage_recording_review"
  ]
}

Account key

Account key ไม่ผูกกับธุรกิจใด — มีสิทธิ์เต็ม (manage_all) ในทุกธุรกิจที่เจ้าของ key เป็นสมาชิก เรียก whoami โดยไม่ต้องส่ง header X-Business-Id เพื่อดู id ของธุรกิจที่ส่งให้ endpoint อื่นได้ ซึ่งก็คือรายการในฟิลด์ businesses

{
  "level": "account",
  "userId": "0192...",
  "scopes": ["manage_all"],
  "businesses": [
    { "id": "0192...", "name": "Acme Co", "slug": "acme" },
    { "id": "0193...", "name": "Globex", "slug": "globex" }
  ]
}

businesses แสดงเฉพาะธุรกิจ ส่วนพื้นที่ Meet ส่วนตัวของคุณไม่ใช่ธุรกิจ จึงไม่อยู่ในรายการนี้ ถ้าจะอ่านการประชุมของตัวเอง ให้ส่ง X-Business-Id: personal (อ่านอย่างเดียว ดูหน้า Meetings)

สำหรับ account key ทุก endpoint อื่นต้องส่ง header X-Business-Id: <business id> เพื่อเลือกว่าจะทำงานกับธุรกิจไหน ยกเว้นการอ่านการประชุมของตัวเอง ซึ่งใช้ X-Business-Id: personal ดูเพิ่มที่ เริ่มต้นใช้งาน → API key ระดับบัญชี