Send the SMS
Send short message data, such as text, destination number and sender identification by sending a POST request and we transfer the message to the destination network.
Authorizations
Seção intitulada “Authorizations ”Request Body required
Seção intitulada “Request Body required ”The new sms resource
SMS
object
The message text can have a length of up to 1530 characters. With a Unicode SMS, the maximum character length is reduced to 670 characters. Internal encoding is UTF-8.
Sender-ID of the message. Can be a number (up to 15 digits) or a text (up to 11 character). In case of a number please use preferentially E.164 phone number format. A sender of text may contain spaces but no other special characters. Please note that some countries do not support own sender IDs or do require pre-registration. Our system automatically tries to detect whether a sender ID is a text or a phone number. Avoid special characters in a number and enter it the same way as it would be dialed on a phone.
Para mensagens de voz (text2speech, text2speech_ssml): se sender_id não estiver em conformidade com o formato E.164 (por exemplo, sem o prefixo +, contendo caracteres não numéricos), a mensagem será enviada a partir do número padrão do sistema +493075435114. Alguns provedores de telefonia downstream podem substituir ou não respeitar o número de remetente definido pelo usuário — o identificador de chamada real apresentado ao destinatário depende das capacidades do provedor.
Recipient (international) number:
- +491701234567 (E.164)
- 00491701234567
- 491701234567
- 01701234567 (if the account is registered in Germany) will be convert to +491701234567
If the number is not in an E.164 format then the service will convert it based on user’s address. To avoid problems with the converting please use E.164 preferentially.
Fonte ou origem da mensagem
True se a mensagem contém caracteres Unicode, False caso contrário
Idioma da mensagem de voz. Valores possíveis: null (detecção automática) ou um dos seguintes: EN (inglês), DE (alemão), FR (francês), IT (italiano), ES (espanhol), PL (polaco), NL (neerlandês), RO (romeno), PT (português), CS (checo), HU (húngaro), SV (sueco), DA (dinamarquês), FI (finlandês), SK (eslovaco), HR (croata), TR (turco), RU (russo), BG (búlgaro), UK (ucraniano).
String which will be send back to your endpoint. E.g. it can be usable to pass your system message id.
Número máximo de tentativas de entrega para serviços de voz (text2speech, text2speech_ssml). Valores permitidos: null, 1, 2 ou 3 para os serviços text2speech/text2speech_ssml; deve ser nulo para os restantes serviços.
Examples
Mensagem SMS básica
Exemplo de uma mensagem SMS simples com apenas campos obrigatórios
{ "text": "Olá! Esta é uma mensagem SMS de teste.", "sender_id": "+491701234567", "phone": "+14155552671"}Mensagem de voz com texto simples
Exemplo de mensagem de voz texto-para-fala com conteúdo de texto simples
{ "text": "Olá, esta mensagem será convertida em fala e entregue como uma chamada de voz.", "sender_id": "+491701234567", "phone": "+14155552671", "service_code": "text2speech", "voice_lang": "EN"}Mensagem de voz com SSML
Exemplo de texto-para-fala com marcação SSML para síntese de voz aprimorada
{ "text": "<speak>Seu código de verificação é <say-as interpret-as=\"characters\">A1B2C3</say-as>.<break time=\"1s\"/>Por favor, digite-o agora.</speak>", "sender_id": "+491701234567", "phone": "+14155552671", "service_code": "text2speech", "voice_lang": "EN"}Mensagem de voz com chamada única (sem tentativas)
Exemplo de mensagem de voz sintetizada com conteúdo em texto simples e uma única tentativa de entrega sem repetições.
{ "text": "Olá, esta mensagem será convertida em voz e entregue como uma chamada de voz.", "sender_id": "+491701234567", "phone": "+14155552671", "service_code": "text2speech", "voice_lang": "PT", "attempts_count_max": 1}Mensagem SMS Unicode
Exemplo de SMS com caracteres Unicode (emojis, caracteres especiais, scripts não latinos)
{ "text": "\\ud83c\\udf89 Bem-vindos! Welcome! \\u6b22\\u8fce\\u5149\\u4e34! \\u0645\\u0631\\u062d\\u0628\\u0627 \\u0628\\u0643\\u0645!", "sender_id": "+491701234567", "phone": "+14155552671", "is_unicode": true}Mensagem transliterada
Exemplo de mensagem com transliteração de caracteres não GSM para uma SMS GSM pura (ver exemplo de resposta)
{ "text": "Nem todos os caracteres especiais estão incluídos no conjunto de caracteres GSM, ex. apenas o apóstrofe correto: Carro da Anna funciona, mas não a casa do Max. Acentos funcionam parcialmente: André, mas não todos: Háns. Hífens normais - funcionam, mas não os mais longos: –", "sender_id": "Test", "phone": "+14155552671", "is_unicode": false}Mensagem com exclusão de texto
Exemplo de SMS onde o texto da mensagem será excluído após a entrega por segurança/privacidade
{ "text": "Seu código de verificação é: 123456. Esta mensagem será excluída após a entrega.", "sender_id": "+491701234567", "phone": "+14155552671", "is_text_deleted": true}SMS com dados de callback
Exemplo de SMS com dados de callback para notificações de status de entrega e rastreamento personalizado
{ "text": "Seu pedido #12345 foi enviado e está a caminho!", "sender_id": "+491701234567", "phone": "+14155552671", "callback_data": "order_12345_shipping_notification"}Responses
Seção intitulada “ Responses ”Sms resource created
SMS
object
JSON-LD ID
JSON-LD type
The message text can have a length of up to 1530 characters. With a Unicode SMS, the maximum character length is reduced to 670 characters. Internal encoding is UTF-8.
Sender-ID of the message. Can be a number (up to 15 digits) or a text (up to 11 character). In case of a number please use preferentially E.164 phone number format. A sender of text may contain spaces but no other special characters. Please note that some countries do not support own sender IDs or do require pre-registration. Our system automatically tries to detect whether a sender ID is a text or a phone number. Avoid special characters in a number and enter it the same way as it would be dialed on a phone.
Para mensagens de voz (text2speech, text2speech_ssml): se sender_id não estiver em conformidade com o formato E.164 (por exemplo, sem o prefixo +, contendo caracteres não numéricos), a mensagem será enviada a partir do número padrão do sistema +493075435114. Alguns provedores de telefonia downstream podem substituir ou não respeitar o número de remetente definido pelo usuário — o identificador de chamada real apresentado ao destinatário depende das capacidades do provedor.
Recipient (international) number:
- +491701234567 (E.164)
- 00491701234567
- 491701234567
- 01701234567 (if the account is registered in Germany) will be convert to +491701234567
If the number is not in an E.164 format then the service will convert it based on user’s address. To avoid problems with the converting please use E.164 preferentially.
Timestamp de entrega programada
Status of the sms. For more info see SMS status codes
Timestamp when message was sent to the mobile network provider
Fonte ou origem da mensagem
Status of the SMS delivery from gateway
IP address of the host which sent request
Timestamp when the entity was added to the system by the user
True se a mensagem contém caracteres Unicode, False caso contrário
Unique entity UUID
Código do país
Idioma da mensagem de voz. Valores possíveis: null (detecção automática) ou um dos seguintes: EN (inglês), DE (alemão), FR (francês), IT (italiano), ES (espanhol), PL (polaco), NL (neerlandês), RO (romeno), PT (português), CS (checo), HU (húngaro), SV (sueco), DA (dinamarquês), FI (finlandês), SK (eslovaco), HR (croata), TR (turco), RU (russo), BG (búlgaro), UK (ucraniano).
Count of the SMS parts (concatenated messages)
Count of chars in the message text
String which will be send back to your endpoint. E.g. it can be usable to pass your system message id.
Bulk ID
Identificador da chave API
Código de serviço ou gateway
True se o texto da mensagem foi excluído, False caso contrário
Price
True - SMS was sent, False - SMS wasn’t sent yet
Link to all requests by a SMS list
Link to count of request by a short link
Número máximo de tentativas de entrega para serviços de voz (text2speech, text2speech_ssml). Valores permitidos: null, 1, 2 ou 3 para os serviços text2speech/text2speech_ssml; deve ser nulo para os restantes serviços.
Examples
Basic sms Message response
API response for a successfully request with minimum parameters
{ "@context": "/contexts/sms", "@id": "/sms/11111111-2222-3333-4444-555555555555", "@type": "sms", "text": "Hello! This is a test SMS message.", "sender_id": "+19388888025", "phone": "+14155552671", "delivery_at": 0, "status_code": 0, "gateway_sent_at": 0, "source": 0, "dlr_code": 0, "ip": "10.1.1.1", "created_at": 1755868416, "is_unicode": false, "uuid": "11111111-2222-3333-4444-555555555555", "iso2": "US", "voice_lang": null, "parts_count": 1, "chars_count": 34, "callback_data": null, "bulk_id": null, "key_id": 8291, "service_code": "direct", "is_text_deleted": false, "price": 0.056, "is_sent": false, "requests": "/sms/11111111-2222-3333-4444-555555555555/requests", "clicks": "/sms/11111111-2222-3333-4444-555555555555/clicks"}Transliterated message response
API response for a successfully sent transliterated SMS message
{ "@context": "/contexts/sms", "@id": "/sms/11111111-2222-3333-4444-555555555555", "@type": "sms", "text": "Nicht alle Sonderzeichen sind im GSM Zeichensatz enthalten, z.B. nur das richtige Apostroph: Anna's Auto geht, aber nicht Max's Haus. Akzente gehen teilweise: André, jedoch nicht alle: Hans. Normale Bindestriche - gehen, nicht allerdings längere: -", "sender_id": "Test", "phone": "+491701234567", "delivery_at": 0, "status_code": 100, "gateway_sent_at": 1755780931, "source": 0, "dlr_code": 16, "ip": "1.1.1.1", "created_at": 1755780931, "is_unicode": false, "uuid": "11111111-2222-3333-4444-555555555555", "iso2": "DE", "voice_lang": "DE", "parts_count": 2, "chars_count": 248, "callback_data": null, "bulk_id": null, "key_id": 200100, "service_code": "direct", "is_text_deleted": false, "price": 0.13, "is_sent": true, "requests": "/sms/11111111-2222-3333-4444-555555555555/requests", "clicks": "/sms/11111111-2222-3333-4444-555555555555/clicks"}Message with text deletion response
API response for a successfully sent SMS with text deletion enabled
{ "@context": "/contexts/sms", "@id": "/sms/11111111-2222-3333-4444-555555555555", "@type": "sms", "text": "", "sender_id": "USSender", "phone": "+14155552671", "delivery_at": 0, "status_code": 100, "gateway_sent_at": 1755783151, "source": 0, "dlr_code": 0, "ip": "10.1.1.1", "created_at": 1755783151, "is_unicode": false, "uuid": "11111111-2222-3333-4444-555555555555", "iso2": "US", "voice_lang": null, "parts_count": 1, "chars_count": 79, "callback_data": null, "bulk_id": null, "key_id": 8207, "service_code": "direct", "is_text_deleted": true, "price": 0.07, "is_sent": true, "requests": "/sms/11111111-2222-3333-4444-555555555555/requests", "clicks": "/sms/11111111-2222-3333-4444-555555555555/clicks"}SMS
object
The message text can have a length of up to 1530 characters. With a Unicode SMS, the maximum character length is reduced to 670 characters. Internal encoding is UTF-8.
Sender-ID of the message. Can be a number (up to 15 digits) or a text (up to 11 character). In case of a number please use preferentially E.164 phone number format. A sender of text may contain spaces but no other special characters. Please note that some countries do not support own sender IDs or do require pre-registration. Our system automatically tries to detect whether a sender ID is a text or a phone number. Avoid special characters in a number and enter it the same way as it would be dialed on a phone.
Para mensagens de voz (text2speech, text2speech_ssml): se sender_id não estiver em conformidade com o formato E.164 (por exemplo, sem o prefixo +, contendo caracteres não numéricos), a mensagem será enviada a partir do número padrão do sistema +493075435114. Alguns provedores de telefonia downstream podem substituir ou não respeitar o número de remetente definido pelo usuário — o identificador de chamada real apresentado ao destinatário depende das capacidades do provedor.
Recipient (international) number:
- +491701234567 (E.164)
- 00491701234567
- 491701234567
- 01701234567 (if the account is registered in Germany) will be convert to +491701234567
If the number is not in an E.164 format then the service will convert it based on user’s address. To avoid problems with the converting please use E.164 preferentially.
Timestamp de entrega programada
Status of the sms. For more info see SMS status codes
Timestamp when message was sent to the mobile network provider
Fonte ou origem da mensagem
Status of the SMS delivery from gateway
IP address of the host which sent request
Timestamp when the entity was added to the system by the user
True se a mensagem contém caracteres Unicode, False caso contrário
Unique entity UUID
Código do país
Idioma da mensagem de voz. Valores possíveis: null (detecção automática) ou um dos seguintes: EN (inglês), DE (alemão), FR (francês), IT (italiano), ES (espanhol), PL (polaco), NL (neerlandês), RO (romeno), PT (português), CS (checo), HU (húngaro), SV (sueco), DA (dinamarquês), FI (finlandês), SK (eslovaco), HR (croata), TR (turco), RU (russo), BG (búlgaro), UK (ucraniano).
Count of the SMS parts (concatenated messages)
Count of chars in the message text
String which will be send back to your endpoint. E.g. it can be usable to pass your system message id.
Bulk ID
Identificador da chave API
Código de serviço ou gateway
True se o texto da mensagem foi excluído, False caso contrário
Price
True - SMS was sent, False - SMS wasn’t sent yet
Link to all requests by a SMS list
Link to count of request by a short link
Número máximo de tentativas de entrega para serviços de voz (text2speech, text2speech_ssml). Valores permitidos: null, 1, 2 ou 3 para os serviços text2speech/text2speech_ssml; deve ser nulo para os restantes serviços.
Examples
Basic sms Message response
API response for a successfully request with minimum parameters
{ "text": "Hello! This is a test SMS message.", "sender_id": "+19388888025", "phone": "+14155552671", "delivery_at": 0, "status_code": 0, "gateway_sent_at": 0, "source": 0, "dlr_code": 0, "ip": "10.1.1.1", "created_at": 1755868416, "is_unicode": false, "uuid": "11111111-2222-3333-4444-555555555555", "iso2": "US", "voice_lang": null, "parts_count": 1, "chars_count": 34, "callback_data": null, "bulk_id": null, "key_id": 8291, "service_code": "direct", "is_text_deleted": false, "price": 0.056, "is_sent": false, "requests": "/sms/11111111-2222-3333-4444-555555555555/requests", "clicks": "/sms/11111111-2222-3333-4444-555555555555/clicks"}Respuesta de mensagem transliterada
Resposta da API para uma mensagem SMS transliterada enviada com sucesso
{ "text": "Nicht alle Sonderzeichen sind im GSM Zeichensatz enthalten, z.B. nur das richtige Apostroph: Anna's Auto geht, aber nicht Max's Haus. Akzente gehen teilweise: André, jedoch nicht alle: Hans. Normale Bindestriche - gehen, nicht allerdings längere: -", "sender_id": "Test", "phone": "+491701234567", "delivery_at": 0, "status_code": 100, "gateway_sent_at": 1755780931, "source": 0, "dlr_code": 16, "ip": "1.1.1.1", "created_at": 1755780931, "is_unicode": false, "uuid": "11111111-2222-3333-4444-555555555555", "iso2": "DE", "voice_lang": "DE", "parts_count": 2, "chars_count": 248, "callback_data": null, "bulk_id": null, "key_id": 200100, "service_code": "direct", "is_text_deleted": false, "price": 0.13, "is_sent": true, "requests": "/sms/11111111-2222-3333-4444-555555555555/requests", "clicks": "/sms/11111111-2222-3333-4444-555555555555/clicks"}Resposta de mensagem com exclusão de texto
Resposta da API para um SMS enviado com sucesso com exclusão de texto ativada
{ "text": "", "sender_id": "USSender", "phone": "+14155552671", "delivery_at": 0, "status_code": 100, "gateway_sent_at": 1755783151, "source": 0, "dlr_code": 0, "ip": "10.1.1.1", "created_at": 1755783151, "is_unicode": false, "uuid": "11111111-2222-3333-4444-555555555555", "iso2": "US", "voice_lang": null, "parts_count": 1, "chars_count": 79, "callback_data": null, "bulk_id": null, "key_id": 8207, "service_code": "direct", "is_text_deleted": true, "price": 0.07, "is_sent": true, "requests": "/sms/11111111-2222-3333-4444-555555555555/requests", "clicks": "/sms/11111111-2222-3333-4444-555555555555/clicks"}Invalid input
Client ID or API key isn’t active or invalid!
There are not enough funds on your account!
Account isn’t activated. Please wait or contact to support!
The request was well-formed but was unable to be followed due to semantic errors
O endereço IP foi bloqueado temporariamente, pois durante um curto período de tempo foram enviadas várias solicitações com credenciais inválidas. Aguarde e tente mais tarde.
Code Samples
#!/usr/bin/env bashcurl -X POST https://api.lox24.eu/sms \ -H 'Content-Type: application/json' \ -H 'X-LOX24-AUTH-TOKEN: 1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx' \ -d '{ "sender_id": "My Sender", "phone": "+49751234567", "source": 111, "service_code": "direct", "text": "Test message", "delivery_at": 1573724611, "is_unicode": true, "callback_data": "123456", "voice_lang": "DE"}'using Newtonsoft.Json;using Newtonsoft.Json.Linq;using System;using System.IO;using System.Net;using System.Text;
namespace Lox24.Api{ class client { static void Main() { string key = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"; string url = "https://api.lox24.eu/sms";
var data = new { sender_id = "My Sender", text = "Test message", service_code = "direct", phone = "+49751234567", delivery_at = 1573724611, is_unicode = true, callback_data = "123456", voice_lang = "DE" };
string postdata = JsonConvert.SerializeObject(data);
Console.WriteLine("Post data: {0}", postdata);
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ReadWriteTimeout = 100000; httpWebRequest.ContentType = "application/json; charset=utf-8"; httpWebRequest.Accept = "application/json"; // or application/ld+json httpWebRequest.Method = "POST"; httpWebRequest.KeepAlive = true; httpWebRequest.Headers.Add("X-LOX24-AUTH-TOKEN", key); httpWebRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(postdata); streamWriter.Flush(); streamWriter.Close(); } try { using (HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse()) {
if(resp.StatusCode == HttpStatusCode.Created) { Console.WriteLine("Success:{0} {1}", (int)resp.StatusCode, "sms resource created"); } else { Console.WriteLine("Error: wrong response code {0} on create sms", (int)resp.StatusCode); }
Stream respStream = resp.GetResponseStream(); using (StreamReader sr = new StreamReader(respStream, Encoding.UTF8)) { string responseText = sr.ReadToEnd(); Console.WriteLine("responseText : {0}", responseText); } }
} catch (System.Net.WebException ex) { var webResponse = ex.Response as System.Net.HttpWebResponse; Console.WriteLine("Error:{0}", webResponse.StatusCode);
switch (webResponse.StatusCode) { case HttpStatusCode.BadRequest: // 400 Console.WriteLine("Error:400 Invalid input"); break; case HttpStatusCode.Unauthorized: // 401 Console.WriteLine("Error:401 Client ID or API key isn't active or invalid!"); break; case HttpStatusCode.PaymentRequired: // 402 Console.WriteLine("Error:402 There are not enough funds on your account!"); break; case HttpStatusCode.Forbidden: // 403 Console.WriteLine("Error:403 Account isn't activated. Please wait or contact to support!"); break; case HttpStatusCode.NotFound: // 404 Console.WriteLine("Error:404 Resource not found"); break; case HttpStatusCode.InternalServerError: // 500 case HttpStatusCode.BadGateway: //502 case HttpStatusCode.ServiceUnavailable: // 503 case HttpStatusCode.GatewayTimeout: // 504 Console.WriteLine("System error! Please contact to LOX24 support!"); break; } } } }package main
import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http")
func main() {
const Method = "POST" const URL = "https://api.lox24.eu/sms" const Token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"
payload := map[string]interface{}{ "sender_id": "My Sender", "phone": "+49751234567", "source": 111, "service_code": "direct", "text": "Test message", "delivery_at": 1593724611, "is_unicode": true, "callback_data": "123456", "voice_lang": "DE", }
jsonPayload, _ := json.Marshal(payload)
client := &http.Client{}
req, err := http.NewRequest(Method, URL, bytes.NewBuffer(jsonPayload)) if err != nil { log.Fatal(err) }
req.Header.Add("X-LOX24-AUTH-TOKEN", Token) req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req) if err != nil { log.Fatal(err) }
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body) if err != nil { log.Fatal(err) }
switch res.StatusCode { case 201: fmt.Println((string(body))) case 400: fmt.Println("Error: code = 400 - Invalid input") case 401: fmt.Println("Error: code = 401 - Client ID or API key isn't active or invalid!") case 403: fmt.Println("Error: code = 403 - Account isn't activated. Please wait or contact to support!") default: fmt.Printf("Error: code = %d\n", res.StatusCode) }}package eu.lox24.doc.sms;
import org.json.JSONObject;
import java.io.IOException;import java.net.HttpURLConnection;import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.time.Duration;
public class PostSmsCollection {
public static void main(String[] args) {
var key = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"; var url = "https://api.lox24.eu/sms";
var json = new JSONObject(); json.put("sender_id", "My Sender"); json.put("text", "Test message"); json.put("service_code", "direct"); json.put("phone", "+49751234567"); json.put("delivery_at", 1573724611); json.put("is_unicode", true); json.put("callback_data", "123456"); json.put("voice_lang", "DE");
var postData = json.toString();
System.out.println("Post data: " + postData);
var httpRequest = HttpRequest.newBuilder(URI.create(url)) .timeout(Duration.ofMillis(100000)) .setHeader("Content-Type", "application/json; charset=utf-8") .setHeader("Accept", "application/json") // or application/ld+json .setHeader("X-LOX24-AUTH-TOKEN", key) .POST(HttpRequest.BodyPublishers.ofString(postData)) .build();
var client = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_1_1) // Http 1.1 clients are kept alive be default .build();
try { var httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
if (httpResponse.statusCode() == HttpURLConnection.HTTP_CREATED) { System.out.println("Success:" + httpResponse.statusCode() + " " + "sms resource created"); System.out.println("Response text : \n" + httpResponse.body());
} else {
System.out.println("Error: wrong response code " + httpResponse.statusCode() + " on create sms");
switch (httpResponse.statusCode()) {
case HttpURLConnection.HTTP_BAD_REQUEST: // 400 System.out.println("Error:400 Invalid input"); break; case HttpURLConnection.HTTP_UNAUTHORIZED: // 401 System.out.println("Error:401 Client ID or API key isn't active or invalid!"); break; case HttpURLConnection.HTTP_PAYMENT_REQUIRED: // 402 System.out.println("Error:402 There are not enough funds on your account!"); break; case HttpURLConnection.HTTP_FORBIDDEN: // 403 System.out.println("Error:403 Account isn't activated. Please wait or contact to support!"); break; case HttpURLConnection.HTTP_INTERNAL_ERROR: // 500 case HttpURLConnection.HTTP_BAD_GATEWAY: //502 case HttpURLConnection.HTTP_UNAVAILABLE: // 503 case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: // 504 System.out.println("System error! Please contact to LOX24 support!"); break; }
}
} catch (IOException | InterruptedException e) { e.printStackTrace(); } }}/* * Post sms */const token = "7b7c6063bab885ce79814b5ff1ee6885";
var postObj = { sender_id: 'My Sender', text: 'Test message', service_code: 'direct', phone: '+49751234567', delivery_at: 1573724611, is_unicode: true, callback_data: "123456", voice_lang: "DE"};
var postdata = JSON.stringify(postObj);
const https = require('https');const options = { hostname: 'api.lox24.eu', path: '/sms', method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Content-Length': postdata.length, 'X-LOX24-AUTH-TOKEN': token }}
const req = https.request(options, res => { if (res.statusCode == 201) { console.log("Success: code = 201 - sms resource created"); res.on('data', d => { process.stdout.write(d) }) } else if (res.statusCode == 400) console.log("Error: code = 400 - Invalid input"); else if (res.statusCode == 401) console.log("Error: code = 401 - Client ID or API key isn't active or invalid!"); else if (res.statusCode == 402) console.log("Error: code = 402 - There are not enough funds on your account!"); else if (res.statusCode == 403) console.log("Error: code = 403 - Account isn't activated. Please wait or contact to support!");})
req.on('error', error => { console.error(error)})req.write(postdata);req.end();<?php
$uri = 'https://api.lox24.eu/sms';
$token = '1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx';
$body = [ 'sender_id' => 'My Sender', 'text' => "First line\nSecond line", 'service_code' => 'direct', 'phone' => '+49751234567', 'delivery_at' => 1573724611, 'is_unicode' => true, 'callback_data' => '123456', 'voice_lang' => 'DE',];
if(!$body = json_encode($body)) { die('JSON encoding error!');}
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_POST => true, CURLOPT_URL => $uri, CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => [ "X-LOX24-AUTH-TOKEN: {$token}", 'Accept: application/json', // or application/ld+json 'Content-Type: application/json', ], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,]);
$response = curl_exec($curl);$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);curl_close($curl);
$data = json_decode($response, JSON_OBJECT_AS_ARRAY);
if(201 === $code) { echo 'Success: response data = ' . var_export($data, true);} else { echo "Error: code = {$code}, data = " . var_export($data, true);}import jsonimport requests
token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"
url = 'https://api.lox24.eu/sms'
data = { 'sender_id': "My Sender", 'text' : "Test message", 'service_code' : "direct", 'phone': "+49751234567", 'delivery_at': 1573724611, 'is_unicode': True, 'callback_data' => '123456', 'voice_lang' => 'DE'}
headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-LOX24-AUTH-TOKEN': token,}
print("Post data : ", json.dumps(data, indent=4))
try: # timeout is 100 seconds, the payload is automatically converted to json format res = requests.post(url, headers=headers, json=data, timeout=100) if res.status_code != 201: # Created print("Error: Wrong response code on create sms") res.raise_for_status() else: print(f'Success: code = {res.status_code} - sms resource created') print("Response: ", json.dumps(res.json(), indent=4))
except requests.HTTPError: if res.status_code == 400: print("Error:400 Invalid input") elif res.status_code == 401: print("Error: code = 401 - Client ID or API key isn't active or invalid!") elif res.status_code == 402: print("Error:402 There are not enough funds on your account!") elif res.status_code == 403: print("Error: code = 403 - Account isn't activated. Please wait or contact to support!") elif res.status_code == 404: print("Error:404 Resource not found") elif res.status_code in (500, 502, 503, 504): print("System error! Please contact to LOX24 support!") else: print(f"Error: code {res.status_code}") print(json.dumps(res.json(), indent=4))