Attachments
Gerar URL de upload
Gera uma presigned URL para upload directo de um ficheiro para o S3 — o ficheiro nunca passa pelo Sendaki. A URL expira em 1 hora. Depois de fazeres o PUT para essa URL, usa a key devolvida no campo attachments[].key de POST /emails.
POST
/
attachments
/
presign
Gerar URL de upload
curl --request POST \
--url https://awsapi.sendaki.tech/attachments/presign \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"filename": "fatura-001.pdf",
"org_id": "org_123",
"content_type": "application/pdf"
}
'import requests
url = "https://awsapi.sendaki.tech/attachments/presign"
payload = {
"filename": "fatura-001.pdf",
"org_id": "org_123",
"content_type": "application/pdf"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({filename: 'fatura-001.pdf', org_id: 'org_123', content_type: 'application/pdf'})
};
fetch('https://awsapi.sendaki.tech/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://awsapi.sendaki.tech/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',
'org_id' => 'org_123',
'content_type' => 'application/pdf'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://awsapi.sendaki.tech/attachments/presign"
payload := strings.NewReader("{\n \"filename\": \"fatura-001.pdf\",\n \"org_id\": \"org_123\",\n \"content_type\": \"application/pdf\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://awsapi.sendaki.tech/attachments/presign")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"fatura-001.pdf\",\n \"org_id\": \"org_123\",\n \"content_type\": \"application/pdf\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://awsapi.sendaki.tech/attachments/presign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"fatura-001.pdf\",\n \"org_id\": \"org_123\",\n \"content_type\": \"application/pdf\"\n}"
response = http.request(request)
puts response.read_body{
"url": "https://sendaki.s3.us-east-1.amazonaws.com/attachments/org123/1778360121432-fatura-001.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Expires=3600&X-Amz-Signature=...",
"key": "attachments/org123/1778360121432-fatura-001.pdf",
"expires_in": 3600
}{
"error": "filename é obrigatório"
}{
"message": "Unauthorized"
}{
"error": "mensagem do erro"
}Authorizations
API key gerada em app.sendaki.tech → Settings → API Keys.
Body
application/json
Previous
Gerar URL de downloadGera uma presigned URL temporária para download de um ficheiro do S3. A URL expira em 1 hora.
Next
⌘I
Gerar URL de upload
curl --request POST \
--url https://awsapi.sendaki.tech/attachments/presign \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"filename": "fatura-001.pdf",
"org_id": "org_123",
"content_type": "application/pdf"
}
'import requests
url = "https://awsapi.sendaki.tech/attachments/presign"
payload = {
"filename": "fatura-001.pdf",
"org_id": "org_123",
"content_type": "application/pdf"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({filename: 'fatura-001.pdf', org_id: 'org_123', content_type: 'application/pdf'})
};
fetch('https://awsapi.sendaki.tech/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://awsapi.sendaki.tech/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',
'org_id' => 'org_123',
'content_type' => 'application/pdf'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://awsapi.sendaki.tech/attachments/presign"
payload := strings.NewReader("{\n \"filename\": \"fatura-001.pdf\",\n \"org_id\": \"org_123\",\n \"content_type\": \"application/pdf\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://awsapi.sendaki.tech/attachments/presign")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"fatura-001.pdf\",\n \"org_id\": \"org_123\",\n \"content_type\": \"application/pdf\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://awsapi.sendaki.tech/attachments/presign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"fatura-001.pdf\",\n \"org_id\": \"org_123\",\n \"content_type\": \"application/pdf\"\n}"
response = http.request(request)
puts response.read_body{
"url": "https://sendaki.s3.us-east-1.amazonaws.com/attachments/org123/1778360121432-fatura-001.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Expires=3600&X-Amz-Signature=...",
"key": "attachments/org123/1778360121432-fatura-001.pdf",
"expires_in": 3600
}{
"error": "filename é obrigatório"
}{
"message": "Unauthorized"
}{
"error": "mensagem do erro"
}