PrismDraft SDK

articleGroups

The methods of pd.articleGroups. Inputs and outputs are described in Conventions; every method can also fail as described in Errors.

Methods

pd.articleGroups.list(input, init?)

List articles, one item per content piece

GET /api/article-groups

One page of translation groups, newest change first, and how many match in all. A group is every language version of one article (they share translationGroupId). A group is listed when any of its versions passes all the filters given, and it always carries all its versions, matching or not. title and primaryLanguage are the oldest version's, the one the others were translated from. status is the status every version shares, or MIXED. GET /api/articles is unchanged and still lists one item per language version.

Input

Name In Type Required Description
workspaceId query string (uuid) yes Workspace whose articles are listed.
projectId query string (uuid) no Only groups of this project. Omit for every project of the workspace.
categoryId query string (uuid) no Only groups with a version carrying this category.
category query string (uuid) no Alias of categoryId. Giving both is accepted only when they are the same id; otherwise the request is refused with INVALID_REQUEST.
status query "DRAFT" | "QUEUED" | "PROCESSING" | "NEEDS_REVIEW" | "CHANGES_REQUESTED" | "APPROVED" | "PUBLISHED" no Only groups with at least one version in this status.
language query string no Only groups with a version whose primary language is exactly this tag.
q query string no Case-insensitive title search; a group matches when any version's title does.
createdBy query "me" no me keeps only groups with a version created by the caller: the signed-in user, or the user who created the API key. Refused with INVALID_REQUEST for a key that has no creating user.
limit query integer no Groups per page, 1 to 100. Default: 25.
offset query integer no Number of groups to skip before the page starts. Default: 0.
init init { signal?: AbortSignal; timeoutMs?: number } no The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout.

Returns 200 OK

Field Type Required Description
groups object[] yes This page of groups, the most recently changed first.
groups[].translationGroupId string (uuid) yes Id shared by every language version of the article; the {translationGroupId} of the group routes.
groups[].projectId string (uuid) yes Id of the project every version of the group belongs to.
groups[].primaryLanguage string yes Language tag of the oldest version, the one the others were translated from.
groups[].title string yes Title of the oldest version.
groups[].status "DRAFT" | "QUEUED" | "PROCESSING" | "NEEDS_REVIEW" | "CHANGES_REQUESTED" | "APPROVED" | "PUBLISHED" | "MIXED" yes The status every version shares, or MIXED when the versions differ.
groups[].updatedAt string (date-time) yes When any version of the group last changed.
groups[].versions object[] yes Every language version of the group, oldest first, whether or not it matched the list filters.
groups[].versions[].id string (uuid) yes Id of this language version, usable as articleId in /api/articles/{articleId}.
groups[].versions[].language string yes Language tag of this version, e.g. en or fr-CA.
groups[].versions[].slug string yes URL slug of this version, unique among the project's articles.
groups[].versions[].title string yes Title of this version, in its own language.
groups[].versions[].status "DRAFT" | "QUEUED" | "PROCESSING" | "NEEDS_REVIEW" | "CHANGES_REQUESTED" | "APPROVED" | "PUBLISHED" yes Workflow status of this version.
groups[].versions[].publishedAt string (date-time) | null yes When this version was published; null while it is not published.
groups[].versions[].updatedAt string (date-time) yes When this version last changed.
total integer yes Number of groups with a matching version over all pages, not only this one.

Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.

Example

import { PrismDraft } from "@prism-draft/sdk";

const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });

const result = await pd.articleGroups.list({
  workspaceId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);

pd.articleGroups.get(input, init?)

Read one content piece with all its language versions

GET /api/article-groups/{translationGroupId}

One translation group with every language version, oldest first, in the shape of an item of GET /api/article-groups. Needs articles.read. The workspace is resolved from the group; 404 when it does not exist or the caller cannot see it.

Input

Name In Type Required Description
translationGroupId path string (uuid) yes Id shared by every language version of one article, as translationGroupId on an article or in GET /api/article-groups.
init init { signal?: AbortSignal; timeoutMs?: number } no The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout.

Returns 200 OK

Field Type Required Description
group object yes The translation group with all its language versions.
group.translationGroupId string (uuid) yes Id shared by every language version of the article; the {translationGroupId} of the group routes.
group.projectId string (uuid) yes Id of the project every version of the group belongs to.
group.primaryLanguage string yes Language tag of the oldest version, the one the others were translated from.
group.title string yes Title of the oldest version.
group.status "DRAFT" | "QUEUED" | "PROCESSING" | "NEEDS_REVIEW" | "CHANGES_REQUESTED" | "APPROVED" | "PUBLISHED" | "MIXED" yes The status every version shares, or MIXED when the versions differ.
group.updatedAt string (date-time) yes When any version of the group last changed.
group.versions object[] yes Every language version of the group, oldest first, whether or not it matched the list filters.
group.versions[].id string (uuid) yes Id of this language version, usable as articleId in /api/articles/{articleId}.
group.versions[].language string yes Language tag of this version, e.g. en or fr-CA.
group.versions[].slug string yes URL slug of this version, unique among the project's articles.
group.versions[].title string yes Title of this version, in its own language.
group.versions[].status "DRAFT" | "QUEUED" | "PROCESSING" | "NEEDS_REVIEW" | "CHANGES_REQUESTED" | "APPROVED" | "PUBLISHED" yes Workflow status of this version.
group.versions[].publishedAt string (date-time) | null yes When this version was published; null while it is not published.
group.versions[].updatedAt string (date-time) yes When this version last changed.

Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.

Example

import { PrismDraft } from "@prism-draft/sdk";

const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });

const result = await pd.articleGroups.get({
  translationGroupId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);

pd.articleGroups.delete(input, init?)

Delete every language version of a content piece

DELETE /api/article-groups/{translationGroupId}

Permanent, in one transaction. Each version that was PUBLISHED emits an article.unpublished webhook (reason: "deleted"). Needs articles.delete. Every deleted version writes an articles.deleted audit entry, and the stored image files no other row refers to are removed afterwards. 404 when the group does not exist or the caller cannot see it.

Input

Name In Type Required Description
translationGroupId path string (uuid) yes Id shared by every language version of one article, as translationGroupId on an article or in GET /api/article-groups.
init init { signal?: AbortSignal; timeoutMs?: number } no The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout.

Returns 200 OK

Field Type Required Description
ok true yes Always true: the group's versions were deleted. A failure is an error response.
deleted string (uuid)[] yes Ids of the language versions that were deleted.

Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.

Example

import { PrismDraft } from "@prism-draft/sdk";

const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });

const result = await pd.articleGroups.delete({
  translationGroupId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);

pd.articleGroups.approve(input, init?)

Approve the language versions of a group

POST /api/article-groups/{translationGroupId}/approve

Moves the chosen language versions from NEEDS_REVIEW to APPROVED in one transaction and records a review on each. Needs articles.approve. All-or-nothing: a version already APPROVED is skipped; if any other cannot be approved (not in NEEDS_REVIEW, still being generated, or an empty draft left by a failed translation) none moves and the answer is 409 with the blocked versions. Each approved version emits its own article.approved webhook, writes an audit entry and emails the version's author. languages that the group has no version in are refused with INVALID_REQUEST.

Input

Name In Type Required Description
translationGroupId path string (uuid) yes Id shared by every language version of one article, as translationGroupId on an article or in GET /api/article-groups.
body body object no
body.languages body string[] no Only these language versions. Omit for every version of the group.
body.comment body string no Approve only: stored with the review.
init init { signal?: AbortSignal; timeoutMs?: number } no The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout.

Returns 200 OK

Field Type Required Description
applied string (uuid)[] yes Ids of the versions that changed status.
skipped string (uuid)[] yes Ids of the versions left as they were: already at the target status, or, for unpublish, not published.

Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.

Example

import { PrismDraft } from "@prism-draft/sdk";

const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });

const result = await pd.articleGroups.approve({
  translationGroupId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);

pd.articleGroups.publish(input, init?)

Publish the language versions of a group

POST /api/article-groups/{translationGroupId}/publish

Moves the chosen language versions from APPROVED to PUBLISHED in one transaction. Needs articles.publish. All-or-nothing: a version already PUBLISHED is skipped; if any other is not APPROVED none moves and the answer is 409 with the blocked versions. Each published version emits its own article.published webhook and writes an audit entry; when the project has a CMS integration, a publishing job is queued for it and runs after the answer. languages that the group has no version in are refused with INVALID_REQUEST.

Input

Name In Type Required Description
translationGroupId path string (uuid) yes Id shared by every language version of one article, as translationGroupId on an article or in GET /api/article-groups.
body body object no
body.languages body string[] no Only these language versions. Omit for every version of the group.
body.comment body string no Approve only: stored with the review.
init init { signal?: AbortSignal; timeoutMs?: number } no The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout.

Returns 200 OK

Field Type Required Description
applied string (uuid)[] yes Ids of the versions that changed status.
skipped string (uuid)[] yes Ids of the versions left as they were: already at the target status, or, for unpublish, not published.

Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.

Example

import { PrismDraft } from "@prism-draft/sdk";

const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });

const result = await pd.articleGroups.publish({
  translationGroupId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);

pd.articleGroups.unpublish(input, init?)

Unpublish the language versions of a group

POST /api/article-groups/{translationGroupId}/unpublish

Takes the chosen versions that are PUBLISHED back to DRAFT and skips the others; it is never blocked, and with nothing published it answers 200 with nothing applied. Needs articles.publish. Each unpublished version emits its own article.unpublished webhook (reason: "status_changed") and writes an audit entry. languages that the group has no version in are refused with INVALID_REQUEST.

Input

Name In Type Required Description
translationGroupId path string (uuid) yes Id shared by every language version of one article, as translationGroupId on an article or in GET /api/article-groups.
body body object no
body.languages body string[] no Only these language versions. Omit for every version of the group.
body.comment body string no Approve only: stored with the review.
init init { signal?: AbortSignal; timeoutMs?: number } no The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout.

Returns 200 OK

Field Type Required Description
applied string (uuid)[] yes Ids of the versions that changed status.
skipped string (uuid)[] yes Ids of the versions left as they were: already at the target status, or, for unpublish, not published.

Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.

Example

import { PrismDraft } from "@prism-draft/sdk";

const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });

const result = await pd.articleGroups.unpublish({
  translationGroupId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);