API Dokümantasyonu

Panelin yapabildiği her şey API'den de yapılabilir: site bağla, plan çıkar, makale üret, düzenle, yayınla, WP yönet. Kendi altyapına içerik beslemek için webhook veya çekme (pull) kullan.

Hızlı başlangıç

# 1) Panel → Hesap → API erişimi → token oluştur (fbk_...)
# 2) Tüm istekler:
curl https://app.fatbotter.com/api/autopilot/articles \
  -H "Authorization: Bearer fbk_xxxxxxxx"

# Tek konuyu üretip yayınlat:
curl -X POST https://app.fatbotter.com/api/autopilot/items/ITEM_ID/run \
  -H "Authorization: Bearer fbk_xxxxxxxx"

Temel adres: https://app.fatbotter.com/api · Tüm gövdeler JSON (Content-Type: application/json), yalnızca /uploads multipart kabul eder. Hatalar: { "message": "...", "statusCode": 4xx } · 402 = kredi yetersiz, 403 = BYOK kota/lisans.

Kimlik doğrulama

Panel → Hesap → "API erişimi" bölümünden kişisel token oluştur (fbk_...). Token oluşturma anında bir kez gösterilir. Her isteğe şu başlığı ekle: Authorization: Bearer fbk_xxx

GET/auth/me

Hesap bilgisi ve bakiye

Yanıt

{ "id": "...", "email": "...", "billingMode": "CREDITS", "creditBalance": "481.19" }

Siteler

GET/sites

Bağlı siteleri listele

Yanıt

[{ "id": "site_id", "url": "https://...", "platform": "wordpress", "status": "CONNECTED" }]
POST/sites

WordPress sitesi bağla (bağlantı anında doğrulanır)

İstek gövdesi

{ "url": "https://siteniz.com", "wpUsername": "admin", "wpAppPassword": "xxxx xxxx xxxx xxxx", "businessContext": "Antalya'da kamp ve bungalov tesisi..." }

💡 wpAppPassword: WP panelinde Kullanıcılar → Profil → Uygulama Şifreleri bölümünden alınır.

POST/platforms/xenforo/connect

XenForo forumu bağla

İstek gövdesi

{ "url": "https://forum.siteniz.com", "apiKey": "XF-Api-Key değeri", "forumUserId": 1, "businessContext": "..." }

Yanıt

{ "id": "site_id", "forums": [{ "id": 5, "title": "Genel" }] }

💡 Dönen forums listesinden hedef forumu POST /platforms/xenforo/{siteId}/node ile ({ "nodeId": 5 }) kaydet.

POST/platforms/custom/connect

Özel altyapı bağla (webhook + API ile çekme)

İstek gövdesi

{ "url": "https://siteniz.com", "webhookUrl": "https://siteniz.com/fatbotter-hook", "businessContext": "..." }

Yanıt

{ "id": "site_id", "webhookSecret": "fbs_..." }

💡 webhookSecret bir kez gösterilir. Makale yayınlandığında webhookUrl adresine imzalı JSON POST edilir.

💡 İmza doğrulama: X-FatBotter-Signature başlığı = HMAC-SHA256(ham istek gövdesi, webhookSecret) hex.

💡 webhookUrl vermezsen makaleleri GET /autopilot/articles ile çekersin.

POST/sites/{siteId}/sync

WP sitesindeki mevcut tüm yazıları envantere tara

Yanıt

{ "synced": 42 }
GET/sites/{siteId}/posts

Taranan içerik envanteri (kelime sayısı, iyileştirme durumu)

POST/sites/posts/{postId}/improve

Eski yazıya AI iyileştirme önerisi üret (kredi düşer, 1-3 dk)

POST/sites/posts/{postId}/apply

Onaylanan iyileştirmeyi WP'deki yazıya uygula

POST/sites/{siteId}/chat

Site ajanıyla konuş

İstek gövdesi

{ "message": "Bu ay hangi konulara odaklanalım?" }

Yanıt

{ "reply": "...", "briefUpdated": true }

Otopilot — plan ve üretim

POST/autopilot/plans

Gerçek Keyword Planner verisiyle içerik planı çıkar (1-2 dk sürer)

İstek gövdesi

{ "siteId": "site_id", "articleCount": 20, "cadencePerWeek": 2 }

Yanıt

{ "id": "plan_id", "status": "DRAFT", "items": [{ "id": "item_id", "title": "...", "targetKeyword": "...", "monthlyVolume": 480, "competition": "LOW" }] }
GET/autopilot/plans

Planları listele

GET/autopilot/plans/{planId}

Plan detayı (konular + durumlar + makale linkleri)

POST/autopilot/plans/{planId}/approve

Planı onayla — Otopilot takvime göre üretmeye başlar

POST/autopilot/plans/{planId}/pause

Otopilotu duraklat

POST/autopilot/items/{itemId}/run

Tek konuyu HEMEN uçtan uca işlet: üret + görsel doğrula + yayınla (2-5 dk)

Yanıt

{ "articleId": "...", "url": "https://siteniz.com/yazi-slug/" }
GET/autopilot/report

30 günlük özet + günlük seri (üretilen, yayınlanan, kredi)

Makaleler

GET/autopilot/articles

Tüm makaleleri listele (durum, yayın URL'si dahil)

GET/autopilot/articles/{articleId}

Makale detayı: tam HTML, SEO alanları, görseller, üretim maliyeti

PATCH/autopilot/articles/{articleId}

Makaleyi düzenle — yayındaysa hedef platformda da güncellenir

İstek gövdesi

{ "title": "...", "html": "<h2>...</h2>", "seoTitle": "50-70 karakter", "seoDesc": "150-160 karakter" }

Yanıt

{ ..., "wpUpdated": true }

Dosya yükleme ve medya

Makale içi görseller için: önce yükle, dönen URL'yi HTML'de <img src> olarak kullan. Editördeki "Görsel yükle" butonu da bu ucu kullanır.

POST/uploads

Görsel yükle (multipart/form-data, alan adı: file, max 15 MB). Otomatik webp'ye çevrilir (max 1600px).

Yanıt

{ "url": "/api/media/uploads/1753...abc.webp", "fileName": "...", "bytes": 84210 }

💡 curl örneği: curl -X POST https://app.fatbotter.com/api/uploads -H "Authorization: Bearer fbk_xxx" -F "[email protected]"

GET/media/{yol}

Yüklenen görselleri servis eder (herkese açık, 1 yıl cache).

WordPress yönetimi

Bağlı WP sitesinin tüm yönetimi (canlı proxy — veriler WP'den anlık okunur/yazılır).

GET/sites/{siteId}/wp/categories

Kategoriler · POST ile yeni ekle: { "name": "..." }

GET/sites/{siteId}/wp/tags

Etiketler · POST ile yeni ekle

GET/sites/{siteId}/wp/comments?status=hold

Yorumlar (hold | approved | spam)

POST/sites/{siteId}/wp/comments/{commentId}

Yorum moderasyonu

İstek gövdesi

{ "status": "approved" }  // approved | hold | spam | trash
GET/sites/{siteId}/wp/pages

Sayfalar · POST ile oluştur: { "title", "content", "status" }

GET/sites/{siteId}/wp/media

Medya kütüphanesi · DELETE /media/{id} ile sil

GET/sites/{siteId}/wp/settings

Site ayarları · POST ile güncelle: { "title", "description" }

Krediler ve faturalama

GET/billing/balance

Bakiye + plan (CREDITS / BYOK_MONTHLY / BYOK_YEARLY) + BYOK kotası

GET/billing/packages

Paket fiyatları — BYOK aylık/yıllık + makale başı model fiyatları

GET/billing/transactions

Kredi hareketleri (son 100)

POST/billing/topup

Kredi yükleme — PayTR ödeme token'ı döner

İstek gövdesi

{ "amountTry": 500 }
POST/billing/license

BYOK paketi satın al — PayTR ödeme token'ı döner

İstek gövdesi

{ "kind": "BYOK_MONTHLY" }  // BYOK_MONTHLY | BYOK_YEARLY
GET/tokens

API token'larını listele · POST { "name": "..." } ile oluştur · DELETE /tokens/{id} ile iptal et

Webhook formatı (Özel platform)

Makale yayınlandığında webhook adresine POST edilir. İmzayı mutlaka doğrula:

// Gelen istek
POST https://siteniz.com/fatbotter-hook
X-FatBotter-Signature: 3f2a... (HMAC-SHA256 hex)

{
  "event": "article.published",
  "article": {
    "id": "...", "title": "...", "slug": "...",
    "html": "<h2>...</h2>...",
    "seoTitle": "...", "seoDesc": "...", "excerpt": "...", "tags": "a, b, c",
    "heroImage": { "fileName": "slug.webp", "alt": "...", "base64": "..." }
  }
}

// Node.js doğrulama örneği
const crypto = require('crypto');
const expected = crypto.createHmac('sha256', WEBHOOK_SECRET)
  .update(rawBody).digest('hex');
if (expected !== req.headers['x-fatbotter-signature']) return res.status(401).end();