AjansOps API

REST API referansı. Tüm endpoint'ler JSON kabul eder ve JSON döndürür. Base URL:

https://app.ajansops.com/api

Kimlik Doğrulama

Şu an API session-based auth kullanıyor (cookie tabanlı NextAuth). Tarayıcı dışından erişim için bearer token / API key sistemi geliştirme aşamasında — Pro+ plan kullanıcıları için iletişime geç.

Tüm protected endpoint'ler 401 döner eğer session yoksa:

{ "error": "Unauthorized" }

Hata Kodları

KodAnlam
401Giriş yok
403Rol yetersiz (RBAC)
404Kaynak yok
409Çakışma (unique)
429Rate limit (Retry-After header)
503Servis yapılandırılmadı (Stripe, SMTP vb.)

Rate Limits

  • POST /api/users/invite — 10/saat per admin
  • GET /api/account/export — 3/saat per user
  • POST /api/leads/scrape, /api/seo/scrape — plan bazlı aylık limit
  • POST /api/emails/send — plan bazlı aylık limit

Aşıldığında: HTTP 429 + Retry-After header (saniye cinsinden)

Sites

GET/api/sitesVIEWER
POST/api/sitesEDITOR
PATCH/api/sites/:idEDITOR
DELETE/api/sites/:idADMIN
# Site oluştur
curl -X POST https://app.ajansops.com/api/sites \
  -H "Cookie: authjs.session-token=..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Örnek Site",
    "domain": "example.com",
    "techStack": "nextjs",
    "apifyKeywords": ["seo keyword"],
    "leadSearchTerms": ["istanbul restoran"]
  }'

Content

POST/api/content/bulkEDITOR
PUT/api/content/:siteId/:postIdEDITOR
DELETE/api/content/:siteId/:postIdEDITOR
# Toplu publish
curl -X POST /api/content/bulk \
  -d '{
    "action": "publish",
    "items": [{ "siteId": "...", "postId": "..." }]
  }'

Leads & Scrape

POST/api/leads/scrapeEDITOR
GET/api/leads/scrapeVIEWER

Yanıt (status check):

{
  "success": true,
  "data": {
    "running": false,
    "lastScrapedAt": "2026-04-24T03:15:00Z",
    "totalLeads": 280,
    "lastRun": { "action": "scrape.lead.success", "at": "..." }
  }
}

Agents

POST/api/agents/:id/runEDITOR

Emails

POST/api/emails/sendEDITOR
{
  "to": "musteri@firma.com",
  "subject": "Teklif",
  "html": "<p>Merhaba...</p>",
  "templateId": "optional-template-cuid"
}

Email Webhooks

Resend uyumlu. Resend Dashboard → Webhooks → /api/webhooks/email

Desteklenen event'ler:

  • email.delivered → status SENT
  • email.bounced → status BOUNCED + usage refund
  • email.opened → openedAt işaretlenir
  • email.clicked → clickedAt işaretlenir
  • email.complained → status BOUNCED

Güvenlik: x-webhook-secret header ile shared secret (env: EMAIL_WEBHOOK_SECRET)

Billing Webhooks

Stripe Dashboard → Webhooks → /api/billing/webhook. Signing secret: STRIPE_WEBHOOK_SECRET env değişkeni.

Dinlenilen event'ler:

  • checkout.session.completed → Subscription oluştur/aktif
  • customer.subscription.updated/deleted → status senkronu
  • invoice.payment_failed → PAST_DUE + notification

Health Check

GET/api/healthpublic
{
  "status": "healthy",
  "checks": {
    "postgres": { "ok": true, "latencyMs": 1 },
    "ollama": { "ok": true, "latencyMs": 2 }
  }
}

200 OK = healthy, 503 = degraded. UptimeRobot/Pingdom uyumlu.

Veri Export

GET/api/account/exportany-user

Kullanıcının tüm verilerini JSON olarak indirir (KVKK md. 11 + GDPR Art. 20 uyumlu).

Rate limit: 3 request/saat.


Yardıma mı ihtiyacın var?

Entegrasyon yardımı, özel ihtiyaçlar veya Enterprise planı için iletişime geç.