Uploading files =============== Files are sent inside the JSON request body, base 64 encoded — there is no multipart endpoint and no separate upload step. The file travels on the same request that creates or updates the record it belongs to. Two resources accept a file, and they do **not** share a field name or a response shape. Read the one you need rather than generalising from the other. +-----------------+-------------+---------------------------------------+---------------------------+ | Resource | Field | Accepted types | Where the result lands | +=================+=============+=======================================+===========================+ | Delegate | ``image`` | ``image/jpeg``, ``image/png``, | the delegate's ``image`` | | | | ``image/webp`` | | +-----------------+-------------+---------------------------------------+---------------------------+ | Interaction | ``upload`` | ``image/jpeg``, ``image/png``, | the interaction's | | | | ``image/webp``, ``video/mp4`` | ``linked`` | +-----------------+-------------+---------------------------------------+---------------------------+ Both fields cap at **10 MB** of decoded content. .. note:: Devices do **not** accept a file through the API. A device has an ``image`` in its responses, but it can only be set in the Control Room. Sending ``image`` to ``POST /device/new`` or ``PATCH /device/{idType}:{id}`` is not ignored — the field is unknown to that endpoint, so the whole request fails validation with *This form should not contain extra fields*. Encoding the file ----------------- Two forms are accepted for either field. A **data URL**, which is preferred because the media type it carries is used to pick the stored file's extension:: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... Or a **bare base 64 string**, with no prefix:: iVBORw0KGgoAAAANSUhEUgAA... Decoding is strict: any character outside the base 64 alphabet makes the request fail rather than silently truncating. Do not wrap the value in newlines, and do not URL-encode it. The declared media type is validated against the accepted list for that field, so a PNG announced as ``image/gif`` is rejected. Delegate images --------------- Send ``image`` alongside any other field, on either ``POST /delegate/new`` or ``PATCH /delegate/{idType}:{id}``. .. code-block:: text POST /delegate/new .. code-block:: json { "firstName": "Ada", "lastName": "Lovelace", "email": "ada@example.satellite.co.nz", "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." } The file is stored as a media record and the delegate's ``image`` is set to point at it. In **responses**, ``image`` is not the value you sent nor an identifier — it is a resolved public URL for the stored file, or ``null`` when the delegate has no image: .. code-block:: json { "data": { "id": 42, "firstName": "Ada", "image": "/media/ada-lovelace-6512ab3f9c1d4.png" } } Interaction uploads ------------------- Interactions use ``upload``, not ``image``, and additionally accept ``video/mp4``. Send it on ``POST /interaction/new/{interactionType}``: .. code-block:: text POST /interaction/new/upload .. code-block:: json { "firstDelegate": 42, "firstDevice": 123, "upload": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ..." } The file becomes a media record, and the interaction points at it. Internally that is a ``linkedClass`` / ``linkedId`` pair, but the API does not return those raw — it resolves them and returns the media itself under ``linked``: .. code-block:: json { "data": { "id": 9001, "interactionType": "upload", "linked": { "id": 5567, "publicId": "139e6763-d96a-4f59-95a4-42af15d12579", "_type": "contentmedia", "original": "/media/evidence-6512ab3f9c1d4.jpg", "name": "upload.jpg", "mimeType": "image/jpeg", "createdAt": "2026-09-01T09:15:22+12:00" } } } ``linked.original`` is the URL to fetch the file. ``linked`` is ``null`` when the interaction points at nothing, and this is the general "this interaction refers to something" mechanism — an upload is one use of it. The interaction types intended for this are ``upload`` and ``image``, though the field is accepted on any type. One file across a batch ----------------------- ``POST /interaction/batch`` takes the file once, in ``sharedValues``, and links **every** interaction in the batch to that single media record. This is the right shape for one photo that evidences several interactions — do not repeat the base 64 payload per interaction. .. code-block:: text POST /interaction/batch .. code-block:: json { "interactions": { "a": { "firstDelegate": 42, "interactionType": "upload" }, "b": { "firstDelegate": 43, "interactionType": "upload" } }, "sharedValues": { "firstDevice": 123, "upload": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ..." } } Both interactions come back with the same media under ``linked``. Reading a file back ------------------- A stored file is served by:: GET /resolve/{id}.{format} ``{id}`` accepts either the media record's numeric id or its UUID — ``linked.id`` and ``linked.publicId`` in the response above. ``{format}`` is the file extension you want. For delegate images you rarely need this route: the ``image`` field in a delegate response is already a URL you can request directly. Size and failure ---------------- A payload above the 10 MB decoded limit, an unaccepted media type, or a string that is not valid base 64 all fail the request with a validation error naming the field. Remember that base 64 inflates a file by roughly a third, so a 10 MB file is about 13.4 MB on the wire — check your client's own request body limit before assuming the server rejected it.