JavaScript ile SMS gönderme: hazır örnek kodlar

Node.js 18+ yerleşik fetch ile; sunucu tarafında çalıştırın. Her istek POST, gövde JSON; api_id ve api_key panelde Hesabım → API Bilgilerimi Görüntüle bölümünde.

Taban adres: https://api.toplusmspaketleri.com/api/v1 · Demo hesapta deneme için 10 kredi tanımlanır. Kodu tarayıcıda değil sunucuda çalıştırın; api_key gizli kalmalı.

1 - N gönderim

POST/1toN

Aynı mesajı bir ya da birden çok numaraya gönderir.

  • sender olarak hesabınıza tanımlı gönderici adını (başlık) ya da 850'li numaranızı gönderin.
  • Türkçe karakter için message_type değerini turkce yapın.
  • İleri tarihli gönderim için send_time alanını Y-m-d H:i:s biçiminde ekleyin; hemen gönderim için bu alanı yazmayın.
  • Ticari içerikte message_content_type değeri ticari, bilgilendirmede bilgi olmalıdır.
// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/1toN";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY",
  "sender": "SMSBASLIGINIZ",
  "message_type": "normal",
  "message": "Bu bir test mesajıdır.",
  "message_content_type": "bilgi",
  "phones": [
    "5xxxxxxxxx",
    "5xxxxxxxxx"
  ]
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

N - N gönderim

POST/NtoN

Her numaraya farklı mesaj gönderir (kişiye özel hitap, kod, tutar).

  • phones dizisindeki her öğe phone ve message alanı taşır.
  • send_time örneği ileri tarihli gönderimi gösterir; hemen gönderim için kaldırın.
// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/NtoN";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY",
  "sender": "SMSBASLIGINIZ",
  "message_type": "normal",
  "send_time": "2026-12-01 10:00:00",
  "message_content_type": "bilgi",
  "phones": [
    {
      "phone": "5xxxxxxxxx",
      "message": "Sayın Ayşe Yılmaz, siparişiniz kargoya verildi."
    },
    {
      "phone": "5xxxxxxxxx",
      "message": "Sayın Ali Kaya, randevunuz yarın 14:00."
    }
  ]
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

Gönderici adı sorgulama

POST/senders

Hesabınıza tanımlı gönderici adlarını (başlıkları) listeler.

// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/senders";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY"
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

Kullanıcı bilgilerini alma

POST/user/information

Hesap bilgisi ve kalan kredi.

// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/user/information";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY"
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

Rapor sorgulama: rapor detayı

POST/report/detail?page=1&pageSize=20

Bir gönderimin numara bazında teslimat durumu, sayfalı.

  • report_id her gönderimden sonra dönen kimliktir.
  • Sayfalama için adrese page ekleyin; varsayılan sayfa 20 kayıt, pageSize ile 1-100 arası.
  • Tüm veriyi sayfasız almak için page ve pageSize göndermeyin.
// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/report/detail?page=1&pageSize=20";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY",
  "report_id": 926410
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

Rapor sorgulama: tarih bazlı

POST/report/between

Tarih aralığındaki gönderimlerin raporu.

  • start_date ve end_date Y-m-d H:i:s biçiminde olmalıdır.
// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/report/between";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY",
  "start_date": "2026-11-01 00:00:00",
  "end_date": "2026-11-30 23:59:59"
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

Rapor sorgulama: sonuç sorgusu

POST/report/single

Tek gönderimin sonuç özeti.

  • report_id her gönderimden sonra dönen kimliktir.
// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/report/single";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY",
  "report_id": 926382
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());

İleri tarihli SMS iptali

POST/cancel/future-sms

Henüz gitmemiş ileri tarihli gönderimi iptal eder.

  • id alanına iptal edilecek gönderimin rapor kimliğini yazın.
// Node.js 18+ (yerleşik fetch). Anahtarları tarayıcı koduna koymayın; sunucuda çalıştırın.
const url = "https://api.toplusmspaketleri.com/api/v1/cancel/future-sms";
const payload = {
  "api_id": "API_ID",
  "api_key": "API_KEY",
  "id": 926382
};

const response = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
console.log(response.status, await response.json());
Yanıt kodları

200 başarılı (report_id döner) · 401 api bilgileri hatalı · 422 eksik alan ya da onaysız gönderici adı · 404 rapor bulunamadı.

API Soruları →

JavaScript entegrasyonunuz bugün çalışsın

Ücretsiz üyelik, anında api_id ve api_key, takıldığınızda teknik destek.