Recipes

Complete examples: blogs, offers, lead analysis, Jobs, tokens and the CLI login flow.

Every recipe assumes CGENIUS_API_URL and CGENIUS_API_TOKEN are set (Start here).

Wait for a Job (any language)

async function waitForJob(jobId: string): Promise<unknown> {
  const headers = { Authorization: `Bearer ${process.env.CGENIUS_API_TOKEN}` };
  for (;;) {
    const res = await fetch(`${process.env.CGENIUS_API_URL}/api/v1/jobs/${jobId}`, { headers });
    if (res.status === 429) { await sleep(1000 * Number(res.headers.get('retry-after') ?? 5)); continue; }
    const body = await res.json();
    if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
    const { job } = body;
    if (job.status === 'COMPLETED') return job.result;
    if (job.status === 'FAILED') throw new Error(`${job.error.code}: ${job.error.message}`);
    if (job.status === 'CANCELLED') throw new Error('cancelled');
    await sleep(3000);
  }
}
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
job_id="<jobId>"
while :; do
  body=$(curl -sS "$CGENIUS_API_URL/api/v1/jobs/$job_id" -H "Authorization: Bearer $CGENIUS_API_TOKEN")
  status=$(echo "$body" | jq -r '.job.status')
  echo "$status $(echo "$body" | jq -r '.job.progress')%"
  case "$status" in COMPLETED|FAILED|CANCELLED) echo "$body" | jq '.job'; break;; esac
  sleep 3
done

Find your agents

Generations name an EpsimoAgents assistant (the agent that writes). List the user's assistants and let the user pick one, or use the one they named. Scope: content:read; needs AI access.

curl -sS "$CGENIUS_API_URL/api/v1/assistants" -H "Authorization: Bearer $CGENIUS_API_TOKEN" | jq '.items[] | {assistant_id, name}'
curl -sS "$CGENIUS_API_URL/api/v1/projects" -H "Authorization: Bearer $CGENIUS_API_TOKEN" | jq '.items[] | {project_id, name}'

Use assistant_id as agentConfiguration.defaultAgentId (blog v3), requestData.assistantId (blog v2), assistant_id (blog v1) or assistantId (lead ideas).

Write a blog (v3 engine)

Scopes: content:write, jobs:write; needs AI access.

curl -sS -X POST "$CGENIUS_API_URL/api/v1/blogs/v3/pipelines" \
  -H "Authorization: Bearer $CGENIUS_API_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"requestData":{"topic":"Zero-trust for SMBs","title":"Zero trust, small budget","keywords":"zero trust, SMB","tone":"practical","blogSize":"medium","includeFAQ":true},
       "agentConfiguration":{"defaultAgentId":"<assistant id>"}}'

requestData.topic and agentConfiguration.defaultAgentId are required; researchAgentId, outlineAgentId and writingAgentId override the default agent per phase. The Job id is the pipeline id. Read it with GET /api/v1/blogs/v3/pipelines/{id} or GET /api/v1/jobs/{id}. When it is COMPLETED, result.resources names the content item.

Regenerate one section of a finished blog (index from 0):

curl -sS -X POST "$CGENIUS_API_URL/api/v1/blogs/v3/pipelines/<id>/sections/2/regenerate" \
  -H "Authorization: Bearer $CGENIUS_API_TOKEN" -H "Idempotency-Key: $(uuidgen)"

Resume a failed pipeline: POST /api/v1/blogs/v3/pipelines/{id}/resume.

Write a blog (v2 or v1 engine)

# v2: requestData.topic, wordCount, blogSize (single|small|medium|big|huge), assistantId
curl -sS -X POST "$CGENIUS_API_URL/api/v1/blogs/v2/tasks" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"requestData":{"topic":"Edge AI","wordCount":1200,"blogSize":"medium","assistantId":"<assistant id>"}}'

# v1: assistant_id, topic, blogSize
curl -sS -X POST "$CGENIUS_API_URL/api/v1/blogs/v1/jobs" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"assistant_id":"<assistant id>","topic":"Edge AI","blogSize":"small"}'

Suggest content ideas from leads

Scopes: content:write, jobs:write; needs AI access (it reads the Lead App as the user).

curl -sS -X POST "$CGENIUS_API_URL/api/v1/ideation/analyze" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"leadIds":["<lead id>","<lead id>"]}'

The finished Job's result holds suggestions and leadsAnalyzed.

Generate an offer

variant: batch (one section per subject) or basic, zero, mid, full (the new-batch pipelines; mid and full need assistantsId: {"assistantsId": "<assistant id>"}).

curl -sS -X POST "$CGENIUS_API_URL/api/v1/generate/offer" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"variant":"batch","client_name":"Acme","subjects":["SEO audit","Content plan"],
       "offerRecord":{"id":"<offer id>"},"assistantsId":["<assistant id>","<assistant id>"]}'

Ideas from LeadGenius leads

Content ideas from the user's own LeadGenius leads, written by an agent. The agent never sees contact data (names, e-mails, phone numbers and URLs are removed). Scopes: content:read to list companies; content:write and jobs:write to start; needs AI access.

  1. Find the company. The answer also says which company the user last used for ideas.
curl -sS "$CGENIUS_API_URL/api/v1/lead-app/companies" -H "Authorization: Bearer $CGENIUS_API_TOKEN"
# {"companies":[{"id":"company-…","name":"Acme","role":"owner"}],"selectedCompanyId":"company-…"}
  1. Start the Job. mode is deep (themes per group of 25 leads, then the ideas; a few minutes for a few hundred leads) or quick (statistics and 40 representative leads; about a minute).
curl -sS -X POST "$CGENIUS_API_URL/api/v1/ideation/lead-ideas" \
  -H "Authorization: Bearer $CGENIUS_API_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"assistantId":"<assistant id>","companyId":"<company id>","mode":"deep","ideaCount":8,
       "focus":"We sell managed cloud security to mid-size manufacturers",
       "filters":{"minScore":60,"since":"2026-01-01"},"maxLeads":200}'

Optional fields: leadIds (hand-picked leads, at most 300), filters.statuses, filters.keyword, maxLeads (1 to 300), ideaCount (3 to 15), focus (what the company offers; it replaces the brand voice).

  1. Wait for the Job (Wait for a Job). job.result.suggestions holds the ideas: topic, description, content type, target audience, angles, keywords, rationale, confidence, and the lead ids each idea comes from. 403 forbidden means the user is not a member of that company.

Write a social post and send it to Buffer

The server writes the post with one of the user's agents and saves it to their content. Scopes: content:write, jobs:write (and publish:write to send). Needs AI access.

  1. Start the Job. length is short, medium (default) or long. Add "illustration":true and an imageAssistantId (an assistant with the DALL-E tool) for an image; brandVoiceId for a brand voice; "save":false to keep it out of the user's content.
curl -sS -X POST "$CGENIUS_API_URL/api/v1/generate/social-posts" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"assistantId":"<assistant id>","topic":"Why small teams ship faster","platform":"linkedin","length":"long"}'
# 202 {"job":{"jobId":"job_…","status":"PENDING",…}}
  1. Wait for the Job (Wait for a Job). job.result has text (what the network shows), markdown, fit (status ok, short, long or over), image (with illustration: url, the agent's link, valid about an hour; path, the saved copy; or a note when no image was made) and contentId, the saved post.

  2. Send it: POST /api/v1/publish/buffer (Publish through Buffer) with "text": job.result.text, "contentId": job.result.contentId (the Buffer posts are recorded on the saved post) and, for the illustration, "imageUrl": job.result.image.path (the s3:// path of the saved copy; Buffer gets a 30-day download link). Ask the user first.

Emails (POST /api/v1/generate/emails), presentations (POST /api/v1/generate/presentations) and research reports (POST /api/v1/generate/research, with an assistant that has a web search tool) work the same way; see their fields in the API reference.

Make a video ad from an idea

The server writes a short ad script from one of the user's ideas, renders one MP4 per format on AWS Lambda and saves the ad to their content, linked to the idea. Scopes: content:write, jobs:write (and publish:write to post). Needs AI access.

  1. Start the Job with an idea: ideationId (one of the user's saved ideas) or idea ({"topic", "description", "targetAudience", "angles", "keywords"}, for example a suggestion of ideation.leadIdeas).
curl -sS -X POST "$CGENIUS_API_URL/api/v1/generate/video-ads" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"assistantId":"<assistant id>","ideationId":"<idea id>","formats":["9:16","1:1"],"lengthSeconds":30,
       "platform":"instagram","url":"acme.com/demo","brand":{"name":"Acme","primary":"#1d4ed8","accent":"#f59e0b"}}'

formats: 9:16 (Reels, TikTok, Shorts, Stories), 1:1 (feeds), 4:5 (Instagram and Facebook feed), 16:9 (YouTube, LinkedIn, X). lengthSeconds: 15, 30, 45 or 60. Add "images":true and an imageAssistantId (an assistant with the DALL-E tool) for photos behind up to three scenes; a photo that can't be made leaves a note and the ad still renders. To check the script before rendering, send "render":false, then start a second Job with the edited job.result.script as script.

  1. Follow it with GET /api/v1/generate/video-ads/{jobId} (it also advances the Job). Rendering takes about 10 to 40 seconds per format. On COMPLETED, job.result has script, caption (with hashtags), videos (format, path, url valid 7 days, width, height, durationSeconds) and contentId.

  2. Post it, after the user confirms: POST /api/v1/publish/buffer with "text": job.result.caption, "contentId", and the right video per channel in versions: {"<instagram channel id>": {"text": "<caption>", "videoUrl": "<the 9:16 path>"}, "<linkedin channel id>": {"text": "<caption>", "videoUrl": "<the 1:1 path>"}}. A top-level videoUrl goes to every channel. Paths (s3://…) of the user's own videos are sent to Buffer as 7-day links.

Credits and buying

Generations spend the user's EpsimoAgents credits: each new agent thread costs its model's price (1 for GPT-4o, less for cheaper models), and each rendered video costs 1. A research report is about 7, a video ad in two formats 3, a social post 1. Scopes: settings:read to read, settings:write to buy. Needs AI access.

curl -sS "$CGENIUS_API_URL/api/v1/billing" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  | jq '{creditsLeft, plan: .status.subscription.plan_name, packs: [.catalog.packs[] | {id, threads, amount}]}'

When credits are short, a generation answers 402 credits_exhausted before it starts (error.details.estimatedCredits, creditsLeft). To buy, after the user agrees, POST /api/v1/billing/checkout with {"kind":"pack","itemId":"pack_100"} (packs never expire) or {"kind":"plan","itemId":"pro"} (monthly), and give the user the returned url to pay on Stripe. Never pay for them. Credits are added once Stripe confirms the payment, usually within seconds: poll GET /api/v1/billing. POST /api/v1/billing/portal opens the Stripe portal to change or cancel a plan.

Send content to your sites

GET /api/v1/content?type=social_post lists the user's saved content, newest first; GET /api/v1/content/{id} reads one record. GET /api/v1/publish/endpoints lists the user's sites (Settings → Integrations). After the user confirms, send:

curl -sS -X POST "$CGENIUS_API_URL/api/v1/content/<content id>/send" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" -d '{"endpointId":"<endpoint id>"}'
# {"ok":true,"httpStatus":200,"message":"Accepted (HTTP 200): …","delivery":{…}}

The default simple format sends the title, the HTML content and the featured image link; "options":{"format":"full"} sends every section and field. ok: false means the site refused it (see httpStatus and message). The send is recorded on the content either way.

Size a social post for each channel

Each network has its own limit, ideal length, structure and hashtag count. Read the rules once and write to them, then check the text before publishing. Scope: content:read. No AI access needed.

curl -sS "$CGENIUS_API_URL/api/v1/social/channels" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  | jq '.channels[] | {channel, maxChars, target, lengths, structure, hashtags, image}'
ChannelLimitShortStandard (target)LongHashtagsImage
LinkedIn (linkedin)3,000400 to 8001,300 to 2,000; hook in the first 210 characters2,200 to 2,9003 to 51200 × 627
X (twitter or x)28050 to 120120 to 220; threads220 to 275at most 21600 × 900
Facebook (facebook)5,00080 to 250400 to 8001,000 to 2,000at most 31200 × 630
Instagram (instagram)2,196150 to 400500 to 1,000; hook in the first 125 characters1,200 to 2,1005 to 151080 × 1350
Threads (threads)500100 to 200200 to 350; threads350 to 480at most 11080 × 1350

lengths gives the short, medium (standard) and long ranges; target is the medium one, and social/fit checks against it.

The API answer is the source of truth. Check a draft and get a version that fits:

curl -sS -X POST "$CGENIUS_API_URL/api/v1/social/fit" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -d '{"channel":"x","text":"<the post>"}'
# {"channel":"twitter","length":412,"maxChars":280,"status":"over","hashtagCount":4,"hashtagsOk":false,
#  "fitted":"<cut to 280 with 2 hashtags>","thread":["… 1/2","… 2/2"]}

status is over (the network refuses it), long or short (outside the ideal range) or ok. fitted is cut at a paragraph, sentence or word, keeps the first hashtags allowed, and equals the text when it already fits. thread is there when the channel has threads and the post is longer than one post. Prefer rewriting the post yourself to the rules; use fitted when the user wants a quick cut.

Receive content on your site

When a user sends content to an endpoint of Settings › Integrations ("Send to your sites"), cgenius sends it to the endpoint URL as JSON, in one of two formats the user picks: Simple (the default, ready for WordPress) or Full.

Headers of every request:

HeaderValue
AuthorizationBearer <the token of the endpoint in Settings › Integrations>, when one is set
X-Publish-Eventcontent.publish (JSON) or content.image (multipart/form-data)
X-Publish-Delivery-IdThe deliveryId
Content-Typeapplication/json, or multipart/form-data for images
User-AgentEpsimoAI-Publisher/1.0 (or the User-Agent set in the endpoint headers)

Simple format (the default): ready for WordPress

One request with a flat object: the post fields WordPress needs, the featured image, and a little context. Every key is always present (null or [] when there is nothing). Choose Full in the dialog for the body split into sections and blocks and every detail of the record (described below).

{
  "event": "content.publish",
  "format": "simple",
  "schemaVersion": 1,
  "deliveryId": "5b7a3c0e-1f2d-4c5b-9a8e-7d6c5b4a3f21",
  "sentAt": "2026-12-02T09:00:00.000Z",
  "id": "44ec852a-3956-4a89-a6a5-b101882c45ec",
  "type": "blog",
  "status": "publish",
  "title": "A lead handoff checklist for marketing and sales",
  "slug": "lead-handoff-checklist",
  "excerpt": "A lead handoff is the point at which a marketing conversation becomes a sales responsibility.",
  "content": "<p>A lead handoff is the point at which a marketing conversation becomes a sales responsibility.</p><h2>Agree on what makes a lead ready for sales</h2><p>Work through the following checklist together:</p><ul><li><strong>Define a suitable organisation.</strong> Agree which types of organisation you can serve.</li><li><strong>Define a relevant need.</strong> Identify the problems that make an enquiry worth discussing.</li></ul><p><img src=\"https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png\" alt=\"Handoff stages\"></p><h2>Conclusion</h2><ol><li>Is the next owner clear?</li><li>Can it be recorded in the CRM?</li></ol><p>Want help? <a href=\"https://example.com/contact\">Talk to us</a>.</p>",
  "featured_image": {
    "url": "https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-featured-1.png",
    "alt": null,
    "filename": "lead-handoff-checklist-featured-1.png"
  },
  "images": [
    {
      "url": "https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png",
      "alt": "Handoff stages",
      "filename": "lead-handoff-checklist-inline-2.png"
    }
  ],
  "videos": [],
  "tags": [
    "crm"
  ],
  "seo": {
    "title": "Lead handoff checklist",
    "description": "A lead handoff is the point at which a marketing conversation becomes a sales responsibility.",
    "keywords": [
      "lead handoff",
      "lead qualification",
      "CRM"
    ]
  },
  "context": {
    "topic": "Lead handoff checklist",
    "audience": "Demand-generation and sales leaders",
    "tone": "professional",
    "word_count": 81,
    "reading_time_minutes": 1,
    "created_at": "2026-12-01T10:00:00.000Z",
    "updated_at": "2026-12-01T11:30:00.000Z",
    "platform": null,
    "hashtags": [],
    "subject": null,
    "source": "canvas"
  }
}
FieldIn WordPress
titlePost title (post_title)
contentPost content (post_content)
excerptExcerpt (post_excerpt)
slugSlug (post_name)
statusStatus: publish or draft (post_status)
tagsTags, by name
featured_image.urlFeatured image: download it to the media library, then set it as the post thumbnail
images[].urlBody images: download each one and replace its url in content (the links last 30 days)
videos[].urlVideo ads: a [video] shortcode (or a video block) in the content
seo.title, seo.descriptionYoast (_yoast_wpseo_title, _yoast_wpseo_metadesc) or Rank Math (rank_math_title, rank_math_description)
idA post meta (_cgenius_id), to update the same post on the next send

WordPress plugin (no other tool needed)

Point the cgenius endpoint at https://YOUR-SITE/wp-json/cgenius/v1/publish with a token, and install this plugin:

<?php
/**
 * Plugin Name: cgenius receiver
 * Description: Publishes the posts cgenius sends ("Send to your sites", Simple format).
 *
 * 1. Save this file as wp-content/plugins/cgenius-receiver/cgenius-receiver.php and activate the plugin.
 * 2. In wp-config.php: define('CGENIUS_TOKEN', 'the token you set on the endpoint in cgenius');
 *    Optional: define('CGENIUS_AUTHOR_ID', 2); // the WordPress user the posts belong to (default 1)
 * 3. In cgenius, Settings > Integrations: endpoint URL https://YOUR-SITE/wp-json/cgenius/v1/publish, same token.
 */

add_action('rest_api_init', function () {
    register_rest_route('cgenius/v1', '/publish', [
        'methods'             => 'POST',
        'callback'            => 'cgenius_receive',
        'permission_callback' => function (WP_REST_Request $request) {
            return defined('CGENIUS_TOKEN') && CGENIUS_TOKEN !== ''
                && hash_equals('Bearer ' . CGENIUS_TOKEN, (string) $request->get_header('authorization'));
        },
    ]);
});

function cgenius_receive(WP_REST_Request $request) {
    $p = $request->get_json_params();
    if (($p['event'] ?? '') !== 'content.publish' || ($p['format'] ?? '') !== 'simple') {
        return new WP_Error('cgenius_format', 'Send the Simple format', ['status' => 400]);
    }
    require_once ABSPATH . 'wp-admin/includes/media.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    require_once ABSPATH . 'wp-admin/includes/image.php';

    // The same cgenius content updates the post made for it.
    $existing = get_posts([
        'post_type' => 'post', 'post_status' => 'any', 'numberposts' => 1, 'fields' => 'ids',
        'meta_key' => '_cgenius_id', 'meta_value' => $p['id'],
    ]);
    $post = [
        'post_type'    => 'post',
        'post_title'   => $p['title'],
        'post_content' => $p['content'],
        'post_excerpt' => $p['excerpt'],
        'post_name'    => $p['slug'],
        'post_status'  => $p['status'] === 'publish' ? 'publish' : 'draft',
        'post_author'  => defined('CGENIUS_AUTHOR_ID') ? CGENIUS_AUTHOR_ID : 1,
    ];
    if ($existing) $post['ID'] = $existing[0];
    $id = wp_insert_post(wp_slash($post), true);
    if (is_wp_error($id)) return $id;
    update_post_meta($id, '_cgenius_id', $p['id']);
    wp_set_post_tags($id, $p['tags'], false);

    // Body images: copy them to the media library (the cgenius links last 30 days).
    $content = $p['content'];
    foreach ($p['images'] as $img) {
        $media = media_sideload_image($img['url'], $id, $img['alt'] ?? '', 'id');
        if (!is_wp_error($media)) $content = str_replace($img['url'], wp_get_attachment_url($media), $content);
    }
    // Video ads: each rendered video, played in the post.
    foreach (($p['videos'] ?? []) as $video) {
        $content .= "\n\n" . '[video src="' . esc_url($video['url']) . '"]';
    }
    if ($content !== $p['content']) wp_update_post(wp_slash(['ID' => $id, 'post_content' => $content]));

    // Featured image.
    if (!empty($p['featured_image']['url'])) {
        $media = media_sideload_image($p['featured_image']['url'], $id, $p['featured_image']['alt'] ?? '', 'id');
        if (!is_wp_error($media)) set_post_thumbnail($id, $media);
    }

    // SEO plugin fields (keep the lines of the plugin you use).
    update_post_meta($id, '_yoast_wpseo_title', $p['seo']['title']);
    update_post_meta($id, '_yoast_wpseo_metadesc', $p['seo']['description']);
    update_post_meta($id, 'rank_math_title', $p['seo']['title']);
    update_post_meta($id, 'rank_math_description', $p['seo']['description']);

    // cgenius shows this link on the content.
    return ['id' => $id, 'url' => get_permalink($id)];
}

From an automation tool (n8n, Make, Activepieces…)

Map the fields above to a "Create post" step, or use this JavaScript, which creates the post through the WordPress REST API with an application password:

// cgenius (Simple format) -> a WordPress post, through the WordPress REST API.
// Node 18+, n8n Code node, Pipedream... No dependencies.
// wp = { url: "https://your-site.example", user: "editor", appPassword: "xxxx xxxx xxxx xxxx" }
// (Users > Profile > Application Passwords in WordPress).
async function publishToWordPress(body, wp) {
  if (typeof body === "string") body = JSON.parse(body);
  if (body.event !== "content.publish" || body.format !== "simple") throw new Error("Send the Simple format");
  const auth = "Basic " + Buffer.from(wp.user + ":" + wp.appPassword).toString("base64");
  const api = (path, init = {}) =>
    fetch(wp.url.replace(/\/$/, "") + "/wp-json/wp/v2" + path, { ...init, headers: { Authorization: auth, ...init.headers } })
      .then(async (r) => { if (!r.ok) throw new Error(path + ": HTTP " + r.status + " " + (await r.text())); return r.json(); });

  // Copy an image to the media library; returns its id and URL.
  const upload = async (img) => {
    const file = await fetch(img.url);
    const media = await api("/media", {
      method: "POST",
      headers: { "Content-Type": file.headers.get("content-type") || "image/png", "Content-Disposition": 'attachment; filename="' + (img.filename || "image.png") + '"' },
      body: Buffer.from(await file.arrayBuffer()),
    });
    if (img.alt) await api("/media/" + media.id, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ alt_text: img.alt }) });
    return media;
  };

  // Tags by name: find or create each one.
  const tagIds = [];
  for (const name of body.tags) {
    const found = await api("/tags?search=" + encodeURIComponent(name));
    const tag = found.find((t) => t.name.toLowerCase() === name.toLowerCase()) || (await api("/tags", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name }) }));
    tagIds.push(tag.id);
  }

  let content = body.content;
  for (const img of body.images) content = content.split(img.url).join((await upload(img)).source_url);
  // Video ads: each rendered video as a video block.
  for (const v of body.videos || []) content += '\n<!-- wp:video --><figure class="wp-block-video"><video controls src="' + v.url + '"></video></figure><!-- /wp:video -->';
  const featured = body.featured_image ? await upload(body.featured_image) : null;

  return api("/posts", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      title: body.title,
      content,
      excerpt: body.excerpt,
      slug: body.slug,
      status: body.status, // "publish" or "draft"
      tags: tagIds,
      ...(featured ? { featured_media: featured.id } : {}),
    }),
  }); // returns the post; answer cgenius with { url: post.link }
}

JSON Schema (simple format)

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://app.cgenius.app/schemas/content.publish.simple.v1.json",
  "title": "cgenius content.publish, simple format (schemaVersion 1)",
  "type": "object",
  "properties": {
    "event": {
      "type": "string",
      "const": "content.publish",
      "description": "Always \"content.publish\""
    },
    "format": {
      "type": "string",
      "const": "simple",
      "description": "Always \"simple\""
    },
    "schemaVersion": {
      "type": "integer",
      "const": 1,
      "description": "1"
    },
    "deliveryId": {
      "type": "string",
      "description": "The id of this send"
    },
    "sentAt": {
      "type": "string",
      "format": "date-time",
      "description": "When it was sent (ISO 8601)"
    },
    "id": {
      "type": "string",
      "description": "cgenius content id: the same content sent again has the same id, so update the post you made for it"
    },
    "type": {
      "type": "string",
      "description": "blog, social (or the network: linkedin...), email..."
    },
    "status": {
      "type": "string",
      "enum": [
        "publish",
        "draft"
      ],
      "description": "publish, or draft to keep it as a draft"
    },
    "title": {
      "type": "string",
      "description": "Post title"
    },
    "slug": {
      "type": "string",
      "description": "URL slug"
    },
    "excerpt": {
      "type": "string",
      "description": "Short summary"
    },
    "content": {
      "type": "string",
      "description": "The body as HTML, without the title; images point at download links"
    },
    "featured_image": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "url": {
          "type": "string",
          "description": "Download link (no sign-in, valid 30 days): copy the image to your media library"
        },
        "alt": {
          "type": [
            "string",
            "null"
          ],
          "description": "Alt text"
        },
        "filename": {
          "type": [
            "string",
            "null"
          ],
          "description": "A file name for it"
        }
      },
      "required": [
        "url",
        "alt",
        "filename"
      ],
      "description": "The main image; null when there is none"
    },
    "images": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Download link (no sign-in, valid 30 days): copy the image to your media library"
          },
          "alt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Alt text"
          },
          "filename": {
            "type": [
              "string",
              "null"
            ],
            "description": "A file name for it"
          }
        },
        "required": [
          "url",
          "alt",
          "filename"
        ],
        "description": "An image"
      },
      "description": "The other images of the body (already in content by their url)"
    },
    "videos": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Public download link of the MP4"
          },
          "format": {
            "type": "string",
            "description": "9:16, 1:1, 4:5 or 16:9"
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Width in pixels"
          },
          "height": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Height in pixels"
          },
          "duration_seconds": {
            "type": [
              "number",
              "null"
            ],
            "description": "Length in seconds"
          }
        },
        "required": [
          "url",
          "format",
          "width",
          "height",
          "duration_seconds"
        ],
        "description": "A video"
      },
      "description": "Rendered videos (video ads); [] for other content"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Tag names"
    },
    "seo": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "description": "SEO title (70 characters at most)"
        },
        "description": {
          "type": "string",
          "description": "Meta description (160 characters at most)"
        },
        "keywords": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Keywords"
        }
      },
      "required": [
        "title",
        "description",
        "keywords"
      ],
      "description": "For your SEO plugin"
    },
    "context": {
      "type": "object",
      "properties": {
        "topic": {
          "type": [
            "string",
            "null"
          ],
          "description": "Topic"
        },
        "audience": {
          "type": [
            "string",
            "null"
          ],
          "description": "Target audience"
        },
        "tone": {
          "type": [
            "string",
            "null"
          ],
          "description": "Tone"
        },
        "word_count": {
          "type": "integer",
          "description": "Words"
        },
        "reading_time_minutes": {
          "type": "integer",
          "description": "Reading time at 200 words a minute"
        },
        "created_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "Created (ISO 8601)"
        },
        "updated_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "Last changed (ISO 8601)"
        },
        "platform": {
          "type": [
            "string",
            "null"
          ],
          "description": "Social posts: the network"
        },
        "hashtags": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Social posts: hashtags, with #"
        },
        "subject": {
          "type": [
            "string",
            "null"
          ],
          "description": "Emails: the subject"
        },
        "source": {
          "type": [
            "string",
            "null"
          ],
          "description": "Where it was written (canvas...)"
        }
      },
      "required": [
        "topic",
        "audience",
        "tone",
        "word_count",
        "reading_time_minutes",
        "created_at",
        "updated_at",
        "platform",
        "hashtags",
        "subject",
        "source"
      ],
      "description": "Details that are not post fields"
    }
  },
  "required": [
    "event",
    "format",
    "schemaVersion",
    "deliveryId",
    "sentAt",
    "id",
    "type",
    "status",
    "title",
    "slug",
    "excerpt",
    "content",
    "featured_image",
    "images",
    "videos",
    "tags",
    "seo",
    "context"
  ],
  "description": "A post cgenius sends to your endpoint (one request, Content-Type: application/json). Every key is always present."
}

Full format

The full format makes these requests, in this order:

  1. The structured content: one POST with Content-Type: application/json and event: "content.publish". By default this is the only request: every image is a download link in images[].url (no sign-in, valid 30 days), and the <img src> of the HTML points at it.
  2. Each image file, only when the user chooses "Links, then each file in its own request": one POST per image, multipart/form-data, event: "content.image", the file in the field file, with the same deliveryId. A webhook tool that shows only its last request then shows an image request: the content is the one before it.

Every key of the JSON is always there (null, [] or {} when there is nothing), so a parser built from the sample below fits every send. Copy the sample or the JSON Schema into your tool, or start from the parsers.

Sample request

{
  "event": "content.publish",
  "schemaVersion": 1,
  "deliveryId": "5b7a3c0e-1f2d-4c5b-9a8e-7d6c5b4a3f21",
  "sentAt": "2026-12-02T09:00:00.000Z",
  "status": "publish",
  "endpoint": {
    "id": "ep-1",
    "name": "My website"
  },
  "imageDelivery": "link",
  "content": {
    "id": "44ec852a-3956-4a89-a6a5-b101882c45ec",
    "type": "blog",
    "kind": "blog",
    "title": "Lead handoff checklist",
    "headline": "A lead handoff checklist for marketing and sales",
    "slug": "lead-handoff-checklist",
    "subtitle": null,
    "excerpt": "A lead handoff is the point at which a marketing conversation becomes a sales responsibility.",
    "tags": [
      "blog",
      "crm"
    ],
    "topic": "Lead handoff checklist",
    "tone": "professional",
    "audience": "Demand-generation and sales leaders",
    "source": "canvas",
    "threadId": "7f0c1d2e-0000-4000-8000-000000000000",
    "createdAt": "2026-12-01T10:00:00.000Z",
    "updatedAt": "2026-12-01T11:30:00.000Z",
    "body": {
      "html": "<h1>A lead handoff checklist for marketing and sales</h1><p>A lead handoff is the point at which a marketing conversation becomes a sales responsibility.</p><h2>Agree on what makes a lead ready for sales</h2><p>Work through the following checklist together:</p><ul><li><strong>Define a suitable organisation.</strong> Agree which types of organisation you can serve.</li><li><strong>Define a relevant need.</strong> Identify the problems that make an enquiry worth discussing.</li></ul><p><img src=\"https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png\" alt=\"Handoff stages\"></p><h2>Conclusion</h2><ol><li>Is the next owner clear?</li><li>Can it be recorded in the CRM?</li></ol><p>Want help? <a href=\"https://example.com/contact\">Talk to us</a>.</p>",
      "markdown": "# A lead handoff checklist for marketing and sales\n\nA lead handoff is…",
      "text": "A lead handoff checklist for marketing and sales\nA lead handoff is the point at which a marketing conversation becomes a sales responsibility.\nAgree on what makes a lead ready for sales\nWork through the following checklist together:\nDefine a suitable organisation. Agree which types of organisation you can serve.\nDefine a relevant need. Identify the problems that make an enquiry worth discussing.\nConclusion\nIs the next owner clear?\nCan it be recorded in the CRM?\nWant help? Talk to us."
    },
    "sections": [
      {
        "index": 0,
        "heading": null,
        "level": 0,
        "anchor": null,
        "text": "A lead handoff is the point at which a marketing conversation becomes a sales responsibility.",
        "html": "<p>A lead handoff is the point at which a marketing conversation becomes a sales responsibility.</p>",
        "blocks": [
          {
            "type": "paragraph",
            "text": "A lead handoff is the point at which a marketing conversation becomes a sales responsibility.",
            "html": "<p>A lead handoff is the point at which a marketing conversation becomes a sales responsibility.</p>",
            "level": null,
            "ordered": null,
            "items": [],
            "imageId": null,
            "src": null,
            "alt": null,
            "language": null,
            "rows": []
          }
        ]
      },
      {
        "index": 1,
        "heading": "Agree on what makes a lead ready for sales",
        "level": 2,
        "anchor": "agree-on-what-makes-a-lead-ready-for-sales",
        "text": "Work through the following checklist together:\nDefine a suitable organisation. Agree which types of organisation you can serve.\nDefine a relevant need. Identify the problems that make an enquiry worth discussing.",
        "html": "<p>Work through the following checklist together:</p><ul><li><strong>Define a suitable organisation.</strong> Agree which types of organisation you can serve.</li><li><strong>Define a relevant need.</strong> Identify the problems that make an enquiry worth discussing.</li></ul><p><img src=\"https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png\" alt=\"Handoff stages\"></p>",
        "blocks": [
          {
            "type": "paragraph",
            "text": "Work through the following checklist together:",
            "html": "<p>Work through the following checklist together:</p>",
            "level": null,
            "ordered": null,
            "items": [],
            "imageId": null,
            "src": null,
            "alt": null,
            "language": null,
            "rows": []
          },
          {
            "type": "list",
            "text": "Define a suitable organisation. Agree which types of organisation you can serve.\nDefine a relevant need. Identify the problems that make an enquiry worth discussing.",
            "html": "<ul><li><strong>Define a suitable organisation.</strong> Agree which types of organisation you can serve.</li><li><strong>Define a relevant need.</strong> Identify the problems that make an enquiry worth discussing.</li></ul>",
            "level": null,
            "ordered": false,
            "items": [
              {
                "label": "Define a suitable organisation.",
                "text": "Define a suitable organisation. Agree which types of organisation you can serve.",
                "html": "<strong>Define a suitable organisation.</strong> Agree which types of organisation you can serve."
              },
              {
                "label": "Define a relevant need.",
                "text": "Define a relevant need. Identify the problems that make an enquiry worth discussing.",
                "html": "<strong>Define a relevant need.</strong> Identify the problems that make an enquiry worth discussing."
              }
            ],
            "imageId": null,
            "src": null,
            "alt": null,
            "language": null,
            "rows": []
          },
          {
            "type": "image",
            "text": "Handoff stages",
            "html": "<p><img src=\"https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png\" alt=\"Handoff stages\"></p>",
            "level": null,
            "ordered": null,
            "items": [],
            "imageId": "inline-1",
            "src": "https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png",
            "alt": "Handoff stages",
            "language": null,
            "rows": []
          }
        ]
      },
      {
        "index": 2,
        "heading": "Conclusion",
        "level": 2,
        "anchor": "conclusion",
        "text": "Is the next owner clear?\nCan it be recorded in the CRM?\nWant help? Talk to us.",
        "html": "<ol><li>Is the next owner clear?</li><li>Can it be recorded in the CRM?</li></ol><p>Want help? <a href=\"https://example.com/contact\">Talk to us</a>.</p>",
        "blocks": [
          {
            "type": "list",
            "text": "Is the next owner clear?\nCan it be recorded in the CRM?",
            "html": "<ol><li>Is the next owner clear?</li><li>Can it be recorded in the CRM?</li></ol>",
            "level": null,
            "ordered": true,
            "items": [
              {
                "label": null,
                "text": "Is the next owner clear?",
                "html": "Is the next owner clear?"
              },
              {
                "label": null,
                "text": "Can it be recorded in the CRM?",
                "html": "Can it be recorded in the CRM?"
              }
            ],
            "imageId": null,
            "src": null,
            "alt": null,
            "language": null,
            "rows": []
          },
          {
            "type": "paragraph",
            "text": "Want help? Talk to us.",
            "html": "<p>Want help? <a href=\"https://example.com/contact\">Talk to us</a>.</p>",
            "level": null,
            "ordered": null,
            "items": [],
            "imageId": null,
            "src": null,
            "alt": null,
            "language": null,
            "rows": []
          }
        ]
      }
    ],
    "links": [
      {
        "text": "Talk to us",
        "url": "https://example.com/contact"
      }
    ],
    "callToAction": {
      "text": "Talk to us",
      "url": "https://example.com/contact"
    },
    "seo": {
      "metaTitle": "Lead handoff checklist",
      "metaDescription": "A lead handoff is the point at which a marketing conversation becomes a sales responsibility.",
      "keywords": [
        "lead handoff",
        "lead qualification",
        "CRM"
      ]
    },
    "social": null,
    "email": null,
    "slides": [],
    "metrics": {
      "wordCount": 81,
      "characterCount": 488,
      "readingTimeMinutes": 1,
      "sectionCount": 3,
      "imageCount": 2
    },
    "fields": {}
  },
  "featuredImageId": "illustration",
  "images": [
    {
      "id": "illustration",
      "role": "featured",
      "alt": null,
      "caption": null,
      "originalSrc": null,
      "filename": "lead-handoff-checklist-featured-1.png",
      "contentType": "image/png",
      "size": null,
      "url": "https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-featured-1.png",
      "data": null,
      "note": null,
      "delivery": "link"
    },
    {
      "id": "inline-1",
      "role": "inline",
      "alt": "Handoff stages",
      "caption": null,
      "originalSrc": "https://app.cgenius.app/api/image-proxy?url=s3%3A%2F%2Fbucket%2FpdfFile%2Fu%2Fchart.png",
      "filename": "lead-handoff-checklist-inline-2.png",
      "contentType": "image/png",
      "size": null,
      "url": "https://app.cgenius.app/api/publish/image-links/0448c448-0000-4000-8000-000000000000/ep-1/AQICAHh-sample-token/lead-handoff-checklist-inline-2.png",
      "data": null,
      "note": null,
      "delivery": "link"
    }
  ],
  "videos": []
}

Field reference

FieldTypeMeaning
eventstringAlways "content.publish" (the images come as "content.image" requests)
schemaVersioninteger1. A new version is announced before it changes how a key is read
deliveryIdstringThe id of this send; the image requests carry it too
sentAtstringWhen it was sent (ISO 8601)
statusstringWhat the user asks your site to do: publish it, or keep it as a draft
endpointobjectYour endpoint, as named in cgenius
endpoint.idstringEndpoint id
endpoint.namestringEndpoint name
imageDeliverystringHow the images come: link (download links in this request, the default), separate (links, then each file in its own request), inline (links and base64), or none
contentobjectThe content
content.idstringcgenius content id (stable: use it to update the same post on a new send)
content.typestringStored type: blog, social_post, email, research_report, commercial_offer, presentation…
content.kindstringNormalized kind: blog, social (or the network: linkedin, twitter…), email, presentation…
content.titlestringThe title of the content
content.headlinestringnull
content.slugstringA URL slug of the title
content.subtitlestringnull
content.excerptstringA short summary (about 300 characters)
content.tagsstring[]Tags
content.topicstringnull
content.tonestringnull
content.audiencestringnull
content.sourcestringnull
content.threadIdstringnull
content.createdAtstringnull
content.updatedAtstringnull
content.bodyobjectThe whole body; a format not chosen in the send options is null
content.body.htmlstringnull
content.body.markdownstringnull
content.body.textstringnull
content.sectionsobject[]The body split at its headings, each with its blocks
content.sections[].indexinteger0, 1, 2… in reading order
content.sections[].headingstringnull
content.sections[].levelintegerHeading level 1 to 3; 0 for the text before the first heading
content.sections[].anchorstringnull
content.sections[].textstringThe section as plain text (one line per paragraph or list item)
content.sections[].htmlstringThe section as HTML, without its heading
content.sections[].blocksobject[]The section, block by block
content.sections[].blocks[].typestringparagraph, list, heading (h4–h6), quote, code, image, table, divider, or html (anything else, kept as is)
content.sections[].blocks[].textstringPlain text (list: one line per item; code: the code)
content.sections[].blocks[].htmlstringThe block as HTML
content.sections[].blocks[].levelintegernull
content.sections[].blocks[].orderedbooleannull
content.sections[].blocks[].itemsobject[]list: its items; else []
content.sections[].blocks[].items[].labelstringnull
content.sections[].blocks[].items[].textstringThe item as plain text
content.sections[].blocks[].items[].htmlstringThe item as HTML
content.sections[].blocks[].imageIdstringnull
content.sections[].blocks[].srcstringnull
content.sections[].blocks[].altstringnull
content.sections[].blocks[].languagestringnull
content.sections[].blocks[].rowsarray[]table: the cells’ text, row by row, header row first; else []
content.linksobject[]Every link of the body, in order
content.links[].textstringLink text
content.links[].urlstringURL
content.callToActionobjectnull
content.callToAction.textstringText
content.callToAction.urlstringnull
content.seoobjectSearch details
content.seo.metaTitlestringTitle for <title> (70 characters at most)
content.seo.metaDescriptionstringMeta description (160 characters at most)
content.seo.keywordsstring[]Keywords
content.socialobjectnull
content.social.platformstringnull
content.social.hashtagsstring[]Hashtags, with #
content.social.callToActionstringnull
content.social.lengthstringnull
content.emailobjectnull
content.email.subjectstringnull
content.email.recipientstringnull
content.slidesobject[]Presentations: the slides; else []
content.slides[].titlestringTitle
content.slides[].contentstringText
content.slides[].notesstringSpeaker notes
content.slides[].imageUrlstringnull
content.metricsobjectCounts
content.metrics.wordCountintegerWords
content.metrics.characterCountintegerCharacters of the plain text
content.metrics.readingTimeMinutesintegerReading time at 200 words a minute
content.metrics.sectionCountintegerSections
content.metrics.imageCountintegerImages in images[]
content.fieldsobjectEvery other field of the record (research, ideas…); {} when the user left them out
featuredImageIdstringnull
imagesobject[]Every image of the content
images[].idstringIts id: featured and gallery images "linked-…", the saved illustration "illustration", body images "inline-1", "inline-2"…, slide images "slide-1", "slide-2"…
images[].rolestringfeatured (the main image), illustration, gallery, or inline (in the body)
images[].altstringnull
images[].captionstringnull
images[].originalSrcstringnull
images[].filenamestringnull
images[].contentTypestringnull
images[].sizeintegernull
images[].deliverystringlink: download it from url; file: url too, and the file comes next in its own request (content.image); inline: url too, and the bytes in data; unavailable: not sent (see note)
images[].urlstringnull
images[].datastringnull
images[].notestringnull
videosobject[]Rendered videos (video ads); [] for other content
videos[].formatstring9:16, 1:1, 4:5 or 16:9
videos[].urlstringPublic download link of the MP4
videos[].widthintegernull
videos[].heightintegernull
videos[].durationSecondsnumbernull
videos[].sizeInBytesintegernull

Image requests

Form fieldMeaning
fileThe image file (with its file name and content type)
eventAlways "content.image"
deliveryIdThe deliveryId of the content request it belongs to
contentIdcontent.id
imageIdIts id in images[] of the content request
rolefeatured, illustration, gallery or inline
index0, 1, 2… among the files of this send
totalHow many files this send has
altAlt text (only when there is one)
captionCaption (only when there is one)
originalSrcinline images: the src used in the body (only for those)

No-code tools (n8n, Make, Zapier, Activepieces…)

  1. Use a webhook trigger that parses JSON (not a "raw" webhook): the fields then arrive under body (for example body.content.title).
  2. If the tool asks for a sample or a data structure, paste the sample JSON (or the JSON Schema). Every key is always present, so the structure it builds fits every send.
  3. Images: download each one from images[].url (an HTTP GET, no sign-in) when you need the file; the HTML already points at those links.
  4. If the user sends files too ("then each file in its own request"), branch on the X-Publish-Event header (or body.event): content.publish is the post; content.image is one image file (multipart, field "file"), with deliveryId and imageId to attach it to the post.
  5. Loop over body.content.sections (heading, text, html, blocks) to build the page, or use body.content.body.html (or .markdown) as a whole.
  6. Use body.content.id as the key of the post: a new send of the same content has the same id, so update instead of duplicating.
  7. Answer 2xx when it is stored. Answer JSON with "url" (or "link") to show the published page on the content in cgenius.

JavaScript

// cgenius → your site (schemaVersion 1). Plain JavaScript, no dependencies:
// Node, n8n Code node, Pipedream, Activepieces code step, Cloudflare Workers...
// Give it the request body (already parsed JSON, or the raw JSON string).
function parseCgeniusContent(body) {
  if (typeof body === "string") body = JSON.parse(body);
  if (!body || body.event !== "content.publish") throw new Error("Not a cgenius content request");
  if (body.schemaVersion !== 1) console.warn("cgenius schemaVersion " + body.schemaVersion + ": check the field reference");
  const c = body.content;
  const imagesById = Object.fromEntries(body.images.map((i) => [i.id, i]));
  return {
    deliveryId: body.deliveryId,        // the image requests that follow carry the same id
    publish: body.status === "publish", // false: keep it as a draft
    id: c.id,                           // stable: update the same post on a new send
    type: c.type,
    kind: c.kind,
    title: c.headline || c.title,
    slug: c.slug,
    subtitle: c.subtitle,
    excerpt: c.excerpt,
    tags: c.tags,
    seo: c.seo,                         // { metaTitle, metaDescription, keywords }
    html: c.body.html,
    markdown: c.body.markdown,
    text: c.body.text,
    sections: c.sections.map((s) => ({
      heading: s.heading,
      level: s.level,
      anchor: s.anchor,
      text: s.text,
      html: s.html,
      paragraphs: s.blocks.filter((b) => b.type === "paragraph").map((b) => b.text),
      lists: s.blocks.filter((b) => b.type === "list").map((b) => ({
        ordered: b.ordered,
        items: b.items.map((i) => ({ label: i.label, text: i.text })),
      })),
      images: s.blocks.filter((b) => b.type === "image").map((b) => imagesById[b.imageId] || { src: b.src, alt: b.alt }),
      blocks: s.blocks,                 // everything, in order
    })),
    links: c.links,
    callToAction: c.callToAction,       // { text, url } or null
    social: c.social,                   // social posts, else null
    email: c.email,                     // emails, else null
    slides: c.slides,
    metrics: c.metrics,
    fields: c.fields,                   // every other detail of the record
    featuredImage: body.featuredImageId ? imagesById[body.featuredImageId] : null,
    images: body.images,
    // Each image: i.url downloads it (no sign-in). Body images: <img src> in html already points at i.url.
    imageFilesToExpect: body.images.filter((i) => i.delivery === "file").length, // requests that follow ("separate" only)
  };
}

// An image request (multipart/form-data, field "file"): keep it with its post.
// fields = the form fields, file = the uploaded file (name, type, bytes).
function parseCgeniusImage(fields, file) {
  if (fields.event !== "content.image") throw new Error("Not a cgenius image request");
  return {
    deliveryId: fields.deliveryId,
    contentId: fields.contentId,
    imageId: fields.imageId,            // matches images[].id of the content request
    role: fields.role,                  // featured | illustration | gallery | inline
    index: Number(fields.index),
    total: Number(fields.total),
    alt: fields.alt || null,
    originalSrc: fields.originalSrc || null, // inline images: replace this src in the HTML
    file,
  };
}

// Example: Express, one URL for both requests.
// npm i express multer
// const express = require("express");
// const multer = require("multer");
// const app = express();
// const upload = multer({ storage: multer.memoryStorage() });
// app.post("/cgenius", express.json({ limit: "20mb" }), upload.single("file"), (req, res) => {
//   if (req.get("authorization") !== "Bearer " + process.env.CGENIUS_ENDPOINT_TOKEN) return res.sendStatus(401);
//   const event = req.get("x-publish-event") || (req.body && req.body.event);
//   if (event === "content.publish") {
//     const post = parseCgeniusContent(req.body);
//     // ...create or update the post with id post.id...
//     return res.status(201).json({ url: "https://your-site.example/blog/" + post.slug }); // shown on the content in cgenius
//   }
//   if (event === "content.image") {
//     const image = parseCgeniusImage(req.body, req.file); // req.file.buffer, .originalname, .mimetype
//     // ...store the file, attach it to the post with id image.contentId...
//     return res.json({ ok: true });
//   }
//   res.status(400).json({ error: "Unknown event" });
// });
// app.listen(3000);

Python

# cgenius -> your site (schemaVersion 1). Python 3.8+, no dependencies.
import json

def parse_cgenius_content(body):
    """body: the request JSON (dict) or its raw text."""
    if isinstance(body, (str, bytes)):
        body = json.loads(body)
    if body.get("event") != "content.publish":
        raise ValueError("Not a cgenius content request")
    c = body["content"]
    images_by_id = {i["id"]: i for i in body["images"]}
    return {
        "delivery_id": body["deliveryId"],      # the image requests carry the same id
        "publish": body["status"] == "publish",  # False: keep it as a draft
        "id": c["id"],                           # stable: update the same post on a new send
        "type": c["type"],
        "kind": c["kind"],
        "title": c["headline"] or c["title"],
        "slug": c["slug"],
        "subtitle": c["subtitle"],
        "excerpt": c["excerpt"],
        "tags": c["tags"],
        "seo": c["seo"],                         # metaTitle, metaDescription, keywords
        "html": c["body"]["html"],
        "markdown": c["body"]["markdown"],
        "text": c["body"]["text"],
        "sections": [
            {
                "heading": s["heading"],
                "level": s["level"],
                "anchor": s["anchor"],
                "text": s["text"],
                "html": s["html"],
                "paragraphs": [b["text"] for b in s["blocks"] if b["type"] == "paragraph"],
                "lists": [
                    {"ordered": b["ordered"], "items": [{"label": i["label"], "text": i["text"]} for i in b["items"]]}
                    for b in s["blocks"] if b["type"] == "list"
                ],
                "images": [images_by_id.get(b["imageId"]) or {"src": b["src"], "alt": b["alt"]}
                           for b in s["blocks"] if b["type"] == "image"],
                "blocks": s["blocks"],           # everything, in order
            }
            for s in c["sections"]
        ],
        "links": c["links"],
        "call_to_action": c["callToAction"],     # {"text", "url"} or None
        "social": c["social"],                   # social posts, else None
        "email": c["email"],                     # emails, else None
        "slides": c["slides"],
        "metrics": c["metrics"],
        "fields": c["fields"],                   # every other detail of the record
        "featured_image": images_by_id.get(body["featuredImageId"]) if body["featuredImageId"] else None,
        "images": body["images"],
        "image_files_to_expect": sum(1 for i in body["images"] if i["delivery"] == "file"),
    }


def parse_cgenius_image(fields, file):
    """An image request (multipart/form-data): fields = the form fields, file = the uploaded file."""
    if fields.get("event") != "content.image":
        raise ValueError("Not a cgenius image request")
    return {
        "delivery_id": fields["deliveryId"],
        "content_id": fields["contentId"],
        "image_id": fields["imageId"],           # matches images[].id of the content request
        "role": fields["role"],                  # featured | illustration | gallery | inline
        "index": int(fields["index"]),
        "total": int(fields["total"]),
        "alt": fields.get("alt"),
        "original_src": fields.get("originalSrc"),  # inline images: replace this src in the HTML
        "file": file,
    }

# Example: Flask, one URL for both requests.  pip install flask
# import os
# from flask import Flask, request, jsonify
# app = Flask(__name__)
# @app.post("/cgenius")
# def cgenius():
#     if request.headers.get("Authorization") != "Bearer " + os.environ["CGENIUS_ENDPOINT_TOKEN"]:
#         return "", 401
#     event = request.headers.get("X-Publish-Event")
#     if event == "content.publish":
#         post = parse_cgenius_content(request.get_json())
#         # ...create or update the post with id post["id"]...
#         return jsonify(url="https://your-site.example/blog/" + post["slug"]), 201
#     if event == "content.image":
#         image = parse_cgenius_image(request.form, request.files["file"])
#         # ...image["file"].save(...), attach it to the post image["content_id"]...
#         return jsonify(ok=True)
#     return jsonify(error="Unknown event"), 400

JSON Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://app.cgenius.app/schemas/content.publish.v1.json",
  "title": "cgenius content.publish (schemaVersion 1)",
  "type": "object",
  "properties": {
    "event": {
      "type": "string",
      "const": "content.publish",
      "description": "Always \"content.publish\" (the images come as \"content.image\" requests)"
    },
    "schemaVersion": {
      "type": "integer",
      "const": 1,
      "description": "1. A new version is announced before it changes how a key is read"
    },
    "deliveryId": {
      "type": "string",
      "description": "The id of this send; the image requests carry it too"
    },
    "sentAt": {
      "type": "string",
      "format": "date-time",
      "description": "When it was sent (ISO 8601)"
    },
    "status": {
      "type": "string",
      "enum": [
        "publish",
        "draft"
      ],
      "description": "What the user asks your site to do: publish it, or keep it as a draft"
    },
    "endpoint": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Endpoint id"
        },
        "name": {
          "type": "string",
          "description": "Endpoint name"
        }
      },
      "required": [
        "id",
        "name"
      ],
      "description": "Your endpoint, as named in cgenius"
    },
    "imageDelivery": {
      "type": "string",
      "enum": [
        "separate",
        "inline",
        "link",
        "none"
      ],
      "description": "How the images come: link (download links in this request, the default), separate (links, then each file in its own request), inline (links and base64), or none"
    },
    "content": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "cgenius content id (stable: use it to update the same post on a new send)"
        },
        "type": {
          "type": "string",
          "description": "Stored type: blog, social_post, email, research_report, commercial_offer, presentation…"
        },
        "kind": {
          "type": "string",
          "description": "Normalized kind: blog, social (or the network: linkedin, twitter…), email, presentation…"
        },
        "title": {
          "type": "string",
          "description": "The title of the content"
        },
        "headline": {
          "type": [
            "string",
            "null"
          ],
          "description": "The h1 the body opens with (the displayed title); not repeated in sections"
        },
        "slug": {
          "type": "string",
          "description": "A URL slug of the title"
        },
        "subtitle": {
          "type": [
            "string",
            "null"
          ],
          "description": "Subtitle"
        },
        "excerpt": {
          "type": "string",
          "description": "A short summary (about 300 characters)"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Tags"
        },
        "topic": {
          "type": [
            "string",
            "null"
          ],
          "description": "Topic"
        },
        "tone": {
          "type": [
            "string",
            "null"
          ],
          "description": "Tone (professional, friendly…)"
        },
        "audience": {
          "type": [
            "string",
            "null"
          ],
          "description": "Target audience"
        },
        "source": {
          "type": [
            "string",
            "null"
          ],
          "description": "Where it was written (canvas, presentation-editor)"
        },
        "threadId": {
          "type": [
            "string",
            "null"
          ],
          "description": "Canvas thread id"
        },
        "createdAt": {
          "type": [
            "string",
            "null"
          ],
          "description": "Created (ISO 8601)"
        },
        "updatedAt": {
          "type": [
            "string",
            "null"
          ],
          "description": "Last changed (ISO 8601)"
        },
        "body": {
          "type": "object",
          "properties": {
            "html": {
              "type": [
                "string",
                "null"
              ],
              "description": "HTML"
            },
            "markdown": {
              "type": [
                "string",
                "null"
              ],
              "description": "Markdown (content written in the Canvas)"
            },
            "text": {
              "type": [
                "string",
                "null"
              ],
              "description": "Plain text"
            }
          },
          "required": [
            "html",
            "markdown",
            "text"
          ],
          "description": "The whole body; a format not chosen in the send options is null"
        },
        "sections": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "integer",
                "description": "0, 1, 2… in reading order"
              },
              "heading": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The heading text; null for the text before the first heading"
              },
              "level": {
                "type": "integer",
                "description": "Heading level 1 to 3; 0 for the text before the first heading"
              },
              "anchor": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "A slug of the heading, for in-page links; null without a heading"
              },
              "text": {
                "type": "string",
                "description": "The section as plain text (one line per paragraph or list item)"
              },
              "html": {
                "type": "string",
                "description": "The section as HTML, without its heading"
              },
              "blocks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "paragraph",
                        "list",
                        "heading",
                        "quote",
                        "code",
                        "image",
                        "table",
                        "divider",
                        "html"
                      ],
                      "description": "paragraph, list, heading (h4–h6), quote, code, image, table, divider, or html (anything else, kept as is)"
                    },
                    "text": {
                      "type": "string",
                      "description": "Plain text (list: one line per item; code: the code)"
                    },
                    "html": {
                      "type": "string",
                      "description": "The block as HTML"
                    },
                    "level": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "heading: 4 to 6; else null"
                    },
                    "ordered": {
                      "type": [
                        "boolean",
                        "null"
                      ],
                      "description": "list: true when numbered; else null"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "The item’s leading bold text (\"Name the owner\"), without a trailing colon; null when the item has none"
                          },
                          "text": {
                            "type": "string",
                            "description": "The item as plain text"
                          },
                          "html": {
                            "type": "string",
                            "description": "The item as HTML"
                          }
                        },
                        "required": [
                          "label",
                          "text",
                          "html"
                        ],
                        "description": "A list item"
                      },
                      "description": "list: its items; else []"
                    },
                    "imageId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "image: its id in images[]; else null"
                    },
                    "src": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "image: its src in the HTML; else null"
                    },
                    "alt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "image: its alt text; else null"
                    },
                    "language": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "code: its language when known; else null"
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "description": "table: the cells’ text, row by row, header row first; else []"
                    }
                  },
                  "required": [
                    "type",
                    "text",
                    "html",
                    "level",
                    "ordered",
                    "items",
                    "imageId",
                    "src",
                    "alt",
                    "language",
                    "rows"
                  ],
                  "description": "A block of a section; every block has every key (null or [] when it does not apply)"
                },
                "description": "The section, block by block"
              }
            },
            "required": [
              "index",
              "heading",
              "level",
              "anchor",
              "text",
              "html",
              "blocks"
            ],
            "description": "A part of the body, split at its h1–h3 headings"
          },
          "description": "The body split at its headings, each with its blocks"
        },
        "links": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "description": "Link text"
              },
              "url": {
                "type": "string",
                "description": "URL"
              }
            },
            "required": [
              "text",
              "url"
            ],
            "description": "A link"
          },
          "description": "Every link of the body, in order"
        },
        "callToAction": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "text": {
              "type": "string",
              "description": "Text"
            },
            "url": {
              "type": [
                "string",
                "null"
              ],
              "description": "URL"
            }
          },
          "required": [
            "text",
            "url"
          ],
          "description": "The call to action: the post’s own, else the last link of the last section; null when there is none"
        },
        "seo": {
          "type": "object",
          "properties": {
            "metaTitle": {
              "type": "string",
              "description": "Title for <title> (70 characters at most)"
            },
            "metaDescription": {
              "type": "string",
              "description": "Meta description (160 characters at most)"
            },
            "keywords": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Keywords"
            }
          },
          "required": [
            "metaTitle",
            "metaDescription",
            "keywords"
          ],
          "description": "Search details"
        },
        "social": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "platform": {
              "type": [
                "string",
                "null"
              ],
              "description": "linkedin, twitter, facebook, instagram, threads"
            },
            "hashtags": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Hashtags, with #"
            },
            "callToAction": {
              "type": [
                "string",
                "null"
              ],
              "description": "Call to action text"
            },
            "length": {
              "type": [
                "string",
                "null"
              ],
              "description": "short, medium or long"
            }
          },
          "required": [
            "platform",
            "hashtags",
            "callToAction",
            "length"
          ],
          "description": "Social posts; null for other content"
        },
        "email": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "subject": {
              "type": [
                "string",
                "null"
              ],
              "description": "Subject"
            },
            "recipient": {
              "type": [
                "string",
                "null"
              ],
              "description": "Recipient"
            }
          },
          "required": [
            "subject",
            "recipient"
          ],
          "description": "Emails; null for other content"
        },
        "slides": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "description": "Title"
              },
              "content": {
                "type": "string",
                "description": "Text"
              },
              "notes": {
                "type": "string",
                "description": "Speaker notes"
              },
              "imageUrl": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Download link of the slide image (also in images[], id \"slide-1\", \"slide-2\"…); null when it has none"
              }
            },
            "required": [
              "title",
              "content",
              "notes",
              "imageUrl"
            ],
            "description": "A slide"
          },
          "description": "Presentations: the slides; else []"
        },
        "metrics": {
          "type": "object",
          "properties": {
            "wordCount": {
              "type": "integer",
              "description": "Words"
            },
            "characterCount": {
              "type": "integer",
              "description": "Characters of the plain text"
            },
            "readingTimeMinutes": {
              "type": "integer",
              "description": "Reading time at 200 words a minute"
            },
            "sectionCount": {
              "type": "integer",
              "description": "Sections"
            },
            "imageCount": {
              "type": "integer",
              "description": "Images in images[]"
            }
          },
          "required": [
            "wordCount",
            "characterCount",
            "readingTimeMinutes",
            "sectionCount",
            "imageCount"
          ],
          "description": "Counts"
        },
        "fields": {
          "type": "object",
          "description": "Every other field of the record (research, ideas…); {} when the user left them out"
        }
      },
      "required": [
        "id",
        "type",
        "kind",
        "title",
        "headline",
        "slug",
        "subtitle",
        "excerpt",
        "tags",
        "topic",
        "tone",
        "audience",
        "source",
        "threadId",
        "createdAt",
        "updatedAt",
        "body",
        "sections",
        "links",
        "callToAction",
        "seo",
        "social",
        "email",
        "slides",
        "metrics",
        "fields"
      ],
      "description": "The content"
    },
    "featuredImageId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The id in images[] of the main image; null when there is none"
    },
    "images": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Its id: featured and gallery images \"linked-…\", the saved illustration \"illustration\", body images \"inline-1\", \"inline-2\"…, slide images \"slide-1\", \"slide-2\"…"
          },
          "role": {
            "type": "string",
            "enum": [
              "featured",
              "illustration",
              "gallery",
              "inline"
            ],
            "description": "featured (the main image), illustration, gallery, or inline (in the body)"
          },
          "alt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Alt text"
          },
          "caption": {
            "type": [
              "string",
              "null"
            ],
            "description": "Caption"
          },
          "originalSrc": {
            "type": [
              "string",
              "null"
            ],
            "description": "inline images: the src used in body.html and blocks, to replace with your own URL"
          },
          "filename": {
            "type": [
              "string",
              "null"
            ],
            "description": "A file name for it (\"my-post-featured-1.png\")"
          },
          "contentType": {
            "type": [
              "string",
              "null"
            ],
            "description": "image/png, image/jpeg, image/webp or image/gif"
          },
          "size": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Bytes"
          },
          "delivery": {
            "type": "string",
            "enum": [
              "file",
              "inline",
              "link",
              "unavailable"
            ],
            "description": "link: download it from url; file: url too, and the file comes next in its own request (content.image); inline: url too, and the bytes in data; unavailable: not sent (see note)"
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A download link, no sign-in needed (the app’s own images: valid 30 days); null when not sent"
          },
          "data": {
            "type": [
              "string",
              "null"
            ],
            "description": "inline: the image bytes in base64; else null"
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the image went another way or was not sent"
          }
        },
        "required": [
          "id",
          "role",
          "alt",
          "caption",
          "originalSrc",
          "filename",
          "contentType",
          "size",
          "delivery",
          "url",
          "data",
          "note"
        ],
        "description": "An image of the content"
      },
      "description": "Every image of the content"
    },
    "videos": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "format": {
            "type": "string",
            "description": "9:16, 1:1, 4:5 or 16:9"
          },
          "url": {
            "type": "string",
            "description": "Public download link of the MP4"
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Width in pixels"
          },
          "height": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Height in pixels"
          },
          "durationSeconds": {
            "type": [
              "number",
              "null"
            ],
            "description": "Length in seconds"
          },
          "sizeInBytes": {
            "type": [
              "integer",
              "null"
            ],
            "description": "File size"
          }
        },
        "required": [
          "format",
          "url",
          "width",
          "height",
          "durationSeconds",
          "sizeInBytes"
        ],
        "description": "A video"
      },
      "description": "Rendered videos (video ads); [] for other content"
    }
  },
  "required": [
    "event",
    "schemaVersion",
    "deliveryId",
    "sentAt",
    "status",
    "endpoint",
    "imageDelivery",
    "content",
    "featuredImageId",
    "images",
    "videos"
  ],
  "description": "The structured content cgenius sends to your endpoint (Content-Type: application/json)"
}

Publish through Buffer

The user connects their own Buffer account once (in the app, Settings → Integrations → Buffer, or with PUT /api/v1/connections/buffer and their Buffer personal API key). Then an agent can send posts. Ask the user before sending: publishing is visible outside the app. Scopes: publish:read (status, channels), publish:write (send), connections:manage (connect, disconnect).

  1. Check the connection and list the channels.
curl -sS "$CGENIUS_API_URL/api/v1/connections/buffer" -H "Authorization: Bearer $CGENIUS_API_TOKEN"
curl -sS "$CGENIUS_API_URL/api/v1/connections/buffer/channels" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  | jq '.channels[] | select(.usable) | {id, service, name: (.displayName // .name), notificationOnly}'

409 conflict means no Buffer account is connected: ask the user to connect one. notificationOnly channels (Instagram personal profiles, Facebook groups) get a reminder in the Buffer app and the user publishes by hand.

  1. Send. mode: addToQueue (next free slot), shareNow, customScheduled (with dueAt, at least a minute ahead and within a year) or draft. Give a channel its own text in versions, or a thread (X, Threads, Bluesky, Mastodon) as versions.<channelId>.thread; the first thread post must equal versions.<channelId>.text.
curl -sS -X POST "$CGENIUS_API_URL/api/v1/publish/buffer" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"text":"<LinkedIn post>","channelIds":["<linkedin channel id>","<x channel id>"],
       "mode":"customScheduled","dueAt":"2026-12-02T09:00:00+01:00",
       "imageUrl":"https://…/image.png","contentId":"<content id>",
       "versions":{"<x channel id>":{"text":"First post 1/2","thread":["First post 1/2","Second post 2/2"]}}}'
# {"results":[{"channelId":"…","ok":true,"postId":"…","status":"scheduled","dueAt":"…"},…],"recorded":true}

Each channel has its own result: report the ones with ok: false and their error; the others were sent. contentId records the posts on the content item. Instagram needs an image or a video: a post without one is refused for that channel (ok: false) before it reaches Buffer. Instagram and Facebook posts are a feed post by default, or a reel with a video; choose with versions.<channelId>.postType (post, reel or story). YouTube needs a video; the title comes from the first line of the text. Pinterest needs a board, which the API can't choose yet. imageUrl is a public https URL, or the s3:// path of one of the user's saved images (sent to Buffer as a 30-day download link). provider_limit_reached (429) means Buffer's rate limit: wait Retry-After. connection_needs_reauth means Buffer refused the stored key: ask the user to reconnect.

Keep a generated image

Images an agent generates in EpsimoAgents live at a temporary URL (about an hour). Copy one to ContentGenius storage to keep it. Scopes: media:write (import), media:read (read).

curl -sS -X POST "$CGENIUS_API_URL/api/v1/media/generated-images" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -d '{"url":"https://<EpsimoAgents host>/generated-images/<file>.png"}'
# 201 {"path":"s3://…/pdfFile/<user>/generated-images-….png","key":"pdfFile/…"}

curl -sS "$CGENIUS_API_URL/api/v1/media/images?path=s3://…/pdfFile/<user>/generated-images-….png" \
  -H "Authorization: Bearer $CGENIUS_API_TOKEN" -o image.png

Only URLs on the EpsimoAgents host under /generated-images/ are accepted (422 url_not_allowed otherwise). Store path on the content; read it back with media.images.get.

Read and change settings

Settings are per user: epsimoagents (publish module preferences: project, image agent, image style), integrations (publishing endpoints; their tokens are stored encrypted and returned decrypted to the owner) and ideation (lead ideas defaults: company, agent, mode, filters, focus). Scopes: settings:read, settings:write.

curl -sS "$CGENIUS_API_URL/api/v1/settings/ideation" -H "Authorization: Bearer $CGENIUS_API_TOKEN"
curl -sS -X PUT "$CGENIUS_API_URL/api/v1/settings/ideation" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -d '{"data":{"mode":"quick","ideaCount":6,"focus":"Cloud security for manufacturers"}}'

PUT replaces the whole setting: read it first and send it back with your change. Invalid fields answer 400 validation_failed with error.fields.

Cancel or resume a Job

curl -sS -X POST "$CGENIUS_API_URL/api/v1/jobs/<jobId>/cancel" -H "Authorization: Bearer $CGENIUS_API_TOKEN"
curl -sS -X POST "$CGENIUS_API_URL/api/v1/jobs/<jobId>/resume" -H "Authorization: Bearer $CGENIUS_API_TOKEN"

Manage tokens

Needs tokens:manage. A token can create a narrower child token (never with more Scopes than itself, and never with AI access); revoking a token revokes its children.

curl -sS "$CGENIUS_API_URL/api/v1/tokens" -H "Authorization: Bearer $CGENIUS_API_TOKEN"
curl -sS -X POST "$CGENIUS_API_URL/api/v1/tokens" -H "Authorization: Bearer $CGENIUS_API_TOKEN" \
  -H "Content-Type: application/json" -d '{"name":"read-only report bot","scopes":["content:read","jobs:read"]}'
curl -sS -X DELETE "$CGENIUS_API_URL/api/v1/tokens/<id>" -H "Authorization: Bearer $CGENIUS_API_TOKEN"
curl -sS "$CGENIUS_API_URL/api/v1/audit-events?limit=50" -H "Authorization: Bearer $CGENIUS_API_TOKEN"

CLI login

How a CLI or agent gets a token without the user copying one (a device-style flow):

  1. POST /api/v1/auth/cli-sessions (no auth) with {"scopes":[…],"aiAccess":true,"clientInfo":"my-agent/1.0"} answers {sessionId, userCode, pollSecret, approveUrl, expiresIn: 600, interval: 2}.
  2. Show the user userCode and ask them to open approveUrl. They sign in, compare the code, choose the Scopes and approve (with AI access, they sign in once more on the Cognito page).
  3. Every interval seconds, POST /api/v1/auth/cli-sessions/{sessionId}/exchange with {"pollSecret":"…"}: 202 while pending, then 200 {"token":"cg_…","tokenId":"…"} once. 410 session_expired means expired or denied: start again.
  4. Store the token where the user expects (for the CLI: its config file, readable only by the user). Never show pollSecret or the token.