Folders
Organise the asset and template libraries from the API: create folders, read their ids, move files and delete trees.
Folders are a library's structure: the Assets page and the Templates page browse them, uploads land in them, and the API reads and manages them under that library's scopes. The two libraries have separate trees with the same shape: /assets/folders for assets (below) and /templates/folders for templates (Template folders). A folder has an id, a name, a parent_id (null at the root) and a path (every folder from the root down to it). Names are unique within their parent, case-insensitively.
Reading folders
GET /assets/folders lists one level of the tree: the root by default, or the children of parent_id. Each folder carries its path, its folder_count (direct sub-folders) and its asset_count (assets directly inside).
curl "https://app.nubu.app/api/v1/assets/folders?parent_id=<folder id>" \
-H "Authorization: Bearer nubu_api_..."
To find a folder anywhere in the tree by name, pass q instead: GET /assets/folders?q=summer returns every folder whose name contains it (at most limit, default 200), each with its path. Folder lists are not paged: a level lists all its children.
GET /assets/folders/<id> reads one folder and adds subtree: how many folders and assets lie beneath it.
Creating folders
curl -X POST https://app.nubu.app/api/v1/assets/folders \
-H "Authorization: Bearer nubu_api_..." \
-H "Content-Type: application/json" \
-d '{ "name": "Summer sale", "parent_id": null }'
The answer (201) carries the folder. Pass parent_id to nest it. Several folders go in one call with { "folders": [ { "name": "Hero" , "parent_id": "<id>" }, ... ] } (up to 50): the answer lists a folder or an error per entry, in order. A name already used in the same parent answers 409 conflict; a parent that is not the organisation's answers 422 validation_failed.
Uploading into a folder
Pass "folder_id" when you begin an upload (Uploading assets), on a single begin or on every file of a batch. GET /assets?folder_id=<id> lists what a folder holds.
Renaming and moving
PATCH /assets/folders/<id> with name, parent_id (null for the root) or both. Moving a folder into itself or into one of its own sub-folders answers 422.
Assets move with POST /assets/move:
curl -X POST https://app.nubu.app/api/v1/assets/move \
-H "Authorization: Bearer nubu_api_..." \
-H "Content-Type: application/json" \
-d '{ "asset_ids": ["<asset id>", "<asset id>"], "folder_id": "<folder id>" }'
Up to 1,000 ids in one call; the answer says how many moved (an id that is not the organisation's is skipped). A single asset also moves through PATCH /assets/<id> with folder_id.
Deleting a folder
DELETE /assets/folders/<id> deletes the folder, its sub-folders and every asset inside them, rows and files, freeing the storage they used, exactly as deleting a folder on the Assets page does. The answer counts what went:
{ "deleted": true, "id": "...", "folders": 3, "assets": 12 }
Creatives that used a deleted asset are cleaned up the way the app does it. While any asset inside the tree is queued for a render or rendering, the delete answers 409 conflict with details.reason render_locked and nothing is deleted; wait for the render to finish.
| Scope | Allows |
|---|---|
assets.read | List and read folders |
assets.create | Create folders |
assets.update | Rename and move folders, move assets |
assets.delete | Delete folders and their contents |
Template folders
The template gallery has its own folder tree with the same routes, shapes and rules under /templates/folders, governed by the template scopes:
GET /templates/folderslists a level (parent_id, or the root) or searches the tree (q); each folder carries itspath,folder_countandtemplate_count(templates directly inside).GET /templates/folders/<id>reads one folder and addssubtree: how many folders and templates lie beneath it.POST /templates/folderscreates one folder ({ "name", "parent_id" },201) or several ({ "folders": [...] }, up to 50, afolderor anerrorper entry). A duplicate name in the same parent answers409 conflict; a parent that is not the organisation's answers422.PATCH /templates/folders/<id>renames (name) and moves (parent_id, null for the root); a move into itself or one of its own sub-folders answers422.POST /templates/movewith{ "template_ids": [...], "folder_id": "<id>" }(up to 1,000; null for the root) moves templates in one call and answers how manymoved; a single template also moves throughPATCH /templates/<id>withfolder_id.GET /templates?folder_id=<id>lists what a folder holds, andfolder_idon a template upload's begin call places the new template (Uploading templates).DELETE /templates/folders/<id>deletes the folder, its sub-folders and every template inside them, packages and rows, exactly as deleting a folder on the Templates page does, and answers{ "deleted": true, "id": "...", "folders": 3, "templates": 12 }. Flows that used a deleted template lose their draft creatives and have rendered ones flagged, the way the app does it. While any template inside is used by a creative that is queued or rendering, the delete answers409 conflictwithdetails.reasonrender_lockedand nothing is deleted; wait for the render to finish.
| Scope | Allows |
|---|---|
templates.read | List and read template folders |
templates.create | Create template folders |
templates.update | Rename and move template folders, move templates |
templates.delete | Delete template folders and their contents |