> This page is for version v1 (default).
> For other versions, use one of these documentation indexes:
> - v1 (default): https://doc.youratlas.com/v1/llms.txt
> - v2: https://doc.youratlas.com/v2/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://doc.youratlas.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://doc.youratlas.com/_mcp/server.

# Upload media attachments

POST https://api.youratlas.com/v1/api/campaign-chat/{campaignId}/upload-media
Content-Type: multipart/form-data

Uploads image or video files to attach to a message in a chat session. Send the files as multipart form data.

Reference: https://doc.youratlas.com/api-reference/atlas-api/campaign-chat/upload-chat-media

## Authentication

- `api-key` header (required) — Your Atlas API key. Get it from the Atlas Portal under Settings > API Keys.

## Request

### Path parameters

- `campaignId` (string, required) — ID of the campaign.

### Body (multipart/form-data)

This endpoint expects a multipart form with multiple files.

- `files` (files, required)
- `sessionId` (string, required)

## Response

### 200

Media uploaded

- `urls` (list of string, optional)

## Errors

### 400 Bad Request Error

Bad request

- `error` (ErrorError, optional)

### 401 Unauthorized Error

Invalid or missing API key

- `error` (ErrorError, optional)

### 500 Internal Server Error

Internal server error

- `error` (ErrorError, optional)

## Types

### ErrorError

- `message` (string, optional)
- `code` (string, optional)
- `requestId` (string, optional)

## Examples

**Request**

```json
{
  "files": [
    "<file: photo.jpg>"
  ],
  "sessionId": "7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72"
}
```

**Response**

```json
{
  "urls": [
    "string"
  ]
}
```

**SDK Code**

```python Campaign Chat_uploadChatMedia_example
import requests

url = "https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media"

files = { "files": "open('photo.jpg', 'rb')" }
payload = { "sessionId": "7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72" }
headers = {"api-key": "<apiKey>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript Campaign Chat_uploadChatMedia_example
const url = 'https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media';
const form = new FormData();
form.append('files', 'photo.jpg');
form.append('sessionId', '7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72');

const options = {method: 'POST', headers: {'api-key': '<apiKey>'}};

options.body = form;

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Campaign Chat_uploadChatMedia_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"photo.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sessionId\"\r\n\r\n7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api-key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Campaign Chat_uploadChatMedia_example
require 'uri'
require 'net/http'

url = URI("https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-key"] = '<apiKey>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"photo.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sessionId\"\r\n\r\n7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72\r\n-----011000010111000001101001--\r\n"

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

```java Campaign Chat_uploadChatMedia_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media")
  .header("api-key", "<apiKey>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"photo.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sessionId\"\r\n\r\n7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php Campaign Chat_uploadChatMedia_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media', [
  'multipart' => [
    [
        'name' => 'files',
        'filename' => 'photo.jpg',
        'contents' => null
    ],
    [
        'name' => 'sessionId',
        'contents' => '7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72'
    ]
  ]
  'headers' => [
    'api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Campaign Chat_uploadChatMedia_example
using RestSharp;

var client = new RestClient("https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media");
var request = new RestRequest(Method.POST);
request.AddHeader("api-key", "<apiKey>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"photo.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sessionId\"\r\n\r\n7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Campaign Chat_uploadChatMedia_example
import Foundation

let headers = ["api-key": "<apiKey>"]
let parameters = [
  [
    "name": "files",
    "fileName": "photo.jpg"
  ],
  [
    "name": "sessionId",
    "value": "7b1d4e60-2c9a-4f35-8e1b-6d0f3a9c5e72"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.youratlas.com/v1/api/campaign-chat/campaignId/upload-media")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```