AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Marketing Technology Teams Use the Jasper API to Programmatically Generate On-Brand Content with Custom Brand Voices

Boris Graf · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Marketing technology (MarTech) architects, automation engineers, and content operations leaders face a common scaling bottleneck: marketing teams painstakingly train custom Brand Voices and curate Knowledge Base documents inside Jasper’s web interface, yet engineering teams tasked with generating thousands of e-commerce SKU descriptions, localized landing pages, or daily newsletters still resort to manual copy-pasting or consider writing custom prompts against raw LLM foundation models.

The Jasper REST API solves this disconnect. By exposing Jasper’s core governance assets—specifically Brand Voices (toneId), Knowledge Base items (knowledgeIds), and Style Guides (styleId)—over a secure REST interface, MarTech teams can programmatically execute high-volume generation pipelines while preserving the exact editorial rules configured by marketing stakeholders.

At 365Finds, our institutional stance is clear: if your non-technical marketing organization already maintains its brand guidelines and tone governance within Jasper, MarTech teams should use the official Jasper API rather than building custom prompt-injection layers on raw OpenAI or Anthropic endpoints. Hardcoding tone instructions in application prompts creates organizational drift; leveraging Jasper’s API preserves a single source of truth across both UI users and automated background workers.


1. Authentication and Security Prerequisites

API access requires an active Jasper Business or Enterprise subscription. Jasper provides two authentication models:

  1. Workspace API Key (X-API-Key): Used for unattended server-to-server microservices, data ingest workers, and CI/CD content jobs.
  2. OAuth 2.0 (Authorization Code with PKCE): Used when an integration acts on behalf of a specific logged-in user.

For automated MarTech batch pipelines, use a Workspace API Key.

Generating and Managing API Tokens

  1. Log in to the Jasper dashboard as an Admin or Developer.
  2. Navigate to Settings > Developer Tools > API Tokens (https://app.jasper.ai/settings/dev-tools/tokens).
  3. Generate a dedicated token for your integration (e.g., prod-pim-content-generator).
  4. Store the token in a secure secrets manager (AWS Secrets Manager, HashiCorp Vault, or Google Cloud Secret Manager). Never expose this key in client-side applications.

All REST calls must be directed to https://api.jasper.ai/v1 over HTTPS with the X-API-Key header:

curl --request GET \
  --url https://api.jasper.ai/v1/tones \
  --header 'X-API-Key: YOUR_JASPER_API_KEY' \
  --header 'accept: application/json'

2. Programmatically Discovering Brand Voices and Knowledge Assets

Rather than hardcoding arbitrary IDs or prompt strings, robust automation pipelines dynamically discover and bind existing workspace assets.

Retrieving Brand Voices (/v1/tones)

In Jasper’s REST API, custom Brand Voices are managed under the /v1/tones resource. Each voice has a unique identifier with a ton_ prefix (e.g., ton_2ee766eaa4ef48e59da1d9602bfecf2d).

GET https://api.jasper.ai/v1/tones?page=1&size=20 HTTP/1.1
Host: api.jasper.ai
X-API-Key: YOUR_JASPER_API_KEY
Accept: application/json

Response Example:

[
  {
    "id": "ton_2ee766eaa4ef48e59da1d9602bfecf2d",
    "name": "Acme Enterprise - Authoritative & Concise",
    "value": "This voice is direct, highly professional, and data-driven...",
    "metadata": {
      "channel": "ecommerce",
      "region": "global"
    },
    "settings": {
      "appVisibility": "visible"
    }
  },
  {
    "id": "ton_8a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d",
    "name": "Acme Youth - Energetic & Casual",
    "value": "Vibrant, conversational, friendly tone with punchy sentences...",
    "metadata": {
      "channel": "social",
      "region": "na"
    },
    "settings": {
      "appVisibility": "visible"
    }
  }
]

Retrieving Knowledge Base Items (/v1/knowledge)

Enterprise context (product spec manuals, return policies, compliance disclaimers) is indexed under /v1/knowledge with identifiers prefixed by kno_ (e.g., kno_bce766eaa4ef48e59da1d9602bfecf2d). You can query the knowledge base or run vector searches via POST /v1/knowledge/search to retrieve the relevant IDs for your generation context.


3. Executing Generation Requests with Bound Brand Voice

The primary endpoint for programmatically executing content generation with voice binding is POST https://api.jasper.ai/v1/command.

Payload Structure

The /v1/command endpoint accepts two primary objects: inputs and options.

ParameterTypeRequiredDescription
inputs.commandstringYesThe directive prompt specifying content structure, length, and format.
inputs.contextstringNoRaw input data (product attributes, specs, source bullet points).
inputs.toneIdstringNoThe custom Brand Voice ID (ton_...) to enforce.
inputs.knowledgeIdsarray[string]NoUp to 3 Knowledge Base document IDs (kno_...).
inputs.styleIdstringNoStyle Guide ID (sty_...) defining grammar and capitalization rules.
options.completionTypestringNoquality (thorough reasoning) or performance (faster latency).
options.outputLanguagestringNoTarget language (English, Spanish, French, German, etc.).
options.outputCountnumberNoNumber of variants to generate (1 to 10; default is 1).
options.fallbackToWorkspaceDefaultIqbooleanNoIf true, unassigned voice/style falls back to workspace defaults.

cURL Implementation: E-Commerce Product Description Generation

curl --request POST \
  --url https://api.jasper.ai/v1/command \
  --header 'X-API-Key: YOUR_JASPER_API_KEY' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{
    "inputs": {
      "command": "Generate an on-brand e-commerce product summary. Output valid JSON with keys: \"headline\", \"bullet_points\" (array of 3), and \"editorial_description\" (approx 120 words).",
      "context": "Product: Alpine Apex Carbon Trekking Poles. Weight: 280g per pair. Material: 3K Carbon Fiber. Lock Mechanism: FastLock Aluminum Clamps. Grip: Ergonomic Cork with EVA extension.",
      "toneId": "ton_2ee766eaa4ef48e59da1d9602bfecf2d",
      "knowledgeIds": [
        "kno_bce766eaa4ef48e59da1d9602bfecf2d"
      ]
    },
    "options": {
      "completionType": "quality",
      "outputLanguage": "English",
      "outputCount": 1,
      "fallbackToWorkspaceDefaultIq": false
    }
  }'

Response Schema

{
  "requestId": "4cfeeb0c-7dd3-4118-876a-f1da9acd2545",
  "resource": "content",
  "data": [
    {
      "id": "txt_54bdfbd7a0064953ae42f1f6f68069de",
      "text": "{\n  \"headline\": \"Ultra-Lightweight Rigidity for Demanding Alpine Terrain\",\n  \"bullet_points\": [\n    \"High-modulus 3K carbon fiber construction weighing only 280g per pair\",\n    \"Secure FastLock aluminum lever system for rapid, slip-free height adjustments\",\n    \"Moisture-wicking ergonomic cork grips paired with extended EVA sleeves\"\n  ],\n  \"editorial_description\": \"Engineered for technical backcountry routes, the Alpine Apex Carbon Trekking Poles combine featherweight agility with unyielding structural integrity. Crafted from multi-layer 3K carbon fiber, they absorb heavy trail shocks while keeping pack weight minimal. The reinforced FastLock aluminum clamping mechanism guarantees steadfast security across steep ascents, while natural cork handles adapt to your grip and repel sweat during extended high-altitude ascents.\"\n}"
    }
  ]
}

4. End-to-End Pipeline Architecture: From Catalog to Headless CMS

Building a production-grade generation system requires more than simple HTTP requests. Generating copy for 10,000 product SKUs demands resilience, rate-limit governance, and schema validation before writing into your Headless CMS (such as Contentful or Strapi).

Architecture Overview

[ Product Catalog / PIM / DB ]
             │
             ▼
   [ Message Broker / Queue ]  <--- BullMQ / Celery / Temporal
             │
             ▼ (Concurrency & Token Bucket Throttling <= 100 RPM)
    [ Worker Service ]
             │
             ├── 1. Fetch Brand Voice (`toneId`) & Knowledge (`kno_...`)
             ├── 2. POST https://api.jasper.ai/v1/command
             ├── 3. Parse & Validate JSON (Zod / Pydantic)
             │
             ▼
    [ Headless CMS Ingest ]
             │
             ├── Contentful / Strapi API (Draft State)
             └── Metadata: { jasper_req_id, tone_id, review_status: "pending" }
             │
             ▼
[ Editorial Review Gate (HITL) ] ---> [ Published Content ]

Complete Node.js / TypeScript Pipeline Worker

Below is a production-ready batch worker implementation demonstrating token-bucket throttling, Jasper API invocation, JSON extraction, and Headless CMS staging.

import axios from "axios";
import { z } from "zod";

// 1. Define Output Schema
const ProductCopySchema = z.object({
  headline: z.string(),
  bullet_points: z.array(z.string()),
  editorial_description: z.string()
});
type ProductCopy = z.infer<typeof ProductCopySchema>;

interface SKUItem {
  sku: string;
  name: string;
  specs: string;
  toneId: string;
}

// 2. Generation Service
export class JasperBatchGenerator {
  private client = axios.create({
    baseURL: "https://api.jasper.ai/v1",
    headers: {
      "X-API-Key": process.env.JASPER_API_KEY!,
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    timeout: 30000
  });

  async generateProductCopy(item: SKUItem): Promise<ProductCopy> {
    const payload = {
      inputs: {
        command: "Generate on-brand e-commerce copy. Return strictly raw JSON matching: {\"headline\": string, \"bullet_points\": string[], \"editorial_description\": string}. Do not wrap in markdown fences.",
        context: `SKU: ${item.sku}\nProduct: ${item.name}\nSpecs: ${item.specs}`,
        toneId: item.toneId
      },
      options: {
        completionType: "quality",
        outputLanguage: "English",
        outputCount: 1,
        fallbackToWorkspaceDefaultIq: true
      }
    };

    // Execute with automatic retry on 429
    let attempts = 0;
    while (attempts < 3) {
      try {
        const response = await this.client.post("/command", payload);
        const rawText = response.data.data[0]?.text;
        if (!rawText) throw new Error("Empty response from Jasper API");

        // Parse and validate structured output
        const cleanJson = rawText.replace(/```json/g, "").replace(/```/g, "").trim();
        return ProductCopySchema.parse(JSON.parse(cleanJson));
      } catch (err: any) {
        attempts++;
        if (err.response?.status === 429 && attempts < 3) {
          const delay = Math.pow(2, attempts) * 1000;
          await new Promise((res) => setTimeout(res, delay));
          continue;
        }
        throw new Error(`Failed to generate copy for SKU ${item.sku}: ${err.message}`);
      }
    }
    throw new Error(`Exceeded max retries for SKU ${item.sku}`);
  }

  // 3. Staging to Headless CMS (Strapi / Contentful Draft Pattern)
  async ingestToCMS(sku: string, copy: ProductCopy, toneId: string): Promise<void> {
    await axios.post(
      `${process.env.CMS_BASE_URL}/api/products`,
      {
        data: {
          sku,
          title: copy.headline,
          bullets: copy.bullet_points.join("\n"),
          description: copy.editorial_description,
          status: "draft", // Strict 365Finds Rule: Never publish directly to production
          metadata: {
            generatedBy: "Jasper API",
            brandVoiceId: toneId,
            generatedAt: new Date().toISOString()
          }
        }
      },
      {
        headers: { Authorization: `Bearer ${process.env.CMS_API_TOKEN}` }
      }
    );
  }
}

5. Engineering Governance: Rate Limits, Concurrency, and Error Handling

Operating the Jasper API at enterprise scale requires aligning your message queue with Jasper’s documented infrastructure boundaries:

Rate Limits by Endpoint

Queue Throttling and Workers

Do not fire unthrottled concurrent promises (e.g., Promise.all over 1,000 items). Configure your worker pool with a strict rate limiter capped at 90–100 RPM per workspace. If your business needs exceed 105 RPM, coordinate with your Jasper Customer Success Manager to increase workspace capacity before launching production batch runs.

Model Resiliency and Fallbacks

Jasper’s AI Engine includes built-in model routing and multi-provider failover. If an underlying foundation model experiences latency spikes or outages, Jasper reroutes queries across available LLMs without breaking your API contract.

365Finds Institutional Recommendations

  1. Never skip toneId binding: Avoid baking tone directives directly into inputs.command. Passing toneId activates Jasper’s tuned persona layer, delivering measurable consistency across varying SKU categories.
  2. Enforce Human-in-the-Loop (HITL) CMS Staging: Always ingest programmatic content into Headless CMS systems as draft or needs_review. Programmatic generation handles 90% of copywriting labor, but brand safety requires automated linting and editorial sign-off.
  3. Use fallbackToWorkspaceDefaultIq: true: When building cross-departmental microservices where some incoming jobs lack explicit voice tags, setting this flag prevents generic unbranded outputs by falling back to workspace brand guidelines.

References