Who originates the "default data" for webhooks?

Hello Everyone,

I have a simple project using an Electron. The code basically sends some variables to a server using a webhook and sleeps for a set interval (to save battery power). The server needs to know which device is posting the data, and I know that the device ID is included in the webhook’s default data. However, the ID string itself is very long, which is not the best to optimize data usage. I am not sure if the device ID for the default data is appended to the webhook by the cloud or by the device, hence using up data. If that were the case, I would assign a custom (shorter) ID to my devices which would be sent in the webhook and then use a lookup table in my server to match it to the real (Particle) device ID.

In short, does the “default data” in the webhooks originate from the device or from the cloud?

Sorry if this was already mentioned in the docs or in the forums, I did not find it anywhere.

1 Like

I believe the device ID is appended by the cloud before passing it on to any subscribers, but don’t quote me on that. Either way, if it is sending it from the Electron and you continue using Particle’s publish function it’ll be sending the data anyway, so you might as well use it.

If you didn’t want to use the device ID what you could also do is append your own ID to the webhook data and use that, however that becomes a pain if you setup multiple devices. You’d have to setup a webhook for each device.

1 Like

@morduno, the device ID is crucial to the operation of webhooks and can’t/shouldn’t be modified. Think of it like a MAC address which is required for routing messages on a network.

1 Like

Thank you both for your replies! I apologize for not getting back to this thread sooner, but your observations made perfect sense to me. I will go ahead and use the device ID as is.

1 Like