Queue photo files for import
Stages uploaded photo files and dispatches one UploadSingleFileJob per file so admins can attach images to recipients or donors by a unique field. The endpoint validates file size and image MIME rules through the photo upload helper before queueing. Requires admin file access through user.permissions.
curl --request POST \
--url https://api.gratona.com/v1/admin/import_files/{type}/{program_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form unique_field=hys_id \
--form is_profile_photo=true \
--form files=@example-fileimport requests
url = "https://api.gratona.com/v1/admin/import_files/{type}/{program_id}"
files = { "files": ("example-file", open("example-file", "rb")) }
payload = {
"unique_field": "hys_id",
"is_profile_photo": "true"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('unique_field', 'hys_id');
form.append('is_profile_photo', 'true');
form.append('files', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.gratona.com/v1/admin/import_files/{type}/{program_id}', 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.gratona.com/v1/admin/import_files/{type}/{program_id}",
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=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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.gratona.com/v1/admin/import_files/{type}/{program_id}"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.gratona.com/v1/admin/import_files/{type}/{program_id}")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/import_files/{type}/{program_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"message": "File import jobs have been queued. You will be notified when the imports are complete."
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}Authorizations
Passport bearer token authentication for legacy admin sessions.
Path Parameters
Required path value identifying which record type the files should attach to. Accepted values are entity for recipients and donor for donor records; invalid values return 422.
entity, donor Required program ID used by the queued import job to scope recipient or donor matching for the current client.
Body
Required string. Field key used to match each uploaded file to a recipient or donor.
"hys_id"
Required boolean-like value. Controls whether imported images should become profile photos.
true, false, 0, 1 "true"
Required uploaded image file or files. The helper accepts jpg, jpeg, png, and gif within the configured photo import size limit.
Response
Photo import jobs queued.
"File import jobs have been queued. You will be notified when the imports are complete."
curl --request POST \
--url https://api.gratona.com/v1/admin/import_files/{type}/{program_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form unique_field=hys_id \
--form is_profile_photo=true \
--form files=@example-fileimport requests
url = "https://api.gratona.com/v1/admin/import_files/{type}/{program_id}"
files = { "files": ("example-file", open("example-file", "rb")) }
payload = {
"unique_field": "hys_id",
"is_profile_photo": "true"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('unique_field', 'hys_id');
form.append('is_profile_photo', 'true');
form.append('files', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.gratona.com/v1/admin/import_files/{type}/{program_id}', 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.gratona.com/v1/admin/import_files/{type}/{program_id}",
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=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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.gratona.com/v1/admin/import_files/{type}/{program_id}"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.gratona.com/v1/admin/import_files/{type}/{program_id}")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/import_files/{type}/{program_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"unique_field\"\r\n\r\nhys_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"is_profile_photo\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"message": "File import jobs have been queued. You will be notified when the imports are complete."
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}