ITwinClient
Implemented by
Index
Properties
Methods
- batchAssets
- batchGetAssets
- createAssetAttachmentUploadSession
- createAssets
- createOrUpdateTwin
- createOrUpdateTwinFile
- deleteAsset
- deleteAssetAttachment
- deleteAssetCategory
- deleteAssetPermissions
- deleteAssetType
- deleteTwin
- deleteTwinFile
- deleteTwinPermissions
- downloadTwinContent
- getAsset
- getAssetAttachmentBlob
- getAssetAttachmentUploadStatus
- getAssetCategory
- getAssetGroup
- getAssetType
- getAssetTypeCatalog
- getAssetTypeMetaSchema
- getMyPermissions
- getMyTwinPermissions
- getProcessorEvents
- getTwin
- getTwinContent
- getTwinDiagnostics
- getTwinFile
- getTwinFileContent
- getTwinFileVersion
- getTwinFileVersionContent
- getTwinGroup
- getTwinVersionContent
- getTwinVersionDiagnostics
- getTwinVersionEvents
- listAllAssetPermissions
- listAllTwinPermissions
- listAllTwins
- listAssetAttachments
- listAssetCategories
- listAssetCategoryVersions
- listAssetGroups
- listAssetPermissions
- listAssetTypeVersions
- listAssetTypes
- listAssets
- listTwinFileVersions
- listTwinFiles
- listTwinGroups
- listTwinPermissions
- listTwinVersions
- listTwins
- loadGeometryInfo
- loadGeometryInfoWithFactories
- loadTwin
- loadTwinWithFactories
- loadTwinWithGeometry
- putAssetAttachment
- putAssetCategory
- putAssetType
- restoreAsset
- restoreAssetAttachment
- restoreAssetCategory
- restoreAssetType
- restoreTwin
- restoreTwinFile
- setAssetPermissions
- setTwinPermissions
- 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>
deleteAssetPermissions
Removes the principal from the domain's access control list entirely, answering with it and an empty capability list.
The answer carries the
etagthe revocation wrote: it belongs to the domain, not to the principal, so a revoked principal having no listing entry does not cost the caller one. Chain the next write on it exactly as with setAssetPermissions, without re-reading listAssetPermissions.The etag is always required — a revocation always replaces existing grants — and a request naming none is refused with a
400rather than a conflict, before anything else is asked.Parameters
principalId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<AssetPrincipalPermissionsGet>
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>
deleteTwinPermissions
Removes the principal from the twin's access control list entirely — including any bits outside this capability vocabulary, which is what separates it from a setTwinPermissions call with an empty list.
The etag is always required: a delete always replaces existing grants.
Parameters
twinId: string
principalId: string
etag: string
optionalsignal: AbortSignal
Returns Promise<TwinPrincipalPermissionsGet>
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>
getAssetGroup
Returns one default group by its stable name, case-insensitively.
Parameters
name: string
optionalsignal: AbortSignal
Returns Promise<AssetGroupGet>
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 — the asset-domain vocabulary
ViewAssets,EditAssets,DeleteAssets,EditAssetTypesandManageAssetPermissions. 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.A 503 throws rather than answering with an empty array: the Permission service gave no answer, so the capabilities are unknown rather than absent, and the call is safe to retry unchanged.
Parameters
optionalsignal: AbortSignal
Returns Promise<MyPermissions>
getMyTwinPermissions
Returns the capabilities the caller holds on one specific twin. Open to every authenticated caller — an empty list is an honest answer rather than a refusal — so a UI can gate its controls on this before it knows anything about the caller.
The answer mixes vocabularies: the twin's own
TwinScopedCapabilityvalues, plus the asset-instance capabilitiesViewAssets,EditAssetsandDeleteAssets, which gate the assets hanging off this twin. The catalog capabilities andManageAssetPermissionsare not twin-bound and are absent here.Distinct from getMyPermissions, which answers the customer-scoped question over the whole asset domain. That one returns an empty list on 403; this route has no capability gate to refuse at, so a 403 here means something outside the Twin service refused, and is thrown.
Parameters
twinId: string
optionalsignal: AbortSignal
Returns Promise<MyTwinPermissions>
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>
getTwinGroup
Returns one of the twin's own default groups.
Parameters
twinId: string
groupId: string
optionalsignal: AbortSignal
Returns Promise<TwinGroupGet>
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>>
listAllAssetPermissions
Every entry of listAssetPermissions, paged to exhaustion.
Parameters
optionalsignal: AbortSignal
Returns Promise<AssetPrincipalPermissionsGet[]>
listAllTwinPermissions
Every permission entry on the twin, following the pagination to the end. The whole access-control list of one twin is a handful of entries, and reviewing it is the point of the surface, so this — rather than listTwinPermissions — is what most callers want.
Throws whatever listTwinPermissions throws, from whichever page hit it.
Parameters
twinId: string
optionalsignal: AbortSignal
Returns Promise<TwinPrincipalPermissionsGet[]>
listAllTwins
Fetches all twins by auto-paginating through listTwins. Caps at 1000 pages.
Parameters
optionaloptions: { includeDeleted?: boolean; relatedTo?: string }
relatedTofilters by container ID;includeDeletedincludes soft-deleted twins (returned redacted, default false).optionalincludeDeleted: boolean
optionalrelatedTo: string
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>>
listAssetGroups
Returns the asset domain's default groups —
AssetsReaders,AssetsContributors,AssetsAdministrators— under the ids whose membership confers their preset capabilities.A group whose seeding has not completed for this customer is omitted rather than listed under a placeholder title, so a short list is a state to poll rather than an error.
Parameters
optionalsignal: AbortSignal
Returns Promise<AssetGroupsGet>
listAssetPermissions
Lists one page of the principals holding capabilities on the customer-wide asset domain, with the capabilities each of them holds. The companion administration surface to getMyPermissions, which answers only for the caller.
pagination.nextPageis emitted unconditionally — it is non-null on the last page too — so it is not a termination signal. Page until a response comes back with fewer entries than the limit asked for, or use listAllAssetPermissions, which does that. On an access-review surface, stopping early under-reports who holds capabilities.Parameters
optionaloptions: { limit?: number; page?: string }
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<AssetPrincipalPermissionsGet>>
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>>
listTwinGroups
Returns the three default groups the twin owns —
TwinReaders,TwinContributors,TwinAdministrators— under the ids to name in setTwinPermissions.Not a picker for the principals a twin can be granted to: that is every group in the tenant, which the Permission service lists. These are the groups the twin itself owns, whose membership confers its preset capability levels.
Parameters
twinId: string
optionalsignal: AbortSignal
Returns Promise<TwinGroupsGet>
listTwinPermissions
Lists one page of the permission entries on every scope the twin owns. Each entry carries the etag of the scope it lives on, which is the value to send back when mutating that principal.
pagination.nextPageis emitted unconditionally — it is non-null on the last page too — so it is not a termination signal. Page until a response comes back with fewer entries than the limit asked for, or use listAllTwinPermissions, which does that. On an access-review surface, stopping early under-reports who holds capabilities on the twin.Parameters
twinId: string
optionaloptions: { limit?: number; page?: string }
optionallimit: number
optionalpage: string
optionalsignal: AbortSignal
Returns Promise<PaginatedResponse<TwinPrincipalPermissionsGet>>
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
optionaloptions: { includeDeleted?: boolean; limit?: number; page?: string; relatedTo?: string }
relatedTofilters by container ID;includeDeletedincludes soft-deleted twins (returned redacted, default false);page/limitcontrol pagination.optionalincludeDeleted: boolean
optionallimit: number
optionalpage: string
optionalrelatedTo: string
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>
setAssetPermissions
Replaces what one principal holds on the asset domain. Capabilities absent from
body.permissionsare revoked, and an empty list revokes everything — leaving the principal with no listing entry at all, exactly as deleteAssetPermissions does.body.etagis required whenever the principal already holds capabilities, and may be omitted only to create the grants of one that holds none.Parameters
principalId: string
body: AssetPermissionsPut
optionalsignal: AbortSignal
Returns Promise<AssetPrincipalPermissionsGet>
setTwinPermissions
Replaces the principal's capabilities on the twin, and returns the entry as stored along with the etag to chain the next write on.
permissions: []revokes all four capabilities without removing an entry that carries bits outside this vocabulary.body.etagmay be omitted only for a principal that holds nothing on the twin yet; see TwinPermissionsPut. Both etag refusals arrive as TwinPermissionsConflictError, carrying the current state to retry from.Parameters
twinId: string
principalId: string
body: TwinPermissionsPut
optionalsignal: AbortSignal
Returns Promise<TwinPrincipalPermissionsGet>
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.