Generate, edit, preview, and publish content drafts.
Generate AI content draft
/drafts/generateGenerates an AI content draft from a natural language prompt. Creates a system service account if needed, mints an ephemeral JWT, and calls the AI service. The resulting draft can be reviewed and accepted or rejected via the drafts API.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const data = { prompt: "Example prompt"};
const { data: draft } = await gc.drafts.generateDraft(data);Create an edit draft
/drafts/editCreates a draft copy of existing content for non-destructive editing. The original stays untouched until the draft is accepted. On accept, the copy's content replaces the original. On reject, the copy is deleted.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const data = {};const { data: draft } = await gc.drafts.editDraft(data);Unarchive a draft
/organizations/{id}/projects/{projectId}/mind/drafts/{draftId}/unarchiveRestores a previously archived draft to the default list.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: draft } = await gc.drafts.unarchiveDraft({ id: "id-123", projectId: "proj-123", draftId: "draft-123"});Archive a draft
/organizations/{id}/projects/{projectId}/mind/drafts/{draftId}/archiveHides an accepted draft from the default list without deleting it. Archived drafts are preserved as a paper trail and for AI training data. Only accepted or partially_accepted drafts can be archived.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: draft } = await gc.drafts.archiveDraft({ id: "id-1", projectId: "proj-1", draftId: "draft-1"});Get a draft by ID
/organizations/{id}/projects/{projectId}/mind/drafts/{draftId}Retrieves the full details of a single AI-generated content draft including the prompt, generated content, tool calls, and sources.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: draft } = await gc.drafts.getDraft({ id: "id_123", projectId: "proj_123", draftId: "draft_123"});Delete a draft
/organizations/{id}/projects/{projectId}/mind/drafts/{draftId}Permanently deletes a draft. Only rejected, failed, or cancelled drafts can be deleted. Returns 409 if the draft is in any other status (pending, ready, accepted).
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: result } = await gc.drafts.deleteDraft({ id: "example-id", projectId: "example-project-id", draftId: "example-draft-id"});List drafts for a project
/organizations/{id}/projects/{projectId}/mind/draftsReturns a paginated list of AI-generated content drafts for the specified project. By default archived drafts are hidden — pass includeArchived=true to include them.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: drafts } = await gc.drafts.listDrafts({ id: "YOUR_ID", projectId: "YOUR_PROJECT_ID"});