POST /app/devices

URL requires a body with the following format (Items in bold are required):

Body:

{
  **"pcbSn": *Device SN,
  "companyId": *company ID,**
  "boardName": *User Device Name,
  "pcbMn": *PCB Manufacturer,
  "group": *device group
}

NOTE: group dictates which End Client a device belongs to. End Clients have access to devices whose group matches the user’s username (email).

Response:

{
	"device_id": *Device ID
}

NOTE: device_id is used to access any device specific endpoint.

Code Example

Python example to fetch an access Token.

#!/usr/bin/python3

# Register_Device.py
#
# Register new device through the EDG API
# This example is built on top of the API Login Example
# This example is built on top of the Get Company ID example
#
# Copyright (c) 2021-2023 Engineering Design Group, LLC. All Rights Reserved.
#
# <variable_name> represents value specific to user

import requests
import json
import uuid

#Need an access token to access this API endpoint
import Get_app_token
import Get_Company_Info

def registerDevice(accessToken = "", companyName = "", companyID = ""):

    if accessToken == "":
        accessToken = API_Login_Example.getToken(<user_username>, <user_password>, <client_ID>)

    if companyName == "" or companyID == "":
        companyName, companyID = Get_Company_Info.getCompanyId(accessToken)
        
    #create Unique Identifier for new device
    UUID = str(uuid.uuid4())

    #generate URL for POST request
    baseUrl = <API_URL>
    endpointAddress = "/app/devices"
    deviceRegisterUrl = baseUrl + endpointAddress

    #create header and body to send to API
    authHeader={
        "Authorization": "Bearer " + accessToken,
        "Content-Type": "application/json"
         }

    registerDeviceBody={
        "companyID": companyID,
        "companyName": companyName,
        "boardName": <board_name>,
        "pcbSn": UUID,
        "pcbMn": <pcb_mn>,
        "group": <group_name>
    }

    #register device using a POST request
    response = requests.post(deviceRegisterUrl,
                            headers = authHeader,
                            data = json.dumps(registerDeviceBody),
                            verify = True)

    #display API response code
    print("Device Registered: ", response)

    return response

def main():
    print("Registering new device...")
    registerDevice()

if __name__ == "__main__":
    main()