Help centerIntegrations

Upload and attach files with a hub key

Get an upload address, upload a file, attach it to an update, note, task, form or e-sign, and download a case's files.

In this article9 sections

This page covers uploading files to a case, attaching them, and downloading them, with a hub key. Paths are under https://prd-api-app.caseactive.com/v1/<hub id>/<case id>.

How it works

A file takes three calls: ask for an upload address for the item, upload the file there, then attach it to the item.

ItemUpload addressAttachRemove
An updateGET /posts/<post_id>/drivePUT /posts/<post_id>/mediaDELETE /posts/<post_id>/media
A noteGET /notes/<note_id>/drivePUT /notes/<note_id>/mediaDELETE /notes/<note_id>/media
A taskGET /tasks/<task_id>/drivePUT /tasks/<task_id>/mediaDELETE /tasks/<task_id>/media
A child taskGET /subtasks/<subtask_id>/drivePUT /subtasks/<subtask_id>/mediaDELETE /subtasks/<subtask_id>/media
The document of a form, e-sign or noteGET /<forms, signs or notes>/<id>/drive with media_group=schemasPUT /<forms, signs or notes>/<id>/schema/media—
  • A key can attach files only to updates the Virtual Assistant posted. It can attach to any note, task or child task.
  • To attach a file to a comment, ask for the address with its update's or task's /drive, then use PUT /<posts, signs, tasks or subtasks>/<id>/comments/<comment_id>/media. A key can attach only to its own comments.
  • A form or e-sign holds one document and no other files. Once it has its document, it takes another only if the first failed to convert.

1. Get an upload address

ParameterWhat it doesRequiredDefault
media_groupThe kind of file: docs, images, audios, videos or files, or schemas for a form's, e-sign's or note's documentYes—
media_extensionThe file's extension, such as pdf. It must be one the kind takes; files takes any.Yes—
tag_idThe name the file is saved under, in letters, numbers and dashes, such as repair-estimateYes—
KindExtensions
docs and schemascsv, doc, docx, odt, pdf, ppt, pptx, rtf, txt, xls, xlsx
imagesbmp, gif, jpeg, jpg, png, svg, tiff, webp
audiosaac, aiff, amr, flac, m4a, mp3, oga, opus, wav, wma, and less common audio formats
videos3gp, avi, flv, m4v, mkv, mov, mp4, mpeg, mpg, ogg, webm, wmv, and less common video formats
filesAny
curl "https://prd-api-app.caseactive.com/v1/ca-7e6d5c4b3a2f10/cc-1a2b3c4d5e6f70/posts/post::20261002154134_b0accfaac139a9/drive?media_group=docs&media_extension=pdf&tag_id=repair-estimate" \
  -H "Authorization: Bearer YOUR_API_KEY"

It answers url, the address to upload to, and fields, the form fields to send with the file. fields.key is where the file will be saved. The address works for an hour.

2. Upload the file

Send a multipart/form-data POST to url, with every entry in fields as given, then the file last, as file. Set the Content-Type field to the file's type, such as application/pdf. This call goes to the file store, not to the API, so it takes no key.

curl -X POST "<url>" \
  -F "key=<fields.key>" -F "policy=<fields.policy>" \
  -F "...every other entry in fields..." \
  -F "Content-Type=application/pdf" \
  -F "file=@repair-estimate.pdf"

It answers 201. The largest file is the Virtual Assistant's role's limit for that kind, 5,000 MB by default; an Admin can lower it under Settings › Roles. A file over it is refused by the file store. An uploaded file that's never attached is deleted after three days.

3. Attach it

curl -X PUT https://prd-api-app.caseactive.com/v1/ca-7e6d5c4b3a2f10/cc-1a2b3c4d5e6f70/posts/post::20261002154134_b0accfaac139a9/media \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"media": [{"media_key": "<fields.key>"}]}'
{
  "data": {
    "items": [{"media_key": "hosts/ca-7e6d5c4b3a2f10/cases/cc-1a2b3c4d5e6f70/posts/post::20261002154134_b0accfaac139a9/media/docs/20261002154512_5f4e3d2c1b0a99/20261002154512_5f4e3d2c1b0a99.pdf", "media_id": "20261002154512_5f4e3d2c1b0a99"}],
    "currentItemCount": 1
  }
}
  • media takes several files at once. Each must have been uploaded with an address from this same item.
  • Attaching adds files; it never replaces them.
  • On an update, attaching sends your webhooks add_post_media for each file, and the update's email counts its files.

After attaching

Files are processed after attaching: images are resized, audio and video are prepared for playing, and documents are converted to PDF with page images. Files of the kind files are kept as they are.

Each item's read, such as GET /posts/<post_id>, lists its files under media.<kind>.items.<media_id>:

FieldWhat it holds
execution_statusRUNNING while it's processed, then SUCCEEDED or FAILED
originalThe file as uploaded
pdfA document converted to PDF, once ready
flatAn e-sign's locked copy, once everyone has signed
tag_id, content_type, media_sizeIts name, type and size in bytes

While any file is still being processed, the item's encoding lists it. A form or e-sign can't be published until its document is ready.

Downloading a file

Download a file from https://privcdn.caseactive.com/ followed by its original, pdf or flat, with your key in the same header as every call:

curl "https://privcdn.caseactive.com/hosts/ca-7e6d5c4b3a2f10/cases/cc-1a2b3c4d5e6f70/posts/post::20261002154134_b0accfaac139a9/media/docs/20261002154512_5f4e3d2c1b0a99/20261002154512_5f4e3d2c1b0a99.pdf" \
  -H "Authorization: Bearer YOUR_API_KEY" -o repair-estimate.pdf

The key's checks apply as for every call, its IP range included, and it can download from any section the Virtual Assistant's role may read.

Removing a file

DELETE /<item>/media takes a JSON body with the file's media_id and media_group, and answers 200. On an update, your webhooks receive delete_post_media. A form's or e-sign's document can't be removed: delete the item instead.

Example: a PDF on a new update

  1. POST /posts with the update's message. It's posted at once, with a portal notification; its email goes about 30 seconds later and counts the files attached by then, so attach them within that time.
  2. GET /posts/<post_id>/drive?media_group=docs&media_extension=pdf&tag_id=repair-estimate.
  3. Upload the file to url with fields.
  4. PUT /posts/<post_id>/media with fields.key.
  5. Read GET /posts/<post_id> until the file's execution_status is SUCCEEDED.

If a call is refused

StatusmessageWhy
400SchemaFieldsExceptionA parameter is missing or invalid, such as an extension the kind doesn't take, or a tag_id with spaces; errors names it. At media.<n>.media_key, the upload wasn't found, was for another item, or, on /schema/media, wasn't uploaded as schemas; nothing in the request is attached.
403ItemUpdateFailedExceptionThe file is already attached, or the form, e-sign or note already has its document
403ItemAuthorOnlyExceptionThe key tried to attach a file to an update or comment someone else wrote
403CaseClosedExceptionThe case is closed
404ItemNotFoundExceptionThe item, or the file to remove, doesn't exist

The upload itself answers in the file store's own format: EntityTooLarge for a file over the limit, and AccessDenied once the address has expired. For the API's error body and the rest of the codes, see Handle API errors and status codes.

Related articles

Post updates and comments with a hub keyPost updates to a case's feed, reply with comments, and read, edit or delete them from your own software, as the Virtual Assistant.IntegrationsHandle API errors and status codesRead the error body, what 400, 401, 403, 404, 500 and 503 mean, and why an item your key can't see answers 404.Integrations