ITwinClient
Implemented by
Index
Properties
Methods
- batchAssets
- batchGetAssets
- createAssetAttachmentUploadSession
- createAssets
- createOrUpdateTwin
- createOrUpdateTwinFile
- deleteAsset
- deleteAssetAttachment
- deleteAssetCategory
- deleteAssetType
- deleteTwin
- deleteTwinFile
- downloadTwinContent
- getAsset
- getAssetAttachmentBlob
- getAssetAttachmentUploadStatus
- getAssetCategory
- getAssetType
- getAssetTypeCatalog
- getAssetTypeMetaSchema
- getMyPermissions
- getProcessorEvents
- getTwin
- getTwinContent
- getTwinDiagnostics
- getTwinFile
- getTwinFileContent
- getTwinFileVersion
- getTwinFileVersionContent
- getTwinVersionContent
- getTwinVersionDiagnostics
- getTwinVersionEvents
- listAllTwins
- listAssetAttachments
- listAssetCategories
- listAssetCategoryVersions
- listAssetTypeVersions
- listAssetTypes
- listAssets
- listTwinFileVersions
- listTwinFiles
- listTwinVersions
- listTwins
- loadGeometryInfo
- loadGeometryInfoWithFactories
- loadTwin
- loadTwinWithFactories
- loadTwinWithGeometry
- putAssetAttachment
- putAssetCategory
- putAssetType
- restoreAsset
- restoreAssetAttachment
- restoreAssetCategory
- restoreAssetType
- restoreTwin
- restoreTwinFile
- updateAsset
- updateTwin
- uploadAssetAttachmentFile
Properties
readonlybaseUrl
Methods
batchAssets
Executes a batch of asset operations (upsert, delete, restore) atomically. All operations succeed or all are rolled back.
Parameters
twinId: string
operations: AssetBatchOperation[]
Array of batch operations (max 1000).
optionalsignal: AbortSignal
Returns Promise<AssetBatchResponse>
batchGetAssets
Retrieves multiple assets by ID in a single request.
Parameters
twinId: string
ids: string[]
Array of asset IDs (max 1000).
optionalsignal: AbortSignal
Returns Promise<AssetBatchGetResponse>
createAssetAttachmentUploadSession
Creates an upload session for a new attachment. The actual file bytes are uploaded out-of-band to ApiCreateUploadSessionResponse.uploadUrl; use uploadAssetAttachmentFile for the canonical chunked-upload flow. The attachment row is materialized server-side when the blob lands.
Parameters
twinId: string
assetId: string
attachmentId: string
body: AttachmentPost
optionalsignal: AbortSignal
Returns Promise<ApiCreateUploadSessionResponse>
createAssets
createOrUpdateTwin
createOrUpdateTwinFile
Parameters
twinId: string
fileId: string
twinFile: TwinFilePut
optionalsignal: AbortSignal
Returns Promise<TwinFileGet>
deleteAsset
Parameters
twinId: string
assetId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetGet>
deleteAssetAttachment
Soft-deletes an attachment.
Parameters
twinId: string
assetId: string
attachmentId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AttachmentGet>
deleteAssetCategory
Soft-deletes a category. Inserts a new asset_category_versions row with
is_deleted=true; the previous version is retained as an audit trail.Parameters
categoryId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetCategoryGet>
deleteAssetType
Soft-deletes a type. Inserts a new asset_type_versions row with
is_deleted=true; the previous version is retained as an audit trail.Parameters
categoryId: string
typeId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetTypeGet>
deleteTwin
Parameters
twinId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<TwinGet>
deleteTwinFile
Parameters
twinId: string
fileId: string
deleteRequest: TwinFileDelete
optionalsignal: AbortSignal
Returns Promise<TwinFileGet>
downloadTwinContent
Parameters
twinId: string
twinVersion: number
content: TwinContentResponse
optionalsignal: AbortSignal
Returns Promise<ArrayBuffer>
getAsset
Parameters
twinId: string
assetId: string
optionalsignal: AbortSignal
Returns Promise<AssetGet>
getAssetAttachmentBlob
Downloads an attachment's blob as a
Response. The caller decides whether to consume it as text, ArrayBuffer, or Blob.Parameters
twinId: string
assetId: string
attachmentId: string
optionalsignal: AbortSignal
Returns Promise<Response>
getAssetAttachmentUploadStatus
Polls the in-memory upload-session cache for an attachment that's being uploaded.
Parameters
twinId: string
assetId: string
token: string
optionalsignal: AbortSignal
Returns Promise<UploadStatusGet>
getAssetCategory
Parameters
categoryId: string
optionalsignal: AbortSignal
Returns Promise<AssetCategoryGet>
getAssetType
Parameters
categoryId: string
typeId: string
optionalsignal: AbortSignal
Returns Promise<AssetTypeGet>
getAssetTypeCatalog
Returns the customer's asset-type catalog: categories nested with their latest non-deleted types and full metadata schemas inline. One round-trip is enough to populate a picker dropdown and render any per-type metadata form.
Parameters
optionalsignal: AbortSignal
Returns Promise<AssetCatalogResponse>
getAssetTypeMetaSchema
Returns the Twinfinity meta-schema document — the JSON Schema describing valid asset-type metadata schemas. The bytes the backend itself validates against, served verbatim. Power-user tools (Monaco-backed JSON editors, schema-aware tooling) fetch this at runtime so their in-editor diagnostics line up with what the server will accept, decoupled from the FE bundle's build time.
Parameters
optionalsignal: AbortSignal
Returns Promise<Record<string, unknown>>
getMyPermissions
Returns the caller's named, customer-scoped capabilities against the Twin service (e.g.
ViewAssetTypes,EditAssetTypes). The admin app uses this to enable or disable buttons instead of letting the user click through to a 403.No client-side cache — every call hits the wire. Underlying scope grants don't shift within a session, so callers are expected to memoise the result themselves (e.g. via React Query / a once-on-mount fetch) rather than calling this on every render.
Throws TwinUnauthenticatedError on 401 (no valid auth context; caller should redirect to login). Returns an empty
permissionsarray on 403 (authenticated but no Twin-service capabilities). Unknown capability strings should be ignored — adding a new capability is a non-breaking change.Parameters
optionalsignal: AbortSignal
Returns Promise<MyPermissions>
getProcessorEvents
Parameters
twinId: string
twinVersion: number
processorId: string
optionaloffset: number
optionallimit: number
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<TwinProcessorEvent>>
getTwin
Parameters
twin: string | { id: string; version: number }
Twin ID string, or
{id, version}to fetch a specific version.id: string
version: number
optionalsignal: AbortSignal
Returns Promise<TwinGet>
getTwinContent
Returns content for the latest twin version.
Parameters
twinId: string
optionalsignal: AbortSignal
Returns Promise<TwinVersionContentResponse>
getTwinDiagnostics
Parameters
twinId: string
optionalsignal: AbortSignal
Returns Promise<TwinDiagnosticsResponse>
getTwinFile
Parameters
twinId: string
fileId: string
optionalsignal: AbortSignal
Returns Promise<TwinFileGet>
getTwinFileContent
Parameters
twinId: string
fileId: string
optionalsignal: AbortSignal
Returns Promise<Blob>
getTwinFileVersion
Parameters
twinId: string
fileId: string
version: number
optionalsignal: AbortSignal
Returns Promise<TwinFileGet>
getTwinFileVersionContent
Parameters
twinId: string
fileId: string
version: number
optionalsignal: AbortSignal
Returns Promise<Blob>
getTwinVersionContent
Parameters
twinId: string
twinVersion: number
optionalsignal: AbortSignal
Returns Promise<TwinVersionContentResponse>
getTwinVersionDiagnostics
Parameters
twinId: string
twinVersion: number
optionalsignal: AbortSignal
Returns Promise<TwinDiagnosticsResponse>
getTwinVersionEvents
Parameters
twinId: string
twinVersion: number
optionaloffset: number
optionallimit: number
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<TwinProcessorEvent>>
listAllTwins
Fetches all twins by auto-paginating through listTwins. Caps at 1000 pages.
Parameters
optionalrelatedTo: string
Filter twins by container ID.
optionalsignal: AbortSignal
Returns Promise<ListTwinItem[]>
listAssetAttachments
Lists attachments for a single asset.
Parameters
twinId: string
assetId: string
optionaloptions: { includeDeleted?: boolean; limit?: number; offset?: number; page?: string }
optionalincludeDeleted: boolean
optionallimit: number
optionaloffset: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AttachmentGet>>
listAssetCategories
Parameters
optionaloptions: { includeDeleted?: boolean; limit?: number; page?: string }
optionalincludeDeleted: boolean
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AssetCategoryGet>>
listAssetCategoryVersions
Returns every version of a single asset category, newest first. Mirrors
listAssetTypeVersionsandtwin.get_twin_versions.Parameters
categoryId: string
optionaloptions: { includeDeleted?: boolean; limit?: number; page?: string }
optionalincludeDeleted: boolean
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AssetCategoryGet>>
listAssetTypeVersions
Returns every version of a single asset type, newest first. Mirrors
twin.get_twin_versions.Parameters
categoryId: string
typeId: string
optionaloptions: { includeDeleted?: boolean; limit?: number; page?: string }
optionalincludeDeleted: boolean
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AssetTypeGet>>
listAssetTypes
Parameters
categoryId: string
optionaloptions: { includeDeleted?: boolean; limit?: number; page?: string }
optionalincludeDeleted: boolean
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AssetTypeGet>>
listAssets
Parameters
twinId: string
optionaloffset: number
optionallimit: number
optionaloptions: { includeDeleted?: boolean }
optionalincludeDeleted: boolean
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AssetListItem>>
listTwinFileVersions
Parameters
twinId: string
fileId: string
optionaloptions: TwinFileVersionListOptions
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<TwinFileGet>>
listTwinFiles
Parameters
twinId: string
optionaloptions: TwinFileListOptions
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<TwinFileGet>>
listTwinVersions
Parameters
id: string
optionaloptions: { includeDeleted?: boolean; limit?: number; page?: string }
optionalincludeDeleted: boolean
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<ListTwinItem>>
listTwins
Parameters
optionalrelatedTo: string
Filter twins by container ID.
optionalpage: string
optionallimit: number
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<ListTwinItem>>
loadGeometryInfo
Downloads and deserializes geometry info (t8gi) using default types. When no version is specified, searches versions newest-first for one containing t8gi content.
Parameters
twin: string | { id: string; version: number }
Twin ID string, or
{id, version}to load a specific version.id: string
version: number
optionalsignal: AbortSignal
Returns Promise<TwinGeometryInfo<T8GIMeshDescriptor, T8GIStyle, T8GIRegion>>
loadGeometryInfoWithFactories
Downloads and deserializes geometry info (t8gi) using custom factory functions. When no version is specified, searches versions newest-first for one containing t8gi content.
Type parameters
- TMeshDescriptor
- TStyle
- TRegion
Parameters
twin: string | { id: string; version: number }
Twin ID string, or
{id, version}to load a specific version.id: string
version: number
meshDescriptorFactory: (dto: T8GIMeshDescriptorDTO) => TMeshDescriptor
styleFactory: (dto: T8GIStyleDTO) => TStyle
regionFactory: (dto: T8GIRegionDTO) => TRegion
optionalsignal: AbortSignal
Returns Promise<TwinGeometryInfo<TMeshDescriptor, TStyle, TRegion>>
loadTwin
Downloads and deserializes the T8 client model (t8cm + t8cm-ext) using default types. When no version is specified, searches versions newest-first for one containing t8cm content.
Parameters
twin: string | { id: string; version: number }
Twin ID string, or
{id, version}to load a specific version.id: string
version: number
optionalsignal: AbortSignal
Returns Promise<Twin<T8Project<T8Product<T8EntityType<T8Unit>, T8Unit>, T8Unit>, T8Product<T8EntityType<T8Unit>, T8Unit>, T8EntityType<T8Unit>, T8Unit>>
loadTwinWithFactories
Downloads and deserializes the T8 client model using custom factory functions for domain-specific types. When no version is specified, searches versions newest-first for one containing t8cm content.
Type parameters
- TProject
- TProduct
- TEntityType
- TUnit
Parameters
twin: string | { id: string; version: number }
Twin ID string, or
{id, version}to load a specific version.id: string
version: number
projectFactory: (dto: T8ClientProjectDTO<TUnit>) => TProject
productFactory: (dto: T8ClientProductDTO<TUnit>) => TProduct
entityTypeFactory: (dto: T8ClientEntityTypeDTO<TUnit>) => TEntityType
unitFactory: (dto: T8ClientUnitDTO, dataModel: T8ClientModelDTO) => TUnit
connectProject: (dto: T8ClientProjectConnectionsDTO<TProduct>, project: TProject) => void
connectProduct: (dto: T8ClientProductConnectionsDTO<TProduct, TEntityType>, product: TProduct) => void
optionalsignal: AbortSignal
Returns Promise<Twin<TProject, TProduct, TEntityType, TUnit>>
loadTwinWithGeometry
Downloads and deserializes both the client model (t8cm) and geometry (t8gi/t8gd) into a combined result. When no version is specified, searches versions newest-first for one containing both t8cm and t8gi content.
Parameters
twin: string | { id: string; version: number }
Twin ID string, or
{id, version}to load a specific version.id: string
version: number
optionalsignal: AbortSignal
Returns Promise<Twin<T8ProjectWithGeometry, T8ProductWithGeometry<T8EntityType<T8Unit>>, T8EntityType<T8Unit>, T8Unit>>
putAssetAttachment
Updates an attachment's description / soft-delete flag.
documentIdis immutable — rebinding is rejected.Parameters
twinId: string
assetId: string
attachmentId: string
body: AssetAttachmentPut
optionalsignal: AbortSignal
Returns Promise<AttachmentGet>
putAssetCategory
Upserts an asset category. Provide an empty/missing etag for first writes and the existing etag to update.
Parameters
categoryId: string
body: AssetCategoryPut
optionalsignal: AbortSignal
Returns Promise<AssetCategoryGet>
putAssetType
Upserts an asset type. The metadata schema is validated against the Twinfinity meta-schema at the API boundary; invalid schemas surface as a 400 with
cause: MetadataSchemaInvalid.Parameters
categoryId: string
typeId: string
body: AssetTypePut
optionalsignal: AbortSignal
Returns Promise<AssetTypeGet>
restoreAsset
Parameters
twinId: string
assetId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetGet>
restoreAssetAttachment
Restores a soft-deleted attachment.
Parameters
twinId: string
assetId: string
attachmentId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AttachmentGet>
restoreAssetCategory
Restores a soft-deleted category. Inserts a new asset_category_versions row with
is_deleted=false; mirrors twin restore.Parameters
categoryId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetCategoryGet>
restoreAssetType
Restores a soft-deleted type. Inserts a new asset_type_versions row with
is_deleted=false; mirrors twin restore.Parameters
categoryId: string
typeId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetTypeGet>
restoreTwin
Parameters
twinId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<TwinGet>
restoreTwinFile
Parameters
twinId: string
fileId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<TwinFileGet>
updateAsset
updateTwin
uploadAssetAttachmentFile
Uploads a
File/Blobto an existing upload session in one or more chunks, then resolves the upload token so the caller can poll getAssetAttachmentUploadStatus.Parameters
session: ApiCreateUploadSessionResponse
file: Blob
optionalsignal: AbortSignal
Returns Promise<{ token: string }>
Rooted twins base URL — typically
<host>/sites/<container>/_ps/twins. Use this when constructing related URLs (e.g. twin content) that need to live in the same auth scope as the metadata calls.