Developer guide: receiving articles from Shareative
You've been sent this guide because a client (or your company) uses Shareative to write blog articles, and their website is custom-built. The task: a receiving address (endpoint) on the website that accepts the finished article, saves it to the database, and the site displays it from there. For an experienced developer this is about one or two hours.
1. How it works
- You write the receiving endpoint (e.g. https://example.com/shareative-receiver) and give its address to the client.
- The client enters the address in Shareative; a signing key appears there – they send it to you.
- For every finished article, Shareative sends a signed POST request to your endpoint with a JSON body. The image is included too (base64).
- You check the signature, save the article and the image, and return the article's public address.
- The “Send test” button in Shareative sends a sample article – so you can test right away.
2. The request
POST · Content-Type: application/json · we only send to HTTPS addresses (with a valid certificate) · timeout: 30 s
| Header | Meaning |
|---|---|
X-Shareative-Event | test · article.published · article.updated |
X-Shareative-Timestamp | time of sending, Unix seconds |
X-Shareative-Signature | sha256= + hex HMAC-SHA256 with the signing key, over this string: <timestamp>.<raw body> |
Important: compute the signature over the raw (unparsed) body, and reject (401) requests with a wrong signature or older than 5 minutes. Keep the signing key secret (e.g. in an environment variable), not in the code.
3. The body (JSON)
{
"event": "article.published",
"test": false,
"id": "3f1c2a9e-7b4d-4c1e-9a52-0d6e8b7f1a23",
"externalId": null,
"title": "Hogyan válassz futócipőt kezdőként?",
"slug": "hogyan-valassz-futocipot-kezdokent",
"excerpt": "Rövid összefoglaló a cikkről…",
"html": "<h2>Első lépés</h2><p>…</p>",
"markdown": "## Első lépés\n\n…",
"metaTitle": "Futócipő kezdőknek – így válassz jól",
"metaDescription": "Mire figyelj futócipő-vásárláskor…",
"focusKeyword": "futócipő kezdőknek",
"tags": ["futócipő kezdőknek"],
"locale": "hu",
"status": "publish",
"image": {
"filename": "hogyan-valassz-futocipot-kezdokent.webp",
"mime": "image/webp",
"alt": "Futócipők egy polcon",
"base64": "UklGRl…"
},
"sentAt": "2026-11-23T09:00:00.000Z"
}| Field | Meaning |
|---|---|
id | the article's permanent Shareative id – UPDATE by this (the same article may come again later, corrected) |
externalId | on update, the id you returned earlier (null on the first send) |
html | the article body as HTML, WITHOUT the title (that's in title) – h2/h3, p, ul/ol, a, strong, em, blockquote, table |
markdown | the same in Markdown, if you'd rather use that |
metaTitle / metaDescription / focusKeyword | SEO data for <title> and meta description (may be empty depending on the plan) |
status | publish = show it now; draft = save it but don't show it yet |
image | null, or the image: filename, MIME type, alt text and the file in base64. Save it on YOUR server – Shareative deletes its own copy after a while. |
test | true for the “Send test” button – just reply 200, don't save anything |
4. The response
- On success: HTTP 2xx and (optional but recommended) JSON:
{ "id": "…", "url": "https://…/blog/…" } - The url becomes the article's public address in Shareative – the Facebook post links to it, for example. You get the id back as externalId on updates.
- On error (4xx/5xx) Shareative doesn't retry on its own: the client sees an error message and can send the article again.
- The request body including the image can be 10–15 MB – set your server's upload limit to at least 20 MB (PHP: post_max_size).
5. Sample code – PHP
A single file, no framework (with MySQL). Adapt the database part to your own table.
<?php
// shareative-receiver.php – receives articles from Shareative
$key = getenv('SHAREATIVE_SIGNING_KEY'); // the signing key shown on the Shareative card
$body = file_get_contents('php://input');
$ts = $_SERVER['HTTP_X_SHAREATIVE_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_SHAREATIVE_SIGNATURE'] ?? '';
// 1. Signature + freshness check (reject anything older than 5 minutes)
$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, $key);
if (!hash_equals($expected, $sig) || abs(time() - (int) $ts) > 300) {
http_response_code(401);
exit;
}
$a = json_decode($body, true);
header('Content-Type: application/json');
// 2. "Send test" button: just answer, don't save anything
if ($a['event'] === 'test') {
echo '{"ok":true}';
exit;
}
// 3. Save the image on YOUR server (Shareative deletes its copy after a while)
$image = null;
if (!empty($a['image'])) {
$name = preg_replace('/[^A-Za-z0-9._-]/', '', $a['image']['filename']);
file_put_contents(__DIR__ . '/uploads/' . $name, base64_decode($a['image']['base64']));
$image = '/uploads/' . $name;
}
// 4. Insert or update the article, keyed by the Shareative id
$pdo = new PDO('mysql:host=localhost;dbname=mysite;charset=utf8mb4', 'user', 'password');
$st = $pdo->prepare(
'INSERT INTO articles (shareative_id, title, slug, html, excerpt, meta_title, meta_description, image, image_alt, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE title = VALUES(title), slug = VALUES(slug), html = VALUES(html), excerpt = VALUES(excerpt),
meta_title = VALUES(meta_title), meta_description = VALUES(meta_description),
image = COALESCE(VALUES(image), image), image_alt = VALUES(image_alt), status = VALUES(status)'
);
$st->execute([$a['id'], $a['title'], $a['slug'], $a['html'], $a['excerpt'], $a['metaTitle'],
$a['metaDescription'], $image, $a['image']['alt'] ?? null, $a['status']]);
// 5. Reply with the article's public address (Shareative links to it, e.g. from the Facebook post)
echo json_encode(['id' => $a['id'], 'url' => 'https://example.com/blog/' . $a['slug']]);6. Sample code – Node.js
With Express. saveArticle is your own database code.
// shareative-receiver.js – receives articles from Shareative (Node.js + Express)
import express from "express";
import crypto from "node:crypto";
import fs from "node:fs/promises";
const app = express();
const KEY = process.env.SHAREATIVE_SIGNING_KEY; // the signing key shown on the Shareative card
// raw body: the signature is computed on the exact bytes we send
app.post("/shareative-receiver", express.raw({ type: "application/json", limit: "20mb" }), async (req, res) => {
const body = req.body.toString("utf8");
const ts = req.get("X-Shareative-Timestamp") ?? "";
const sig = req.get("X-Shareative-Signature") ?? "";
// 1. Signature + freshness check (reject anything older than 5 minutes)
const expected = "sha256=" + crypto.createHmac("sha256", KEY).update(`${ts}.${body}`).digest("hex");
const valid = sig.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
if (!valid || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return res.sendStatus(401);
const a = JSON.parse(body);
// 2. "Send test" button: just answer, don't save anything
if (a.event === "test") return res.json({ ok: true });
// 3. Save the image on YOUR server (Shareative deletes its copy after a while)
let image = null;
if (a.image) {
const name = a.image.filename.replace(/[^\w.-]/g, "");
await fs.writeFile(`./public/uploads/${name}`, Buffer.from(a.image.base64, "base64"));
image = `/uploads/${name}`;
}
// 4. Insert or update the article, keyed by the Shareative id (your own database code)
await saveArticle({
shareativeId: a.id, title: a.title, slug: a.slug, html: a.html, excerpt: a.excerpt,
metaTitle: a.metaTitle, metaDescription: a.metaDescription, image, imageAlt: a.image?.alt, status: a.status,
});
// 5. Reply with the article's public address (Shareative links to it, e.g. from the Facebook post)
res.json({ id: a.id, url: `https://example.com/blog/${a.slug}` });
});
app.listen(3000);7. Testing
- The client presses “Send test” in Shareative (Brand › Website) – your endpoint receives a test event with a sample article.
- If you reply 2xx, the client sees “the connection works”. If not, they see the error code (e.g. 401 = signature) and an explanation.
- After that, it's worth trying with a real article as a draft (status: draft).
8. If it doesn't work
| What the client sees | Cause and fix |
|---|---|
| “rejected the request (signature)” – 401/403 | You're not using the signing key shown on the card, you sign the parsed (not raw) body, or the server clock is off by more than 5 minutes (enable NTP). |
| “the receiving address doesn't exist” – 404 | Typo in the address, or the endpoint only accepts GET – it must accept POST. |
| “returned an error (413)” | Upload limit too low – make it at least 20 MB (PHP: post_max_size, nginx: client_max_body_size). |
| “returned an error (500)” | Error in the receiving code – check the server's error log. |
| “can't be reached” | The server doesn't answer within 30 s, or the HTTPS certificate is invalid. |