# GLB Constructor

## API METHODS

| HTTP type |               name              |
| --------- | :-----------------------------: |
| PUT       |        [/schema](#schema)       |
| PUT       |           [/glb](#glb)          |
| POST      |      [/assemble](#assemble)     |
| POST      | [/token\_status](#token_status) |

### /schema

**Declaring a file structure for a given token.**<br>

In order to use your GLB models (e.g. clothes, hair) to create an avatar, you must declare model IDs in the models config.

Model config example:\
There are 2 types of models declared here: a hair model and a body model.\
"hair\_male", "hair\_female", "body\_01"  are IDs for each GLB model you upload.

{% code title="models\_config.json" %}

```json
{
	"hair" : [
		"hair_male", "hair_female"
	],
	"body": [
		"body_01"
	]
}
```

{% endcode %}

## Method for loading the schema

<mark style="color:orange;">`PUT`</mark> `https://api.metahumansdk.io/glb_const/schema`

Declaring a file structure for a given token.

#### Request Body

| Name                                     | Type   | Description                                                 |
| ---------------------------------------- | ------ | ----------------------------------------------------------- |
| token<mark style="color:red;">\*</mark>  | string | Registered token.                                           |
| schema<mark style="color:red;">\*</mark> | binary | JSON file with description of the structure of your models. |

{% tabs %}
{% tab title="200: OK The request is successful" %}

```javascript
{
  "result": {
    "status": "schema loaded successfully"
  }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Error while processing" %}

```
{
    "error": {
            "code": int
            "message": str
    }
}
```

Check in [ERRORS](/service-apis-for-creating-virtual-avatars/errors/3d-face-reconstruction.md) section for possible error response examples.
{% endtab %}
{% endtabs %}

### /glb

**Uploading the GLB model declared in your schema.**<br>

A token is used for authorization.

{% hint style="warning" %}
Note: the GLB models you upload must fit our embbeded head size and position.
{% endhint %}

## Method for loading GLB models

<mark style="color:orange;">`PUT`</mark> `https://api.metahumansdk.io/glb_const/glb`

Upload your GLB model declared in your schema.

#### Request Body

| Name                                         | Type   | Description                                                          |
| -------------------------------------------- | ------ | -------------------------------------------------------------------- |
| token<mark style="color:red;">\*</mark>      | string | Registered token.                                                    |
| data<mark style="color:red;">\*</mark>       | binary | GLB model loaded as a binary stream using an in-memory bytes buffer. |
| sha256<mark style="color:red;">\*</mark>     | string | Check sum sha256 of GLB file.                                        |
| data\_type<mark style="color:red;">\*</mark> | string | Loaded model type in schema.                                         |
| data\_id<mark style="color:red;">\*</mark>   | string | Loaded model ID in schema.                                           |

{% tabs %}
{% tab title="200: OK The request is successful" %}

```javascript
{
  "result": {
    "status": "model loaded successfully"
  }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Error while processing" %}

```
{
    "error": {
            "code": int
            "message": str
    }
}
```

Check in [ERRORS](/service-apis-for-creating-virtual-avatars/errors/3d-face-reconstruction.md) section for possible error response examples.

{% endtab %}
{% endtabs %}

### /assemble

**Assembling the GLB model of a 3D avatar.**

\
Embbeded head model description:

* number of vertices: 5255
* UV texture: created using [3D Face Reconstruction Service](/service-apis-for-creating-virtual-avatars/getting-started/3d-face-reconstruction.md) from photo
* blendshapes: ARKit standard

## Method for constructing result GLB

<mark style="color:green;">`POST`</mark> `https://api.metahumansdk.io/glb_const/assemble`

Assembling a GLB model of an 3D avatar.

#### Request Body

| Name                                             | Type    | Description                                                                                                                              |
| ------------------------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| token<mark style="color:red;">\*</mark>          | string  | Registered token.                                                                                                                        |
| head\_uv<mark style="color:red;">\*</mark>       | binary  | Image texture from [3D Face Reconstruction Service](https://digitalhuman.metahumansdk.io/reconstruction/run_pipeline).                   |
| head\_config<mark style="color:red;">\*</mark>   | binary  | JSON file with model parameters from [3D Face Reconstruction Service](https://digitalhuman.metahumansdk.io/reconstruction/run_pipeline). |
| models\_congig<mark style="color:red;">\*</mark> | binary  | JSON file with model ID for model types from the schema.                                                                                 |
| custom\_models                                   | array   | List of custom (not preloaded) GLB model loaded as a binary stream using an in-memory bytes buffer.                                      |
| add\_facs                                        | boolean | Adding FACS blendshapes in GLB model.                                                                                                    |

{% tabs %}
{% tab title="200: OK the request is successful, a file with GLB model will be returned" %}

```javascript
string($binary)
```

{% endtab %}

{% tab title="422: Unprocessable Entity the input could not be interpreted correctly" %}

```
{
    "error": {
            "code": int
            "message": str
    }
}
```

Check in [ERRORS](/service-apis-for-creating-virtual-avatars/errors/3d-face-reconstruction.md) section for possible error response examples.
{% endtab %}
{% endtabs %}

### /status

**Server and token health check.**

## Method for checking status

<mark style="color:green;">`POST`</mark> `https://api.metahumansdk.io/glb_const/status`

Server and token health check.

#### Request Body

| Name  | Type   | Description       |
| ----- | ------ | ----------------- |
| token | string | Registered token. |

{% tabs %}
{% tab title="200: OK the request is successful" %}

```javascript
{
    "result": {
        "status": "ok"
    }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Error while processing" %}

```
{
    "error": {
            "code": int
            "message": str
    }
}
```

Check in [ERRORS](/service-apis-for-creating-virtual-avatars/errors/3d-face-reconstruction.md) section for possible error response examples.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.metahumansdk.io/service-apis-for-creating-virtual-avatars/api-methods/glb-constructor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
