# TextureController

## Overview

* [Description](#description)
  * [Texture object](#texture-object)
  * [JSON Fields](#json-fields)
  * [CSV Fields](#csv-fields)
* [API Reference](#api-reference)
  * [GET /](#get-)
  * [POST /](#post-)
  * [GET /:id](#get-id)
  * [DELETE /:id](#delete-id)
  * [PUT /:id (json)](#put-id-json)
  * [PUT /:id (multipart)](#put-id-multipart)

## Description

Path /v2/textures

Handles all requests regarding texture: creating, updating, deleting.

### Texture Object

An example for a texture JSON object.

```json
{
  "id": 42,
  "material": "catalog1:aMaterialId",
  "mapping": "RGBA",
  "platform": "web",
  "image": "https://catalog.roomle.com/textures/82c3f8bce4f2ea5958bbe969465c827a9cc06ac9/image.jpg",
  "mmHeight": 250,
  "mmWidth": 250,
  "tileable": true,
  "definition": {
    "mmHeight": 250,
    "mmWidth": 250,
    "tileable": true,
    "mapping": "RGBA"
  }
}
```

Responses are usually wrapped in a meta object, which contains additional information about the response and may contain a single texture or a list of textures.

```
{
    "texture": 
        {textureObject},
    "textures": [
        {textureObject1},
        {textureObject2},
        ...
    ],
    "meta": {
        "lastUpdated": "2018-01-23T09:15:39.000Z",
        "cached": false,
        "total": 2,
        "serverTime": "2019-03-14T12:29:08.549Z"
    }
}
```

### JSON Fields

* id
* material
* mapping
* image
* mmHeight
* mmWidth
* tileable
* definition

### CSV Fields

* tex\<N>\_mapping: the mapping for the texture (e.g. "RGB", "RGBA", "XYZ" ...)
* tex\<N>\_mmwidth
* tex\<N>\_mmheight
* tex\<N>\_tileable: 0 for false, 1 for true
* tex\<N>\_image: URL to the texture image

## API Reference

### GET /

List of all textures matching the filter and visible to the Client

Generates: application/json

Response: Returns a container with a list of [Texture JSON object](#texture-json-object).

Query Parameters

| Name         | Type            | Comment                                       |
| ------------ | --------------- | --------------------------------------------- |
| ids\[]       | List of strings | filters the result to the given texture ids   |
| materials\[] | List of strings | filters the result to the given material ids; |
| catalog      | String          | filters the result to the given catalog id    |

### POST /

Accepts: json

Generates: json

for uploading a texture to a given material. There are meta data which has to be set and a definition parameter which has some well known properties but is extendable with custom properties.

meta information:

* material: String ("catalog1:materialExtId1")
* image: String
* platform: String ("web")

definition well known properties:

* mapping: String ("RGBA")
* mmWidth: Long
* mmHeight: Long
* tileable: Boolean

### GET /:id

Returns a specific texture.

Generates: application/json

Response (200 OK): [Texture JSON object](#texture-json-object)

### DELETE /:id

Deletes a specific texture.

Response (204 NO CONTENT)

### PUT /:id (json)

Updates the meta-information of a texture. Image needs to be uploaded explicitly (using ).

Accepts: application/json Generates: application/json

Body: [Texture JSON object](#texture-json-object)

Response (200 OK): updated [Texture JSON object](#texture-json-object)

Accepts: json

Generates: json

updates an existing texture with new information.

### PUT /:id (multipart)

updates assets on an texture

Accepts: multipart-formdata

Generates: application/json

parameters:

* the data, either as file or as URL. if both are provided, the URL is used
  * file : datafile to be uploaded
  * fileUrl: the publicly available url to the datafile
* type: type of the asset

possible types are images:

* "source" - as image file

Response (200 OK): updated [Texture JSON object](#texture-json-object) with updated asset

For more information on the assets, please check [ElementAssets](/rubens/rest-api/rest-api-reference/endpoints/elementassets.md#uploadable-types)


---

# 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.roomle.com/rubens/rest-api/rest-api-reference/endpoints/texture.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.
