コンテンツにスキップ

ThingAPI

Thing API は、サーバー、部屋、センサー、ネットワークサービス、長時間実行されるタスクなど、時間の経過とともに変化する長期的に存在するオブジェクトを表します。 Thing を作成すると、thing_id が返されます。更新、アーカイブ、および削除の呼び出しでは、その ID が使用されます。

POST /thing/create
POST /thing/update
POST /thing/archive
POST /thing/delete

リクエストの本文は JSON である必要があり、不明なフィールドは拒否されます。プライベート Gateway が PUSHGO_TOKEN を有効にする場合は、Authorization: Bearer <token> を含めます。

ヘッダー必須説明
Content-Type: application/jsonはいリクエスト本文の形式。
Authorization: Bearer <token>ゲートウェイに依存プライベート Gateway が PUSHGO_TOKEN を有効にする場合にのみ必要です。
/thing/create -> thing_id
|
+-> /thing/update can be called many times
|
+-> /thing/archive inactive but history remains
|
+-> /thing/delete removed or retired
フィールドタイプ必須説明
channel_idstringはいターゲットチャンネルID。
passwordstringはいChannel パスワード、通常は 8 ~ 128 文字。
op_idstringいいえ冪等性キー。生成され、省略された場合は返されます。
ciphertextstringいいえオプションの E2EE 暗号文ペイロード。
ルート必須のビジネス分野
/thing/createobserved_at
/thing/updatething_idobserved_at
/thing/archivething_idobserved_at
/thing/deletething_idobserved_at
フィールドタイプルール
thing_idstring更新、アーカイブ、削除に必要です。作成時に送信してはなりません。
titlestring作成時に推奨されます。 Gateway は現在、不足している title を拒否しません。
descriptionstringオプション。空の文字列は欠落しているものとして扱われます。
tagsstring[]最大 32 項目、それぞれ最大 64 文字、トリミングおよび重複排除。
primary_imagestringオプションの URL、最大 2048 文字。
imagesstring[]最大 32 個の画像 URL、それぞれ最大 2048 文字。
created_atnumber作成のみ。省略すると observed_at に戻ります。
deleted_atnumber削除のみ。省略すると observed_at に戻ります。
observed_atnumber必須;この状態更新の観察時間 (Unix ミリ秒)。
external_idsobjectキーパターン [A-Za-z0-9_:.\-]、キー <= 64;値は string または null です。
location_type + location_valuestring + string必ず一緒に登場する必要があります。タイプは physicalgeoclouddatacenter、または logical です。
attrsobjectオブジェクトパッチ; null はキーを削除します。配列は許可されません。ネストされたオブジェクト レベルは 1 つだけです。
metadataobjectスカラー値のみ。キー <= 64、値 <= 512。
Terminal window
curl -X POST https://gateway.pushgo.dev/thing/create \
-H "Content-Type: application/json" \
-d '{
"channel_id": "YOUR_CHANNEL_ID",
"password": "YOUR_CHANNEL_PASSWORD",
"title": "Home NAS",
"description": "Primary storage in the living room rack",
"observed_at": 1713750000000,
"tags": ["nas", "home"],
"location_type": "physical",
"location_value": "home/living-room",
"attrs": {
"online": true,
"disk_used": 0.72,
"temperature": 43.2
}
}'

応答:

{
"success": true,
"data": {
"channel_id": "YOUR_CHANNEL_ID",
"op_id": "op-20260422-001",
"thing_id": "8a1fc4b3d9f04fd2857f92f66f7cc5d1",
"accepted": true
},
"error": null,
"error_code": null
}

返された thing_id を保存します。更新、アーカイブ、および削除の呼び出しにはこれが必要です。

Terminal window
curl -X POST https://gateway.pushgo.dev/thing/update \
-H "Content-Type: application/json" \
-d '{
"channel_id": "YOUR_CHANNEL_ID",
"password": "YOUR_CHANNEL_PASSWORD",
"thing_id": "8a1fc4b3d9f04fd2857f92f66f7cc5d1",
"observed_at": 1713750600000,
"attrs": {
"disk_used": 0.74,
"temperature": 44.1
}
}'

attrsはパッチです。毎回完全な状態を送信する必要はありません。キーを削除するには、null を渡します。

{
"attrs": {
"temporary_alarm": null
}
}

アーカイブは、もうアクティブではないが履歴を保持する必要があるオブジェクト用です。

Terminal window
curl -X POST https://gateway.pushgo.dev/thing/archive \
-H "Content-Type: application/json" \
-d '{
"channel_id": "YOUR_CHANNEL_ID",
"password": "YOUR_CHANNEL_PASSWORD",
"thing_id": "8a1fc4b3d9f04fd2857f92f66f7cc5d1",
"observed_at": 1713751200000,
"attrs": {
"online": false
}
}'

オブジェクトが削除または廃止される場合は、/thing/delete を使用します。

Terminal window
curl -X POST https://gateway.pushgo.dev/thing/delete \
-H "Content-Type: application/json" \
-d '{
"channel_id": "YOUR_CHANNEL_ID",
"password": "YOUR_CHANNEL_PASSWORD",
"thing_id": "8a1fc4b3d9f04fd2857f92f66f7cc5d1",
"observed_at": 1713751800000,
"deleted_at": 1713751800000
}'

アソシエイト Message および Event

Section titled “アソシエイト Message および Event”

Thing は永続オブジェクトを表します。関連するアラートでは、Message を thing_id とともに使用できます。関連プロセスは、Event を thing_id とともに使用できます。

シナリオモデル
現在の NAS CPU、温度、ディスク使用率Thing
NAS 上の 1 つのディスクに関する警告Message + thing_id
NAS バックアップの開始から完了までEvent + thing_id

Thing API は共有応答エンベロープを使用します。 accepted=true は、Gateway がディスパッチに入ったことを意味し、すべてのデバイスがシステム通知を表示したことを意味しません。

ステータス典型的な理由
400observed_at がありません、不明なフィールド、無効な attrs または external_ids
401プライベート Gateway Bearer トークンが見つからないか、間違っています。
404Channel または thing_id は存在しません。
413リクエストボディが 32KB を超えています。
503ディスパッチは完全には成功しませんでした。