ファイル管理
Brevo CRM の Files API を使うと、Tajo プラットフォーム上のコンタクト、企業、商談に紐づく添付ファイルをアップロードして管理できます。
概要
ファイル管理は次のような用途で欠かせません。
- 商談ドキュメント: 提案書、契約書、合意書を保管します
- 顧客レコード: 請求書、領収書、やり取りの記録を添付します
- ロイヤルティプログラムの資料: プログラムの詳細や特典の概要を共有します
- コンプライアンス: エンタープライズアカウント向けに文書の監査証跡を維持します
- チームでの連携: 営業チームのメンバー間でリソースを共有します
クイックスタート
ファイルをアップロードする
POST https://api.brevo.com/v3/crm/filesContent-Type: multipart/form-dataapi-key: YOUR_API_KEY
--boundaryContent-Disposition: form-data; name="file"; filename="enterprise-proposal.pdf"Content-Type: application/pdf
[file content]--boundaryContent-Disposition: form-data; name="dealIds"
deal_abc123def456--boundaryContent-Disposition: form-data; name="companyIds"
comp_123456789--boundaryContent-Disposition: form-data; name="contactIds"
12345--boundary--レスポンス
{ "id": "file_001", "name": "enterprise-proposal.pdf", "size": 245760, "contentType": "application/pdf", "dealIds": ["deal_abc123def456"], "companyIds": ["comp_123456789"], "contactIds": [12345], "created_at": "2026-01-25T14:30:00Z"}ファイルを取得する
すべてのファイルを一覧する
GET https://api.brevo.com/v3/crm/files?limit=50&offset=0&sort=descContent-Type: application/jsonapi-key: YOUR_API_KEYレスポンス
{ "items": [ { "id": "file_001", "name": "enterprise-proposal.pdf", "size": 245760, "contentType": "application/pdf", "dealIds": ["deal_abc123def456"], "companyIds": ["comp_123456789"], "created_at": "2026-01-25T14:30:00Z" } ], "total": 1}ファイルを絞り込む
GET https://api.brevo.com/v3/crm/files?filters[dealIds]=deal_abc123def456&sort=created_at:desc単一のファイルを取得する
GET https://api.brevo.com/v3/crm/files/{file_id}Content-Type: application/jsonapi-key: YOUR_API_KEYファイルをダウンロードする
GET https://api.brevo.com/v3/crm/files/{file_id}/dataapi-key: YOUR_API_KEYファイル管理の自動化
商談ドキュメントのワークフロー
商談のライフサイクル全体を通じて、ドキュメントを自動的に管理します。
class DealDocumentManager { constructor() { this.filesApi = new FilesApi(); }
async attachProposal(dealId, proposalBuffer, companyName) { const fileName = `proposal-${companyName.toLowerCase().replace(/\s+/g, '-')}-${Date.now()}.pdf`;
const file = await this.filesApi.uploadFile({ file: proposalBuffer, fileName: fileName, dealIds: [dealId] });
// Create a note referencing the uploaded proposal await this.notesApi.createNote({ text: `Proposal uploaded: ${fileName}`, dealIds: [dealId] });
return file; }
async attachContract(dealId, contractBuffer, companyId) { const fileName = `contract-${dealId}-${new Date().toISOString().slice(0, 10)}.pdf`;
const file = await this.filesApi.uploadFile({ file: contractBuffer, fileName: fileName, dealIds: [dealId], companyIds: [companyId] });
return file; }
async getDealDocuments(dealId) { const files = await this.filesApi.getFiles({ filters: { dealIds: dealId }, sort: 'created_at:desc' });
return { proposals: files.items.filter(f => f.name.startsWith('proposal-')), contracts: files.items.filter(f => f.name.startsWith('contract-')), other: files.items.filter(f => !f.name.startsWith('proposal-') && !f.name.startsWith('contract-') ), totalSize: files.items.reduce((sum, f) => sum + f.size, 0) }; }}ロイヤルティプログラムのドキュメント
class LoyaltyDocumentManager { async generateAndAttachBenefitsSummary(companyId, tier) { const company = await this.companiesApi.getCompany(companyId);
const summary = await this.generateBenefitsPDF({ companyName: company.name, tier: tier, benefits: this.getTierBenefits(tier), annualSpend: company.attributes.annual_spend, pointsBalance: company.attributes.loyalty_points });
return await this.filesApi.uploadFile({ file: summary, fileName: `loyalty-benefits-${tier.toLowerCase().replace(/\s+/g, '-')}.pdf`, companyIds: [companyId] }); }
async attachTierUpgradeDocuments(companyId, oldTier, newTier) { const documents = [ { name: 'tier-upgrade-confirmation', content: this.generateUpgradeConfirmation(oldTier, newTier) }, { name: 'new-benefits-guide', content: this.generateBenefitsGuide(newTier) } ];
const uploaded = []; for (const doc of documents) { const file = await this.filesApi.uploadFile({ file: doc.content, fileName: `${doc.name}-${Date.now()}.pdf`, companyIds: [companyId] }); uploaded.push(file); }
return uploaded; }}対応しているファイル形式
| 種別 | 拡張子 | 最大サイズ |
|---|---|---|
| ドキュメント | .pdf, .doc, .docx, .txt | 10 MB |
| 表計算 | .xls, .xlsx, .csv | 10 MB |
| 画像 | .png, .jpg, .jpeg, .gif | 5 MB |
| プレゼンテーション | .ppt, .pptx | 10 MB |
API メソッドリファレンス
// Upload a fileconst file = await filesApi.uploadFile({ file: fileBuffer, fileName: 'proposal.pdf', dealIds: ['deal_abc123'], companyIds: ['comp_123']});
// Get file metadataconst file = await filesApi.getFile('file_001');
// Download file dataconst fileData = await filesApi.downloadFile('file_001');
// Delete fileawait filesApi.deleteFile('file_001');
// List files with filteringconst files = await filesApi.getFiles({ filters: { dealIds: 'deal_abc123' }, sort: 'created_at:desc', limit: 50});ベストプラクティス
- 命名規則: 日付を含む分かりやすいファイル名を付けて、識別しやすくします
- レコードとの紐づけ: 関連するすべての商談、企業、コンタクトにファイルを関連付けます
- バージョン管理: ファイル名にバージョン番号または日付を含めます
- サイズの管理: 大きなファイルは圧縮してからアップロードします
- アクセス制御: ファイルの関連付けを定期的に見直し、適切なアクセス権を保ちます
- 整理: 古くなったドキュメントを削除し、CRM のレコードを管理しやすい状態に保ちます
エラー処理
try { const file = await filesApi.uploadFile(fileData); console.log('File uploaded:', file.id);} catch (error) { if (error.status === 400) { console.error('Invalid file data:', error.message); } else if (error.status === 413) { console.error('File size exceeds maximum limit'); } else if (error.status === 415) { console.error('Unsupported file type'); } else { console.error('Unexpected error:', error); }}