Skip to content

设备转移

设备转移

将设备从当前组织转移到另一个组织。转移后:

  • 设备在新组织中,需重新分配至设备组
  • 设备的绑定时间 bind_time 会重置

请求

http
POST /api/v2/devices/{device_id}/transfer/

请求参数

字段类型必填说明
target_org_slugstring目标组织的slug

请求示例

json
{
    "target_org_slug": "target_organization_slug"
}

响应

json
{
    "detail": "设备已成功转移到目标组织"
}

错误响应

状态码说明
400无效的请求数据
401未认证
403没有权限执行此操作
404设备或目标组织不存在

示例

Python

python
def transfer_device(device_id, target_org_slug):
    """设备转移
    
    Args:
        device_id: 设备ID
        target_org_slug: 目标组织的slug
    """
    headers = {
        "Authorization": f"Bearer {ACCESS_TOKEN}",
        "Content-Type": "application/json"
    }
    
    data = {
        "target_org_slug": target_org_slug
    }
    
    url = f"{API_BASE}/devices/{device_id}/transfer/"
    response = requests.post(url, headers=headers, json=data)
    return response.json()

# 使用示例
device_id = "device_1"
target_org_slug = "target_organization_slug"
result = transfer_device(device_id, target_org_slug)
print(f"迁移结果: {result}")

cURL

bash
curl -X POST "https://ums.holdingbyte.com/api/v2/devices/device_1/transfer/" \
     -H "Authorization: Bearer your_access_token" \
     -H "Content-Type: application/json" \
     -d '{"target_org_slug": "target_organization_slug"}'