Import models
Import one file or several variants, wait for the object or poll the job yourself, and retry safely.
An import turns 3D files into an object. objects.importModel() does the whole flow in one call: it uploads each file, starts the import job and, if you ask, waits for it. The examples assume a client:
import Vizbl from '@vizbl/node';
const vizbl = new Vizbl(); // reads VIZBL_API_KEYImport one file
Pass a local path in file. name defaults to the file name without its extension.
const object = await vizbl.objects.importModel({
file: './chair.glb',
name: 'Oak lounge chair',
description: 'Solid oak frame with a linen seat.',
tags: ['chair', 'oak'],
mechanic: 'floor',
wait: true,
});
console.log(object.tinuuid, object.url);The tinuuid is the object's id: pass it to Core AR, the Android SDK and the iOS SDK to show the object, and to the Developer API to edit or delete it. The url is the object's public showcase page.
mechanic says where the object can be placed in AR: floor, wall, ceiling, carpet, or all for anywhere. Every option is listed in the reference.
Import variants
An object can have several variants, for example one per colour or material. Pass them in variants instead of file, in the order you want them shown. The first one is the default.
const object = await vizbl.objects.importModel({
name: 'Oak lounge chair',
variants: [
{ file: './chair-oak.glb', name: 'Oak' },
{ file: './chair-walnut.glb', name: 'Walnut' },
],
wait: true,
});The SDK uploads two files at a time. Change that with uploadConcurrency.
Import a file from memory
file also takes a Buffer, Uint8Array, ArrayBuffer or Blob. Data from memory has no file name, so pass fileName: the SDK takes the file type from its extension.
const response = await fetch('https://example.com/models/chair.glb');
const data = new Uint8Array(await response.arrayBuffer());
const object = await vizbl.objects.importModel({
name: 'Oak lounge chair',
file: { data, fileName: 'chair.glb' },
wait: true,
});Wait for the object, or not
wait | importModel() resolves with |
|---|---|
true | The finished job, with the object's tinuuid and url. |
{ pollIntervalMs, maxWaitMs, signal } | The same, with your own polling settings. |
false or left out | The queued job, as soon as the import has started. |
While it waits, the SDK reads the job every 2 seconds, or after the delay the job suggests, for up to 15 minutes. If the import fails or takes longer than maxWaitMs, the call throws a VizblImportError.
Long imports don't have to hold a request open. Start the import without wait, keep the jobId, and read the job later:
const job = await vizbl.objects.importModel({ file: './chair.glb' });
// store job.jobId, then later, for example in a background worker:
const current = await vizbl.objects.imports.get(job.jobId);
console.log(current.status); // queued, processing, succeeded or failed
const object = await vizbl.objects.imports.wait(job.jobId); // until it finishes
console.log(object.tinuuid, object.url);Job status explains the statuses and stages.
Publishing
An imported object is published only if your account publishes imports automatically. That setting is off by default: the object is then a draft, and its url opens once you publish it in your dashboard or with the Developer API, as Publish later shows.
Retry an import safely
If starting an import fails before you have the job, for example on a network error, you can't tell whether the import started. An idempotency key settles it: repeat the request with the same key and the same body, and the API returns the job it already started instead of importing the files twice. Idempotency explains how the API matches keys.
importModel() uploads the files again on every call, so a repeated call sends new upload ids and a different body. With the same idempotencyKey, the API then answers 409 if the first import has started, and nothing is imported twice, but you don't get that first job back. To retry and keep the job, import step by step: upload once, then repeat only objects.imports.create() with the same key.
Import step by step
To upload the file yourself, for example from your own storage or a queue worker, run the steps of importModel() one by one.
Get an upload URL
import { readFile } from 'node:fs/promises';
const data = await readFile('./chair.glb');
const upload = await vizbl.uploads.presign({
type: 'model_source',
fileName: 'chair.glb',
fileSize: data.byteLength,
fileType: 'model/gltf-binary',
});Upload the file
Send a multipart POST to uploadUrl with every field of uploadFields, then the file in a field named file. This request goes straight to storage and carries no API key.
const form = new FormData();
for (const [name, value] of Object.entries(upload.uploadFields)) {
form.append(name, value);
}
form.append('file', new Blob([data], { type: 'model/gltf-binary' }), 'chair.glb');
const response = await fetch(upload.uploadUrl, { method: 'POST', body: form });
if (!response.ok) {
throw new Error(`Upload failed with status ${response.status}`);
}Start the import
List the variants by uploadId, in display order.
const job = await vizbl.objects.imports.create(
{
name: 'Oak lounge chair',
variants: [{ uploadId: upload.uploadId, name: 'Default' }],
},
{ idempotencyKey: 'import-chair-2026-06-11' },
);Wait for the object
const object = await vizbl.objects.imports.wait(job.jobId);
console.log(object.tinuuid, object.url);Delete an object
const result = await vizbl.objects.delete('…');
console.log(result); // { tinuuid: '…', status: 'deleted' }Deleting removes the object from your account and from every place that shows it.