Files & attachments

Records can carry files: contracts on a company, a photo on a product, a signed form on a contact. A file lives in one of two places on a record:

  • A file field: a field of type file with its own rules: which types it accepts, the largest file, and whether it holds one file (a new upload replaces the old one) or several. The record's value of the field lists its files, so filters and segments can ask "has a contract" (exists).
  • General attachments: the record's "Files", for anything else. Every accepted type is allowed, up to 25 MB per file.

Add a file field

cURL
curl -X POST https://crm.codefab.dev/api/v1/objects/company/fields \
-H "X-API-Key: cfk_…" -H "Content-Type: application/json" \
-d '{"key": "contract", "label": "Contract", "type": "file",
"validation": {"allowedTypes": ["pdf"], "maxSizeMb": 10, "multiple": false}}'

Accepted types: pdf, png, jpg, jpeg, gif, webp, txt, csv, docx, xlsx, pptx, doc, xls, zip. maxSizeMb can be at most 100. A file field can't be required or unique, because files are added once the record exists.

Upload

cURL
curl -X POST https://crm.codefab.dev/api/v1/records/{recordId}/files \
-H "X-API-Key: cfk_…" \
-F "file=@Avtal 2026.pdf" -F "field=contract"

Leave out field to add a general attachment. The response is the stored file, with the type detected from its content.

What is checked

CheckError
The extension is allowed here422 file_type_not_allowed
The content really is that type (a renamed program stays a program)422 file_content_mismatch
No active content: scripts or launch actions in a PDF, macros in Office files, programs inside a zip422 file_unsafe
The file fits the field's (or 25 MB) size limit413 file_too_large
Your organisation's storage has room409 storage_limit_reached

Read, download, remove

  • GET /api/v1/records/{recordId}/files: the record's files.
  • GET /api/v1/files/{fileId}/content: the bytes, as a download (?inline=true shows an image or PDF in the browser).
  • DELETE /api/v1/files/{fileId}: removes the file; its content is erased from storage within minutes.
  • GET /api/v1/files/usage: how much your organisation stores, and its limit.

A file field's value is maintained by these endpoints: sending a changed list through the records API is refused, sending it unchanged is fine.

Storage, privacy and billing

  • Each organisation's files are stored separately, in the EU, and never served across organisations.
  • Deleting a record deletes its files. A GDPR erasure of a contact deletes their files, and the files in personal-data (pii) file fields of their linked records. A GDPR export lists the person's files.
  • Each organisation has a storage limit (500 MB unless agreed otherwise). Storage is billed per MB stored, at the month's peak.