Bulk Create Device Keys

Description

The bulk key create method generates a list of device ids and keys. The default alphabet id strings is “abcdefghijkmnopqrstuvwxyz3479” aka [a-z0-9] \ [0,1,2,5,6,8,l] see http://ux.stackexchange.com/questions/53341/are-there-any-letters-numbers-that-should-be-avoided-in-an-id The default length for random ids is 8 it gives 29^8 500246412961 different possibilities.

The request object takes a count parameter and a tags parameter. Count cannot exceed 1000. Tags is of type map encoded in json.

The request returns a batch ID as a reference to all devices created with the specific call.

Request

POST /v1/domains/:domain/keys/devices
{
  count: number,
  tags?{
    [key: string]: string
  }
}

Response

Successful response contains the following JSON formated body:

{
  count: number,
  batchId: number,
  keys: {
    deviceId: string,
    preSharedKey: string,
    tags?:{
      [key: string]: string
    }
  }[]
}

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/domains/:domain/keys/devices" \
  -H "Authorization: Bearer <ApiKey>" \
  -H "X-Nabto-Organization: <OrganizationId>" \
  -H "Content-Type: application/json" \
  -d '{ count: 42, tags?{"foo": "bar" }}'

Response

{
   count: 42,
  batchId: 42,
  keys: [{
     deviceId: "a.mydomain.example.net",
    preSharedKey: "01010101010101010101010101010101",
    tags:{
      "foo": "bar" 
    }
     
  },
  ...]
}