Add Public key to device

Description

Add a public key to a device to allow it to connect to the signaling server. The added key will be stored using the fingerprint of the public key as key ID. This ID must be referenced when the device connects to the signaling server.

Request

POST /v1/webrtc/products/:product/devices/:device/publickeys
{
   publicKey: string 
}

Response

Successful response contains the following JSON formated body:

{
   productId: string,
  deviceId: string,
  name: string|null,
  publicKeys: {
    id: string,
    key: string
  }[],
  batchId: number|null,
  tags: {
    [key: string]: string
  },
  created: string,
  connected: boolean,
  lastConnect: string|null 
}

Response Status codes:

  • 200 on success

Request headers

This request must have the following headers:

  • Authorization: bearer <ApiKey>
  • X-Nabto-Organization: <organizationId>
  • Content-Type: application/json

Example

Request

curl -XPOST "https://api.cloud.nabto.com/v1/webrtc/products/:product/devices/:device/publickeys" \
  -H "Authorization: Bearer <ApiKey>" \
  -H "X-Nabto-Organization: <OrganizationId>" \
  -H "Content-Type: application/json" \
  -d '{ "publicKey": "<publicKey>"}'

Response

{
   "productId": "pr-abcdefgh",
  "deviceId": "a.mydomain.example.net",
  "name": "friendly name",
  "publicKeys": [{
     "id": "<id>",
    "key": "<key>" 
  },
  ...],
  "batchId": 42,
  "tags": {
    "foo": "bar" 
  },
  "created": "2022-10-18T10:17:24.299Z",
  "connected": true,
  "lastConnect": "<lastConnect>"
}