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.
- Yönetici Girişi (/admin): Sistem yöneticisinin girdiği yönetim panelidir. 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",
"publishDate": "2026-07-20T15:00:00",
"status": "pending",
"companyId": 1,
"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": [
{
"platformId": 1,
"name": "instagram",
"title": "Platforma Özel Başlık (Instagram)",
"description": "Instagram özel gönderi açıklaması",
"publishDate": "2026-07-20T15:30:00"
}
]
}
]
}
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",
"publishDate": "2026-07-20T15:00:00",
"status": "pending",
"companyId": 1,
"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": [
{
"platformId": 1,
"name": "instagram",
"title": "Platforma Özel Başlık (Instagram)",
"description": "Instagram özel gönderi açıklaması",
"publishDate": "2026-07-20T15:30:00"
}
]
}
}
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",
"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/status
Mevcut bir gönderinin yalnızca durumunu (status) günceller. Olası değerler: pending, published, failed. Diğer değerler gönderildiğinde 400 Bad Request hatası alınır.
curl -X PUT \
-H "Authorization: Bearer YOUR_AUTH_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "published"
}' \
http://localhost:3000/api/posts/4/status
fetch('/api/posts/4/status', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_AUTH_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: "published"
})
})
.then(res => res.json())
.then(data => console.log('Durum güncellendi:', data.success));
{
"success": true,
"message": "Post status updated successfully."
}
DELETE /api/posts/:id
Belirtilen benzersiz kimliğe (ID) sahip planlanmış gönderiyi veritabanından kalıcı olarak siler.
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": "...",
"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ı"
}' \
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."
}