Start a unit custom field file upload
Starts an upload for a file that will become the value of a file-type custom field on this unit. Returns where to send the bytes; nothing is attached until you set the field's value with the session id.
Authorization
AuthorizationstringrequiredPath parameters
unitIdstringrequiredSnowflake id of the unit, as a decimal string.
customFieldIdstringrequiredSnowflake id of the custom field definition, from the list-custom-fields response on this unit.
Body
application/json
Describe the file you are about to upload. MagicDoor checks it against the rules for that custom field and hands back somewhere to POST the bytes to.
fileNamestringrequiredThe file's name including its extension, 1 to 250 characters. MagicDoor uses the extension when it decides whether the file is allowed.
fileSizeintegerrequiredSize of the file in bytes. Must be at least 1.
contentTypestringrequiredMIME type of the file, 1 to 200 characters, for example "image/jpeg".
Response
200 · An upload session. Nothing has been attached yet.
sessionIdstringSnowflake id of the session. Pass it back as referenceFileUploadSessionId when you set the field's value.
endpointstringThe absolute URL to send the file to. It belongs to the storage provider, not to MagicDoor, so do not add the MagicDoor bearer token to that request.
methodstringThe HTTP method to use against endpoint, for example "POST".
fieldsobjectExtra form fields the storage provider requires with the upload, as a map of field name to value. Send them alongside the file. It can be empty when the provider needs none.
expiresstring · date-timeWhen the session stops accepting the upload. A wall clock in the company's timezone, with no offset.
400 · `fileName`, `fileSize` or `contentType` is missing, blank, or outside its length limits, or `fileSize` is below 1. The response carries an `errors` member mapping each rejected field name to its message.
422 · The file storage service refused the session — usually a content type the custom field does not accept, or a size outside its limits.
401 · The access token is missing, expired, or not for this company.
404 · No unit or no custom field with that id, or one of them belongs to another company.
- Ask for a session
Call this endpoint with the file's name, size and content type.
- Upload the bytes
Send the file to the
endpointthe response gives you, using itsmethod, and include every entry offieldswith it. That request goes to the storage provider, so it does not carry your MagicDoor token. - Attach it
Call Set a unit custom field on the same unit and custom field, passing this session's id as
referenceFileUploadSessionId, or as one entry ofreferenceFileUploadSessionIdswhen the field holds several files.