Skip to content

Commit 881f4a2

Browse files
Merge pull request #548 from contentstack/feat/add-unpublish-taxonomy
Feat/add unpublish taxonomy
2 parents 266817f + 550ce6b commit 881f4a2

7 files changed

Lines changed: 2396 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [v1.30.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.30.2) (2026-04-22)
4+
5+
- Update dependencies
6+
37
## [v1.30.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.30.1) (2026-04-14)
48

59
- Enh

lib/stack/taxonomy/index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,52 @@ export function Taxonomy (http, data = {}) {
320320
throw error(err)
321321
}
322322
}
323+
324+
/**
325+
* @description The Unpublish taxonomy call initiates a job to unpublish a taxonomy and/or specific terms from the specified environments and locales.
326+
* @memberof Taxonomy
327+
* @func unpublish
328+
* @param {Object} data - Unpublish details (same shape as publish: locales, environments, items, etc.)
329+
* @param {string} [api_version=''] - Optional API version (e.g., '3.2')
330+
* @param {Object=} params - Optional query parameters. If params.branch is set, it is sent as the branch request header.
331+
* @returns {Promise<Object>} Response object with unpublish job details
332+
* @example
333+
* import * as contentstack from '@contentstack/management'
334+
* const client = contentstack.client()
335+
*
336+
* const unpublishData = {
337+
* locales: ["en-us"],
338+
* environments: ["development"],
339+
* items: [
340+
* { uid: "taxonomy_testing" }
341+
* ]
342+
* }
343+
* client.stack({ api_key: 'api_key'}).taxonomy().unpublish(unpublishData, '3.2')
344+
* .then((response) => console.log(response))
345+
*/
346+
this.unpublish = async function (data, api_version = '', params = {}) {
347+
try {
348+
const { branch, ...queryParams } = params
349+
const headers = {
350+
headers: { ...cloneDeep(this.stackHeaders) },
351+
params: queryParams
352+
}
353+
if (api_version) {
354+
headers.headers.api_version = api_version
355+
}
356+
if (branch) {
357+
headers.headers.branch = branch
358+
}
359+
const response = await http.post(`${this.urlPath}/unpublish`, data, headers)
360+
if (response.data) {
361+
return response.data
362+
} else {
363+
throw error(response)
364+
}
365+
} catch (err) {
366+
throw error(err)
367+
}
368+
}
323369
}
324370
bindModuleHeaders(this)
325371
}

0 commit comments

Comments
 (0)