Easymailing
Files

Start a file upload

POST /files

POST/files

First of the two steps to attach a file to a contact, company or opportunity: declares the file (record, name and exact size) and reserves its space in the storage of the account. The file only exists for the record once its bytes are sent with set_file_content.

When to use: When a person wants to attach a document or image to a record. Flow: 1) call create_file with a fresh UUID in the Idempotency-Key header; 2) within 30 minutes send the raw bytes, exactly size_bytes long, to set_file_content with the uuid of the response; 3) the file becomes available and appears in list_files. The file name must end in one of these extensions: csv, tsv, txt, rtf, pdf, doc, docx, xls, xlsx, ppt, pptx, odt, ods, odp, gif, jpg, jpeg, png, webp, svg, tif, tiff, zip, rar and tar; at most 20 MiB.

When not to use: To change the name or description of a file that already exists, use update_file. To write text about a record, use create_note. The API cannot attach files that are in Google Drive or at a URL; only bytes sent by the caller.

Side effects: Reserves size_bytes of the storage of the whole account for 30 minutes, which can make another upload fail with crm_file_quota_exceeded meanwhile; the reservation is returned when the upload completes, is cancelled with delete_file, or expires (expired reservations are cleaned up by an hourly job). Nothing is visible on the record yet: the activity entry and the listing appear only when the content is stored. Nothing is sent to anyone and no webhook fires.

Permissions: Requires a CRM seat and the crm.contacts_companies.write capability. A file inherits the access of the record it is attached to: for a file of an opportunity the user needs the crm.opportunities.work capability and work access to its pipeline instead. A file the user cannot reach is reported as not found, never as forbidden.

Authorization

X-Auth-Token<token>

Value for the X-Auth-Token header parameter.

In: header

Header Parameters

Idempotency-Key*string

A new UUID v4 for each file you want to attach. Repeating the call with the same key and the same declaration returns the file already created instead of reserving space twice, while that file is uploading, analyzing or available. The key space is global to the account. A key whose file ended failed or rejected is spent: use a new one.

Formatuuid

Request Body

The new File resource

TypeScript Definitions

Use the request body type in TypeScript.

CRM Files of the public API (fase 5). Generated from the proposal by fase-5/tools/gen_files_api.py and edited by hand afterwards: the texts are the proposal's. Every operation checks the CRM access in its provider or processor before anything else, because API Platform evaluates security after the provider.

Two operations are binary, as in the panel's internal API: set_file_content takes the raw bytes (deserialize: false, its Content-Type is checked by the processor before the body is opened) and get_file_content answers a streamed attachment (output: false, serialize: false). Their bodies are declared by hand in openapiContext.

list_files pages forward only by cursor (cursor[gt], the use case has no backwards page): cursor is the opaque position API Platform copies into hydra:next, and {@see ForwardOnlyCursor} drops the hydra:previous it would also build. It is never published.

Response Body

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X POST "https://api.easymailing.com/files" \  -H "X-Auth-Token: YOUR_API_KEY" \  -H "Idempotency-Key: f2b9c7d0-41e8-4a35-9d6c-7e0a3b8c5d12" \  -H "Content-Type: application/json" \  -d '{    "record": "/entity/1",    "filename": "string",    "size_bytes": 1  }'
{  "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",  "record": "/entity/1",  "record_type": "contact",  "display_name": "string",  "description": "string",  "original_name": "string",  "mime_type": "string",  "size_bytes": 0,  "source": "upload",  "status": "uploading",  "previewable": true,  "created_by": {    "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",    "kind": "user",    "name": "string"  },  "version": 0,  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}