Fetching user's available companies
The list of companies available to the authenticated user is available with a special field available under the Query type. This field is called availableCompanies. It is similar to the connection types seen so far, except that the pageInfo field is missing.

Here is a query example:
{
availableCompanies
{
totalCount
items
{
name
vismaNetCompanyId
vismaNetCustomerId
}
}
}{
"data": {
"availableCompanies": {
"totalCount": 2,
"items": [
{
"name": "Marius Test AS",
"vismaNetCompanyId": 5280...
"vismaNetCustomerId": 9123...
},
{
"name": "JAM&WAFFLES",
"vismaNetCompanyId": 5199...
"vismaNetCustomerId": 9456...
}
]
}
}
}The availableCompanies field has several optional arguments:
- an argument called
customerNothat indicates the Visma.net number of the customer for which available companies should be retrieved - an argument called
firstthat indicates the number of elements to be fetched from the top of the companies list - an argument called
lastthat indicates the number of elements to be fetched from the back of the companies list; if bothfirstandlastare present,firstis used andlastis ignored - an argument called
orderBythat defines the sorting order of the result - a deprecated argument called
sortOrderthat defines the sorting order of the result
To fetch companies specific to a particular customer, pass its Visma.net identifier in the customerNo parameter, as shown in the following example:
{
availableCompanies(customerNo : 12345678)
{
totalCount
items
{
name
vismaNetCompanyId
}
}
}{
"data": {
"availableCompanies": {
"totalCount": 2,
"items": [
{
"name": "Marius Test AS",
"vismaNetCompanyId": 5280...
},
{
"name": "JAM&WAFFLES",
"vismaNetCompanyId": 5199...
}
]
}
}
}If the customerNo parameter is missing, the companies available to all the available customers in the list are returned.
To retrieve the list of available customers see Fetching user’s available customers.
Service context
When you authenticate with client credentials (using a client ID and a client secret), fetching the list of available companies requires specifying a customer no (as described earlier).
You can find out the customer number in two ways:
- Authenticate with a Visma.net user and use the
availableCustomersfield to fetch the list (see Fetching user’s available customers). - Retrieve this information from Visma.Net Admin.
To do the latter:
- Logon to https://adm.visma.net/
- Open the Configuration tab
- Copy the value for Visma.net Customer ID

When then customer ID is not provided, an error is returned, as follows:
{
"errors": [
{
"message": "GraphQL.ExecutionError: Could not fetch the list of available companies. Customer number is mandatory."
}
],
"data": {
"availableCompanies": null
},
"extensions": {
"vbnxt-trace-id": "..."
}
}