PrismDraft SDK

social

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

Methods

pd.social.generate(input, init?)

Repurpose an article into social posts

POST /api/articles/{articleId}/social

Asks the model to rewrite the article's text as one post per channel (x, linkedin, newsletter, summary, quote, caption) in the article's language, from its first 8,000 characters. The posts replace every post stored for the article: regenerating gives a new set, and a post cannot be edited on its own. Requires articles.update. Costs no credits but counts against the ai_operations quota (429 QUOTA_EXCEEDED when used up). 400 INVALID_REQUEST when the article has no text yet.

Input

Name In Type Required Description
articleId path string (uuid) yes Id of an article. The workspace and project it belongs to are read from the article, never from the request; the caller must be a member of that workspace (and of the project, when it has members). For anyone else the answer is 404 RESOURCE_NOT_FOUND, the same as for an id that does not exist.
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
posts object[] yes The article's posts, ordered by channel as listed in the enum. Empty until social.generate has run.
posts[].id string (uuid) yes Id of the post.
posts[].articleId string (uuid) yes Id of the article the post was written from.
posts[].channel "x" | "linkedin" | "newsletter" | "summary" | "quote" | "caption" yes The format the copy is written for: x (a short post for X), linkedin (a LinkedIn post), newsletter (an introduction for a newsletter), summary (a short summary of the article), quote (a pull quote meant to be taken verbatim from the article) or caption (a caption for sharing).
posts[].content string yes The text of the post, up to 3000 characters, in the article's language.
posts[].createdAt string (date-time) yes When the post was generated, as an ISO 8601 UTC date-time.
posts[].updatedAt string (date-time) yes When the post was last changed, as an ISO 8601 UTC date-time.

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.social.generate({
  articleId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);

pd.social.list(input, init?)

The social posts stored for an article

GET /api/articles/{articleId}/social

Returns the posts last generated for the article, one per channel, ordered by channel; empty before social.generate has run. Requires articles.read.

Input

Name In Type Required Description
articleId path string (uuid) yes Id of an article. The workspace and project it belongs to are read from the article, never from the request; the caller must be a member of that workspace (and of the project, when it has members). For anyone else the answer is 404 RESOURCE_NOT_FOUND, the same as for an id that does not exist.
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
posts object[] yes The article's posts, ordered by channel as listed in the enum. Empty until social.generate has run.
posts[].id string (uuid) yes Id of the post.
posts[].articleId string (uuid) yes Id of the article the post was written from.
posts[].channel "x" | "linkedin" | "newsletter" | "summary" | "quote" | "caption" yes The format the copy is written for: x (a short post for X), linkedin (a LinkedIn post), newsletter (an introduction for a newsletter), summary (a short summary of the article), quote (a pull quote meant to be taken verbatim from the article) or caption (a caption for sharing).
posts[].content string yes The text of the post, up to 3000 characters, in the article's language.
posts[].createdAt string (date-time) yes When the post was generated, as an ISO 8601 UTC date-time.
posts[].updatedAt string (date-time) yes When the post was last changed, as an ISO 8601 UTC date-time.

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.social.list({
  articleId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);