How do I import and export via JSON?
Quick answer
Section titled “Quick answer”JSON works in both directions: export delivers your assets as a JSON
array with all fields; import accepts a .json file with an array of
asset objects (or a single object). As with CSV import, only
asset_type and name are required per object. JSON is the better
choice when you want to transfer nested values like tags (a list) or
custom_fields (an object), which CSV can’t represent.
Prerequisites
Section titled “Prerequisites”JSON import/export is included in the Basic plan. The license’s asset limit applies to imports.
-
Open the “Import & Export” section. Select the section for Data (route /data) in the navigation. The upload field notes “Supported formats: CSV, JSON”.
-
Upload a JSON file. Drag your
.jsonfile into the field or select it. A valid file contains an array of asset objects:assets-import.json [{"asset_type": "hardware","name": "ThinkPad T14 – Vertrieb","serial_number": "PF-3X9K2L","manufacturer": "Lenovo","status": "active","tags": ["notebook", "vertrieb"]},{"asset_type": "network","name": "Core-Switch 01","manufacturer": "Cisco","location": "Rechenzentrum / Rack A1"}] -
Start the import. Click “Start Import”. The result reports the number of imported records.
Screenshot pendingimport-export-json-01Uploading a JSON file in the import area with the format note CSV, JSONJSON files are imported through the same upload field as CSV. -
Export as JSON. For the reverse direction, choose the format JSON for the export and download the file — it contains all fields, including
tagsandcustom_fields.
Export as JSON (optionally filtered by type and status):
curl -H "Authorization: Bearer inv_dein_token" \ "https://demo.notory.io/api/v1/assets/export?fmt=json&asset_type=hardware&status=active" \ --output assets.jsonThe file is an array of complete asset objects (the same format as the API
response when creating one — including id, tenant_id, tags,
custom_fields).
Import a JSON file (multipart/form-data, field file):
curl -X POST https://demo.notory.io/api/v1/assets/import \ -H "Authorization: Bearer inv_dein_token" \ -F "file=@assets-import.json"{ "message": "Successfully imported 2 assets", "data": { "count": 2 }}Notory recognizes JSON by the .json extension. For other extensions, it
first tries to parse JSON and then falls back to CSV.
Possible errors: 401 (token missing/invalid). If the file isn’t valid
JSON and can’t be read as CSV either, the import fails; individual invalid
objects are — as with CSV import — skipped.
What happens behind the scenes?
Section titled “What happens behind the scenes?”- Array or single object: The file may contain an array of objects or a single object. Anything else (e.g. a number or a string) is rejected.
- Same validation as CSV: Each object is checked individually against the asset schema; invalid objects are skipped, and the valid ones are created. The response only counts the successes.
- More data types than CSV:
tags(a list),custom_fields(an object), numbers, and dates arrive typed — no detour through text like in CSV. Custom fields insidecustom_fieldsare validated against the custom fields defined for the tenant. - Roundtrip with caution: A JSON export can be imported again —
unknown fields like
id,tenant_id, orcreated_atare ignored and reassigned in that case. However, this creates new assets (the old ones aren’t updated), since there’s no duplicate check. - Encoding: UTF-8; umlauts are not a problem.
Related topics
Section titled “Related topics”- How do I import and export data?
- Import assets from a CSV file
- Export your inventory for a backup
- Catalog — define custom fields — the basis for
custom_fields