curl --request POST \
--url https://api.isnap.ai/v1/attachments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"content_type": "<string>",
"size_bytes": 2684354560
}
'import requests
url = "https://api.isnap.ai/v1/attachments"
payload = {
"filename": "<string>",
"content_type": "<string>",
"size_bytes": 2684354560
}
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: '<string>', content_type: '<string>', size_bytes: 2684354560})
};
fetch('https://api.isnap.ai/v1/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.isnap.ai/v1/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 => json_encode([
'filename' => '<string>',
'content_type' => '<string>',
'size_bytes' => 2684354560
]),
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.isnap.ai/v1/attachments"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"size_bytes\": 2684354560\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.isnap.ai/v1/attachments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"size_bytes\": 2684354560\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.isnap.ai/v1/attachments")
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\": \"<string>\",\n \"content_type\": \"<string>\",\n \"size_bytes\": 2684354560\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"upload_url": "<string>",
"upload_expires_at": "<string>",
"required_headers": {},
"status": "<string>",
"warnings": [
"<string>"
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}Create an attachment
Registers a file and returns a signed URL to upload it, valid 15 minutes.
curl --request POST \
--url https://api.isnap.ai/v1/attachments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"content_type": "<string>",
"size_bytes": 2684354560
}
'import requests
url = "https://api.isnap.ai/v1/attachments"
payload = {
"filename": "<string>",
"content_type": "<string>",
"size_bytes": 2684354560
}
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: '<string>', content_type: '<string>', size_bytes: 2684354560})
};
fetch('https://api.isnap.ai/v1/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.isnap.ai/v1/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 => json_encode([
'filename' => '<string>',
'content_type' => '<string>',
'size_bytes' => 2684354560
]),
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.isnap.ai/v1/attachments"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"size_bytes\": 2684354560\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.isnap.ai/v1/attachments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"size_bytes\": 2684354560\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.isnap.ai/v1/attachments")
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\": \"<string>\",\n \"content_type\": \"<string>\",\n \"size_bytes\": 2684354560\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"upload_url": "<string>",
"upload_expires_at": "<string>",
"required_headers": {},
"status": "<string>",
"warnings": [
"<string>"
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}{
"success": false,
"data": "<unknown>",
"error": {
"status": 123,
"code": "<string>",
"message": "<string>",
"retry_after": 123,
"retry_at": "<string>",
"issues": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>",
"min": 123,
"max": 123
}
]
},
"trace_id": "<string>",
"request_id": "<string>"
}- Credential: an API key. A trial key returns
401 unauthorized. See Sending a file. - Line-scoped keys: the list of a line-scoped key is not applied: an attachment belongs to the account.
Idempotency-Key: honored. The key belongs to the account. While the attachment isawaiting_uploadand before its deadline, a repeat returns the sameidwith a newupload_url. See Creating an attachment.- Events: none, also when the attachment becomes
ready,failedorexpired. - Personal data:
filenameis shown to the contact and can hold personal data, andupload_urlis a credential untilupload_expires_at. Do not copy them into logs, tickets or other tools. - Next steps: upload the file with one
PUTtoupload_url, withrequired_headers, beforeupload_expires_at. Then wait forstatus: readybefore you send the attachment.
Errors
| Status | error.code | When |
|---|---|---|
| 400 | validation_failed | filename is empty or longer than 255 characters, content_type is empty or longer than 100, or size_bytes is not an integer of at least 1. |
| 409 | idempotency_terminal_state | The Idempotency-Key was used for an attachment that is no longer awaiting_upload, or whose upload deadline passed. Create the attachment again with a new key. |
| 413 | attachment_exceeds_storage_limit | size_bytes is over 5,368,709,120 bytes (5 GiB). In the SDK, it arrives as an UnprocessableEntityError. |
Authorizations
An API key created in the iSnap dashboard, or a trial key, sent as Authorization: Bearer <key>. An API key starts with isnap_live_ or isnap_test_; both act on the same account, lines and billing. A trial key acts on its trial only.
Body
The file to register. iSnap does not check these values against the uploaded file.
File name, 1 to 255 characters. It is returned on the attachment and on the messages that carry it.
1 - 255Content type of the file, 1 to 100 characters, for example image/jpeg. Every value is accepted. A value that starts with audio/ makes iSnap convert the file before the attachment is ready.
1 - 100Size of the file in bytes: at least 1 and at most 5,368,709,120 (5 GiB). Above it the API returns 413 attachment_exceeds_storage_limit. Above 100,000,000 the call succeeds and warnings contains large_attachment_may_delay_delivery.
1 <= x <= 5368709120Response
The attachment, created and waiting for the upload.
Always true on a success response.
true The attachment created, with the URL to upload its file to.
Show child attributes
Show child attributes
Trace id of the request that produced this response: 32 lowercase hexadecimal characters. Quote it when you report a problem to iSnap.
Id of the request that produced this response: req_ followed by 25 letters or digits.