Skip to content
Help · Websites and blogs

Connect your website to Posttai

Any website, not just WordPress. Posttai delivers the article through a signed webhook, or your site fetches it from the content API. This guide has the contract and ready-made examples. Field names stay in Portuguese, as the API sends them.

Choose how to connect

The rest of Posttai (editor, calendar, approval, AI and reports) works the same for all of them.

Posttai webhook

Websites with their own back end, in any language.

When it's time to publish, Posttai sends a signed POST with the article. Your site saves it and replies with the link.

Content API

Static sites, or Nuxt or Next with a build step.

Your site fetches the articles with a read key, or through the JSON and RSS feeds.

WordPress

WordPress.com or self-hosted WordPress.

WordPress.com login or an application password, no code at all.

Connect by webhook

  1. In the app, open Canais (Channels), choose Site and enter the https:// URL that will receive the articles.
  2. Posttai shows the signing secret (whsec_…) only once. Store it in an environment variable on your site, such as POSTTAI_SEGREDO.
  3. Deploy the code that receives the call (see the examples below) and click connect. Posttai sends a signed ping event and only saves the channel if the response is 2xx.

The URL must be public: https only, port 443 or 8443, no user in the URL and a name that resolves to a public IP. Internal or private addresses are refused.

What reaches your site

A POST with Content-Type: application/json and these headers:

  • x-posttai-evento: artigo.publicar or ping.
  • x-posttai-entrega: ent_…, the same across every attempt of the same publication. The same value comes signed in the body (entrega): use the one in the body so you don't save twice.
  • x-posttai-assinatura: t=UNIX,v1=HEX, with v1 = HMAC-SHA256(secret, "T.BODY") over the exact bytes of the body (T is the same number as t).

Body of artigo.publicar:

{
  "evento": "artigo.publicar",
  "entrega": "ent_3f9a0c1b2d4e5f60718293a4b5c6d7e8",
  "id": "6720f0c1a2b3c4d5e6f70809",
  "titulo": "Café coado: o guia",
  "slug": "cafe-coado-o-guia",
  "resumo": "Como coar café em casa.",
  "html": "<h2>Por que coar</h2>\n<p>…</p>",
  "markdown": "## Por que coar\n\n…",
  "imagens": [
    {
      "url": "https://cdn.posttai.com/…/capa.webp",
      "alt": "Xícara de café",
      "largura": 1200,
      "altura": 630
    }
  ],
  "categorias": [
    "Receitas"
  ],
  "tags": [
    "café"
  ],
  "seo": {
    "titulo": "Café coado: o guia",
    "descricao": "Como coar café em casa.",
    "palavraChave": "café coado"
  },
  "publicarEm": "2026-10-10T12:00:00.000Z",
  "idioma": "pt-BR",
  "marca": {
    "nome": "Sua marca"
  }
}
  • id is the post's id in Posttai (the same if the article is resent). marca carries only the name.
  • The html comes out escaped and safe; the markdown is sent as written.
  • The ping brings { evento: "ping", entrega, id, criadoEm, marca: { nome } }.

Response, errors and retries

  • Success: reply 2xx with { "url": "https://…" }. The link becomes the publication's address, goes into the report and goes to the networks when publishing together.
  • Permanent error: 4xx (except 408 and 429) stops immediately, with your message (erro, error or message) on the publication.
  • Retry: 5xx, 408, 429, timeouts or network drops go back to the queue after 1, 5, 15 and 60 minutes (5 attempts in total).
  • Redirects (3xx) are not followed. Each call has a 15-second timeout.
  • If it fails for good, the post is marked with an error and the app's bell lets you know.

Verifying the signature

  • Verify against the raw body, before parsing the JSON.
  • Accept only a v1 with 64 hexadecimal characters and compare in constant time.
  • Reject a t more than 5 minutes off your clock.
  • Rotating the secret without downtime: when you generate a new secret, for 24 hours the header carries two v1 values (the new and the previous one). Accept the call if any v1 matches POSTTAI_SEGREDO or POSTTAI_SEGREDO_ANTERIOR; after that, delete the previous one.

Ready-made examples

The same ones shown on the channel screen in the app. All of them verify the signature, return 400 for invalid requests and 5xx when saving fails (Posttai retries), and save only once per entrega.

Node (Express)
// Node + Express: npm i express
import express from 'express'
import crypto from 'node:crypto'

const app = express()
// Segredos aceitos: o atual e, durante a troca, o anterior. Sempre em variável de ambiente.
const SEGREDOS = [process.env.POSTTAI_SEGREDO, process.env.POSTTAI_SEGREDO_ANTERIOR].filter(Boolean)
const HEX64 = /^[0-9a-f]{64}$/

// corpo: Buffer com os bytes exatos; cabecalho: "t=<unix>,v1=<hex>[,v1=<hex>]".
function assinaturaValida (corpo, cabecalho, segredos = SEGREDOS) {
  const partes = String(cabecalho || '').split(',').map(p => p.trim())
  const tTexto = partes.find(p => p.startsWith('t='))?.slice(2) || ''
  const t = /^\d{1,12}$/.test(tTexto) ? Number(tTexto) : 0
  // Só v1 com 64 caracteres hex; o resto é descartado ANTES de comparar (bytes com bytes, 32 e 32).
  const recebidas = partes.filter(p => p.startsWith('v1=')).map(p => p.slice(3)).filter(v => HEX64.test(v)).map(v => Buffer.from(v, 'hex'))
  if (!t || !recebidas.length || Math.abs(Date.now() / 1000 - t) > 300) return false // janela de 5 min
  return segredos.some(segredo => {
    const esperada = crypto.createHmac('sha256', segredo).update(`${t}.`).update(corpo).digest()
    return recebidas.some(r => crypto.timingSafeEqual(r, esperada))
  })
}

// express.raw: a assinatura é sobre os bytes exatos do corpo (nada de express.json antes desta rota).
app.post('/api/posttai', express.raw({ type: 'application/json', limit: '2mb' }), async (req, res) => {
  let dados
  try {
    const corpo = Buffer.isBuffer(req.body) ? req.body : Buffer.alloc(0)
    if (!assinaturaValida(corpo, req.get('x-posttai-assinatura'))) return res.status(401).json({ erro: 'Assinatura inválida' })
    dados = JSON.parse(corpo.toString('utf8'))
  } catch {
    return res.status(400).json({ erro: 'Pedido inválido' })
  }
  if (dados?.evento === 'ping') return res.json({ ok: true })
  if (dados?.evento !== 'artigo.publicar' || typeof dados.entrega !== 'string') return res.status(400).json({ erro: 'Evento desconhecido' })
  try {
    // dados.entrega vem DENTRO do corpo assinado e se repete nas novas tentativas:
    // grave o artigo uma vez só por entrega (ex.: índice único na sua tabela).
    const url = await salvarArtigo(dados.entrega, dados) // sua função: devolve o link do artigo
    return res.json({ url })
  } catch {
    return res.status(500).json({ erro: 'Falha ao gravar' }) // 5xx: a Posttai tenta de novo
  }
})

app.listen(3000)
Nuxt (server route)
// Nuxt 3: server/api/posttai.post.ts
import crypto from 'node:crypto'

const HEX64 = /^[0-9a-f]{64}$/

function assinaturaValida (corpo: Buffer, cabecalho: string, segredos: string[]) {
  const partes = cabecalho.split(',').map(p => p.trim())
  const tTexto = partes.find(p => p.startsWith('t='))?.slice(2) || ''
  const t = /^\d{1,12}$/.test(tTexto) ? Number(tTexto) : 0
  // Só v1 com 64 caracteres hex; o resto é descartado ANTES de comparar.
  const recebidas = partes.filter(p => p.startsWith('v1=')).map(p => p.slice(3)).filter(v => HEX64.test(v)).map(v => Buffer.from(v, 'hex'))
  if (!t || !recebidas.length || Math.abs(Date.now() / 1000 - t) > 300) return false
  return segredos.some(segredo => {
    const esperada = crypto.createHmac('sha256', segredo).update(`${t}.`).update(corpo).digest()
    return recebidas.some(r => crypto.timingSafeEqual(r, esperada))
  })
}

export default defineEventHandler(async (event) => {
  const segredos = [process.env.POSTTAI_SEGREDO, process.env.POSTTAI_SEGREDO_ANTERIOR].filter(Boolean) as string[]
  let dados: any
  try {
    const corpo = (await readRawBody(event, false)) || Buffer.alloc(0) // bytes exatos
    if (!assinaturaValida(corpo, getHeader(event, 'x-posttai-assinatura') || '', segredos)) {
      setResponseStatus(event, 401)
      return { erro: 'Assinatura inválida' }
    }
    dados = JSON.parse(corpo.toString('utf8'))
  } catch {
    setResponseStatus(event, 400)
    return { erro: 'Pedido inválido' }
  }
  if (dados?.evento === 'ping') return { ok: true }
  if (dados?.evento !== 'artigo.publicar' || typeof dados.entrega !== 'string') {
    setResponseStatus(event, 400)
    return { erro: 'Evento desconhecido' }
  }
  // dados.entrega vem no corpo assinado e se repete nas novas tentativas: grave uma vez só por entrega.
  const url = await salvarArtigo(dados.entrega, dados) // sua função; se lançar, o Nuxt responde 500 e a Posttai tenta de novo
  return { url }
})
Next (route handler)
// Next.js (App Router): app/api/posttai/route.ts
import crypto from 'node:crypto'

export const runtime = 'nodejs' // node:crypto

const SEGREDOS = [process.env.POSTTAI_SEGREDO, process.env.POSTTAI_SEGREDO_ANTERIOR].filter(Boolean) as string[]
const HEX64 = /^[0-9a-f]{64}$/

function assinaturaValida (corpo: Buffer, cabecalho: string) {
  const partes = cabecalho.split(',').map(p => p.trim())
  const tTexto = partes.find(p => p.startsWith('t='))?.slice(2) || ''
  const t = /^\d{1,12}$/.test(tTexto) ? Number(tTexto) : 0
  // Só v1 com 64 caracteres hex; o resto é descartado ANTES de comparar.
  const recebidas = partes.filter(p => p.startsWith('v1=')).map(p => p.slice(3)).filter(v => HEX64.test(v)).map(v => Buffer.from(v, 'hex'))
  if (!t || !recebidas.length || Math.abs(Date.now() / 1000 - t) > 300) return false
  return SEGREDOS.some(segredo => {
    const esperada = crypto.createHmac('sha256', segredo).update(`${t}.`).update(corpo).digest()
    return recebidas.some(r => crypto.timingSafeEqual(r, esperada))
  })
}

export async function POST (req: Request) {
  let dados: any
  try {
    const corpo = Buffer.from(await req.arrayBuffer()) // bytes exatos, antes de qualquer JSON.parse
    if (!assinaturaValida(corpo, req.headers.get('x-posttai-assinatura') || '')) {
      return Response.json({ erro: 'Assinatura inválida' }, { status: 401 })
    }
    dados = JSON.parse(corpo.toString('utf8'))
  } catch {
    return Response.json({ erro: 'Pedido inválido' }, { status: 400 })
  }
  if (dados?.evento === 'ping') return Response.json({ ok: true })
  if (dados?.evento !== 'artigo.publicar' || typeof dados.entrega !== 'string') {
    return Response.json({ erro: 'Evento desconhecido' }, { status: 400 })
  }
  // dados.entrega vem no corpo assinado e se repete nas novas tentativas: grave uma vez só por entrega.
  const url = await salvarArtigo(dados.entrega, dados) // sua função; se lançar, o Next responde 500 e a Posttai tenta de novo
  return Response.json({ url })
}
PHP
<?php
// PHP 7.4+: posttai.php
header('Content-Type: application/json');

function assinatura_valida(string $corpo, string $cabecalho, array $segredos): bool
{
    $t = 0;
    $recebidas = [];
    foreach (explode(',', $cabecalho) as $parte) {
        $par = explode('=', trim($parte), 2);
        if (count($par) !== 2) continue;
        [$chave, $valor] = $par;
        if ($chave === 't' && preg_match('/^[0-9]{1,12}\z/', $valor) === 1) $t = (int) $valor;
        // Só v1 com 64 caracteres hex; o resto é descartado antes de comparar.
        if ($chave === 'v1' && preg_match('/^[0-9a-f]{64}\z/', $valor) === 1) $recebidas[] = $valor;
    }
    if ($t === 0 || count($recebidas) === 0 || abs(time() - $t) > 300) return false;
    foreach ($segredos as $segredo) {
        $esperada = hash_hmac('sha256', $t . '.' . $corpo, $segredo);
        foreach ($recebidas as $r) {
            if (hash_equals($esperada, $r)) return true;
        }
    }
    return false;
}

try {
    $corpo = file_get_contents('php://input'); // bytes exatos
    $segredos = array_filter([getenv('POSTTAI_SEGREDO'), getenv('POSTTAI_SEGREDO_ANTERIOR')]);
    if (!is_string($corpo) || !assinatura_valida($corpo, (string) ($_SERVER['HTTP_X_POSTTAI_ASSINATURA'] ?? ''), $segredos)) {
        http_response_code(401);
        echo json_encode(['erro' => 'Assinatura inválida']);
        exit;
    }
    $dados = json_decode($corpo, true, 64, JSON_THROW_ON_ERROR);
} catch (\Throwable $e) {
    http_response_code(400);
    echo json_encode(['erro' => 'Pedido inválido']);
    exit;
}

$evento = is_array($dados) ? ($dados['evento'] ?? '') : '';
if ($evento === 'ping') {
    echo json_encode(['ok' => true]);
    exit;
}
if ($evento !== 'artigo.publicar' || !is_string($dados['entrega'] ?? null)) {
    http_response_code(400);
    echo json_encode(['erro' => 'Evento desconhecido']);
    exit;
}

// $dados['entrega'] vem no corpo assinado e se repete nas novas tentativas: grave uma vez só por entrega.
$url = salvar_artigo($dados['entrega'], $dados); // sua função: devolve o link (se falhar, responda 500)
echo json_encode(['url' => $url]);
Python (Flask)
# Python 3 + Flask: pip install flask
import hashlib
import hmac
import json
import os
import re
import time

from flask import Flask, jsonify, request

app = Flask(__name__)
SEGREDOS = [s for s in (os.environ.get('POSTTAI_SEGREDO'), os.environ.get('POSTTAI_SEGREDO_ANTERIOR')) if s]
HEX64 = re.compile(r'[0-9a-f]{64}')
NUMERO = re.compile(r'[0-9]{1,12}')


def assinatura_valida(corpo: bytes, cabecalho: str) -> bool:
    partes = [p.strip() for p in (cabecalho or '').split(',')]
    t_texto = next((p[2:] for p in partes if p.startswith('t=')), '')
    t = int(t_texto) if NUMERO.fullmatch(t_texto) else 0
    # Só v1 com 64 caracteres hex; o resto é descartado antes de comparar (bytes com bytes).
    recebidas = [bytes.fromhex(p[3:]) for p in partes if p.startswith('v1=') and HEX64.fullmatch(p[3:])]
    if not t or not recebidas or abs(time.time() - t) > 300:
        return False
    for segredo in SEGREDOS:
        esperada = hmac.new(segredo.encode(), f'{t}.'.encode() + corpo, hashlib.sha256).digest()
        if any(hmac.compare_digest(esperada, r) for r in recebidas):
            return True
    return False


@app.post('/api/posttai')
def posttai():
    try:
        corpo = request.get_data(cache=False)  # bytes exatos
        if not assinatura_valida(corpo, request.headers.get('x-posttai-assinatura', '')):
            return jsonify(erro='Assinatura inválida'), 401
        dados = json.loads(corpo)
    except Exception:
        return jsonify(erro='Pedido inválido'), 400
    if not isinstance(dados, dict):
        return jsonify(erro='Pedido inválido'), 400
    if dados.get('evento') == 'ping':
        return jsonify(ok=True)
    if dados.get('evento') != 'artigo.publicar' or not isinstance(dados.get('entrega'), str):
        return jsonify(erro='Evento desconhecido'), 400
    # dados['entrega'] vem no corpo assinado e se repete nas novas tentativas: grave uma vez só por entrega.
    url = salvar_artigo(dados['entrega'], dados)  # sua função: devolve o link (se lançar, o Flask responde 500)
    return jsonify(url=url)

Content API and feeds

For static or built sites: create a read key (pts_…) on the channel screen and send it in the Authorization: Bearer header. The key reads only that channel's articles (Profissional / Agência plans).

  • GET /v1/sites/:idCanal/artigos?pagina=1&porPagina=20&desde=… lists published articles, newest first (up to 100 per page).
  • GET /v1/sites/:idCanal/artigos/:slug returns one article.
  • GET /v1/sites/:idCanal/feed.json and /rss.xml are the public feeds, if enabled on the channel.
  • Every response has an ETag and answers 304 to If-None-Match; 60-second cache.
  • Limits: 120 reads per minute per key and 300 per IP.
  • The key is for the server or the site's build only. Never in code that ships to the browser; to read directly in the browser, use the feeds.
curl https://api.posttai.com/v1/sites/ID_DO_CANAL/artigos \
  -H "Authorization: Bearer $POSTTAI_CHAVE_SITE"

Deploy hook: enter your deploy hook URL (Vercel, Netlify, DigitalOcean, Cloudflare) and, after each published article, Posttai calls it so your site rebuilds.

Publish together

In the editor, check Publicar o artigo no site e as redes com o link (publish the article on the site and the networks with the link). The article goes out first; the networks get the text with the article's link, with UTM and through the Posttai shortener, so you can see each network's clicks. If the site is slow, the networks wait up to 30 minutes (or go out without the link, if you prefer).

AI also writes the article from the post or carousel, with title, summary, slug and SEO.

Start today

Put your website on the calendar

Create your account, connect your site and your networks, and publish it all together.

  • 7 days free
  • No card needed to try
  • Unlimited posts on every plan
Talk to us