Müşteri Yönetimi
Müşteri (tenant) CRUD işlemleri, veritabanı yönetimi, kullanıcı yönetimi ve modül atama.
Base URL: /api/admin/customers
Yetkilendirme: Bearer Token (Admin)
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Müşteri İşlemleri
POST /
Yeni müşteri oluşturur.
Request Body:
{
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"maxUploadFileSizeMb": 10
}
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
name | string | Evet | Müşteri adı |
slug | string | Evet | URL-dostu benzersiz tanımlayıcı |
domain | string | Evet | Müşteri domain adresi |
maxUploadFileSizeMb | int | Evet | Tenant için maksimum upload boyutu (MB) |
Response — 201 Created:
{
"success": true,
"data": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"apiKey": "generated-api-key",
"isActive": true,
"maxUploadFileSizeMb": 10,
"createdAt": "2026-03-27T10:00:00Z"
}
}
GET /
Tüm müşterileri sayfalanmış olarak listeler.
Query Parametreleri:
| Parametre | Tip | Varsayılan | Açıklama |
|---|---|---|---|
page | int | 1 | Sayfa numarası |
pageSize | int | 10 | Sayfa başına kayıt |
Response — 200 OK:
{
"success": true,
"data": {
"items": [
{
"id": "3fa85f64-...",
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"apiKey": "generated-api-key",
"isActive": true,
"maxUploadFileSizeMb": 10,
"createdAt": "2026-03-27T10:00:00Z"
}
],
"page": 1,
"pageSize": 10,
"totalCount": 1,
"totalPages": 1
}
}
GET /{id}
Müşteri detayını (veritabanı bilgisi dahil) getirir.
Response — 200 OK:
{
"success": true,
"data": {
"id": "3fa85f64-...",
"name": "Acme Corp",
"slug": "acme-corp",
"domain": "acme.com",
"apiKey": "generated-api-key",
"isActive": true,
"maxUploadFileSizeMb": 10,
"createdAt": "2026-03-27T10:00:00Z",
"database": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": true
}
}
}
PUT /{id}
Müşteri bilgilerini günceller.
Request Body:
{
"name": "Acme Corp Updated",
"domain": "new-acme.com",
"isActive": true,
"maxUploadFileSizeMb": 25
}
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
name | string | Evet | Müşteri adı |
domain | string | Evet | Domain adresi |
isActive | boolean | Evet | Aktiflik durumu |
maxUploadFileSizeMb | int | Evet | Tenant maksimum upload boyutu (MB) |
Response — 200 OK: CustomerResponse objesi döner.
DELETE /{id}
Müşteriyi siler (soft delete).
Response — 204 No Content
Veritabanı Yönetimi
POST /{id}/database
Müşteri veritabanı bilgilerini kaydeder.
Request Body:
{
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"password": "secret"
}
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
host | string | Evet | Veritabanı sunucusu |
port | int | Evet | Port numarası |
databaseName | string | Evet | Veritabanı adı |
username | string | Evet | Kullanıcı adı |
password | string | Evet | Şifre |
Response — 201 Created:
{
"success": true,
"data": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": false
}
}
PUT /{id}/database
Veritabanı bilgilerini günceller.
Request Body: SaveDatabaseRequest ile aynı.
Response — 200 OK:
{
"success": true,
"data": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": false
}
}
GET /{id}/database
Veritabanı bilgilerini getirir.
Response — 200 OK:
{
"success": true,
"data": {
"host": "localhost",
"port": 5432,
"databaseName": "tenant_acme",
"username": "postgres",
"isInitialized": true
}
}
POST /{id}/database/test
Veritabanı bağlantısını test eder.
Response — 200 OK:
{
"success": true,
"data": {
"success": true,
"message": "Baglanti basarili"
}
}
POST /{id}/database/initialize
Tenant veritabanını başlatır (migration + seed data).
Bu işlem yalnızca bir kez yapılmalıdır. Veritabanı bağlantı bilgileri önceden kaydedilmiş olmalıdır.
Response — 200 OK:
{
"success": true,
"message": "Veritabanı başarıyla başlatıldı."
}
Kullanıcı Yönetimi
POST /{customerId}/users
Müşteriye yeni tenant kullanıcısı ekler.
Request Body:
{
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"password": "SecurePass123"
}
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
email | string | Evet | E-posta adresi |
fullName | string | Evet | Ad soyad |
password | string | Evet | Şifre |
Response — 201 Created:
{
"success": true,
"data": {
"id": "3fa85f64-...",
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"isActive": true,
"createdAt": "2026-03-27T10:00:00Z"
}
}
GET /{customerId}/users
Müşteriye ait tüm kullanıcıları listeler.
Response — 200 OK:
{
"success": true,
"data": [
{
"id": "3fa85f64-...",
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"isActive": true,
"createdAt": "2026-03-27T10:00:00Z"
}
]
}
GET /{customerId}/users/{userId}
Belirli bir kullanıcıyı getirir.
Response — 200 OK:
{
"success": true,
"data": {
"id": "3fa85f64-...",
"email": "user@example.com",
"fullName": "Ali Yılmaz",
"isActive": true,
"createdAt": "2026-03-27T10:00:00Z"
}
}
PUT /{customerId}/users/{userId}
Kullanıcı bilgilerini günceller.
Request Body:
{
"email": "updated@example.com",
"fullName": "Ali Yılmaz Updated",
"isActive": true
}
Response — 200 OK: TenantUserResponse objesi döner.
DELETE /{customerId}/users/{userId}
Kullanıcıyı siler (soft delete).
Response — 204 No Content
Modül Yönetimi
GET /{id}/modules
Müşteriye atanmış modülleri listeler.
Response — 200 OK:
{
"success": true,
"data": [
{
"moduleId": "3fa85f64-...",
"moduleName": "Blog",
"moduleCode": "blog",
"isActive": true
}
]
}
POST /{id}/modules
Müşteriye modül atar.
Request Body:
{
"moduleId": "3fa85f64-...",
"isActive": true
}
Response — 201 Created:
{
"success": true,
"data": {
"moduleId": "3fa85f64-...",
"moduleName": "Blog",
"moduleCode": "blog",
"isActive": true
}
}
PUT /{id}/modules/{moduleId}
Modül atamasını günceller.
Query Parametreleri:
| Parametre | Tip | Açıklama |
|---|---|---|
isActive | boolean | Modül aktiflik durumu |
Response — 200 OK:
{
"success": true,
"data": {
"moduleId": "3fa85f64-...",
"moduleName": "Blog",
"moduleCode": "blog",
"isActive": false
}
}
Olası Hatalar
| Kod | Durum |
|---|---|
401 | Token eksik veya geçersiz |
403 | Admin yetkisi yok |
404 | Müşteri, veritabanı kaydı, kullanıcı veya modül bulunamadı |
409 | Müşteri slug'ı, kullanıcı email'i veya modül ataması zaten mevcut |