Is there a way to add a device to a product through API?

I don’t see any documentation in the API for this. Surely there must be a way…

Hey @incorvia,

Yes, there is a way to do this. The endpoint is: https://api.particle.io/v1/products/:productIdOrSlug/devices. You will need to use an access token from a member of the product team to authenticate properly.

You have two ways you can hit the endpoint. The first is to pass {id: [deviceIDToImport]} into the body of the request. This will import a single device. You can also pass a file to the endpoint, a single-column .txt file that contains a list of device IDs that you’d like to import.

You can always inspect the network activity on the devices page of the console to see more details about how this works. Better documentation on product endpoints is coming soon!

Hope this helps,

Jeff

3 Likes

Let us know if this helps @incorvia, thanks for the help Jeff!

Thank is very helpful! Of course updated docs even more so :wink: so thanks for working on that! Will take a bit to integrate this into my project and therefore test it but thanks for the information.

1 Like

@jeiden - can I name the device on import?

We name our devices with a short code that is also displayed on the product label (basically a serial number). It makes tech support way easier. So I’m trying to figure out a way to import a device as a product (because it was just flashed/tested) with a name (the serial code it gets assigned on the line).

I’ve messed around with some form data options on this endpoint but I’m not seeing it…

@mebrunet Unfortunately we don’t support that right now. You’d need to write a script that wraps our API to mass-update many devices’ names. But that’s a good idea!

Is there a recommended way to add devices to product in a production setting? Say you have a P1 based design. Do you need to add all the P1 devices you buy to your product before populating them onto your PCB? How would that work? A barcode scanner for the QR code on the P1 and a script to individually hit the add device to product end point? Or do you get a csv list of deviceIds when you order a tray of devices? Or can you specify your product info when you order the tray?

I can’t see an alternative since I want to use an Ionic app, and I can’t just supply full client id&secret with scope=all in the app. Which is what I would have to do to add the device in the app, isn’t it?

This is probably documented but I’m afraid I can’t find it. Any pointers?

2 Likes