> For the complete documentation index, see [llms.txt](https://docs.bugbug.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bugbug.io/public-api-reference/folders.md).

# Folders

## List folders

> Returns folders for the project. Filter by \`kind\` or \`parentId\`.

```json
{"openapi":"3.1.0","info":{"title":"BugBug.io Public API","version":"v2"},"tags":[],"security":[{"tokenAuth":[]},{"Bearer":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PaginatedV2FolderList":{"type":"object","required":["count","results"],"properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true,"format":"uri"},"previous":{"type":"string","nullable":true,"format":"uri"},"results":{"type":"array","items":{"$ref":"#/components/schemas/V2Folder"}}}},"V2Folder":{"type":"object","properties":{"id":{"type":"string","format":"uuid","readOnly":true},"name":{"type":"string","readOnly":true},"kind":{"enum":["test","component","file"],"type":"string","description":"* `test` - Test\n* `component` - Component\n* `file` - File","readOnly":true},"depth":{"type":"integer","readOnly":true},"parentId":{"type":["string","null"],"format":"uuid","readOnly":true}},"required":["depth","id","kind","name","parentId"]}}},"paths":{"/api/v2/folders/":{"get":{"operationId":"v2_folders_list","description":"Returns folders for the project. Filter by `kind` or `parentId`.","summary":"List folders","parameters":[{"in":"query","name":"kind","schema":{"type":"string","enum":["component","file","test"]},"description":"* `test` - Test\n* `component` - Component\n* `file` - File"},{"in":"query","name":"ordering","schema":{"type":"array","items":{"type":"string","enum":["-created","-depth","-name","created","depth","name"]}},"description":"Ordering\n\n* `name` - Name\n* `-name` - Name (descending)\n* `created` - Created\n* `-created` - Created (descending)\n* `depth` - Depth\n* `-depth` - Depth (descending)","explode":false,"style":"form"},{"name":"page","required":false,"in":"query","description":"A page number within the paginated result set.","schema":{"type":"integer"}},{"name":"page_size","required":false,"in":"query","description":"Number of results to return per page.","schema":{"type":"integer"}},{"in":"query","name":"parentId","schema":{"type":"string","format":"uuid"}},{"in":"query","name":"query","schema":{"type":"string"}}],"tags":["Folders"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedV2FolderList"}}},"description":""},"401":{"description":"Authentication credentials were missing or invalid."}}}}}}
```

## Create a folder

> Creates a new folder. Project is taken from the auth token.

```json
{"openapi":"3.1.0","info":{"title":"BugBug.io Public API","version":"v2"},"tags":[],"security":[{"tokenAuth":[]},{"Bearer":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"V2FolderCreate":{"type":"object","properties":{"name":{"type":"string","maxLength":255},"kind":{"enum":["test","component","file"],"type":"string","description":"* `test` - Test\n* `component` - Component\n* `file` - File"},"parentId":{"type":["string","null"],"format":"uuid"}},"required":["kind","name"]},"V2Folder":{"type":"object","properties":{"id":{"type":"string","format":"uuid","readOnly":true},"name":{"type":"string","readOnly":true},"kind":{"enum":["test","component","file"],"type":"string","description":"* `test` - Test\n* `component` - Component\n* `file` - File","readOnly":true},"depth":{"type":"integer","readOnly":true},"parentId":{"type":["string","null"],"format":"uuid","readOnly":true}},"required":["depth","id","kind","name","parentId"]}}},"paths":{"/api/v2/folders/":{"post":{"operationId":"v2_folders_create","description":"Creates a new folder. Project is taken from the auth token.","summary":"Create a folder","parameters":[],"tags":["Folders"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/V2FolderCreate"}},"application/json":{"schema":{"$ref":"#/components/schemas/V2FolderCreate"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/V2Folder"}}},"description":""},"400":{"description":"Request body failed validation."},"401":{"description":"Authentication credentials were missing or invalid."}}}}}}
```

## Get folder by ID

> Returns a single folder.

```json
{"openapi":"3.1.0","info":{"title":"BugBug.io Public API","version":"v2"},"tags":[],"security":[{"tokenAuth":[]},{"Bearer":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"V2Folder":{"type":"object","properties":{"id":{"type":"string","format":"uuid","readOnly":true},"name":{"type":"string","readOnly":true},"kind":{"enum":["test","component","file"],"type":"string","description":"* `test` - Test\n* `component` - Component\n* `file` - File","readOnly":true},"depth":{"type":"integer","readOnly":true},"parentId":{"type":["string","null"],"format":"uuid","readOnly":true}},"required":["depth","id","kind","name","parentId"]}}},"paths":{"/api/v2/folders/{id}/":{"get":{"operationId":"v2_folders_retrieve","description":"Returns a single folder.","summary":"Get folder by ID","parameters":[{"in":"path","name":"id","schema":{"type":"string","format":"uuid"},"description":"A UUID string identifying this folder.","required":true}],"tags":["Folders"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/V2Folder"}}},"description":""},"401":{"description":"Authentication credentials were missing or invalid."},"404":{"description":"Resource not found."}}}}}}
```

## Delete folder

> Deletes a folder. Fails with 400 if folder is not empty unless \`force=true\` is passed. When forced, contained tests/components are unlinked and subtree is soft-deleted.

```json
{"openapi":"3.1.0","info":{"title":"BugBug.io Public API","version":"v2"},"tags":[],"security":[{"tokenAuth":[]},{"Bearer":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}}},"paths":{"/api/v2/folders/{id}/":{"delete":{"operationId":"v2_folders_destroy","description":"Deletes a folder. Fails with 400 if folder is not empty unless `force=true` is passed. When forced, contained tests/components are unlinked and subtree is soft-deleted.","summary":"Delete folder","parameters":[{"in":"query","name":"force","schema":{"type":"boolean"},"description":"If true, deletes folder even if non-empty (cascades to subtree)."},{"in":"path","name":"id","schema":{"type":"string","format":"uuid"},"description":"A UUID string identifying this folder.","required":true}],"tags":["Folders"],"responses":{"204":{"description":"No response body"},"401":{"description":"Authentication credentials were missing or invalid."},"404":{"description":"Resource not found."}}}}}}
```

## Update folder (rename or move)

> Updates folder name and/or moves the folder to a different parent. Pass \`parentId=null\` to move to root.

```json
{"openapi":"3.1.0","info":{"title":"BugBug.io Public API","version":"v2"},"tags":[],"security":[{"tokenAuth":[]},{"Bearer":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PatchedV2FolderUpdate":{"type":"object","properties":{"name":{"type":"string","maxLength":255},"parentId":{"type":["string","null"],"format":"uuid"}}},"V2Folder":{"type":"object","properties":{"id":{"type":"string","format":"uuid","readOnly":true},"name":{"type":"string","readOnly":true},"kind":{"enum":["test","component","file"],"type":"string","description":"* `test` - Test\n* `component` - Component\n* `file` - File","readOnly":true},"depth":{"type":"integer","readOnly":true},"parentId":{"type":["string","null"],"format":"uuid","readOnly":true}},"required":["depth","id","kind","name","parentId"]}}},"paths":{"/api/v2/folders/{id}/":{"patch":{"operationId":"v2_folders_partial_update","description":"Updates folder name and/or moves the folder to a different parent. Pass `parentId=null` to move to root.","summary":"Update folder (rename or move)","parameters":[{"in":"path","name":"id","schema":{"type":"string","format":"uuid"},"description":"A UUID string identifying this folder.","required":true}],"tags":["Folders"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/PatchedV2FolderUpdate"}},"application/json":{"schema":{"$ref":"#/components/schemas/PatchedV2FolderUpdate"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/V2Folder"}}},"description":""},"400":{"description":"Request body failed validation."},"401":{"description":"Authentication credentials were missing or invalid."},"404":{"description":"Resource not found."}}}}}}
```

## Get folder tree

> Returns the full nested folder tree for a given kind.

```json
{"openapi":"3.1.0","info":{"title":"BugBug.io Public API","version":"v2"},"tags":[],"security":[{"tokenAuth":[]},{"Bearer":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PaginatedV2FolderTreeNodeList":{"type":"object","required":["count","results"],"properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true,"format":"uri"},"previous":{"type":"string","nullable":true,"format":"uri"},"results":{"type":"array","items":{"$ref":"#/components/schemas/V2FolderTreeNode"}}}},"V2FolderTreeNode":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"kind":{"type":"string"},"depth":{"type":"integer"},"parentId":{"type":["string","null"],"format":"uuid"},"created":{"type":"string","format":"date-time"},"contentCount":{"type":"integer"},"children":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["children","contentCount","created","depth","id","kind","name","parentId"]}}},"paths":{"/api/v2/folders/tree/":{"get":{"operationId":"v2_folders_tree_list","description":"Returns the full nested folder tree for a given kind.","summary":"Get folder tree","parameters":[{"in":"query","name":"kind","schema":{"type":"string","enum":["component","file","test"]},"description":"Folder kind.","required":true},{"in":"query","name":"ordering","schema":{"type":"array","items":{"type":"string","enum":["-created","-depth","-name","created","depth","name"]}},"description":"Ordering\n\n* `name` - Name\n* `-name` - Name (descending)\n* `created` - Created\n* `-created` - Created (descending)\n* `depth` - Depth\n* `-depth` - Depth (descending)","explode":false,"style":"form"},{"name":"page","required":false,"in":"query","description":"A page number within the paginated result set.","schema":{"type":"integer"}},{"name":"page_size","required":false,"in":"query","description":"Number of results to return per page.","schema":{"type":"integer"}},{"in":"query","name":"parentId","schema":{"type":"string","format":"uuid"}},{"in":"query","name":"query","schema":{"type":"string"}}],"tags":["Folders"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedV2FolderTreeNodeList"}}},"description":""},"401":{"description":"Authentication credentials were missing or invalid."}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bugbug.io/public-api-reference/folders.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
