Skip to content

Code Examples

Here you find examples of your first simple interactions with the API. By following the steps you see exactly how to build up your own data in Netilion.

You can use the interactive API documentation with your technical user credentials to run these commands at first. Once your application is ready and authorized it can run these direclty to the API.

These examples show you how to use the tenant as a tool to create your own masterdata and use it then with an asset.

If you have already created some data on our official Netilion Service Apps you might have already a tenant. You can retrieve your tenants by running:

GET v1/tenants

In case you have none, go ahead and create a tenant.

Create your tenant

POST v1/tenants

Request body:

{
"name": "My tenant",
"description": "Tenant for section A"
}

Create a company / manufacturer

POST v1/companies

Request body:

{
"name": "My Company",
"tenant": {
"id": 5
}
}

There are more attributes available. The example contains the minimum. To create your own record of a company, you need to add your own tenant in the request.

Response body :

{
"id": 15,
"name": "My Company",
"tenant": {
"id": 5,
"href": ""https://api.netilion.endress.com/v1/tenants/5"
},
"products": [
{
"id": 25,
"href": ""https://api.netilion.endress.com/v1/products/25"
}
]
}

You can now use the company id to proceed, creating a product. Note, that there was a default product generated automatically. This is the “unknown product”. Its a placeholder, as all companies need to have at least a product in the system.

Create a product

POST v1/products
{
"name": "Actuator",
"product_code": "091-904",
"manufacturer": {
"id": 15
},
"status": {
"id": 2
},
"tenant": {
"id": 5
}
}

There are more attributes available. The example contains the minimum. To create your own product, you need to add your own tenant in the request as well as the company you created within that tenant.
You need to specify a product status (undefined, available, etc.).

You can get a list of options as follows and add a product status id in the request.

GET v1/product/statuses

Response body :

{
"id": 35,
"product_code": "091-904",
"name": "Actuator",
"status": {
"id": 2,
"href": ""https://api.netilion.endress.com/v1/products/35/status"
},
"manufacturer": {
"id": 15,
"href": ""https://api.netilion.endress.com/v1/companies/15"
},
"tenant": {
"id": 5,
"href": ""https://api.netilion.endress.com/v1/tenants/5"
}..
}

Create an asset

POST v1/assets

Request body:

{
"serial_number": "9384382",
"production_date": "2012-01-25",
"status": {
"id": 2
},
"product": {
"id": 35
},
"tenant": {
"id": 5
}
}

There are more attributes available. The example contains the minimum. To create an asset of your own product, you need to add your tenant in the request as well as the product you created within that tenant.

You need to specify an asset status (undefined, active etc.).

Get a list of options as follows and add an asset status id in the request.

GET v1/asset/statuses

Response body:

{
"id": 450,
"serial_number": "9384382",
"production_date": "2012-01-25",
"status": {
"id": 2,
"href": ""https://api.netilion.endress.com/v1/assets/450/status"
},
"product": {
"id": 35,
"href": ""https://api.netilion.endress.com/v1/products/35"
},
"tenant": {
"id": 5,
"href": ""https://api.netilion.endress.com/v1/tenants/5"
},
}

Create an asset status

In case your desired asset status is not available among the default entries, you can create it. Use your tenant in the request.

POST v1/asset/statuses

Request body:

{
"code": "special_asset_status",
"name": "special asset status",
"tenant": {
"id": 5
}
}

The code serves to identify and optionally add translations to the record. Learn more in the internationalisation section about translations.

Create a node

POST v1/nodes

Request body:

{
"name": "Root",
"type": {
"id": 3
}
}

You need to specify an node type (location, site etc.). You need to specify an node type (location, site etc.).

Get a list of options as follows and add a node type id in the request.

GET v1/node/types

Create a nested node

POST v1/nodes

Request body:

{
"name": "Child",
"type": {
"id": 3
},
"parent": {
"id": 7
},
}

Add the id of the first node you have created as parent_id in the body of the second request to create a hierarchy. You need to stay consistent on the node type when nesting nodes.

Create an asset-instrumentation assignment

Once you have an asset and an instrumentation, the association is possible from both sides.

POST v1/assets/1/instrumentations

Request body:

{
"instrumentations": [
{
"id": 9
}
]
}

one or many instrumentations can be added in a comma separated list of objects. Alternatively you can use the instrumentation as fixed point and add assets to it:

POST v1/instrumentations/9/assets

Request body:

{
"assets": [
{
"id": 1
}
]
}

The same structure applies for node instrumentation assignment.

See the API documentation for all endpoints in detail.