diff --git a/CHANGELOG.md b/CHANGELOG.md index ca1ced4..cbdb29b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Fixed +- Fixed `create_list_from_template_in_folder` and `create_list_from_template_in_space` returning HTTP 404. The URL path used `/list/template/{templateId}` (with a slash) instead of `/list_template/{templateId}` (with an underscore), which is what the ClickUp API expects per the [createListFromTemplate](https://developer.clickup.com/reference/createlistfromtemplate) and [createListFromTemplateInSpace](https://developer.clickup.com/reference/createlistfromtemplateinspace) endpoints. ## [1.12.0] - 2025-04-14 diff --git a/src/clickup-client/lists.ts b/src/clickup-client/lists.ts index 46537b5..7bd703a 100644 --- a/src/clickup-client/lists.ts +++ b/src/clickup-client/lists.ts @@ -116,25 +116,45 @@ export class ListsClient { } /** - * Create a new list from a template in a folder + * Create a new list from a template in a folder. + * The POST response from ClickUp returns `deleted: true` as an artefact — + * we refetch the list immediately to return its real state. * @param folderId The ID of the folder to create the list in * @param templateId The ID of the template to use * @param params The list parameters - * @returns The created list + * @returns The created list with real (post-creation) state */ async createListFromTemplateInFolder(folderId: string, templateId: string, params: CreateListParams): Promise { - return this.client.post(`/folder/${folderId}/list/template/${templateId}`, params); + const created = await this.client.post(`/folder/${folderId}/list_template/${templateId}`, params); + if (created?.id) { + try { + return await this.getList(created.id); + } catch { + return created; + } + } + return created; } /** - * Create a new list from a template in a space + * Create a new list from a template in a space. + * The POST response from ClickUp returns `deleted: true` as an artefact — + * we refetch the list immediately to return its real state. * @param spaceId The ID of the space to create the list in * @param templateId The ID of the template to use * @param params The list parameters - * @returns The created list + * @returns The created list with real (post-creation) state */ async createListFromTemplateInSpace(spaceId: string, templateId: string, params: CreateListParams): Promise { - return this.client.post(`/space/${spaceId}/list/template/${templateId}`, params); + const created = await this.client.post(`/space/${spaceId}/list_template/${templateId}`, params); + if (created?.id) { + try { + return await this.getList(created.id); + } catch { + return created; + } + } + return created; } }