跳转到内容

实体 API (Thing)

实体 API 使用以下四个入口:

  • POST /thing/create
  • POST /thing/update
  • POST /thing/archive
  • POST /thing/delete
  • 请求体必须是 JSON。
  • 请求模型为严格解析,未声明字段会直接报错(400)。
  • Authorization: Bearer <token> 仅在网关开启鉴权时必填。
字段类型必填说明
channel_idstring目标频道 ID。
passwordstring频道密码,长度 8-128。
op_idstring幂等键;不传则网关自动生成并在响应回传。
路由业务硬必填字段
/thing/createobserved_at
/thing/updatething_idobserved_at
/thing/archivething_idobserved_at
/thing/deletething_idobserved_at
字段类型必填规则
thing_idstring更新/归档/删除必填创建时不能传;由网关生成。
titlestring否(创建建议传)产品语义上建议 create 传入主标题;当前网关不会因缺失 title 拒绝创建。
descriptionstring空字符串会按缺省处理。
tagsstring[]最多 32 项,每项最多 64 字符,trim 后去重。
primary_imagestring可选 URL,最大 2048 字符。
imagesstring[]最多 32 项,每项最多 2048 字符,trim 后去重。
created_atnumbercreate 允许;不传时回退为 observed_at
deleted_atnumberdelete 允许;不传时回退为 observed_at
external_idsobjectkey 仅允许 [A-Za-z0-9_:.\-],且 key <= 64;value 仅 stringnull(null 表示删键)。
location_type + location_valuestring + string成对必须同时出现。location_type 仅允许 physical/geo/cloud/datacenter/logical
observed_atnumberUnix 秒时间戳,作为本次对象分发的发生时间。
attrsobject对象补丁;value 为 null 表示删键;不允许数组;对象嵌套仅支持一层。
metadataobject仅支持标量值(string/number/bool),key <= 64,value <= 512。
Terminal window
curl -X POST https://gateway.pushgo.cn/thing/create \
-H "Content-Type: application/json" \
-d '{
"channel_id": "06J0FZG1Y8XGG14VTQ4Y3G10MR",
"password": "pass-1234",
"title": "客厅温度计",
"observed_at": 1713750000,
"tags": ["sensor", "temperature"],
"attrs": { "temperature": 22.5 }
}'
{
"success": true,
"data": {
"channel_id": "06J0FZG1Y8XGG14VTQ4Y3G10MR",
"op_id": "op-20260422-001",
"thing_id": "8a1fc4b3d9f04fd2857f92f66f7cc5d1",
"accepted": true
},
"error": null,
"error_code": null
}