# Possible to add Encoder Stack & Payload Parser to web API created devices?

**URL:** <https://community.tago.io/t/possible-to-add-encoder-stack-payload-parser-to-web-api-created-devices/1494>\
**Category:** Support\
**Created:** [November 2, 2023, 4:23pm UTC](https://community.tago.io/t/possible-to-add-encoder-stack-payload-parser-to-web-api-created-devices/1494 "2023-11-02T16:23:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtrembley](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jtrembley](https://community.tago.io/u/jtrembley)\
**Post date:** [November 2, 2023, 4:23pm UTC](https://community.tago.io/t/possible-to-add-encoder-stack-payload-parser-to-web-api-created-devices/1494/1 "2023-11-02T16:23:21Z")

</div>

Hello,

When a new immutable device is [created](https://docs.tago.io/docs/api/create-new-device) using the web API on a TagoCore, is it possible to also assign the Encoder Stack & Payload Parser? Or, is there any method other than having to log in to the TagoCore and select them manually?

Thank you!

---

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.tago.io/u/mateus.silva)\
**Post date:** [November 3, 2023, 1:03pm UTC](https://community.tago.io/t/possible-to-add-encoder-stack-payload-parser-to-web-api-created-devices/1494/2 "2023-11-03T13:03:14Z")

</div>

Yes, it is possible to assign the Encoder Stack & Payload Parser when creating a new device using the API. This can be achieved by using a Connector. A Connector is a feature that simplifies the management of device payload parsers and allows developers to showcase their products to others.

When you create a device using a Connector, the payload parser of the Connector is automatically assigned to the device. This means that you don’t have to manually select the payload parser for each device.

Here are the steps to create a Connector:

1. Access the following link: [https://admin.tago.io/connectors](https://admin.tago.io/connectors)

2. Click on the “Create your own connector” button located at the top right.

3. On the next page, click on the “Add connector” button at the top right.

4. In the modal that appears, provide a name and select the network server for your connector.

5. On the connector’s page, enter a description and an image URL.

6. Click on the “Payload Parser” tab in the top menu.

7. Insert JavaScript (NodeJS) code that decodes the data received from your device into a TagoIO compatible format.

8. Ensure that your code does not exceed 64kB and click on the “Save” button.

Once you have created the connector, you can use it to create devices. The payload parser of the connector will be automatically assigned to the devices created using it. This way, you can avoid having to manually select the payload parser for each device.

Here is an example of how to create a device with a specific connector using the TagoIO API:

```auto
POST /device
Content-Type: application/json
Authorization: YOUR-TOKEN-HERE

{
  "name": "My Device",
  "connector": "connector-id-here",
  ...
}

```

---

<div class="post-metadata">

**Author:** ![jtrembley](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jtrembley](https://community.tago.io/u/jtrembley)\
**Post date:** [November 29, 2023, 3:15pm UTC](https://community.tago.io/t/possible-to-add-encoder-stack-payload-parser-to-web-api-created-devices/1494/3 "2023-11-29T15:15:01Z")

</div>

Hey Mateus,

Thanks for your response! I’m looking to specifically do this in TagoCore rather than [Tago.io](http://Tago.io). I don’t see a way of adding device connectors in TagoCore currently, so is there another way to accomplish this?

---

<div class="post-metadata">

**Author:** ![stoklosa](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@stoklosa](https://community.tago.io/u/stoklosa)\
**Post date:** [November 30, 2023, 11:58am UTC](https://community.tago.io/t/possible-to-add-encoder-stack-payload-parser-to-web-api-created-devices/1494/4 "2023-11-30T11:58:16Z")

</div>

Hi Jeffrey,

It’s possible to create a device with an encoder and parser using the following examples:

To create a new device:

```auto
curl --location 'http://localhost:8888/device' \--header 'Content-Type: application/json' \--header 'token: 303125d9-b63f-429c-9a84-3fe5f7940701' \--data '{ "name": "Test", "type": "mutable", "payload_parser": "/path/to/parser.js", "encoder_stack": ["f22e91922b1882fecc0028a0e49fb194:network-everynet-encoder"]}'

```

To update an existing device:

```auto
curl --location --request PUT 'http://localhost:8888/device/710161439e79b1955b109327' \--header 'Content-Type: application/json' \--header 'token: 303125d9-b63f-429c-9a84-3fe5f7940701' \--data '{ "payload_parser": "/path/to/parser.js", "encoder_stack": ["f22e91922b1882fecc0028a0e49fb194:network-everynet-encoder"]}'

```

Unfortunately, there’s currently no straightforward method to obtain the encoder stack ID. This ID is a combination of the plugin ID and the encoder name. I recommend creating a device with the required encoders and using the API to retrieve the information.
