File attachments

Request an upload session for an attachment

Starts an upload for a file you want to attach to a record. Returns where to send the bytes and a session id to hand to the attach call. The session is tied to the record in the path, so it can only be attached there.

POST
https://api.portal.magicdoor.com/company-app/file-attachments/{entityType}/{entityId}/upload-sessions

Authorization

Authorizationstringrequired
Bearer token — Send your API token in the Authorization header as Bearer <token>. Requests without a valid token are rejected with 401 Unauthorized.

Path parameters

entityTypeenum<string>required

What kind of record the file hangs off. Written in the path in lower case, for example lease.

example: leaseleaseunitpropertyportfoliocompanytenantvendormaintenanceRequestworkOrderbilltransactionchatchatMessagepropertyManagerunknownrentalApplicationleaseTemplateleaseDocumentassociationViolationownerunitListingfileworkOrderGroup
entityIdstringrequired

The record the file hangs off, of the kind named by entityType. A Snowflake id sent as a decimal string.

example: 1830472847398404096

Body

application/json

fileNamestringrequired

Name to store the file under, 1 to 250 characters.

example: notice.pdf
fileSizeintegerrequired

Size of the file in bytes. Must be at least 1.

example: 84213
contentTypestringrequired

MIME type of the file, 1 to 200 characters.

example: application/pdf

Response

200 · Where to send the file bytes.

sessionIdstring

The upload session. Hand this id back to the endpoint that attaches the file once the bytes are uploaded. A Snowflake id sent as a decimal string.

endpointstring

Absolute URL to send the file bytes to.

methodstring

HTTP method to use when sending the bytes, for example POST.

fieldsobject

Form fields that must accompany the upload, as a name to value map. Send them as multipart/form-data together with the file itself.

expiresstring · date-time

When the session stops accepting an upload, in the company's timezone.

401 · The access token is missing, expired, or not valid for this company.

Attaching a file takes three calls.

  1. Ask for an upload session here. You get back an endpoint, a method, and a map of fields.
  2. Send the bytes to that endpoint as multipart/form-data, including every entry in fields plus the file itself.
  3. Call POST /company-app/file-attachments/{entityType}/{entityId} with the sessionId you got back.

The session stops working at expires. A session whose file is never attached is discarded.