Import bank statement
curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form 'import={
"bookkeeping_period_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "import": "{
\"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"
}" }
headers = {"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('import', '{
"bookkeeping_period_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import', 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://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import",
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=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\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://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import"
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=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\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://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import")
.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=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import")
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=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"data": {
"custom_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"upload_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"statement": {
"starting_balance": {
"date": "2023-12-25",
"amount": 123
},
"ending_balance": {
"date": "2023-12-25",
"amount": 123
},
"transactions": [
{
"date": "2023-12-25",
"amount": 123,
"direction_reason": "<string>",
"direction": "CREDIT",
"status": "POSTED",
"description": "<string>"
}
]
},
"created_transaction_count": 123,
"pending_transaction_count": 123,
"checks": [
{
"name": "POSTED_TRANSACTIONS_PRESENT",
"status": "passed",
"details": "<string>",
"violating_transactions": [
{
"date": "2023-12-25",
"amount": 123,
"direction_reason": "<string>",
"direction": "CREDIT",
"status": "POSTED",
"description": "<string>"
}
]
}
]
}
}{
"type": "InvalidParameters",
"description": "<string>",
"error_enum": "InvalidPayload",
"meta": {}
}{
"type": "InvalidParameters",
"description": "<string>",
"error_enum": "InvalidPayload",
"meta": {}
}Custom Accounts
Import bank statement
Upload one PDF bank statement. The bookkeeping period must be monthly. Only posted transactions are imported after statement validation succeeds.
POST
/
v1
/
businesses
/
{businessId}
/
custom-accounts
/
{customAccountId}
/
bank-statement-import
Import bank statement
curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form 'import={
"bookkeeping_period_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "import": "{
\"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"
}" }
headers = {"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('import', '{
"bookkeeping_period_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import', 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://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import",
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=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\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://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import"
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=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\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://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import")
.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=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/custom-accounts/{customAccountId}/bank-statement-import")
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=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"import\"\r\n\r\n{\r\n \"bookkeeping_period_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"data": {
"custom_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"upload_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"statement": {
"starting_balance": {
"date": "2023-12-25",
"amount": 123
},
"ending_balance": {
"date": "2023-12-25",
"amount": 123
},
"transactions": [
{
"date": "2023-12-25",
"amount": 123,
"direction_reason": "<string>",
"direction": "CREDIT",
"status": "POSTED",
"description": "<string>"
}
]
},
"created_transaction_count": 123,
"pending_transaction_count": 123,
"checks": [
{
"name": "POSTED_TRANSACTIONS_PRESENT",
"status": "passed",
"details": "<string>",
"violating_transactions": [
{
"date": "2023-12-25",
"amount": 123,
"direction_reason": "<string>",
"direction": "CREDIT",
"status": "POSTED",
"description": "<string>"
}
]
}
]
}
}{
"type": "InvalidParameters",
"description": "<string>",
"error_enum": "InvalidPayload",
"meta": {}
}{
"type": "InvalidParameters",
"description": "<string>",
"error_enum": "InvalidPayload",
"meta": {}
}Upload one PDF statement for a custom account using a monthly bookkeeping period. The statement must pass validation before its posted transactions are imported; pending transactions are not imported. Re-uploading the same PDF returns a 400 error, even if the filename changes, and does not create another import.
To remove its imported transactions, use Archive bank statement upload.
Find a monthly
bookkeeping_period_id with List bookkeeping periods for a business. Send import as a JSON object in the multipart request alongside the PDF; the request itself is not an application/json body. For example:
curl --request POST \
--url "https://sandbox.layerfi.com/v1/businesses/$BUSINESS_ID/custom-accounts/$CUSTOM_ACCOUNT_ID/bank-statement-import" \
--header "Authorization: Bearer $TOKEN" \
--form 'import={"bookkeeping_period_id":"BOOKKEEPING_PERIOD_UUID"}' \
--form 'file=@statement.pdf;type=application/pdf'
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The UUID of the business.
The UUID of the custom account.
Body
multipart/form-data
Response
Statement imported and posted transactions created.
Show child attributes
Show child attributes