Last modified: Mar 13, 2023

Configuration

A description of required configurations before using Altinn CLI.

Configuration

The configuration of Altinn CLI is contained in appsettings.json in the repository.

It contains three sections:

  1. Top level config
  2. Maskinporten settings
  3. InstantiationConfig

Top level configurations

These configurations cover where to read and store data for the general commands, as well as setting up base addresses for both Platform Storage and the app owner to interact with.

Below are the default values, further follows a description of each property.

{
  "StorageBaseAddress": "https://platform.tt02.altinn.no/storage/api/v1",
  "AppBaseAddress": "https://{org}.apps.tt02.altinn.no",
  "StorageOutputFolder": "c:/storage/Output",
  "StorageInputFolder": "c:/storage/Input",
  "CommandDefinitionFile": "C:/storage/CommandDefs/Commands.json"
}
NameDescription
StorageBaseAddressBase address for Platform Storage. Use domain tt02.altinn.no or altinn.no
AppBaseAddressBase address for the app owner in Altinn. Use domain tt02.altinn.no or altinn.no
StorageOutputFolderFolder where all output data should be stored. I.e. where to store downloaded instance data.
StorageInputFolderFolder where all input data can be found. I.e. where all instance templates are available,
CommandDefinitionFilePath for custom command definitions. If file exists, default commands will not be available.

Maskinporten settings

All clients interacting with an Altinn App and Altinn Platform must be authenticated using an Altinn Token. In Altinn CLI, this is enabled by first authenticating through Maskinporten, and then converting the token.

Maskinporten settings cover the configuration for the registered client in maskinporten, as well as enabling an automatic exchange into an Altinn Token before sending a request.

Read more about setting up a maskinporten client with a custom key here.

A closer description of the config values is available here.

Your maskinporten setting should look something like the example below. Note that ExchangeToAltinnToken is set to true, and the scopes that are required. for interacting with an app or the platform.

  "MaskinportenSettings": {
    "Environment": "ver2",
    "ClientId": "e15abbbc-36ad-4300-abe9-021c9a245e20",
    "Scope": "altinn:serviceowner altinn:serviceowner/instances.read altinn:serviceowner/instances.write",
    "EncodedJwk": "eyJwIjoiMms2RlZMRW9iVVY0dmpjRjRCVWNLOUhasdfasdfarhgawfN2YXE5eE95a3NyS1Q345435S19oNV45645635423545t45t54wrgsdfgsfdgsfd444aefasdf5NzdFcWhGTGtaSVAzSmhZTlA0MEZOc1EifQ==",
    "ExhangeToAltinnToken": true
  }

Instantiation configuration

The instantiation configuration is used by the batch command to identify folders to read/write from and to, as well as to find the mappings for Altinn App entities such as applicationId and dataType.

Below is a description of each property in the config, further follows an example of an instantiation configuration.

NameDescription
InputFolderThe folder where all batch files are available to be processed
OutputFolderThe folder where all processed batch files are moved to
ErrorFolderThe folder where the generated batch of all failed jobs is stored
ApplicationIdLookupA dictionary for mapping ExternalServiceCode to ApplicationId
DataTypeLookupA dictionary for mapping DataFormatId to dataType
"InstantiationConfig": {
    "InputFolder": "C:/altinn-batch/input",
    "OutputFolder": "C:/altinn-batch/output/",
    "ErrorFolder": "C:/altinn-batch/error/",
    "ApplicationIdLookup": {
      "5681": "ttd/apps-test",
      "1337": "ttd/apps-test-prod",
    },
    "DataTypeLookup": {
      "6823": "default",
      "1337": "Kursdomene_BliTjenesteeier_M_2020-05-25_5703_34553_SERES"
    }
  }
  • Maskinporten setup

    Step-by-step guide on how to set up a client with Altinn-scopes and custom keys.