Importing data from Excel with an AI assistant
Importing data from Excel with an AI assistant
You can import data from an Excel file into the platform by asking an AI assistant to do it. The assistant reads the spreadsheet, matches the columns to the attributes of a template, and creates one data card for each row through the MCP server or the REST API. This works with any AI tool that can read a file and connect to one of these interfaces, for example Claude Code.
Choose the Interface
-
MCP server. The assistant connects to the platform as a signed-in user and uses the tools
list_templates,describe_template,list_datacards,create_datacardandupdate_datacard. The assistant learns the attributes of a template by itself, so you can describe the import in plain language. External MCP connections are a technical preview. For the setup, see Connecting External AI Clients to the Pro ESM MCP Server. - REST API. The assistant sends requests to the data card endpoints with a token that an integration user has obtained. This is a good choice when the import runs from a script that the assistant writes for you, and when you want to repeat the import later. For the setup and the endpoints, see REST API Overview and REST API Interface Description.
In both cases the import runs with the permissions of the user who signs in. The user needs permission to create data cards in the template and in the folder.
Prepare the Spreadsheet
- Use one sheet for one template, with a header row and one data card per row.
- Give each column a name that makes it easy to match to an attribute of the template. The assistant can match names such as "Summary" to an attribute, and it asks you when it cannot decide.
- For attributes with a fixed list of values, use the values that the template defines.
- For reference attributes, include the ID of the data card that the row refers to. The MCP server and the REST API match references by data card ID, not by name. If your spreadsheet has names, first ask the assistant to look up the matching IDs with
list_datacards(MCP) or the list endpoint of the REST API, and add them to the spreadsheet.
Import with the MCP Server
- Connect the AI tool to the MCP server as described in the connection guide.
- Give the assistant the spreadsheet and tell it what to import. For example: "Import the rows in this file as data cards of the template incident. Check the template first, and show me how you map the columns before you create anything."
- The assistant reads the template with
describe_template. This tells it which attributes exist, which are required, which have fixed values and in which folders data cards can be created. - Check the mapping that the assistant proposes. Fix it if a column is matched to the wrong attribute.
- Ask the assistant to create the first rows, and check the data cards in the platform before you continue with the rest.
The tool create_datacard creates one data card for each call. If a required attribute has no value, or a value is not valid, the call creates nothing and returns a list of the attributes that failed, so the assistant can correct the values and try again. Attributes that the platform fills in by itself, such as generated IDs and timestamps, are not set from the spreadsheet.
Import with the REST API
- Create an integration user with a role that allows the use of the external API, as described in the REST API Overview.
- Find the address of the API. It is the address of your environment followed by
/rest-api/itsm/v1, for examplehttps://yourMatrix42environment.m42cloud.com/rest-api/itsm/v1. The address in your browser may end with/itsm, which is not part of the API address. - Find the attribute codes of the template. Send
GET /dc/{templateCode}. The response lists the attributes of the template by code, the folders in which data cards can be created (folderCode) and the allowed values of attributes that have a list of values. Match the columns of the spreadsheet to these codes. - Give the assistant the spreadsheet, the address of the API, the template code and the folder code. Ask it to write an import script that logs in, sends one create request for each row, and writes a result file that lists the created data card IDs and the rows that failed.
- Run the script first with one row, check the data card in the platform, and then run the rest.
Log in. Send a POST to /users/login with the form fields login and password (content type application/x-www-form-urlencoded). The token is returned in the Authorization header of the response and starts with Bearer. Send it as it is in the Authorization header of the following requests, without adding Bearer again.
Create a data card. Send a POST to /dc/{templateCode}/data with the folder and the attribute values in the request body. Each attribute is written as a list of values. For an attribute with a list of values, use the value text as the template shows it. Send numbers as numbers.
{
"folderCode": "test_management",
"data": {
"test_name": { "values": [ { "value": "Login with valid credentials" } ] },
"test_type": { "values": [ { "value": "Regression test" } ] },
"test_status": { "values": [ { "value": "1 Planned" } ] },
"test_sequence_order": { "values": [ { "value": 1 } ] }
}
}A successful request returns the status 201 and the ID of the new data card. Do not send the attributes that the platform fills in by itself, such as the data card ID and the created and updated times. The query parameter createEmptyReferences controls whether new references are created when the referred data card does not exist. See the REST API Interface Description for the full request.
Limits. The token is valid for 15 minutes by default (security.external.api.token.expiration.time), so the script should log in again when it receives the status 401. The REST API accepts 30 requests per minute by default (external.api.max.requests.per.minute), so the script should pause between requests or you should ask your administrator to raise the limit for the import. Setting names and availability can change between versions.
Good Practices
- Test the import in a test environment first, with five to ten rows.
- Write the ID of every created data card to the result file straight away. If the script stops in the middle, the rows that were already created are known, and a new run does not create them again.
- Run the import only once for a set of rows. Each create call adds a new data card, so repeating a run creates the rows again. To correct data cards that already exist, ask the assistant to find them with the list tool and change them with
update_datacard. - When you update a multi-value attribute, the values that you send replace all the existing values of that attribute. Include the values that must stay.
- Ask the assistant to report how many rows were created and which rows failed, and compare the number with the number of rows in the spreadsheet.
- Review the result. An AI assistant can match a column to the wrong attribute, so check a sample of the created data cards against the spreadsheet.
Setting names and availability can change between versions.
Table of Contents