# File

<details>

<summary>File Schema</summary>

* **id**: Unique id for every file
* **parent\_id**: Unique id for parent file
* **name**: name of the file
* **is\_folder**: File type, True means folder and false means file
* **ext**:&#x20;
* **type**: Type of file
* **file\_paths**: paths of file
* **uuid**: Unique identifier string(UUID Format)
* **size**: Size of the file
* **active**: Active/Inactive state of file
* **created\_at:** File creation timestamp
* **modified\_at:** Last modified timestamp of file
* **mime\_type**: Mime type of the file
* **num\_files**:&#x20;
* **lable**: The lable of the file
* **metadata**: The file metadata
* **file\_urls**: The actual url of the file

</details>

## Upload File From URL

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/file/uploadFileFromURL`

Create new file from url

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                      | Type   | Description                                  |
| ----------------------------------------- | ------ | -------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark> | String | Unique identifier string of the organization |
| url<mark style="color:red;">\*</mark>     | String | The file url                                 |
| relativePath                              | String |                                              |
| name                                      | String | Name of the file                             |
| thumbnailURL                              | String | The url of thumbnail                         |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": {
        "success": true
    },
    "data": {
        "id": 438554,
        "parent_id": 438477,
        "name": "1 (3).jpg",
        "is_folder": false,
        "ext": null,
        "type": "IMAGE",
        "file_paths": {
            "o": "o/1.jpg"
        },
        "uuid": "c6f34f02-0cb9-46b2-a40d-62ea41b895b7",
        "size": "44891",
        "active": true,
        "created_at": "2022-10-20T12:53:35.228Z",
        "modified_at": "2022-10-20T12:53:35.382Z",
        "mime_type": null,
        "num_files": null,
        "label": null,
        "metadata": null,
        "file_urls": {
            "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c6f34f02-0cb9-46b2-a40d-62ea41b895b7/o/1.jpg"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## Get File

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/file/get`

Get file by id

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                      | Type   | Description                                  |
| ----------------------------------------- | ------ | -------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark> | String | Unique identifier string of the organization |
| fileId<mark style="color:red;">\*</mark>  | Number | Unique ID of the file                        |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "status": {
        "success": true
    },
    "data": {
        "id": 438555,
        "parent_id": 438477,
        "name": "1 (4).jpg",
        "is_folder": false,
        "ext": null,
        "type": "IMAGE",
        "file_paths": {
            "o": "o/1.jpg",
            "t": "t/1 (4).jpg"
        },
        "uuid": "c00b65c6-924c-47f9-a9e5-e13a88bd4bb8",
        "size": "44891",
        "active": true,
        "created_at": "2022-10-21T09:07:57.771Z",
        "modified_at": "2022-10-21T09:07:58.521Z",
        "mime_type": null,
        "num_files": null,
        "label": null,
        "metadata": {
            "ext": "jpg",
            "mimeType": "image/jpeg",
            "resolution": {
                "x": 550,
                "y": 368
            }
        },
        "file_urls": {
            "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c00b65c6-924c-47f9-a9e5-e13a88bd4bb8/o/1.jpg",
            "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c00b65c6-924c-47f9-a9e5-e13a88bd4bb8/t/1%20(4).jpg",
            "r": "https://u.vrgmetri.com/image/{{TRANSFORM_PARAMS}}/gm-gb-test/media/2022-9/yzvcei/c00b65c6-924c-47f9-a9e5-e13a88bd4bb8/o/1.jpg"
        }
    }
}
```

{% endtab %}

{% tab title="200: OK No File Found" %}

```javascript
{
    "status": {
        "success": false,
        "errorMessage": "No file found"
    }
}
```

{% endtab %}
{% endtabs %}

## Create Folder

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/file/createFolder`

Create folder by name inside given parent

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                       | Type   | Description                                  |
| ------------------------------------------ | ------ | -------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark>  | String | Unique identifier string of the organization |
| name<mark style="color:red;">\*</mark>     | String | The name of folder                           |
| parentId<mark style="color:red;">\*</mark> | Number | Parent folder unique id                      |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "status": {
        "success": true
    },
    "data": {
        "id": 438557,
        "parent_id": 438477,
        "name": "new folder (1)",
        "is_folder": true,
        "ext": null,
        "type": null,
        "file_paths": null,
        "uuid": null,
        "size": null,
        "active": true,
        "created_at": "2022-10-21T10:42:44.856Z",
        "modified_at": "2022-10-21T10:42:44.856Z",
        "mime_type": null,
        "num_files": null,
        "label": null,
        "metadata": null,
        "file_urls": {}
    }
}
```

{% endtab %}

{% tab title="200: OK When Node doesn't belong to root" %}

```javascript
{
    "status": {
        "success": false,
        "errorMessage": "The parent node doesn't belong to the root"
    }
}
```

{% endtab %}
{% endtabs %}

## List Folder

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/file/listFolder`

List all file and folder from root or parent folder

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                       | Type   | Description                                  |
| ------------------------------------------ | ------ | -------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark>  | String | Unique identifier string of the organization |
| folderId<mark style="color:red;">\*</mark> | Number | Parent folder unique id                      |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "status": {
        "success": true
    },
    "data": [
        {
            "id": 438551,
            "parent_id": 438477,
            "name": "1 (1).jpg",
            "is_folder": false,
            "ext": null,
            "type": "IMAGE",
            "file_paths": {
                "o": "o/1.jpg",
                "t": "t/1 (1).jpg"
            },
            "uuid": "8f1453ed-417b-4502-988f-334550cda9b5",
            "size": "44891",
            "active": true,
            "created_at": "2022-10-19T10:24:21.367Z",
            "modified_at": "2022-10-19T10:24:22.076Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": {
                "ext": "jpg",
                "mimeType": "image/jpeg",
                "resolution": {
                    "x": 550,
                    "y": 368
                }
            },
            "file_urls": {
                "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/8f1453ed-417b-4502-988f-334550cda9b5/o/1.jpg",
                "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/8f1453ed-417b-4502-988f-334550cda9b5/t/1%20(1).jpg"
            }
        },
        {
            "id": 438553,
            "parent_id": 438477,
            "name": "1 (2).jpg",
            "is_folder": false,
            "ext": null,
            "type": "IMAGE",
            "file_paths": {
                "o": "o/1.jpg",
                "t": "t/1 (2).jpg"
            },
            "uuid": "6a20110c-fcb9-4599-a16c-66190a227152",
            "size": "44891",
            "active": true,
            "created_at": "2022-10-19T20:25:05.934Z",
            "modified_at": "2022-10-19T20:25:06.589Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": {
                "ext": "jpg",
                "mimeType": "image/jpeg",
                "resolution": {
                    "x": 550,
                    "y": 368
                }
            },
            "file_urls": {
                "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/6a20110c-fcb9-4599-a16c-66190a227152/o/1.jpg",
                "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/6a20110c-fcb9-4599-a16c-66190a227152/t/1%20(2).jpg"
            }
        },
        {
            "id": 438554,
            "parent_id": 438477,
            "name": "1 (3).jpg",
            "is_folder": false,
            "ext": null,
            "type": "IMAGE",
            "file_paths": {
                "o": "o/1.jpg",
                "t": "t/1 (3).jpg"
            },
            "uuid": "c6f34f02-0cb9-46b2-a40d-62ea41b895b7",
            "size": "44891",
            "active": true,
            "created_at": "2022-10-20T12:53:35.228Z",
            "modified_at": "2022-10-20T12:53:36.175Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": {
                "ext": "jpg",
                "mimeType": "image/jpeg",
                "resolution": {
                    "x": 550,
                    "y": 368
                }
            },
            "file_urls": {
                "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c6f34f02-0cb9-46b2-a40d-62ea41b895b7/o/1.jpg",
                "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c6f34f02-0cb9-46b2-a40d-62ea41b895b7/t/1%20(3).jpg"
            }
        },
        {
            "id": 438555,
            "parent_id": 438477,
            "name": "1 (4).jpg",
            "is_folder": false,
            "ext": null,
            "type": "IMAGE",
            "file_paths": {
                "o": "o/1.jpg",
                "t": "t/1 (4).jpg"
            },
            "uuid": "c00b65c6-924c-47f9-a9e5-e13a88bd4bb8",
            "size": "44891",
            "active": true,
            "created_at": "2022-10-21T09:07:57.771Z",
            "modified_at": "2022-10-21T09:07:58.521Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": {
                "ext": "jpg",
                "mimeType": "image/jpeg",
                "resolution": {
                    "x": 550,
                    "y": 368
                }
            },
            "file_urls": {
                "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c00b65c6-924c-47f9-a9e5-e13a88bd4bb8/o/1.jpg",
                "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/c00b65c6-924c-47f9-a9e5-e13a88bd4bb8/t/1%20(4).jpg"
            }
        },
        {
            "id": 438550,
            "parent_id": 438477,
            "name": "1.jpg",
            "is_folder": false,
            "ext": null,
            "type": "IMAGE",
            "file_paths": {
                "o": "o/1.jpg",
                "t": "t/1.jpg"
            },
            "uuid": "07aa3620-d689-41b6-8089-9296c0f318b0",
            "size": "44891",
            "active": true,
            "created_at": "2022-10-19T10:22:10.758Z",
            "modified_at": "2022-10-19T10:22:11.532Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": {
                "ext": "jpg",
                "mimeType": "image/jpeg",
                "resolution": {
                    "x": 550,
                    "y": 368
                }
            },
            "file_urls": {
                "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/07aa3620-d689-41b6-8089-9296c0f318b0/o/1.jpg",
                "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/07aa3620-d689-41b6-8089-9296c0f318b0/t/1.jpg"
            }
        },
        {
            "id": 438479,
            "parent_id": 438477,
            "name": "image-1662354253607.png",
            "is_folder": false,
            "ext": null,
            "type": "IMAGE",
            "file_paths": {
                "o": "o/image-1662354253607.png",
                "t": "t/image-1662354253607.jpg"
            },
            "uuid": "1ffd81f0-21ab-4a84-9ff3-943d43804a4e",
            "size": "76351",
            "active": true,
            "created_at": "2022-09-15T10:21:38.019Z",
            "modified_at": "2022-09-15T10:21:38.660Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": {
                "ext": "png",
                "mimeType": "image/png",
                "resolution": {
                    "x": 932,
                    "y": 610
                }
            },
            "file_urls": {
                "o": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/1ffd81f0-21ab-4a84-9ff3-943d43804a4e/o/image-1662354253607.png",
                "t": "https://u.vrgmetri.com/gm-gb-test/media/2022-9/yzvcei/1ffd81f0-21ab-4a84-9ff3-943d43804a4e/t/image-1662354253607.jpg"
            }
        },
        {
            "id": 438481,
            "parent_id": 438477,
            "name": "imported",
            "is_folder": true,
            "ext": null,
            "type": null,
            "file_paths": null,
            "uuid": null,
            "size": null,
            "active": true,
            "created_at": "2022-09-22T10:30:28.782Z",
            "modified_at": "2022-09-22T10:30:28.782Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": null,
            "file_urls": {}
        },
        {
            "id": 438556,
            "parent_id": 438477,
            "name": "new folder",
            "is_folder": true,
            "ext": null,
            "type": null,
            "file_paths": null,
            "uuid": null,
            "size": null,
            "active": true,
            "created_at": "2022-10-21T10:42:11.772Z",
            "modified_at": "2022-10-21T10:42:11.772Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": null,
            "file_urls": {}
        },
        {
            "id": 438557,
            "parent_id": 438477,
            "name": "new folder (1)",
            "is_folder": true,
            "ext": null,
            "type": null,
            "file_paths": null,
            "uuid": null,
            "size": null,
            "active": true,
            "created_at": "2022-10-21T10:42:44.856Z",
            "modified_at": "2022-10-21T10:42:44.856Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": null,
            "file_urls": {}
        },
        {
            "id": 438558,
            "parent_id": 438477,
            "name": "new folder (2)",
            "is_folder": true,
            "ext": null,
            "type": null,
            "file_paths": null,
            "uuid": null,
            "size": null,
            "active": true,
            "created_at": "2022-10-21T10:57:39.351Z",
            "modified_at": "2022-10-21T10:57:39.351Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": null,
            "file_urls": {}
        },
        {
            "id": 438537,
            "parent_id": 438477,
            "name": "wizards",
            "is_folder": true,
            "ext": null,
            "type": null,
            "file_paths": null,
            "uuid": null,
            "size": null,
            "active": true,
            "created_at": "2022-09-22T10:35:07.122Z",
            "modified_at": "2022-09-22T10:35:07.122Z",
            "mime_type": null,
            "num_files": null,
            "label": null,
            "metadata": null,
            "file_urls": {}
        }
    ]
}
```

{% endtab %}

{% tab title="200: OK When Node doesn't belong to root" %}

```javascript
{
    "status": {
        "success": false,
        "errorMessage": "The parent node doesn't belong to the root"
    }
}
```

{% endtab %}
{% endtabs %}

## Get Root File ID

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/file/getRootFileId`

Get root file by root name

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                      | Type   | Description                                  |
| ----------------------------------------- | ------ | -------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark> | String | Unique identifier string of the organization |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "status": {
        "success": true
    },
    "data": {
        "file": {
            "id": 438477
        }
    }
}
```

{% endtab %}

{% tab title="200: OK When No root file found" %}

```javascript
{
    "status": {
        "success": false,
        "errorMessage": "No root file found"
    }
}
```

{% 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.gmetri.com/metaverse/sdk/gmetri-sdk-apis/file.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.
