Download an attachment
curl --request GET \
--url https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/downloadimport requests
url = "https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download', 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.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"url": "https://files.example.com/3f6c2a1e-8b4d-4f7a-9c2e-5d1b7a9e4c60.jpg?signature=…",
"name": "cupom-fiscal-posto.jpg",
"contentType": "image/jpeg"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "ATTACHMENT_MEMBERSHIP_REQUIRED",
"origin": "ATTACHMENT",
"message": "Organization membership required"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "ATTACHMENT_NOT_FOUND",
"origin": "ATTACHMENT",
"message": "Attachment not found"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "ATTACHMENT_NOT_AVAILABLE",
"origin": "ATTACHMENT",
"message": "Attachment is not available for download yet"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "BAD_REQUEST",
"origin": "ATTACHMENT",
"message": "Bad Request: Your request is invalid or incomplete. Please make sure you are requesting with the right fields.",
"fields": [
{
"field": "attachmentId",
"message": "Invalid UUID",
"code": "ATTACHMENTID_UUID"
}
]
}Download an attachment
Returns a short-lived URL to download the attachment’s file.
GET
/
realms
/
{realmId}
/
organizations
/
{organizationId}
/
attachments
/
{attachmentId}
/
download
Download an attachment
curl --request GET \
--url https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/downloadimport requests
url = "https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download', 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.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.attachment.v2.portao3.com.br/realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"url": "https://files.example.com/3f6c2a1e-8b4d-4f7a-9c2e-5d1b7a9e4c60.jpg?signature=…",
"name": "cupom-fiscal-posto.jpg",
"contentType": "image/jpeg"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "ATTACHMENT_MEMBERSHIP_REQUIRED",
"origin": "ATTACHMENT",
"message": "Organization membership required"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "ATTACHMENT_NOT_FOUND",
"origin": "ATTACHMENT",
"message": "Attachment not found"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "ATTACHMENT_NOT_AVAILABLE",
"origin": "ATTACHMENT",
"message": "Attachment is not available for download yet"
}{
"traceId": "1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b",
"code": "BAD_REQUEST",
"origin": "ATTACHMENT",
"message": "Bad Request: Your request is invalid or incomplete. Please make sure you are requesting with the right fields.",
"fields": [
{
"field": "attachmentId",
"message": "Invalid UUID",
"code": "ATTACHMENTID_UUID"
}
]
}Any member of the organization can download it. The
url works for 10 minutes: fetch it with a plain GET, without an Authorization header, and ask for a new one whenever you need the file — don’t store it. It always serves the file exactly as it was uploaded.
Only an AVAILABLE attachment can be downloaded. Right after the upload, while it is still PENDING_UPLOAD, this answers 409 ATTACHMENT_NOT_AVAILABLE — retry shortly. A DELETED attachment answers the same 409, for good.Path Parameters
ID of your realm.
Format: UUID
ID of the organization the attachment belongs to.
Format: UUID
ID of the attachment, as returned when it was created.
Format: UUID
Response
Successful response
A short-lived link to the attachment's file.
Pre-signed URL that serves the file for 10 minutes. Fetch it with a plain GET and no Authorization header; request a new one when it expires instead of storing it. (The example is shortened.)
Example:
"https://files.example.com/3f6c2a1e-8b4d-4f7a-9c2e-5d1b7a9e4c60.jpg?signature=…"
Name of the file, as sent when the attachment was created.
Example:
"cupom-fiscal-posto.jpg"
Media type of the file, as declared when the attachment was created.
Example:
"image/jpeg"