Estimates
Add an estimate PDF attachment
Add an estimate PDF attachment through the public API.
POST
/
v1
/
estimates
/
{estimateId}
/
pdf-attachments
Add an estimate PDF attachment
curl --request POST \
--url https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-token: <api-key>' \
--form file=@example-file \
--form 'title=<string>'import requests
url = "https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "title": "<string>" }
headers = {"x-api-token": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('title', '<string>');
const options = {method: 'POST', headers: {'x-api-token': '<api-key>'}};
options.body = form;
fetch('https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments', 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.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments",
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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"x-api-token: <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://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments"
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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-token", "<api-key>")
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.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments")
.header("x-api-token", "<api-key>")
.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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-token"] = '<api-key>'
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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"attachment": {
"id": "<string>",
"url": "<string>",
"name": "<string>",
"type": "application/pdf",
"size": 123
}
}{
"code": "general/unauthorised"
}{
"code": "rest-api/insufficient-scope"
}{
"code": "customer-invoices/quote-not-found"
}Send the PDF as the
file part of a multipart request with a title field. The response contains the uploaded file under attachment. You need invoice-module write access.
You can attach up to ten PDFs to a quote. Each file may be at most 10 MiB (10,485,760 bytes). Infinity checks the actual file contents and rejects PDFs whose pages cannot be rendered.
Issued quotes use the same attachment editability rules as invoices: they must have no payments, must not be annulled, must belong to an editable fiscal year, and must be outside settled VAT periods. Draft attachments remain editable.
Attachments added through the API also appear in the quote editor and generated estimate PDF.Authorizations
API token for authentication. Obtain from your Infinity account settings.
Path Parameters
Body
multipart/form-data
Response
The uploaded attachment.
Show child attributes
Show child attributes
⌘I
Add an estimate PDF attachment
curl --request POST \
--url https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-token: <api-key>' \
--form file=@example-file \
--form 'title=<string>'import requests
url = "https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "title": "<string>" }
headers = {"x-api-token": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('title', '<string>');
const options = {method: 'POST', headers: {'x-api-token': '<api-key>'}};
options.body = form;
fetch('https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments', 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.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments",
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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"x-api-token: <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://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments"
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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-token", "<api-key>")
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.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments")
.header("x-api-token", "<api-key>")
.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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.infinity.swiss/v1/estimates/{estimateId}/pdf-attachments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-token"] = '<api-key>'
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\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"attachment": {
"id": "<string>",
"url": "<string>",
"name": "<string>",
"type": "application/pdf",
"size": 123
}
}{
"code": "general/unauthorised"
}{
"code": "rest-api/insufficient-scope"
}{
"code": "customer-invoices/quote-not-found"
}