Geliştirici Dökümantasyonu
n8n Media API uç noktalarını kullanarak programatik olarak medya yükleyin, yönetin ve planlayın.
Kimlik Doğrulama (Authentication)
Tüm API isteklerinde yetkilendirme için API Erişim Anahtarınızı (API Key) kullanmanız gerekir. İstek başlığına (Header) Authorization: Bearer <key> ekleyerek veya X-API-Key: <key> göndererek doğrulamayı gerçekleştirebilirsiniz.
Normal Giriş ve Admin Girişi Farkları
- Kullanıcı Girişi: Şirket çalışanlarının veya entegratörlerin medya yüklemesi yaptığı, planlanmış gönderileri gördüğü ve yönettiği kullanıcı panelidir. Her şirket sadece kendi yüklediği medyaları ve gönderileri görebilir. Giriş yapmak için ana sayfayı (/) kullanabilirsiniz.
- Yönetici Girişi: Sistem yöneticisi (admin / super-admin) rolündeki kullanıcıların girdiği yönetim panelidir. Yöneticiler de aynı giriş sayfasından (/) giriş yapar ve yetkilerine göre üst menüde beliren "Admin Panel" butonunu kullanarak yönetim paneline (/admin) yönlendirilir. Buradan sisteme yeni şirketler eklenebilir, şirketler için kullanıcılar oluşturulabilir ve harici entegrasyonlar (n8n vb.) için API Anahtarları üretilip yönetilebilir.
API Erişim Anahtarı (API Key) Nedir ve Nasıl Alınır?
API Key, harici yazılımların veya otomasyon araçlarının (**n8n**, Make, kendi yazdığınız scriptler) sisteme kullanıcı adı/şifre girmeden güvenli ve doğrudan bağlanmasını sağlar.
- Yönetici hesabı ile /admin adresine gidin.
- API Anahtarları tabından "Yeni Anahtar Oluştur" butonuna basın.
- Anahtar için bir isim belirleyin ve ilişkili olacağı şirketi seçin.
- Sistem tarafından üretilen
gigabyte_api_key_123gibi benzersiz anahtarı kopyalayıp entegrasyonunuzda kullanın.
Örnek HTTP İstek Yapısı
API Key yetkilendirmesiyle istek atarken aşağıdaki gibi HTTP başlıklarını eklemeniz gerekir:
GET /api/posts HTTP/1.1 Host: localhost:3000 Authorization: Bearer gigabyte_api_key_123 Accept: application/json
POST /api/auth
Erişim anahtarınızın geçerli olup olmadığını kontrol eder. Web istemcilerinde oturum başlatma kontrolü için idealdir.
curl -X POST \
-H "Content-Type: application/json" \
-d '{"key": "YOUR_AUTH_KEY"}' \
http://localhost:3000/api/auth
fetch('/api/auth', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ key: 'YOUR_AUTH_KEY' })
})
.then(res => res.json())
.then(data => console.log('Başarılı:', data))
.catch(err => console.error('Hata:', err));
{
"success": true,
"type": "user"
}
GET /api/posts
Şirkete ait planlanmış tüm gönderileri listeler. Filtreleme ve sıralama parametrelerini destekler.
Desteklenen Query Parametreleri:
filter: Gönderi yayınlanma tarihine göre süzme yapar.all: Tüm gönderiler (Varsayılan)has_date: Sadece yayınlanma tarihi girilmiş/planlanmış gönderilerno_date: Yayınlanma tarihi girilmemiş (boş bırakılmış) gönderiler
sort: Gönderilerin sıralama biçimi. Tarihsiz (boş/null) olan gönderiler her iki yönde de listenin en altında kalır.default: Eklenme tarihine göre en yeni önce (Varsayılan)date_asc: Yayınlama tarihine göre artan (Önce En Eski Planlanan)date_desc: Yayınlama tarihine göre azalan (Önce En Yeni Planlanan)
status: Gönderi durumuna göre süzme yapar.all: Tüm gönderiler (Varsayılan)pending: Sadece pending gönderilerpublished: Sadece published gönderilerfailed: Sadece failed gönderiler
# Tarihi olanları yayın tarihine göre artan sırada listele
curl -X GET \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
"http://localhost:3000/api/posts?filter=has_date&sort=date_asc"
fetch('/api/posts?filter=has_date&sort=date_asc', {
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Gönderiler:', data.posts));
{
"success": true,
"posts": [
{
"id": 4,
"title": "Sosyal Medya Gönderisi",
"description": "Genel gönderi açıklaması",
"type": "Reels",
"mediaType": "image",
"publishDate": "2026-07-20T15:00:00",
"status": "pending",
"auto_generate_description": false,
"approvalStatus": "pending",
"approvalRequestedAt": "2026-07-20T15:01:00Z",
"approvalRespondedAt": null,
"rejectReason": null,
"companyId": 1,
"companyName": "GIGABYTE LTD",
"created_at": "2026-07-16T08:00:00Z",
"media": [
{
"id": 12,
"filename": "178418-resim.png",
"original_name": "resim.png",
"mime_type": "image/png",
"size": 1048576,
"url": "http://localhost:3000/media/178418-resim.png"
}
],
"platforms": [
{
"postPlatformId": 12,
"platformPostId": "123456789_ig",
"title": "Platforma Özel Başlık (Instagram)",
"description": "Instagram özel gönderi açıklaması",
"publishDate": "2026-07-20T15:30:00",
"platformStatus": "pending",
"platformPublishedDate": null,
"platformName": "instagram",
"platformId": 1,
"deleteStatus": null,
"deleteRequestedAt": null,
"deleteCompletedAt": null,
"deleteError": null
}
]
}
]
}
GET /api/posts/:id
Belirtilen benzersiz kimliğe (ID) sahip planlanmış gönderinin detaylarını; medya dosyaları, platform ayarları ve tüm ilişkili meta verileriyle birlikte getirir.
curl -X GET \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/posts/4
fetch('/api/posts/4', {
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Gönderi Detayı:', data.post));
{
"success": true,
"post": {
"id": 4,
"title": "Sosyal Medya Gönderisi",
"description": "Genel gönderi açıklaması",
"type": "Reels",
"mediaType": "image",
"publishDate": "2026-07-20T15:00:00",
"status": "pending",
"auto_generate_description": false,
"approvalStatus": "pending",
"approvalRequestedAt": "2026-07-20T15:01:00Z",
"approvalRespondedAt": null,
"rejectReason": null,
"companyId": 1,
"companyName": "GIGABYTE LTD",
"created_at": "2026-07-16T08:00:00Z",
"media": [
{
"id": 12,
"filename": "178418-resim.png",
"original_name": "resim.png",
"mime_type": "image/png",
"size": 1048576,
"url": "http://localhost:3000/media/178418-resim.png"
}
],
"platforms": [
{
"postPlatformId": 12,
"platformPostId": "123456789_ig",
"title": "Platforma Özel Başlık (Instagram)",
"description": "Instagram özel gönderi açıklaması",
"publishDate": "2026-07-20T15:30:00",
"platformStatus": "pending",
"platformPublishedDate": null,
"platformName": "instagram",
"platformId": 1,
"deleteStatus": null,
"deleteRequestedAt": null,
"deleteCompletedAt": null,
"deleteError": null
}
]
}
}
POST /api/posts
Yeni bir planlanmış gönderi oluşturur. Gönderinin genel başlık ve açıklaması haricinde, platforma özel açıklamalar, başlıklar ve özel zamanlamalar tanımlayabilirsiniz. Başarıyla oluşturulduğunda gönderinin tüm bilgileri (ID dahil) döndürülür.
curl -X POST \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Yeni Kampanya",
"description": "Kampanya genel açıklaması",
"type": "Gönderi",
"publishDate": "2026-07-20T15:00:00",
"mediaIds": [12],
"platforms": [
{
"platformId": 1,
"title": "Kampanya Instagram Başlığı",
"description": "İnstagrama özel kampanya detayları...",
"publishDate": "2026-07-20T15:30:00"
}
]
}' \
http://localhost:3000/api/posts
fetch('/api/posts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: "Yeni Kampanya",
description: "Kampanya genel açıklaması",
type: "Gönderi",
publishDate: "2026-07-20T15:00:00",
mediaIds: [12],
platforms: [
{
"platformId": 1,
"title": "Kampanya Instagram Başlığı",
"description": "İnstagrama özel...",
"publishDate": "2026-07-20T15:30:00"
}
]
})
})
.then(res => res.json())
.then(data => console.log('Oluşturuldu:', data));
{
"title": "Kampanya Lansmanı",
"description": "Lansman genel açıklaması",
"type": "Gönderi",
"publishDate": "2026-07-20T12:00:00",
"status": "pending",
"mediaIds": [12, 13],
"platforms": [
{
"platformId": 1,
"title": "Özel Lansman Instagram Başlığı",
"description": "İnstagram detayları...",
"publishDate": "2026-07-20T12:15:00"
},
{
"platformId": 2,
"title": "Lansman Twitter/X Başlığı",
"description": "Twitter detayları...",
"publishDate": ""
}
]
}
{
"success": true,
"postId": 4,
"post": {
"id": 4,
"title": "Yeni Kampanya",
"description": "Kampanya genel açıklaması",
"type": "Gönderi",
"mediaType": "image",
"publishDate": "2026-07-20T15:00:00",
"status": "pending",
"companyId": 1,
"created_at": "2026-07-16T08:00:00Z",
"media": [],
"platforms": [
{
"platformId": 1,
"name": "instagram",
"title": "Kampanya Instagram Başlığı",
"description": "İnstagrama özel kampanya detayları...",
"publishDate": "2026-07-20T15:30:00"
}
]
}
}
PUT /api/posts/:id
Mevcut bir planlanmış gönderinin genel başlığını, açıklamasını, tarihini, medya dosyalarını veya platforma özel başlık/açıklama/zamanlama detaylarını günceller.
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Güncellenmiş Başlık",
"description": "Kampanya genel açıklama güncellemesi",
"type": "Hikaye",
"publishDate": "2026-07-22T10:00:00",
"status": "published",
"mediaIds": [12],
"platforms": [
{
"platformId": 1,
"title": "Güncellenmiş Instagram Başlığı",
"description": "Instagram detay güncellemesi",
"publishDate": "2026-07-22T10:15:00"
}
]
}' \
http://localhost:3000/api/posts/4
fetch('/api/posts/4', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: "Güncellenmiş Başlık",
description: "Kampanya genel açıklama güncellemesi",
type: "Hikaye",
publishDate: "2026-07-22T10:00:00",
status: "published",
mediaIds: [12],
platforms: [
{
"platformId": 1,
"title": "Güncellenmiş Instagram Başlığı",
"description": "Instagram detay güncellemesi",
"publishDate": "2026-07-22T10:15:00"
}
]
})
})
.then(res => res.json())
.then(data => console.log('Güncellendi:', data.success));
{
"success": true,
"message": "Post updated successfully."
}
PUT /api/posts/:id/approval
Mevcut bir gönderinin yalnızca Telegram onay durumunu (approvalStatus) günceller. Olası değerler: not_required, pending, sent, approved, rejected.
- approvalStatus = 'sent': Durum
sentyapıldığındaapprovalRequestedAtdeğeri dışarıdan gönderilebilir; eğer değer verilmezse sunucu tarafından otomatik olarakdateTime nowatanır. - approvalStatus = 'approved' veya 'rejected':
approvalRespondedAtdeğeri sadece bu iki durumda set edilir; eğer değer verilmezse sunucu tarafından otomatik olarakdateTime nowatanır. - rejectReason: Eğer durum
rejectedise, reddedilme sebebi bu alana metin olarak eklenebilir.
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"approvalStatus": "rejected",
"rejectReason": "Görsel kalitesi çok düşük."
}' \
http://localhost:3000/api/posts/4/approval
fetch('/api/posts/4/approval', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
approvalStatus: "rejected",
rejectReason: "Görsel kalitesi çok düşük."
})
})
.then(res => res.json())
.then(data => console.log('Onay durumu güncellendi:', data.success));
{
"success": true,
"message": "Post approval status updated successfully.",
"approvalStatus": "rejected",
"approvalRespondedAt": "2026-07-28T05:45:00.000Z",
"rejectReason": "Görsel kalitesi çok düşük."
}
PUT /api/posts/:id/platforms
Mevcut bir gönderinin platform özel detaylarını (başlık, açıklama, zamanlama), platform yayın durumunu (status: pending, published, failed), yayınlanma zamanını (publishedDate) ve n8n/otomasyon tarafından dönen platformPostId değerlerini günceller.
Bir gönderi çoklu platformda (örn. Instagram, Facebook, LinkedIn) yayınlandığında, n8n paylaşım sürecinde bazı platformlar başarılı (published) olurken bazıları hata (failed) verebilir. Bu nedenle ana gönderi durumu (post.status) API'den elle değiştirilemez; bağlı postPlatform kayıtlarının durumlarına göre otomatik olarak güncellenir:
- Tüm platformlar
publishedise: Ana gönderipublisheddurumuna geçer. - En az bir platform
failedise: Ana gönderifaileddurumuna geçer. - En az bir platform
pendingise: Ana gönderipendingdurumunda kalır.
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"platforms": [
{
"platformId": 1,
"platformPostId": "179283749283749",
"status": "published",
"publishedDate": "2026-07-28T10:00:00.000Z"
},
{
"platformId": 2,
"platformPostId": "fb_987654321",
"status": "failed"
}
]
}' \
http://localhost:3000/api/posts/4/platforms
fetch('/api/posts/4/platforms', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
platforms: [
{
platformId: 1,
platformPostId: "179283749283749",
status: "published"
}
]
})
})
.then(res => res.json())
.then(data => console.log('Platform durumları ve postStatus güncellendi:', data.postStatus));
{
"success": true,
"message": "Post platforms updated successfully.",
"postId": 4,
"postStatus": "failed",
"platforms": [
{
"postPlatformId": 12,
"platformId": 1,
"platformName": "instagram",
"platformPostId": "179283749283749",
"platformStatus": "published",
"platformPublishedDate": "2026-07-28T10:00:00.000Z"
},
{
"postPlatformId": 13,
"platformId": 2,
"platformName": "facebook",
"platformPostId": "fb_987654321",
"platformStatus": "failed",
"platformPublishedDate": null
}
]
}
POST /api/posts/:id/social-delete
Yayınlanmış (postPlatform.status === 'published') platformların sosyal medyadan silinmesi için n8n silme talebi oluşturur. Veritabanındaki post kaydını silmez; talebi deletePostPlatform kuyruğuna aktarır.
- Platform Durumu Şartı: Silme talebi sadece durumu
publishedolan platformlar için oluşturulabilir. Durumupendingveyafailedolan platformlar için silme talebi oluşturulamaz. - Tüm Platformlar:
{ "allPlatforms": true }(veya boş gövde{}) gönderildiğinde gönderiye aitpublisheddurumundaki platformlar içindeletePostPlatformtablosuna ayrı ayrı silme kaydı eklenir. - Seçili Platformlar:
{ "platformIds": [1, 2] }(İletilen platformlar arasındapublishedolmayan varsa 400 Bad Request döner). - Mükerrer Talep Önleme: Zaten silme talebi açılmış (durumu
pendingveyadeleted) platformlar için tekrar silme talebi oluşturulmaz.
fetch('/api/posts/4/social-delete', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
allPlatforms: true
})
})
.then(res => res.json())
.then(data => console.log('Silme Talebi:', data));
{
"success": true,
"message": "1 platform için sosyal medya silme talebi oluşturuldu.",
"requests": [
{
"id": 1,
"postId": 4,
"postPlatformId": 12,
"platformId": 1,
"platformName": "instagram",
"platformPostId": "179283749283749",
"status": "pending"
}
],
"skippedCount": 0
}
GET /api/social-delete-requests
n8n veya harici otomasyon servisleri için silinmesi beklenen sosyal medya silme taleplerini listeler. Admin/global token kullanımında ?companyId=X parametresini destekler.
status (`pending` [varsayılan], `deleted`, `failed`, `all`).
curl -X GET \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
"http://localhost:3000/api/social-delete-requests?status=pending"
fetch('/api/social-delete-requests?status=pending', {
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Silme Talepleri:', data.requests));
{
"success": true,
"requests": [
{
"id": 1,
"postId": 4,
"postPlatformId": 12,
"companyId": 1,
"status": "pending",
"error": null,
"created_at": "2026-07-28T09:00:00.000Z",
"updated_at": null,
"platformPostId": "179283749283749",
"platformId": 1,
"platformName": "instagram",
"postTitle": "Yayınlanan Gönderi"
}
]
}
PUT /api/social-delete-requests/:id
n8n sosyal medyadan paylaşımı sildikten sonra sonucunu (deleted veya failed) Gateway'e bildirir ve deletePostPlatform kaydını günceller.
status(Zorunlu):"deleted"veya"failed".error(İsteğe Bağlı): Silme işlemi başarısız olduğunda (status = "failed"), n8n tarafından hatanın detaylı açıklaması bu alanda iletilir.deletedAt(İsteğe Bağlı):status = "deleted"olarak güncellendiğinde dışarıdan özel bir ISO string iletilebilir; iletilmezse sunucu otomatik olarakdateTime now(ISO string) kaydeder.
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "deleted"
}' \
http://localhost:3000/api/social-delete-requests/1
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "failed",
"error": "Platform token hatası veya gönderi sosyal medyada bulunamadı."
}' \
http://localhost:3000/api/social-delete-requests/1
{
"success": true,
"message": "Delete request status updated successfully.",
"status": "deleted",
"deletedAt": "2026-07-28T09:20:00.000Z"
}
DELETE /api/social-delete-requests/:id
Oluşturulmuş bir sosyal medya silme talebini iptal eder/veritabanından kaldırır. Durumu deleted (sosyal medyadan silinmiş) olan talepler güvenlik nedeniyle iptal edilemez (HTTP 400 Bad Request döner).
curl -X DELETE \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/social-delete-requests/1
fetch('/api/social-delete-requests/1', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY'
}
})
.then(res => res.json())
.then(data => console.log('Silme Talebi İptal Edildi:', data.message));
{
"success": true,
"message": "Silme talebi başarıyla iptal edildi."
}
DELETE /api/posts/:id
Belirtilen benzersiz kimliğe (ID) sahip planlanmış gönderiyi veritabanından kalıcı olarak siler.
Bir gönderinin en az 1 tane bile paylaşılmış (postPlatform.status === 'published') platformu bulunuyorsa, bu gönderi veritabanından kalıcı olarak SİLİNEMEZ. İstek atıldığında 400 Bad Request hatası döner: "Paylaşılmış (published) platformu bulunan gönderiler veritabanından kalıcı olarak silinemez. Lütfen ilgili platform için sosyal medyadan silme talebi oluşturun."
curl -X DELETE \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/posts/4
fetch('/api/posts/4', {
method: 'DELETE',
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Silme Sonucu:', data.success));
{
"success": true,
"message": "Post deleted successfully."
}
POST /api/upload
Sunucuya yeni bir medya dosyası yükler. Sadece resim, video, ses ve GIF uzantılarına izin verilir. Veri tipi multipart/form-data olmalıdır.
curl -X POST \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-F "file=@/path/to/your/image.png" \
http://localhost:3000/api/upload
const formData = new FormData();
formData.append('file', fileInputElement.files[0]);
fetch('/api/upload', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY'
},
body: formData
})
.then(res => res.json())
.then(data => {
if (data.success) {
console.log('Medya URL:', data.file.url);
}
});
{
"success": true,
"file": {
"id": 12,
"filename": "178418-resim.png",
"original_name": "resim.png",
"mime_type": "image/png",
"size": 1048576,
"companyId": 1,
"url": "http://localhost:3000/media/178418-resim.png"
}
}
GET /api/media
Yüklenmiş olan tüm medyaların meta verilerini (boyut, tür, yükleme tarihi, kamuya açık URL) dizi formatında listeler.
curl -X GET \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/media
fetch('/api/media', {
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Medya Listesi:', data.media));
{
"success": true,
"media": [
{
"id": 12,
"filename": "178418-resim.png",
"original_name": "resim.png",
"mime_type": "image/png",
"size": 1048576,
"companyId": 1,
"created_at": "2026-07-16T08:00:00Z",
"url": "http://localhost:3000/media/178418-resim.png"
}
]
}
DELETE /api/media/:id
Belirtilen benzersiz kimliğe (ID) sahip medya dosyasını veritabanından ve diskten kalıcı olarak siler.
curl -X DELETE \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/media/12
fetch('/api/media/12', {
method: 'DELETE',
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Silme Sonucu:', data.success));
{
"success": true,
"message": "Media file deleted successfully."
}
POST /api/posts/:id/media/upload
Yeni bir medya dosyasını sunucuya yükler ve doğrudan belirtilen gönderi (post) ile ilişkilendirir. Veri tipi multipart/form-data olmalı ve dosya file alanında gönderilmelidir.
curl -X POST \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-F "file=@/path/to/your/image.png" \
http://localhost:3000/api/posts/4/media/upload
const formData = new FormData();
formData.append('file', fileInputElement.files[0]);
fetch('/api/posts/4/media/upload', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY'
},
body: formData
})
.then(res => res.json())
.then(data => {
if (data.success) {
console.log('Post ile ilişkilendirilmiş Medya:', data.file);
}
});
POST /api/posts/:id/media
Mevcut bir medya dosyasını (kütüphaneden), belirtilen gönderi (post) ile anında ilişkilendirir. Editördeki sürükle-bırak yükleme akışlarında ve gerçek zamanlı bağlama işlemlerinde kullanılır.
curl -X POST \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{"mediaId": 12}' \
http://localhost:3000/api/posts/4/media
fetch('/api/posts/4/media', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ mediaId: 12 })
})
.then(res => res.json())
.then(data => console.log('İlişkilendirildi:', data.success));
{
"success": true
}
DELETE /api/posts/:id/media/:mediaId
Belirtilen medya dosyasının gönderi ile olan ilişkisini sonlandırır. Medya sunucudan veya kütüphaneden silinmez, sadece bu gönderinin medya listesinden çıkarılır.
curl -X DELETE \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/posts/4/media/12
fetch('/api/posts/4/media/12', {
method: 'DELETE',
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('İlişki Kesildi:', data.success));
{
"success": true
}
POST /api/posts/:id/platforms
Belirtilen gönderiye (post) yeni bir sosyal medya platformu planlaması ekler veya var olan planlamayı günceller (upsert). Platforma özel başlık, açıklama ve yayınlama tarihi tanımlayabilirsiniz.
curl -X POST \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"platformId": 1,
"title": "Platforma Özel Başlık",
"description": "Platforma özel açıklama",
"publishDate": "2026-07-20T16:00:00"
}' \
http://localhost:3000/api/posts/4/platforms
fetch('/api/posts/4/platforms', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
platformId: 1,
title: "Platforma Özel Başlık",
description: "Platforma özel açıklama",
publishDate: "2026-07-20T16:00:00"
})
})
.then(res => res.json())
.then(data => console.log('Platform eklendi:', data.success));
{
"success": true,
"message": "Platform successfully associated with post."
}
Şirket İstekleri ve Kimlik Doğrulama
Bu uç noktalar şirketinize ait bilgileri ve sosyal medya bağlantılarını (tokenları) yönetmenizi sağlar.
Normal (Şirket) Token Kullanımı: İstek atarken companyId göndermenize gerek yoktur. Sistem, anahtarınızın ait olduğu şirketi otomatik olarak tanır ve işlemleri o şirket üzerinde gerçekleştirir.
Admin (Global) Token Kullanımı: İstek atarken işlemin hangi şirkete uygulanacağını belirtmek için URL sonuna ?companyId=1 eklemeli veya JSON gövdesine companyId: 1 eklemelisiniz. Aksi takdirde hata alırsınız.
GET /api/company
Şirket detaylarını (logo, iletişim bilgileri vb.) getirir.
curl -X GET \
-H "Authorization: Bearer YOUR_COMPANY_AUTH_KEY" \
http://localhost:3000/api/company
fetch('/api/company?companyId=1', {
headers: { 'Authorization': 'Bearer YOUR_ADMIN_KEY' }
})
.then(res => res.json())
.then(data => console.log('Şirket Bilgileri:', data.company));
{
"success": true,
"company": {
"id": 1,
"name": "Örnek Şirket LTD",
"logo": "https://logo-url.com/img.png",
"website": "https://...",
"email": "info@...",
"phone": "+90...",
"address": "İstanbul",
"description": "...",
"telegramApprovalEnabled": true,
"telegramChatId": "-100123456789",
"created_at": "2026-07-16T12:00:00Z"
}
}
PUT /api/company
Şirket detaylarını günceller.
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"logo": "https://...",
"website": "https://...",
"email": "info@...",
"phone": "+90...",
"address": "İstanbul...",
"description": "Şirket açıklaması",
"telegramApprovalEnabled": true,
"telegramChatId": "-100123456789"
}' \
http://localhost:3000/api/company
{
"success": true,
"message": "Company details updated."
}
GET /api/connections
Şirketin bağlı olduğu tüm sosyal medya platformlarının bağlantı bilgilerini listeler.
curl -X GET \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/connections
fetch('/api/connections?companyId=1', {
headers: { 'Authorization': 'Bearer YOUR_ADMIN_KEY' }
})
.then(res => res.json())
.then(data => console.log('Bağlantılar:', data.connections));
{
"success": true,
"connections": [
{
"companyId": 1,
"platformId": 1,
"status": "Connected",
"accessToken": "EAA...",
"refreshToken": null,
"tokenExpiry": null,
"platformAccountId": "1784...",
"platformAccountData": "{\"name\": \"IgAccount\"}",
"created_at": "...",
"updated_at": "...",
"platformName": "instagram"
}
]
}
POST /api/connections
Yeni bir sosyal medya bağlantısı oluşturur veya mevcut bağlantıyı günceller. İstek gövdesinde (body) id belirtilmişse, doğrudan ilgili ID'ye sahip bağlantı güncellenir. Eğer ID belirtilmemişse, benzersiz platformAccountId değeri (veya bu değer boşsa ilgili platform eşleşmesi) kullanılarak mevcut kayıt sorgulanır; eşleşme bulunursa o kayıt güncellenir, bulunamazsa yeni bir bağlantı oluşturulur.
curl -X POST \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": 12, // Opsiyonel: Mevcut bir bağlantıyı güncellemek için bağlantı ID'si
"platformId": 1,
"status": "Connected",
"accessToken": "ACCESS_TOKEN_HERE",
"refreshToken": "REFRESH_TOKEN_HERE",
"tokenExpiry": "2026-08-16T12:00:00Z",
"platformAccountId": "BUSINESS_ACCOUNT_ID",
"platformAccountData": {"page_id": "123"}
}' \
http://localhost:3000/api/connections
{
"success": true,
"message": "Connection saved successfully."
}
DELETE /api/connections/:id
Bir sosyal medya bağlantısını kaldırır. Uç nokta parametresindeki :id parametresi, bağlantının kendi benzersiz veritabanı ID değeridir (platformId değildir).
curl -X DELETE \
-H "Authorization: Bearer YOUR_ADMIN_KEY" \
http://localhost:3000/api/connections/12?companyId=1
{
"success": true,
"message": "Connection removed successfully."
}
GET /api/platforms
Sistemde tanımlı tüm sosyal medya platformlarını (Instagram, Facebook, Twitter, vb.) listeler.
curl -X GET \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
http://localhost:3000/api/platforms
fetch('/api/platforms', {
headers: { 'Authorization': 'Bearer YOUR_AUTH_KEY' }
})
.then(res => res.json())
.then(data => console.log('Platformlar:', data.platforms));
{
"success": true,
"platforms": [
{
"id": 1,
"name": "instagram",
"created_at": "2026-07-16T08:00:00Z"
},
{
"id": 2,
"name": "facebook",
"created_at": "2026-07-16T08:00:00Z"
}
]
}
GET /api/admin/companies
Sistemde tanımlı tüm şirketleri listeler. Bu işlemi yapmak için Yönetici (Admin) veya Global API yetkisi gereklidir.
curl -X GET \
-H "Authorization: Bearer YOUR_ADMIN_KEY" \
http://localhost:3000/api/admin/companies
fetch('/api/admin/companies', {
headers: { 'Authorization': 'Bearer YOUR_ADMIN_KEY' }
})
.then(res => res.json())
.then(data => console.log('Şirketler:', data.companies));
{
"success": true,
"companies": [
{
"id": 1,
"name": "GIGABYTE LTD",
"created_at": "2026-07-16T08:00:00Z"
},
{
"id": 2,
"name": "ACME Corp",
"created_at": "2026-07-16T09:00:00Z"
}
]
}
GET /api/admin/apikeys
Sistemde oluşturulmuş tüm API anahtarlarını listeler.
curl -X GET \
-H "Authorization: Bearer YOUR_ADMIN_KEY" \
http://localhost:3000/api/admin/apikeys
fetch('/api/admin/apikeys', {
headers: { 'Authorization': 'Bearer YOUR_ADMIN_KEY' }
})
.then(res => res.json())
.then(data => console.log('API Anahtarları:', data.apiKeys));
{
"success": true,
"apiKeys": [
{
"id": 1,
"key": "media_f893d...",
"name": "ACME Entegrasyon Anahtarı",
"companyId": 2,
"companyName": "ACME Corp",
"created_at": "2026-07-16T10:00:00Z"
},
{
"id": 2,
"key": "media_32fd7...",
"name": "Global API Anahtarı",
"companyId": null,
"companyName": null,
"created_at": "2026-07-16T11:00:00Z"
}
]
}
POST /api/admin/apikeys
Yeni bir API anahtarı oluşturur. Şirket bazlı veya tüm şirketlere erişebilen (global) bir anahtar oluşturabilirsiniz.
# Şirket bazlı API anahtarı oluşturma:
curl -X POST \
-H "Authorization: Bearer YOUR_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Yeni Şirket Anahtarı", "companyId": 2}' \
http://localhost:3000/api/admin/apikeys
# Global (Tüm Şirketlere Erişebilen) API anahtarı oluşturma:
curl -X POST \
-H "Authorization: Bearer YOUR_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Genel Yönetici Anahtarı", "companyId": null}' \
http://localhost:3000/api/admin/apikeys
fetch('/api/admin/apikeys', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ADMIN_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Yeni API Anahtarı',
companyId: 2 // Global için null geçebilirsiniz
})
})
.then(res => res.json())
.then(data => console.log('Yeni API Key:', data.apiKey));
{
"success": true,
"apiKey": {
"id": 3,
"key": "media_e32f50c...",
"name": "Yeni API Anahtarı",
"companyId": 2
}
}
DELETE /api/admin/apikeys/:id
Belirtilen ID'ye sahip API anahtarını iptal eder (siler).
curl -X DELETE \
-H "Authorization: Bearer YOUR_ADMIN_KEY" \
http://localhost:3000/api/admin/apikeys/3
fetch('/api/admin/apikeys/3', {
method: 'DELETE',
headers: { 'Authorization': 'Bearer YOUR_ADMIN_KEY' }
})
.then(res => res.json())
.then(data => console.log('Silme Sonucu:', data.message));
{
"success": true,
"message": "API Key deleted successfully."
}