Last modified: Jul 1, 2025

Automatically Prefill Data - Configuration File

How to set up automatic form data pre-filling using a configuration file.

What does this feature do?

Your Altinn app can automatically fill in parts of the form before the user begins. The data can be retrieved from:

  • The Business Register (for company info)
  • The Population Register (for personal info)
  • The user’s Altinn profile.

When someone starts the form, the fields you select will be automatically populated with the correct data.

How to set it up

1. Create a new file

Navigate to the folder App/models in your app and create a new file.
Important: The file must be named [dataModelName].prefill.json
Example: If your data model is called appModel, you should have these files:

  • appModel.cs
  • appModel.schema.json
  • appModel.prefill.jsonthe new file

2. Add the base configuration

Copy this configuration code into the new file:

{
    "$schema": "https://altinncdn.no/schemas/json/prefill/prefill.schema.v1.json",
    "allowOverwrite": true,
    "ER": {
    },
    "DSF": {
    },
    "UserProfile": {
    }
}

3. Configure which data should be filled automatically

The three groups in the code mirror the three available sources:

  • ER - The Business Register
  • DSF - The Population Register
  • UserProfile - The user’s Altinn profile

Choose which sources you want to use. If any (or all) of the sources should not be used, leave them empty.

Within the group for the relevant source, add lines indicating:

  • Which data field (from the source) you want to retrieve data from
  • Which form field should be filled out

The format is "datafield": "formfield", where:

  • datafield is the name of the field from the source
  • formfield is the name of the field in the form’s data model.

See full list of available data fields for all sources.

Examples

All examples are based on the data model shown below:

Data model for form
Data model for form

Retrieve Organization Number from the Business Register (ER)

This will fill the Organization.OrgNo field with the organization number from the Business Register:

"ER": {
    "OrgNumber": "Organization.OrgNo"
}

Example: Retrieve Personal Number from the Population Register (DSF)

This will fill the Person.PersonNr field with the personal number from the Population Register.

"DSF": {
    "SSN": "Person.PersonNr"
}

Example: Retrieve email from the user’s Altinn profile

This will fill the User.Email field with the email retrieved from the user’s Altinn profile.

"UserProfile": {
    "Email": "User.Email"
}