curl --request POST \
--url https://api.nuvia.ai/v1/resource/upload-attachment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'import requests
url = "https://api.nuvia.ai/v1/resource/upload-attachment"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.nuvia.ai/v1/resource/upload-attachment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nuvia.ai/v1/resource/upload-attachment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nuvia.ai/v1/resource/upload-attachment"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nuvia.ai/v1/resource/upload-attachment")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nuvia.ai/v1/resource/upload-attachment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"extension": "<string>",
"external_url": "<string>",
"file_type": "IMAGE",
"company": "<unknown>",
"_id": "<string>",
"s3_key": "<string>",
"meta": {
"mimeType": "<string>",
"size": 123,
"fileName": "<string>",
"resourceUrl": "<string>"
},
"createdAt": "<unknown>",
"updatedAt": "<unknown>"
}Upload attachment
MESSAGE ATTACHMENT UPLOAD
Uploads a file and creates an attachment record. The attachment can then be used to send media messages (images, audio, video, documents).
π How to use
- Upload the file through this endpoint
- Keep the
_idit returns - Use that
_idon the message sending endpoints (send-image,send-audio,send-video,send-document)
π Supported file types
- IMAGE: images (JPG, PNG, GIF, WEBP)
- AUDIO: audio (MP3, OGG, AAC, AMR)
- VIDEO: video (MP4, 3GP)
- DOCUMENT: documents (PDF, DOC, DOCX, XLS, XLSX, PPT, TXT)
- STICKER: WhatsApp stickers (WEBP)
π Full media sending flow
1. POST /resource/upload-attachment (with file and fileType)
β Returns: { _id: "65f1a2b3c4d5...", external_url: "https://...", ... }
2. POST /messages/send-image (with conversationId and attachment)
β Sends the image to the contact
π Example
Request:
POST /resource/upload-attachment
Content-Type: multipart/form-data
{
"file": [binary file],
"fileType": "IMAGE"
}
Response:
{
"_id": "65f1a2b3c4d5e6f7g8h9i0j1",
"extension": "png",
"external_url": "https://s3.amazonaws.com/bucket/file.png",
"file_type": "IMAGE",
"meta": {
"mimeType": "image/png",
"size": 102400,
"fileName": "foto.png",
"resourceUrl": "https://s3.amazonaws.com/bucket/file.png"
},
"company": "65f...",
"createdAt": "2024-01-15T10:30:00.000Z"
}
Then send the image:
POST /messages/send-image
{
"conversationId": "65f...",
"message": {
"content": "Check out this image!",
"contentType": "IMAGE",
"attachment": "65f1a2b3c4d5e6f7g8h9i0j1"
}
}
β οΈ Important notes
- Maximum size: varies by file type and channel (WhatsApp has its own limits)
- Accepted formats: only formats supported by WhatsApp
- Storage: files are stored on AWS S3
- Public URL: the returned URL is public and directly accessible
- Reuse: the same attachment can be used in several messages
- Persistence: attachments are stored permanently
curl --request POST \
--url https://api.nuvia.ai/v1/resource/upload-attachment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'import requests
url = "https://api.nuvia.ai/v1/resource/upload-attachment"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.nuvia.ai/v1/resource/upload-attachment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nuvia.ai/v1/resource/upload-attachment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nuvia.ai/v1/resource/upload-attachment"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nuvia.ai/v1/resource/upload-attachment")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nuvia.ai/v1/resource/upload-attachment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"extension": "<string>",
"external_url": "<string>",
"file_type": "IMAGE",
"company": "<unknown>",
"_id": "<string>",
"s3_key": "<string>",
"meta": {
"mimeType": "<string>",
"size": 123,
"fileName": "<string>",
"resourceUrl": "<string>"
},
"createdAt": "<unknown>",
"updatedAt": "<unknown>"
}Authorizations
Token JWT de autenticaΓ§Γ£o
Headers
Target company identifier. Required only for global API keys (type=global). Ignored for company API keys and human users.
Body
Response
Attachment created
File extension (jpg, png, pdf, and so on).
Public file URL. Deprecated: prefer deriving a signed URL from s3_key.
File type: IMAGE, AUDIO, VIDEO, DOCUMENT, or STICKER.
IMAGE, AUDIO, VIDEO, DOCUMENT, STICKER Company that owns the attachment.
Attachment ID.
Storage key of the object, used to derive the signed URL.
Additional file metadata: mimeType, size, fileName, and others.
Show child attributes
Show child attributes
When the attachment was created.
When the attachment was last updated.