Document upload requires that files be uploaded first using the Files
API. Use the returned file_id in this request.
Method Signature
align.customers.update(
customerId: string,
data: UpdateCustomerRequest
): Promise<Record<string, never>>
Parameters
The unique customer identifier (UUID format)
Array of document objects to uploadShow Document Object Properties
File ID from a previous file upload
Document purpose: id_document, proof_of_address, selfie, etc.
Optional description of the document
Returns
Returns an empty object {} on success.
Examples
Upload ID Document and Proof of Address
import Align from "@tolbel/align";
const align = new Align({
apiKey: process.env.ALIGN_API_KEY!,
environment: "sandbox",
});
// Step 1: Upload files first
const idDocument = await align.files.upload({
file: idDocumentBuffer,
filename: "drivers-license.jpg",
contentType: "image/jpeg",
});
const proofOfAddress = await align.files.upload({
file: proofOfAddressBuffer,
filename: "utility-bill.pdf",
contentType: "application/pdf",
});
// Step 2: Update customer with documents
await align.customers.update("123e4567-e89b-12d3-a456-426614174000", {
documents: [
{
file_id: idDocument.file_id,
purpose: "id_document",
description: "Driver's license - front",
},
{
file_id: proofOfAddress.file_id,
purpose: "proof_of_address",
description: "Electric bill - January 2024",
},
],
});
console.log("Documents uploaded successfully");
// Step 1: Upload files first
const idDocument = await align.files.upload({
file: idDocumentBuffer,
filename: "drivers-license.jpg",
contentType: "image/jpeg",
});
const proofOfAddress = await align.files.upload({
file: proofOfAddressBuffer,
filename: "utility-bill.pdf",
contentType: "application/pdf",
});
// Step 2: Update customer with documents
await align.customers.update("123e4567-e89b-12d3-a456-426614174000", {
documents: [
{
file_id: idDocument.file_id,
purpose: "id_document",
description: "Driver's license - front",
},
{
file_id: proofOfAddress.file_id,
purpose: "proof_of_address",
},
],
});
Document Purposes
| Purpose | Description | Accepted Formats |
|---|
id_document | Government-issued ID (passport, driver’s license) | JPEG, PNG, PDF |
proof_of_address | Utility bill, bank statement (less than 3 months old) | JPEG, PNG, PDF |
proof_of_source_of_funds | Bank statements, payslips, or tax returns | JPEG, PNG, PDF |
business_formation | Certificate of incorporation, articles of association | PDF |
directors_registry | List of company directors | PDF |
shareholder_registry | List of company shareholders | PDF |
proof_of_nature_of_business | Business plan, website, or invoices | PDF |
other | Any other supporting documentation | JPEG, PNG, PDF |
Error Handling
import { AlignError, AlignValidationError } from "@tolbel/align";
try {
await align.customers.update(customerId, {
documents: [{ file_id: "invalid-file-id", purpose: "id_document" }],
});
} catch (error) {
if (error instanceof AlignValidationError) {
console.error("Invalid document data:", error.errors);
} else if (error instanceof AlignError) {
if (error.statusCode === 404) {
console.error("Customer or file not found");
} else {
console.error(`API Error: ${error.message}`);
}
}
}
After uploading documents, the KYC verification process will automatically
continue. Use webhooks to receive status updates.
Upload File
Upload files before attaching to customer
Get Customer
Check document and KYC status