← Back to Sparknous

API Reference Business

Generate professional writing with Claude via HTTP. Requires a Business plan API key.

Quick start

  1. Subscribe to the Business plan and sign in.
  2. Open AccountAPI keysGenerate API key.
  3. Copy the key immediately — it is only shown once.
  4. Send requests with Authorization: Bearer sn_...

Base URL

https://your-domain.com

Locally: http://localhost:3000

Authentication

Include your API key in every request:

Authorization: Bearer sn_your_api_key_here

Endpoints

POST/api/v1/generate

Stream an AI-generated response from your prompt.

Request headers

HeaderRequiredDescription
AuthorizationYesBearer sn_...
Content-TypeYesapplication/json

Request body (JSON)

FieldTypeRequiredDescription
promptstringYesFull writing instruction (max 12,000 characters)
toolIdstringNoTemplate ID for history (e.g. cover-letter)
toolNamestringNoHuman-readable label saved to history
tonestringNoTone used (e.g. professional)
{
  "prompt": "Write a cover letter for Alex Johnson applying for Senior PM at Acme Corp...",
  "toolId": "cover-letter",
  "toolName": "Cover letter",
  "tone": "professional"
}

Response — streaming (SSE)

Returns text/event-stream in Anthropic-compatible SSE format. Parse data: lines as JSON events. Text arrives in content_block_delta events:

data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"}}

data: {"type":"message_stop"}

Response headers

HeaderDescription
X-Plan-TierYour effective plan (business)
X-Prioritytrue for priority processing

Examples

cURL

curl -N -X POST https://your-domain.com/api/v1/generate \
  -H "Authorization: Bearer sn_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"Write a professional cold email to a SaaS founder about partnership opportunities.","tone":"confident"}'

Node.js

const res = await fetch('https://your-domain.com/api/v1/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sn_YOUR_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    prompt: 'Write a LinkedIn bio for a fintech founder...',
    toolId: 'linkedin-bio',
    tone: 'professional',
  }),
});

const reader = res.body.getReader();
const decoder = new TextDecoder();
let output = '';

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  for (const line of decoder.decode(value).split('\n')) {
    if (!line.startsWith('data: ')) continue;
    try {
      const event = JSON.parse(line.slice(6));
      if (event.type === 'content_block_delta' && event.delta?.text) {
        output += event.delta.text;
        process.stdout.write(event.delta.text);
      }
    } catch {}
  }
}

Python

import requests, json

url = "https://your-domain.com/api/v1/generate"
headers = {
    "Authorization": "Bearer sn_YOUR_KEY",
    "Content-Type": "application/json",
}
payload = {"prompt": "Write ad copy for a fitness app...", "tone": "persuasive"}

with requests.post(url, headers=headers, json=payload, stream=True) as r:
    r.raise_for_status()
    for line in r.iter_lines():
        if not line or not line.startswith(b"data: "):
            continue
        data = line[6:].decode()
        try:
            event = json.loads(data)
            if event.get("type") == "content_block_delta":
                print(event["delta"].get("text", ""), end="", flush=True)
        except json.JSONDecodeError:
            pass

Error codes

StatusMeaning
400Missing or invalid prompt, or prompt too long
401Invalid or missing API key
403API access requires Business plan
429Rate or usage limit reached
502Upstream AI service error
503AI service not configured on server

JSON error shape:

{"error": "Invalid or missing API key. Use Authorization: Bearer sn_..."}

Limits

LimitBusiness plan
GenerationsUnlimited
Max prompt length12,000 characters
Max output tokens2,000 per request
API keys per account3
Rate limit (free-tier fallback)Skipped for Business
Server-side only. Call the API from your backend, scripts, or integrations — never embed API keys in frontend JavaScript or mobile apps where they can be extracted.

Manage keys

Generate and revoke keys from the web app: Account → API keys. Team members on a Business account inherit Business features but only the account owner can manage billing; API keys are tied to the user who creates them.

Support

Business customers get priority support: hello@sparknous.com