# Inserve
Inserve is Dutch software that helps MSPs support their customers in a personal and structured way. The connection to Inserve gives the option to sync information between Sentri and Inserve.

To configure the Inserve connection you need the `admin-sources` RW permissions. 
# Configuration
To configure the Inserve connection, you need to generate an API token in Inserve. You can do this by logging into Inserve, clicking on your avatar, selecting **API Settings**, and then choosing **Create a New API Key**.
### Inserve URL
This is your Inserve URL with `/api/` appended to it.  
For example, you can enter:
`https://company.inserve.nl/api/`

> [!WARNING]  
> Dont forget the last `/` and the `https` in the URL.
### API Token
Fill in your API token generated in Inserve.

### Custom source data
This field is used for additional custom data required by certain actions. For example, it can be used to link product codes to specific server resources, licenses, or backups. The data must be provided in valid JSON format.

Example custom source data:
```json
{
    "data": {
	    "clouddistrubutor": "sentri",
        "subscriptions": {
            "server_cpu": {
                "product_code": "P001"
            },
            "server_memory": {
                "product_code": "P002"
            },
            "server_disks": {
                "product_code": "P003"
            },
            "server_licenses": {
                "cpguard": {
                    "cpguard": {
                        "product_code": "P003"
                    }
                },
                "directadmin": {
                    "Standard": {
                        "product_code": "P004"
                    },
                    "Discounted Standard": {
                        "product_code": "P005"
                    },
                    "Lite": {
                        "product_code": "P006"
                    }
                },
                "installatron": {
                    "installatron": {
                        "product_code": "P007"
                    }
                }
            },
            "server_backup": {
                "borg": {
                    "product_code": "P008"
                },
                "veeam": {
                    "product_code": "P009"
                }
            }
        }
    }
}
```
If a product code is missing, the related action will return an error. Also make sure that each `product_code` exists in Inserve as a product.
## Testing connection
After applying the configuration you can click on **Test Connection** to see if the configuration is correct.
# Source actions
These are the different actions available. These actions maybe not available with certain modules disabled.

## Sync companies from Inserve to Sentri
> [!Important]
> Requires the **Customers** module to be enabled.
> Requires the **customer-companies** RW permissions. 

This API call retrieves all companies from Inserve and creates or updates them in Sentri.

API Call: [[GET Sync companies|GET Sync companies]]
## Sync cloud distributor companies
> [!Important]
> Requires the **Servers** module to be enabled.
> Requires the **servers** RW permissions. 
 
This API call synchronizes _active_ companies in Sentri with the corresponding cloud distributor companies in Inserve. These cloud distributor companies are required to associate Sentri server resources, licenses, and backups with companies in Inserve.

The reason for this is that each cloud distributor uses its own company IDs, which may not exist in Inserve. To solve this, Inserve requires you to create the companies under the cloud distributor so that the company IDs from Sentri can be mapped to the correct company IDs in Inserve.

For example:
```json
{
	"cloud_distributor": "sentri",  
	"mappings": [  
		{
			"cloud_distribution_id": "<id from cloud distribution>",  
			"company_id": "<real company id in Inserve>"  
		}  
	]  
}
``` 
The `cloud_distribution_id` is used to link licenses to the correct company during the **Sync Server Licenses** action.

API Call: [[GET Sync cloud distributor|GET Sync cloud distributor]]
## Sync servers licenses
> [!Important]
> Requires the **Servers** module to be enabled.
> Requires the **servers** RW permissions. 

This API call first executes the **Sync cloud distributor companies** action and then synchronizes all servers in an active, deleted, or trial state with Inserve licenses. It creates or updates server licenses in Inserve if they do not exist or if the license quantities differ from those in Sentri.
It will also only do this to server linked to an active company.

API Call: [[GET Sync server licenses|GET Sync server licenses]]
## Sync server subscriptions
> [!Important]
> Requires the **Servers** module to be enabled.
> Requires the **servers** RW permissions. 

This API call first executes the **Sync cloud distributor** companies action and then creates a subscription if it does not exist, or updates the subscription description if it does. It also creates subscription lines with the correct product_code entered in the **custom source data** JSON field.

API Call: [[GET Sync server subscriptions|GET Sync server subscriptions]]