# Vehicle avatar

## API actions

API path: `/vehicle/avatar`.

### assign

Assigns `icon_id` (from standard icon set) to specified vehicle.

**required sub-user rights**: `vehicle_update`

#### Parameters

| name        | description        | type |
| ----------- | ------------------ | ---- |
| vehicle\_id | ID of the vehicle. | int  |
| icon\_id    | ID of the icon.    | int  |

`icon_id` can be null – this means that uploaded avatar should be used instead of icon.

#### Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/vehicle/avatar/assign' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "vehicle_id": 127722, "icon_id": 1342}'
```

{% endcode %}
{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/vehicle/avatar/assign?hash=a6aa75587e5c59c32d347da438505fc3&vehicle_id=127722&icon_id=1342
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response**

```json
{
  "success": true
}
```

**Errors**

* 201 – Not found in the database - when vehicle with `vehicle_id` not found.

### upload

Uploads avatar image for specified vehicle.\
Then it will be available from `[api_base_url]/<api_static_path>/vehicle/avatars/<file_name>`\
e.g. `https://api.eu.navixy.com/v2/static/vehicle/avatars/abcdef123456789.png`.

**required sub-user rights**: `vehicle_update`

**avatar\_file\_name** returned in response and will be returned from [/vehicle/list](https://github.com/SquareGPS/navixy-api/blob/master/docs/user-api/backend-api/resources/fleet/vehicle/broken-reference/README.md).

**MUST** be a POST multipart request (multipart/form-data),\
with one of the parts being an image file upload (with the name "file").

File part **mime** type must be one of :

* `image/jpeg`
* `image/pjpeg`
* `image/png`
* `image/gif`
* `image/webp`

#### Parameters

| name             | description                | type   |
| ---------------- | -------------------------- | ------ |
| vehicle\_id      | Vehicle ID.                | int    |
| file             | Image file.                | string |
| redirect\_target | Optional. URL to redirect. | string |

If `redirect_target` passed a return redirect to `response=<urlencoded response json>`.

#### Response

```json
{
  "success": true,
  "value": "abcdef123456789.png"
}
```

* `value` - string. Avatar file name.

#### Errors

* 201 – Not found in the database - when vehicle with `vehicle_id` not found.
* 233 – No data file - if `file` part not passed.
* 234 – Invalid data format - if passed `file` with unexpected **mime** type.
* 254 – Cannot save file - on some file system errors.


---

# 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://navixy.com/docs/navixy-api/user-api/backend-api/resources/fleet/vehicle/avatar.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.
