Attachments
Gerar URL de upload
Gera uma URL temporária para upload directo de um ficheiro. A URL expira em 1 hora. Depois de fazeres o PUT para essa URL, usa o attachment_id devolvido no campo attachments[].attachment_id de POST /v1/emails.
POST
/
v1
/
attachments
/
presign
Gerar URL de upload
curl --request POST \
--url https://api.sendaki.tech/v1/attachments/presign \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "fatura-001.pdf",
"content_type": "application/pdf"
}
'import requests
url = "https://api.sendaki.tech/v1/attachments/presign"
payload = {
"filename": "fatura-001.pdf",
"content_type": "application/pdf"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({filename: 'fatura-001.pdf', content_type: 'application/pdf'})
};
fetch('https://api.sendaki.tech/v1/attachments/presign', 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.sendaki.tech/v1/attachments/presign",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filename' => 'fatura-001.pdf',
'content_type' => 'application/pdf'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.sendaki.tech/v1/attachments/presign"
payload := strings.NewReader("{\n \"filename\": \"fatura-001.pdf\",\n \"content_type\": \"application/pdf\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.sendaki.tech/v1/attachments/presign")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"fatura-001.pdf\",\n \"content_type\": \"application/pdf\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sendaki.tech/v1/attachments/presign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"fatura-001.pdf\",\n \"content_type\": \"application/pdf\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "https://storage.sendaki.tech/uploads/...?X-Signature=...",
"attachment_id": "att_9f1c2e7b4a3d4c8f8e6a1b2c3d4e5f60",
"expires_in": 3600
}{
"message": "filename é obrigatório"
}{
"message": "API key inválida ou revogada"
}{
"message": "Erro interno"
}Authorizations
API key gerada em app.sendaki.tech → Settings → API Keys. Formato: sk_....
Body
application/json
⌘I
Gerar URL de upload
curl --request POST \
--url https://api.sendaki.tech/v1/attachments/presign \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "fatura-001.pdf",
"content_type": "application/pdf"
}
'import requests
url = "https://api.sendaki.tech/v1/attachments/presign"
payload = {
"filename": "fatura-001.pdf",
"content_type": "application/pdf"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({filename: 'fatura-001.pdf', content_type: 'application/pdf'})
};
fetch('https://api.sendaki.tech/v1/attachments/presign', 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.sendaki.tech/v1/attachments/presign",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filename' => 'fatura-001.pdf',
'content_type' => 'application/pdf'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.sendaki.tech/v1/attachments/presign"
payload := strings.NewReader("{\n \"filename\": \"fatura-001.pdf\",\n \"content_type\": \"application/pdf\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.sendaki.tech/v1/attachments/presign")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"fatura-001.pdf\",\n \"content_type\": \"application/pdf\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sendaki.tech/v1/attachments/presign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"fatura-001.pdf\",\n \"content_type\": \"application/pdf\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "https://storage.sendaki.tech/uploads/...?X-Signature=...",
"attachment_id": "att_9f1c2e7b4a3d4c8f8e6a1b2c3d4e5f60",
"expires_in": 3600
}{
"message": "filename é obrigatório"
}{
"message": "API key inválida ou revogada"
}{
"message": "Erro interno"
}