Developers
Generate drafts and track background jobs
Repurpose articles, YouTube links, or pasted text; distinguish synchronous generation from asynchronous jobs and poll them without duplicating work.
Updated
Repurpose one source into drafts
POST /v1/generate takes a source url or text and an optional instruction. It runs the same voice, quality, safety, and allowance checks as Krevaya's drafting pipeline. The response arrives after generation finishes and contains source_id and post_ids. This endpoint does not return a background job ID.
curl --fail-with-body --max-time 600 https://api.krevaya.com/v1/generate \
-H "Authorization: Bearer $KREVAYA_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"text":"Our repair intake process has three steps: record the reported symptom, reproduce it with the customer, then agree on the next diagnostic step before ordering parts.","instruction":"Write practical drafts for our workshop audience. Do not add prices or performance claims."}'Use one source at a time: url up to 2,000 characters or text up to 200,000, plus instruction up to 1,000. The MCP repurpose tool exposes the same operation. Both use the currently selected brand and have no brand_id argument. Ensure the intended brand is selected before the call.
Know which operations return jobs
| Operation | How it starts | How to read completion |
|---|---|---|
| Repurpose source | POST /v1/generate or MCP repurpose; synchronous | Read post_ids from the final response |
| Draft a week | MCP draft_week; returns job_id | MCP job_status, then inspect generated posts |
| Import own posting history | POST /v1/brand-memory/import or MCP import_history | MCP job_status |
| Build a brand genome | POST /v1/brand-memory/genome | MCP job_status |
| Export an editable video | MCP export_video | MCP job_status; reports progress where available |
draft_week takes topic and count from 1 to 14, default 7. It plans a week and can schedule generated posts as part of that workflow. Use it only when the user wants a planned week; use repurpose for a source-to-drafts workflow. The job captures the selected brand at start.
Poll with the same account's key
{
"jsonrpc": "2.0",
"id": 20,
"method": "tools/call",
"params": {"name": "job_status", "arguments": {"job_id": "YOUR_JOB_ID"}}
}job_status requires read and returns id, kind, status, result, error, progress, created_at, and finished_at. Wait while status is queued or running. On done, inspect the kind-specific result. On error, show error and stop polling. progress is 0–100 for jobs that report it and can be null for others.
Poll every few seconds and slow down for long jobs. Set a deadline in your own workflow and retain the job ID if the deadline expires. Do not start a second job merely because your first HTTP request or poll timed out.
Separate a failed request from unknown completion
A 400 or an MCP isError result names a request or feature problem. A network timeout only means your client did not receive a final answer. For a known job ID, poll it. For synchronous generation, inspect the current draft queue before retrying: the server may have completed after the connection closed.
Check get_usage before a large run. The generate scope has its own hourly throttle in addition to the shared request budget. Plan allowances and paid-operation charges are independent of that throttle.
Frequently asked questions
Does /v1/generate return a job ID?
No. It is synchronous and returns source_id and post_ids after generation. Import, genome, draft_week, and video export operations use background jobs.
Can I poll a job using only an API key?
Yes. Call the MCP job_status tool with a read-scoped key and the returned job_id. The dashboard /jobs route uses session authentication instead.