AjansOps API
REST API referansı. Tüm endpoint'ler JSON kabul eder ve JSON döndürür. Base URL:
https://app.ajansops.com/apiKimlik 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ı
| Kod | Anlam |
|---|---|
| 401 | Giriş yok |
| 403 | Rol yetersiz (RBAC) |
| 404 | Kaynak yok |
| 409 | Çakışma (unique) |
| 429 | Rate limit (Retry-After header) |
| 503 | Servis yapılandırılmadı (Stripe, SMTP vb.) |
Rate Limits
POST /api/users/invite— 10/saat per adminGET /api/account/export— 3/saat per userPOST /api/leads/scrape,/api/seo/scrape— plan bazlı aylık limitPOST /api/emails/send— plan bazlı aylık limit
Aşıldığında: HTTP 429 + Retry-After header (saniye cinsinden)
Sites
/api/sitesVIEWER/api/sitesEDITOR/api/sites/:idEDITOR/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
/api/content/bulkEDITOR/api/content/:siteId/:postIdEDITOR/api/content/:siteId/:postIdEDITOR# Toplu publish
curl -X POST /api/content/bulk \
-d '{
"action": "publish",
"items": [{ "siteId": "...", "postId": "..." }]
}'Leads & Scrape
/api/leads/scrapeEDITOR/api/leads/scrapeVIEWERYanıt (status check):
{
"success": true,
"data": {
"running": false,
"lastScrapedAt": "2026-04-24T03:15:00Z",
"totalLeads": 280,
"lastRun": { "action": "scrape.lead.success", "at": "..." }
}
}Agents
/api/agents/:id/runEDITOREmails
/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 SENTemail.bounced→ status BOUNCED + usage refundemail.opened→ openedAt işaretleniremail.clicked→ clickedAt işaretleniremail.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/aktifcustomer.subscription.updated/deleted→ status senkronuinvoice.payment_failed→ PAST_DUE + notification
Health Check
/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
/api/account/exportany-userKullanıcının tüm verilerini JSON olarak indirir (KVKK md. 11 + GDPR Art. 20 uyumlu).
Rate limit: 3 request/saat.