---
title: ModelApi
summary: PHP SDK: the Model operations, 12 methods, each with its parameters, result and a complete example.
order: 12
languages: [php]
sdk-package: PHP SDK · BIMworks
link-terms: true
---

# ModelApi

[[page:reference/sdk/php|PHP SDK]] · `BIMworks\Api` · class · 12 methods

Calls related to models, for example to upload or download models

Construct it with the client of [[page:reference/sdk/php#connect|the connect step]]: `new ModelApi(config: $client)`. Each method is one operation of the [[page:api|API part]], where it runs on its page.

<table class="dense">
<thead><tr><th>Method</th><th>Operation</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>[[page:reference/sdk/php/modelapi#addmodelwithurl|addModelWithUrl]]</code></td><td>[[openapi:AddModelWithUrl]]</td><td>Add a new model by providing a URL</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#augmentbcf|augmentBcf]]</code></td><td>[[openapi:AugmentBcf]]</td><td>Add snapshots to a BCF</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#download|download]]</code></td><td>[[openapi:Download]]</td><td>Download the model of the given Version UUID, as uploaded or as IFC or ifcXML.</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#downloadifcxml|downloadIfcXml]]</code></td><td>[[openapi:DownloadIfcXml]]</td><td>Download the model of the given Version UUID serialized as ifcXML (deprecated, use Download with format ifcxml)</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#exportgeometry|exportGeometry]]</code></td><td>[[openapi:ExportGeometry]]</td><td>The geometry of models as glTF</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#exportvectorsvg|exportVectorSvg]]</code></td><td>[[openapi:ExportVectorSvg]]</td><td>Export an orthographic vector drawing (SVG) of a model</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#getcheckin|getCheckin]]</code></td><td>[[openapi:GetCheckin]]</td><td>The status of a checkin</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#getvalidationreport|getValidationReport]]</code></td><td>[[openapi:GetValidationReport]]</td><td>Why a model is invalid, or why its checkin failed</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#lookupmodelhashes|lookupModelHashes]]</code></td><td>[[openapi:LookupModelHashes]]</td><td>Which files the server has already</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#render|render]]</code></td><td>[[openapi:Render]]</td><td>A PNG image of a model</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#schemaconversionreport|schemaConversionReport]]</code></td><td>[[openapi:SchemaConversionReport]]</td><td>The log of a schema conversion</td></tr>
<tr><td><code>[[page:reference/sdk/php/modelapi#uploadmodel|uploadModel]]</code></td><td>[[openapi:UploadModel]]</td><td>Upload a single model using multipart/form-data</td></tr>
</tbody>
</table>

## `addModelWithUrl` {#addmodelwithurl}

```php
public function addModelWithUrl(AddModelWithUrlRequest $add_model_with_url_request): ModelVersion
```

Add a new model by providing a URL. The server fetches the file from `url` (within its egress policy) and checks it in under `node_uuid`. The checkin (parsing, geometry, indexing) follows the upload, which is always waited for. Without `wait_ms` the call answers when the checkin ends, with the new Version, which for a big model can take longer than a gateway waits. With `wait_ms` it answers the Version when the checkin ends within that many milliseconds, and otherwise 202 with the checkin's status and `job_uuid`: follow it with GetCheckin. A checkin still running after an hour answers 202 too. A ZIP of models is checked in where it was received and has no job, so it always waits. The same file name in the same folder adds a Version to that model.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:AddModelWithUrl]] · <code>POST /openapi/model/AddModelWithUrl</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:upload]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>add_model_with_url_request</code></td><td><code>[[page:reference/sdk/php/models#AddModelWithUrlRequest|AddModelWithUrlRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:AddModelWithUrl]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#ModelVersion|ModelVersion]]</code> — Upload was successful

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\AddModelWithUrlRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "node_uuid": "00000000-0000-0000-0000-000000000000",
  "path": "",
  "filename": "",
  "url": "",
  "input_file_type": "IFC",
  "format_settings": {},
  "force_reprocessing": false,
  "tags": [
    "DEMO"
  ],
  "validation_settings": {},
  "wait_ms": 0,
  "force": "NONE"
}
JSON, AddModelWithUrlRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->addModelWithUrl($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `augmentBcf` {#augmentbcf}

```php
public function augmentBcf(\SplFileObject $bcf, string $version_uuid, ?int $width = null, ?int $height = null): \SplFileObject
```

Add snapshots to a BCF. Answers the BCF 2.1 file with a PNG snapshot rendered for each viewpoint that has a perspective camera, of the model `version_uuid`: an integrator keeps its issues and gets BCF with images out of them. Orthogonal viewpoints keep what they had; at most 1000 snapshots are rendered per file.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:AugmentBcf]] · <code>POST /openapi/model/AugmentBcf</code></td></tr>
<tr><th>Scope</th><td>[[scope:geometry:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>bcf</code></td><td><code>\SplFileObject</code><span class="req">required</span></td><td>The file. The BCF 2.1 file</td></tr>
<tr><td><code>version_uuid</code></td><td><code>string</code><span class="req">required</span></td><td></td></tr>
<tr><td><code>width</code></td><td><code>int</code><span class="opt">optional</span></td><td>The snapshots' width in pixels, 300 when absent</td></tr>
<tr><td><code>height</code></td><td><code>int</code><span class="opt">optional</span></td><td>The snapshots' height in pixels, 300 when absent</td></tr>
</tbody>
</table>

### Returns

<code>\SplFileObject</code> — The BCF with the snapshots

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ['bcf' => new SplFileObject('issues.bcf'), 'version_uuid' => 'BIM_WORKS_FIRST_MODEL'];

// 3. The call
$result = (new ModelApi(config: $client))->augmentBcf(...$request);

// 4. The result
copy($result->getPathname(), 'augment-bcf.bcf');
```

## `download` {#download}

```php
public function download(DownloadRequest $download_request): \SplFileObject
```

Download the model of the given Version UUID, as uploaded or as IFC or ifcXML. In case you want to download only a subset of an IFC model, use ifc/query. `format` chooses what comes back; it wins over the Accept header, which is not read by this operation. `original` (the default) is the file as it was uploaded, byte for byte; `ifc` and `ifcxml` serialize the stored model, so they work for any Version whose model parsed as IFC, whatever its upload encoding. With `error_uuid` instead of a model identifier the file of a failed upload comes back as it was uploaded.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:Download]] · <code>POST /openapi/model/Download</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>download_request</code></td><td><code>[[page:reference/sdk/php/models#DownloadRequest|DownloadRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:Download]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>\SplFileObject</code> — The model file. Without target_schema byte-for-byte as it was uploaded, with target_schema the converted file

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\DownloadRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "type": "VersionModelIdentifier",
  "uuid": "BIM_WORKS_FIRST_MODEL"
}
JSON, DownloadRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->download($request);

// 4. The result
copy($result->getPathname(), 'download.ifc');
```

## `downloadIfcXml` {#downloadifcxml}

```php
public function downloadIfcXml(ModelIdentifier $model_identifier): \SplFileObject
```

Download the model of the given Version UUID serialized as ifcXML (deprecated, use Download with format ifcxml). Deprecated, Download with `format` `ifcxml` answers the same file; this operation will be removed in a later release. The stored model is converted on the fly, so this works for any Version whose model parsed as IFC, regardless of the encoding it was uploaded in. The ifcXML dialect follows the model's schema, ISO 10303-28 for IFC2X3 and ifcXML4 for IFC4/IFC4X3.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:DownloadIfcXml]] · <code>POST /openapi/model/DownloadIfcXml</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>model_identifier</code></td><td><code>[[page:reference/sdk/php/models#ModelIdentifier|ModelIdentifier]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:DownloadIfcXml]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>\SplFileObject</code> — The model serialized as ifcXML

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\ModelIdentifier;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "type": "VersionModelIdentifier",
  "uuid": "BIM_WORKS_FIRST_MODEL"
}
JSON, ModelIdentifier::class);

// 3. The call
$result = (new ModelApi(config: $client))->downloadIfcXml($request);

// 4. The result
copy($result->getPathname(), 'download-ifc-xml.xml');
```

## `exportGeometry` {#exportgeometry}

```php
public function exportGeometry(ExportGeometryRequest $export_geometry_request): \SplFileObject
```

The geometry of models as glTF. Exports the triangulated geometry of the objects a BQL condition selects (every product when absent) as one binary glTF file, several models in one file.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ExportGeometry]] · <code>POST /openapi/model/ExportGeometry</code></td></tr>
<tr><th>Scope</th><td>[[scope:geometry:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>export_geometry_request</code></td><td><code>[[page:reference/sdk/php/models#ExportGeometryRequest|ExportGeometryRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ExportGeometry]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>\SplFileObject</code> — The file

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\ExportGeometryRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "models": [
    {
      "type": "UrlModelIdentifier"
    }
  ],
  "query": "",
  "format": "glb",
  "colors": {},
  "only_outside_triangles": false
}
JSON, ExportGeometryRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->exportGeometry($request);

// 4. The result
copy($result->getPathname(), 'export-geometry.glb');
```

## `exportVectorSvg` {#exportvectorsvg}

```php
public function exportVectorSvg(ExportVectorSvgRequest $export_vector_svg_request): \SplFileObject
```

Export an orthographic vector drawing (SVG) of a model. Renders a floor plan, section or elevation of one model as an SVG drawing with occlusion culling (every product its own group), optionally restricted, recoloured and labelled through BQL and BVL. A request carrying `styling` also needs the actions:read scope. The response carries the drawing; the `cache` and `labels` objects of the task response are returned as the `X-BimWorks-Vector` header (JSON).

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ExportVectorSvg]] · <code>POST /openapi/model/ExportVectorSvg</code></td></tr>
<tr><th>Scope</th><td>[[scope:geometry:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>export_vector_svg_request</code></td><td><code>[[page:reference/sdk/php/models#ExportVectorSvgRequest|ExportVectorSvgRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ExportVectorSvg]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>\SplFileObject</code> — The drawing

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\ExportVectorSvgRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{}
JSON, ExportVectorSvgRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->exportVectorSvg($request);

// 4. The result
copy($result->getPathname(), 'export-vector-svg.svg');
```

## `getCheckin` {#getcheckin}

```php
public function getCheckin(GetCheckinRequest $get_checkin_request): CheckinStatus
```

The status of a checkin. The status of the checkin of an upload, by the `job_uuid` an upload answered with 202, or by the `version_uuid` it made. With `wait_ms` the call waits that long for the checkin to end (at most 5 minutes). Once it is DONE the answer holds the Version; once it FAILED, the error. Needs read rights on the model. Checkin jobs are kept for 30 days.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:GetCheckin]] · <code>POST /openapi/model/GetCheckin</code></td></tr>
<tr><th>Scope</th><td>[[scope:fs:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>get_checkin_request</code></td><td><code>[[page:reference/sdk/php/models#GetCheckinRequest|GetCheckinRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:GetCheckin]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#CheckinStatus|CheckinStatus]]</code> — The status

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\GetCheckinRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "job_uuid": "00000000-0000-0000-0000-000000000000",
  "version_uuid": "BIM_WORKS_FIRST_MODEL",
  "wait_ms": 0
}
JSON, GetCheckinRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->getCheckin($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `getValidationReport` {#getvalidationreport}

```php
public function getValidationReport(?GetValidationReportRequest $get_validation_report_request = null): ValidationReportResult
```

Why a model is invalid, or why its checkin failed. The validation report of a Version (`model`) or of a failed checkin (`error_uuid`, from ListNodeErrors): per stage of the checkin (upload, parse, schemaCheck, geometry3d, geometry2d, indexing, ...) its status and its findings, each with its rule, severity and the object it is about. `summary_only` answers the counts.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:GetValidationReport]] · <code>POST /openapi/model/GetValidationReport</code></td></tr>
<tr><th>Scope</th><td>[[scope:query:run]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>get_validation_report_request</code></td><td><code>[[page:reference/sdk/php/models#GetValidationReportRequest|GetValidationReportRequest]]</code><span class="opt">optional</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:GetValidationReport]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#ValidationReportResult|ValidationReportResult]]</code> — The report

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\GetValidationReportRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "error_uuid": "00000000-0000-0000-0000-000000000000",
  "summary_only": false,
  "min_severity": "INFO",
  "stage": "",
  "rule": [
    ""
  ],
  "global_id": "",
  "express_id": 0
}
JSON, GetValidationReportRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->getValidationReport($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `lookupModelHashes` {#lookupmodelhashes}

```php
public function lookupModelHashes(LookupModelHashesRequest $lookup_model_hashes_request): LookupModelHashes200Response
```

Which files the server has already. For each file, whether the server has processed one with the same content, so its upload can send the `hash` instead of the bytes (UploadModel). Hash the first 32 KiB and pass that with the size first, which is cheap; for the files that are known, hash the whole file and pass `full_xxh64`. The answer is in the order asked. `max_concurrent_checkins` is how many checkins the answering server runs at once: an upload scheduler keeps about that many uploads going.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:LookupModelHashes]] · <code>POST /openapi/model/LookupModelHashes</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:upload]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>lookup_model_hashes_request</code></td><td><code>[[page:reference/sdk/php/models#LookupModelHashesRequest|LookupModelHashesRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:LookupModelHashes]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#LookupModelHashes200Response|LookupModelHashes200Response]]</code> — Per file whether it is known

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\LookupModelHashesRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "models": [
    {
      "size": 1048576,
      "partial_xxh64": 12345678901234567890
    }
  ]
}
JSON, LookupModelHashesRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->lookupModelHashes($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `render` {#render}

```php
public function render(RenderRequest $render_request): \SplFileObject
```

A PNG image of a model. Renders one model as a PNG. With `camera` it shows that view; with `view` one of the named angles, framing the whole model. With neither it answers the screenshot the checkin stored, or else the `iso_front_right` view. A workspace whose filter limits the objects gets no image of the whole model. Rendering must be enabled on the instance; a host without a GPU renders on the CPU.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:Render]] · <code>POST /openapi/model/Render</code></td></tr>
<tr><th>Scope</th><td>[[scope:geometry:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>render_request</code></td><td><code>[[page:reference/sdk/php/models#RenderRequest|RenderRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:Render]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>\SplFileObject</code> — The image

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\RenderRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "camera": {
    "position": {
      "x": 0.0,
      "y": 0.0,
      "z": 0.0
    }
  },
  "view": "iso_front_right",
  "size": {}
}
JSON, RenderRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->render($request);

// 4. The result
copy($result->getPathname(), 'render.png');
```

## `schemaConversionReport` {#schemaconversionreport}

```php
public function schemaConversionReport(SchemaConversionReportRequest $schema_conversion_report_request): SchemaConversionReportResponse
```

The log of a schema conversion. What a schema conversion lost, added and changed. For a Version that was made by the statement CONVERT SCHEMA pass its identifier; for a converted download pass the identifier of the Version that was downloaded and the target_schema it was converted to. This call reads a log, it converts nothing; a conversion that was never made is not found. The report holds the summary, exact counters per rule and a capped number of findings per rule. Every single loss and addition is in the detail log, which is never capped.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:SchemaConversionReport]] · <code>POST /openapi/model/SchemaConversionReport</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>schema_conversion_report_request</code></td><td><code>[[page:reference/sdk/php/models#SchemaConversionReportRequest|SchemaConversionReportRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:SchemaConversionReport]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#SchemaConversionReportResponse|SchemaConversionReportResponse]]</code> — The conversion report in the requested format

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\SchemaConversionReportRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "type": "VersionModelIdentifier",
  "uuid": "BIM_WORKS_FIRST_MODEL",
  "target_schema": "IFC4"
}
JSON, SchemaConversionReportRequest::class);

// 3. The call
$result = (new ModelApi(config: $client))->schemaConversionReport($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `uploadModel` {#uploadmodel}

```php
public function uploadModel(?\SplFileObject $file = null, ?string $node_uuid = null, ?string $filename = null, ?int $filesize = null, ?string $content_type = null, ?string $input_file_type = null, ?string $format_settings = null, ?string $hash = null, ?bool $force_reprocessing = null, ?string $tags = null, ?string $validation_settings = null, ?int $wait_ms = null, ?string $force = null): ModelVersion
```

Upload a single model using multipart/form-data. Uploads a file into the folder `node_uuid` (the caller's own root when absent). When LookupModelHashes says the server has the file already, send its `hash` instead of the `file` part: no bytes travel. A hash the server cannot use after all answers NO_STREAM (404); send the file then. The checkin (parsing, geometry, indexing) follows the upload, which is always waited for. Without `wait_ms` the call answers when the checkin ends, with the new Version, which for a big model can take longer than a gateway waits. With `wait_ms` it answers the Version when the checkin ends within that many milliseconds, and otherwise 202 with the checkin's status and `job_uuid`: follow it with GetCheckin. A checkin still running after an hour answers 202 too. A ZIP of models is checked in where it was received and has no job, so it always waits. The same file name in the same folder adds a Version to that model.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:UploadModel]] · <code>POST /openapi/model/UploadModel</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:upload]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>file</code></td><td><code>\SplFileObject</code><span class="opt">optional</span></td><td>The file. A single uploaded model</td></tr>
<tr><td><code>node_uuid</code></td><td><code>string</code><span class="opt">optional</span></td><td>The UUID of the Node to which to add the models</td></tr>
<tr><td><code>filename</code></td><td><code>string</code><span class="opt">optional</span></td><td>Name of the file</td></tr>
<tr><td><code>filesize</code></td><td><code>int</code><span class="opt">optional</span></td><td>Filesize in bytes</td></tr>
<tr><td><code>content_type</code></td><td><code>string</code><span class="opt">optional</span></td><td>The content type. When available this information is taken from the Content-Type of the file part. Allowed values are application/ifc, application/xml (for .ifcxml files), application/pdf, application/e57</td></tr>
<tr><td><code>input_file_type</code></td><td><code>string</code><span class="opt">optional</span></td><td>The type of the model (an InputFileType name). When present and not UNKNOWN it wins over the filename extension</td></tr>
<tr><td><code>format_settings</code></td><td><code>string</code><span class="opt">optional</span></td><td>A JSON-encoded PointCloudFormatSettings object (multipart form fields are strings) with per-upload point cloud format options</td></tr>
<tr><td><code>hash</code></td><td><code>string</code><span class="opt">optional</span></td><td>Instead of the file, its full_xxh64 (see ModelHash) when LookupModelHashes said the server knows it; ignored next to a file, which the server hashes itself. Needs filename</td></tr>
<tr><td><code>force_reprocessing</code></td><td><code>bool</code><span class="opt">optional</span></td><td>Process the file again, also when the server has processed the same file before</td></tr>
<tr><td><code>tags</code></td><td><code>string</code><span class="opt">optional</span></td><td>Tags of the new Version, comma-separated VersionTag names</td></tr>
<tr><td><code>validation_settings</code></td><td><code>string</code><span class="opt">optional</span></td><td>A JSON-encoded ValidationSettings object</td></tr>
<tr><td><code>wait_ms</code></td><td><code>int</code><span class="opt">optional</span></td><td>Answer 202 with the checkin's status when the checkin takes longer than this</td></tr>
<tr><td><code>force</code></td><td><code>string</code><span class="opt">optional</span></td><td>An UploadForce: NONE, NEW_VERSION or NEW_MODEL</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#ModelVersion|ModelVersion]]</code> — Upload was successful

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ['file' => new SplFileObject('model.ifc'), 'filename' => 'model.ifc'];

// 3. The call
$result = (new ModelApi(config: $client))->uploadModel(...$request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```
