curl --request POST \
--url https://files.sandbox.lead.bank/v2/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--header 'Idempotency-Key: <idempotency-key>' \
--form file=@example-file \
--form type=loan_agreement \
--form 'metadata={};type=application/json'import requests
url = "https://files.sandbox.lead.bank/v2/files"
files = { "file": ("example-file", open("example-file", "rb")) }
files["metadata"] = (None, "{}", "application/json")
payload = { "type": "loan_agreement" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('type', 'loan_agreement');
form.append('metadata', '{}');
const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', Authorization: 'Bearer <token>'}
};
options.body = form;
fetch('https://files.sandbox.lead.bank/v2/files', 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://files.sandbox.lead.bank/v2/files",
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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data",
"Idempotency-Key: <idempotency-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://files.sandbox.lead.bank/v2/files"
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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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://files.sandbox.lead.bank/v2/files")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://files.sandbox.lead.bank/v2/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": "file_7RwQ2mK9pL4xT1vN8jS5",
"type": "loan_agreement",
"created_at": "2026-09-14T14:22:01Z",
"metadata": {},
"uploaded_by": "partner",
"file_name": "loan_agreement_acct_4471.pdf",
"content_type": "application/pdf",
"size_bytes": 184233,
"checksum": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
}{
"code": "authentication_missing",
"message": "The request has no authentication credentials. Send your API token in the Authorization header.",
"errors": [
{
"code": "authentication_missing",
"message": "The Authorization header is missing. Send your API token as a bearer token.",
"parameters": [
"Authorization"
]
}
]
}{
"code": "internal_server_error",
"message": "Internal server error. Retry with exponential backoff. For a POST, PATCH or DELETE, reuse the same Idempotency-Key so the request isn't processed twice. If it keeps failing, contact Lead with the Lead-Request-ID."
}Create a File
Upload a File to Lead and get back a Lead-issued id you can reference immediately. File endpoints are served from files.sandbox.lead.bank and files.lead.bank, not the api. hosts.
curl --request POST \
--url https://files.sandbox.lead.bank/v2/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--header 'Idempotency-Key: <idempotency-key>' \
--form file=@example-file \
--form type=loan_agreement \
--form 'metadata={};type=application/json'import requests
url = "https://files.sandbox.lead.bank/v2/files"
files = { "file": ("example-file", open("example-file", "rb")) }
files["metadata"] = (None, "{}", "application/json")
payload = { "type": "loan_agreement" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('type', 'loan_agreement');
form.append('metadata', '{}');
const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', Authorization: 'Bearer <token>'}
};
options.body = form;
fetch('https://files.sandbox.lead.bank/v2/files', 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://files.sandbox.lead.bank/v2/files",
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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data",
"Idempotency-Key: <idempotency-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://files.sandbox.lead.bank/v2/files"
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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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://files.sandbox.lead.bank/v2/files")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://files.sandbox.lead.bank/v2/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
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=\"type\"\r\n\r\nloan_agreement\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\nContent-Type: application/json\r\n\r\n{}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": "file_7RwQ2mK9pL4xT1vN8jS5",
"type": "loan_agreement",
"created_at": "2026-09-14T14:22:01Z",
"metadata": {},
"uploaded_by": "partner",
"file_name": "loan_agreement_acct_4471.pdf",
"content_type": "application/pdf",
"size_bytes": 184233,
"checksum": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
}{
"code": "authentication_missing",
"message": "The request has no authentication credentials. Send your API token in the Authorization header.",
"errors": [
{
"code": "authentication_missing",
"message": "The Authorization header is missing. Send your API token as a bearer token.",
"parameters": [
"Authorization"
]
}
]
}{
"code": "internal_server_error",
"message": "Internal server error. Retry with exponential backoff. For a POST, PATCH or DELETE, reuse the same Idempotency-Key so the request isn't processed twice. If it keeps failing, contact Lead with the Lead-Request-ID."
}Authorizations
Headers
Body
The file bytes, as a standard multipart file part. The part's
own filename and Content-Type headers — which HTTP clients
set automatically — are your declaration of the file's name and
format, and are returned as file_name and content_type.
The filename can be up to 255 characters, must not contain
a path separator (/ or \), and must not be empty,
whitespace only, ., or ... The file itself can be a PDF,
JPEG, or PNG of up to 50 MB (50,000,000 bytes), and its
leading bytes must match the declared format.
The file's type. It decides which objects the file can link to. See the type enum for every value, grouped by the object it links to.
adverse_action_notice, board_resolution, cardholder_agreement, credit_agreement, deposit_agreement, electronic_signature_agreement, lead_funds_transfer_agreement, lead_privacy_policy, loan_agreement, notice_of_incompleteness, ownership_chart, partner_privacy_policy, payment_authorization, periodic_statement, personal_guarantee_agreement, power_of_attorney, pre_approval_terms, register_of_shareholders, signatory_authorization_letter, terms_of_use_policy, truth_in_lending_document, adverse_media, bank_statement, certificate_of_good_standing, consular_id, drivers_license, exchange_listing_certificate, exchange_listing_notice, financial_statement, formation_document, id_selfie, inheritance_letter, investigation_report, investment_record, national_id, partnership_agreement, passport, permanent_residency_id, provincial_id, public_record, salary_verification_letter, sale_agreement, social_security_card, state_id, tax_certificate, tax_return, utility_bill "loan_agreement"
Response
File object created.
The file's type. It decides which objects the file can link to. See the type enum for every value, grouped by the object it links to.
adverse_action_notice, board_resolution, cardholder_agreement, credit_agreement, deposit_agreement, electronic_signature_agreement, lead_funds_transfer_agreement, lead_privacy_policy, loan_agreement, notice_of_incompleteness, ownership_chart, partner_privacy_policy, payment_authorization, periodic_statement, personal_guarantee_agreement, power_of_attorney, pre_approval_terms, register_of_shareholders, signatory_authorization_letter, terms_of_use_policy, truth_in_lending_document, adverse_media, bank_statement, certificate_of_good_standing, consular_id, drivers_license, exchange_listing_certificate, exchange_listing_notice, financial_statement, formation_document, id_selfie, inheritance_letter, investigation_report, investment_record, national_id, partnership_agreement, passport, permanent_residency_id, provincial_id, public_record, salary_verification_letter, sale_agreement, social_security_card, state_id, tax_certificate, tax_return, utility_bill "loan_agreement"
Was this page helpful?

