Broadtype and Subtype Imports
Upload JSONL taxonomies for product browsing and filtering using the imports API.
Use Retrend imports to register your browsing taxonomy before loading products. This guide covers preparing JSON Lines
files for broadtype and subtype imports and calling the two endpoints you’ll use:
POST <https://api.retrend.ai/v2/imports/upload>uploads a JSONL file for one import type.POST <https://api.retrend.ai/v2/imports/check>polls the background job created during the upload.
These examples assume you already created a session token as described in API Dependencies and you
will authenticate each request with organization-id and x-session headers.
Import workflow
- Prepare a newline-delimited JSONL file whose objects match one of the schemas below.
POST /v2/imports/uploadwithmultipart/form-datathat includes the file plus the matchingimport_type(broadtypeorsubtype).- Store the
job_idreturned in the upload response. - Periodically
POST /v2/imports/checkwith thejob_iduntilis_complete: true. - Review validation errors in the dashboard (the API responds synchronously only for structural problems).
Upload request format
The upload endpoint accepts multipart/form-data with two fields:
import_type— usebroadtypeorsubtype. Each file targets exactly one type.file— binary attachment of your.jsonlfile.
curl -X POST "https://api.retrend.ai/v2/imports/upload" \
-H "organization-id: $RETREND_ORG_ID" \
-H "x-session: $RETREND_SESSION" \
-F import_type=broadtype \
-F file=@broadtypes.jsonlThe response includes success (boolean) and job_id (UUID). success reflects whether the upload was accepted; data
validation happens asynchronously based on the job_id.
Preparing JSONL payloads
Each JSON object in your file represents one record. Use UTF-8 encoding, avoid trailing commas, and ensure optional
fields are either omitted or set to null.
Broadtype schema
Broad types define the top-level taxonomy categories shown to shoppers.
| Field | Type | Required | Notes |
|---|---|---|---|
name | string | Yes | Display name of the broad type. Must be unique. |
description | string | Yes | Shopper-facing description. |
image_url | string | No | Public image URL for marketing placements. |
Example broadtype lines:
{"name":"Wine","description":"Still and sparkling wines spanning red, white, and rosé.","image_url":"https://cdn.example.com/images/wine.jpg"}
{"name":"Spirits","description":"Core liquor categories for cocktails and sipping.","image_url":"https://cdn.example.com/images/spirits.jpg"}Subtype schema
Subtypes nest under a broader category. Import matching broad types first.
| Field | Type | Required | Notes |
|---|---|---|---|
name | string | Yes | Subtype display name. |
description | string | Yes | Shopper-facing description. |
broadtype_name | string | Yes | Must match an imported BroadType.name. |
Example subtype lines:
{"name":"Red","description":"Full-bodied to light-bodied red wines.","broadtype_name":"Wine"}
{"name":"Bitters","description":"Cocktail bitters and flavoring agents.","broadtype_name":"Spirits"}Checking import status
Once you have a job_id, poll /v2/imports/check until the response indicates completion:
curl -X POST "https://api.retrend.ai/v2/imports/check" \
-H "organization-id: $RETREND_ORG_ID" \
-H "x-session: $RETREND_SESSION" \
-H "Content-Type: application/json" \
-d "{\"job_id\": \"12345678-1234-1234-1234-123456789012\"}"The API responds with:
{
"is_complete": false
}Keep polling (with exponential backoff) until is_complete switches to true. After completion, review any row-level
issues inside the dashboard's import history to address validation failures.
Tips for smooth taxonomy imports
- Import
broadtypebeforesubtypeto satisfy thebroadtype_namerelationship. - Keep names stable; products reference a subtype name plus its broad type name.
- Start with small sample files to validate formatting before sending large payloads.