Cancel the Bulk processing
PUT /bulks/{id}/cancel
Cancel Bulk’s processing if it has status_code = 0 (New) or status_code = 5 and related to the Bulk messages with is_sent = False
Authorizations
Section titled “Authorizations ”Code Samples
Section titled “ Code Samples ”#!/usr/bin/env bashcurl -X PUT https://api.lox24.eu/bulks/da0fa78c-4699-11ea-a637-96000028b339/cancel \ -H 'X-LOX24-AUTH-TOKEN: 1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx'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 id = "984af866-902e-11ea-aa81-96000028b339"; string url = "https://api.lox24.eu/bulks/" + id + "/cancel";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ReadWriteTimeout = 100000; //this can cause issues which is why we are manually setting this httpWebRequest.Accept = "application/json"; httpWebRequest.Method = "PUT"; //httpWebRequest.KeepAlive = true; httpWebRequest.Headers.Add("X-LOX24-AUTH-TOKEN", key); httpWebRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
try { using (HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse()) { if(resp.StatusCode == HttpStatusCode.OK) { Console.WriteLine("Success: bulk {0} was canceled!", id); } else { Console.WriteLine("Error: bulk {0} wasn't canceled, code = {0}", (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.Unauthorized: // 401 Console.WriteLine("Error:401 Client ID or API key isn't active or invalid!"); 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 ( "fmt" "io/ioutil" "log" "net/http")
func main() {
const Method = "PUT" const URL = "https://api.lox24.eu/bulks/52a84594-9a7b-11ea-b2e9-b8ca3a65338c/cancel" const Token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"
client := &http.Client{}
req, err := http.NewRequest(Method, URL, nil) if err != nil { log.Fatal(err) }
req.Header.Add("X-LOX24-AUTH-TOKEN", Token) req.Header.Add("Accept", "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 200: fmt.Println((string(body))) 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!") case 404: fmt.Println("Error: code = 404 - Resource not found") default: fmt.Printf("Error: code = %d\n", res.StatusCode) }}package eu.lox24.doc.bulks;
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 PutCancelBulksItem {
public static void main(String[] args) {
var key = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"; var id = "343c785b-8567-11ea-aa81-96000028b339"; var url = "https://api.lox24.eu/bulks/" + id + "/cancel";
var httpRequest = HttpRequest.newBuilder(URI.create(url)) .timeout(Duration.ofMillis(100000)) .setHeader("Accept", "application/json") // or application/ld+json .setHeader("X-LOX24-AUTH-TOKEN", key) .PUT(HttpRequest.BodyPublishers.noBody()) .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_OK) { System.out.println("Success:" + httpResponse.statusCode() + " " + "bulks resource updated");
JSONObject parsed = new JSONObject(httpResponse.body());
parsed.keys().forEachRemaining(jsonKey -> System.out.println(jsonKey + ":" + parsed.get(jsonKey))); } else {
System.out.println("Error: wrong response code " + httpResponse.statusCode() + " on update bulks");
switch (httpResponse.statusCode()) { case HttpURLConnection.HTTP_UNAUTHORIZED: // 401 System.out.println("Error:401 Client ID or API key isn't active or invalid!"); 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_NOT_FOUND: // 404 System.out.println("Error:404 Resource not found"); 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(); } }}const host = 'api.lox24.eu';const token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx";
var id = '4897749e-982d-11ea-aa81-96000028b339';
const https = require('https');const options = { hostname: host, path: '/bulks/' + id + '/cancel', method: 'PUT', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-LOX24-AUTH-TOKEN': token }}
const req = https.request(options, res => { if (res.statusCode == 200) { console.log("Success: code = 204 - bulks resource processing canceled"); res.on('data', d => { process.stdout.write(d) }) } else if (res.statusCode == 401) { console.log("Error: code = 401 - Client ID or API key isn't active or invalid!"); } else if (res.statusCode == 403) { console.log("Error: code = 403 - Account isn't activated. Please wait or contact to support!"); } else if (res.statusCode == 404) { console.log("Error: code = 404 - Resource not found"); } else { console.log("Error: code = " + res.statusCode ); }})
req.on('error', error => { console.error(error)})
req.end();<?php
$token = '1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx';
$id = '11111111-2222-3333-4444-55555555555';$uri = 'https://api.lox24.eu/bulks/' . $id . '/cancel';
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => $uri, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_HTTPHEADER => [ "X-LOX24-AUTH-TOKEN: {$token}", 'Accept: application/json', // or application/ld+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(200 === $code) { echo "Bulk with id = {$id} was canceled: " . var_export($data, true);} elseif(404 === $code) { echo "Bulk with id = {$id} not found!";} else { echo "Error: code = {$code}, data = " . var_export($data, true);}import jsonimport requests
token = "1234567:e3f3a759b6677959b6ebfcxxxxxxxxxx"
bulk_id = "343c785b-8567-11ea-aa81-96000028b339"
url = f'https://api.lox24.eu/bulks/{bulk_id}/cancel'
headers = { 'Accept': 'application/json', # or application/ld+json 'X-LOX24-AUTH-TOKEN': token,}
try: # timeout is 100 seconds res = requests.put(url, headers=headers, timeout=100) if res.status_code != 200: # Ok res.raise_for_status() else: print(f'Success: code = {res.status_code} - bullks resource updated') 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 == 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(res.text) print(json.dumps(res.json(), indent=4))Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Unique entity UUID
Bulk ID
Responses
Section titled “ Responses ”Bulks resource updated
object
JSON-LD ID
JSON-LD type
Unique entity UUID
Scheduled delivery timestamp
Bulk’s status:
0- new and not processed5- bulks in progress10- bulks was successfully processed15- bulk’s processing was canceled by the user20- system error201- error: no recipients found
Count of the messages created by the bulk
Unique entity UUID
Timestamp of last changes
IP address of the host which sent request
Example
192.168.1.1True if message contains Unicode characters, False otherwise
Type of the bulk ‘dryrun’ or not
Service or gateway code
API key identifier
Message source or origin
Voice message language. Possible values: null (auto-detection) or one of: EN (English), DE (German), FR (French), IT (Italian), ES (Spanish), PL (Polish), NL (Dutch), RO (Romanian), PT (Portuguese), CS (Czech), HU (Hungarian), SV (Swedish), DA (Danish), FI (Finnish), SK (Slovak), HR (Croatian), TR (Turkish), RU (Russian), BG (Bulgarian), UK (Ukrainian).
True if message text was deleted, False otherwise
Cost of the messages created by the bulk
object
Unique entity UUID
Scheduled delivery timestamp
Bulk’s status:
0- new and not processed5- bulks in progress10- bulks was successfully processed15- bulk’s processing was canceled by the user20- system error201- error: no recipients found
Count of the messages created by the bulk
Unique entity UUID
Timestamp of last changes
IP address of the host which sent request
Example
192.168.1.1True if message contains Unicode characters, False otherwise
Type of the bulk ‘dryrun’ or not
Service or gateway code
API key identifier
Message source or origin
Voice message language. Possible values: null (auto-detection) or one of: EN (English), DE (German), FR (French), IT (Italian), ES (Spanish), PL (Polish), NL (Dutch), RO (Romanian), PT (Portuguese), CS (Czech), HU (Hungarian), SV (Swedish), DA (Danish), FI (Finnish), SK (Slovak), HR (Croatian), TR (Turkish), RU (Russian), BG (Bulgarian), UK (Ukrainian).
True if message text was deleted, False otherwise
Cost of the messages created by the bulk
Invalid input
Client ID or API key isn’t active or invalid!
Account isn’t activated. Please wait or contact to support!
Resource not found
The request was well-formed but was unable to be followed due to semantic errors
IP address was temporary blocked, because during short time from it was sent many request with invalid credentials. Please wait and try later.