> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tess.im/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload Avatar

> Uploads an avatar image for use with a digital employee.

This endpoint accepts `multipart/form-data`. The uploaded image will be processed and made available as an avatar URL and thumbnail URL.

### **Code Examples**

```http cURL theme={null}
curl --request POST \
  --url 'https://api.tess.im/digital-employees/avatar-upload' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'x-workspace-id: YOUR_WORKSPACE_ID' \
  --form 'avatar=@/path/to/avatar.png' \
  --form 'name=My Employee Avatar'
```

```json Node.js theme={null}
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

const form = new FormData();
form.append('avatar', fs.createReadStream('/path/to/avatar.png'));
form.append('name', 'My Employee Avatar');

const config = {
  method: 'post',
  url: 'https://api.tess.im/digital-employees/avatar-upload',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'x-workspace-id': 'YOUR_WORKSPACE_ID',
    ...form.getHeaders()
  },
  data: form
};

try {
  const response = await axios(config);
  console.log(response.data);
} catch (error) {
  console.error(error);
}
```

```python Python theme={null}
import requests

url = "https://api.tess.im/digital-employees/avatar-upload"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "x-workspace-id": "YOUR_WORKSPACE_ID"
}

with open("/path/to/avatar.png", "rb") as f:
    files = {"avatar": f}
    data = {"name": "My Employee Avatar"}
    response = requests.post(url, headers=headers, files=files, data=data)

print(response.json())
```

```php PHP theme={null}
<?php
$curl = curl_init();

$cfile = new CURLFile('/path/to/avatar.png', 'image/png', 'avatar.png');

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.tess.im/digital-employees/avatar-upload",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => [
    'avatar' => $cfile,
    'name' => 'My Employee Avatar'
  ],
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer YOUR_API_KEY",
    "x-workspace-id: YOUR_WORKSPACE_ID"
  ]
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

```java Java theme={null}
import java.io.*;
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;

String boundary = "----FormBoundary" + System.currentTimeMillis();
Path filePath = Path.of("/path/to/avatar.png");
byte[] fileBytes = Files.readAllBytes(filePath);

String body = "--" + boundary + "\r\n"
    + "Content-Disposition: form-data; name=\"avatar\"; filename=\"avatar.png\"\r\n"
    + "Content-Type: image/png\r\n\r\n";
byte[] bodyStart = body.getBytes();

String bodyEnd = "\r\n--" + boundary + "\r\n"
    + "Content-Disposition: form-data; name=\"name\"\r\n\r\n"
    + "My Employee Avatar\r\n"
    + "--" + boundary + "--\r\n";
byte[] bodyEndBytes = bodyEnd.getBytes();

ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(bodyStart);
baos.write(fileBytes);
baos.write(bodyEndBytes);

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.tess.im/digital-employees/avatar-upload"))
    .header("Authorization", "Bearer YOUR_API_KEY")
    .header("x-workspace-id", "YOUR_WORKSPACE_ID")
    .header("Content-Type", "multipart/form-data; boundary=" + boundary)
    .POST(HttpRequest.BodyPublishers.ofByteArray(baos.toByteArray()))
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```go Go theme={null}
package main

import (
    "bytes"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "os"
    "path/filepath"
)

func main() {
    var buf bytes.Buffer
    writer := multipart.NewWriter(&buf)

    file, _ := os.Open("/path/to/avatar.png")
    defer file.Close()
    part, _ := writer.CreateFormFile("avatar", filepath.Base("/path/to/avatar.png"))
    io.Copy(part, file)
    writer.WriteField("name", "My Employee Avatar")
    writer.Close()

    client := &http.Client{}
    req, _ := http.NewRequest("POST", "https://api.tess.im/digital-employees/avatar-upload", &buf)
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("x-workspace-id", "YOUR_WORKSPACE_ID")
    req.Header.Set("Content-Type", writer.FormDataContentType())

    resp, _ := client.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```jsonnet .NET theme={null}
using System.Net.Http;
using System.Net.Http.Headers;
using System.IO;

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
client.DefaultRequestHeaders.Add("x-workspace-id", "YOUR_WORKSPACE_ID");

using var form = new MultipartFormDataContent();
var fileBytes = await File.ReadAllBytesAsync("/path/to/avatar.png");
var fileContent = new ByteArrayContent(fileBytes);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/png");
form.Add(fileContent, "avatar", "avatar.png");
form.Add(new StringContent("My Employee Avatar"), "name");

var response = await client.PostAsync(
    "https://api.tess.im/digital-employees/avatar-upload",
    form);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

```ruby Ruby theme={null}
require 'uri'
require 'net/http'

uri = URI('https://api.tess.im/digital-employees/avatar-upload')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['x-workspace-id'] = 'YOUR_WORKSPACE_ID'

form_data = [
  ['avatar', File.open('/path/to/avatar.png')],
  ['name', 'My Employee Avatar']
]
request.set_form(form_data, 'multipart/form-data')

response = http.request(request)
puts response.read_body
```

### **Headers**

> [!NOTE]
>
> Include your API key in the `Authorization` header as a Bearer token on every request.

**x-workspace-id** `integer` *required*

ID of the workspace. Required for all Digital Employees API requests.

### **Request Body**

**avatar** `file` *required*

Avatar image file. Maximum size: 5 MB. Accepted formats: JPEG, PNG, WebP.

**name** `string`

Optional display name for the avatar. Maximum 255 characters.

### **Response**

```json theme={null}
{
  "data": {
    "id": 1,
    "url": "https://cdn.tess.im/avatars/abc123.png",
    "thumbnail_url": "https://cdn.tess.im/avatars/abc123_thumb.png"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.