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.
| Item | Upload address | Attach | Remove |
|---|---|---|---|
| An update | GET /posts/<post_id>/drive | PUT /posts/<post_id>/media | DELETE /posts/<post_id>/media |
| A note | GET /notes/<note_id>/drive | PUT /notes/<note_id>/media | DELETE /notes/<note_id>/media |
| A task | GET /tasks/<task_id>/drive | PUT /tasks/<task_id>/media | DELETE /tasks/<task_id>/media |
| A child task | GET /subtasks/<subtask_id>/drive | PUT /subtasks/<subtask_id>/media | DELETE /subtasks/<subtask_id>/media |
| The document of a form, e-sign or note | GET /<forms, signs or notes>/<id>/drive with media_group=schemas | PUT /<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 usePUT /<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
| Parameter | What it does | Required | Default |
|---|---|---|---|
media_group | The kind of file: docs, images, audios, videos or files, or schemas for a form's, e-sign's or note's document | Yes | — |
media_extension | The file's extension, such as pdf. It must be one the kind takes; files takes any. | Yes | — |
tag_id | The name the file is saved under, in letters, numbers and dashes, such as repair-estimate | Yes | — |
| Kind | Extensions |
|---|---|
docs and schemas | csv, doc, docx, odt, pdf, ppt, pptx, rtf, txt, xls, xlsx |
images | bmp, gif, jpeg, jpg, png, svg, tiff, webp |
audios | aac, aiff, amr, flac, m4a, mp3, oga, opus, wav, wma, and less common audio formats |
videos | 3gp, avi, flv, m4v, mkv, mov, mp4, mpeg, mpg, ogg, webm, wmv, and less common video formats |
files | Any |
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
}
}
mediatakes 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_mediafor 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>:
| Field | What it holds |
|---|---|
execution_status | RUNNING while it's processed, then SUCCEEDED or FAILED |
original | The file as uploaded |
pdf | A document converted to PDF, once ready |
flat | An e-sign's locked copy, once everyone has signed |
tag_id, content_type, media_size | Its 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
POST /postswith the update'smessage. 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.GET /posts/<post_id>/drive?media_group=docs&media_extension=pdf&tag_id=repair-estimate.- Upload the file to
urlwithfields. PUT /posts/<post_id>/mediawithfields.key.- Read
GET /posts/<post_id>until the file'sexecution_statusisSUCCEEDED.
If a call is refused
| Status | message | Why |
|---|---|---|
| 400 | SchemaFieldsException | A 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. |
| 403 | ItemUpdateFailedException | The file is already attached, or the form, e-sign or note already has its document |
| 403 | ItemAuthorOnlyException | The key tried to attach a file to an update or comment someone else wrote |
| 403 | CaseClosedException | The case is closed |
| 404 | ItemNotFoundException | The 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.