Pingen’s powerful, fully scalable Letter API enables your software solution to send letters via Swiss Post. Our SDKs allow for fast, easy integration.
Pingen’s Post API enables easy software integrations to automatically send letters via Swiss Post and DHL.
We’re passionate about helping you automate processes. That’s why we provide our API to all customers free of charge.
Send letters via Swiss Post in record time with our SDKs for PHP, Java, C#, and .Net.
Pingen supports ISR, ISR+, red payment slips, and QR-bill (Switzerland) as well as SEPA (Germany) and SEPA (Austria).
All of Pingen’s features are also available via our Post API and explained in detail in our documentation.
Pingen provides detailed status information and real time progress updates for each letter submitted via API.
By reselling postal letters, integrators can unlock an exciting, new opportunity to generate additional revenue.
Sending letters via Pingen’s Post API is as easy as sending a standard email. Our API is digital and fully scalable.
Pingen’s Letter API is designed to be flexible and straightforward, making it easy to integrate in no time. In addition to the user-friendly documentation, we also provide code examples to help you get started in no time.
$sToken = ''; //Add your private token here
$sFile = realpath('/path/to/your/file.pdf');
//set URL
$sURL = 'https://api.pingen.com/document/upload/token/' . $sToken;
//build our query data
$aData = array(
'data' => json_encode(array(
'send' => true, //we want to automatically send it
'speed' => 1, //we want to send priority
'color' => 1, //and in color
)),
'file' => '@' . $sFile
);
//set the url, number of POST vars, POST data
$objCurlConn = curl_init();
curl_setopt($objCurlConn,CURLOPT_URL,$sURL);
curl_setopt($objCurlConn,CURLOPT_POST,1);
curl_setopt($objCurlConn,CURLOPT_POSTFIELDS,$aData);
curl_setopt($objCurlConn, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($objCurlConn, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($objCurlConn, CURLOPT_SSL_VERIFYPEER, 0);
//execute post
$sResult = curl_exec($objCurlConn);
// decode result and pass from here on
$aResult = json_decode($sResult, true);
if ($aResult['error']==true)
{
//an error occurred, handle it from here
}else {
//go along with your code here
}
HttpClient httpClient = new DefaultHttpClient();
try {
HttpPost request = new HttpPost("https://api.pingen.com/document/send/id/30/token/MYTOKEN");
JSONObject j = new JSONObject();
j.put("speed", "1");
j.put("color", "1");
List<namevaluepair> nameValuePairs = new ArrayList<namevaluepair>(1);
nameValuePairs.add(new BasicNameValuePair("data", j.toString()));
UrlEncodedFormEntity params = new UrlEncodedFormEntity(nameValuePairs);
request.addHeader("content-type", "application/x-www-form-urlencoded");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
// handle response here...
} catch (Exception ex) {
// handle exception here
} finally {
httpClient.getConnectionManager().shutdown();
}
</namevaluepair></namevaluepair>
using (WebClient client = new WebClient()) {
string jsonRequest = new JavaScriptSerializer().Serialize(new { speed = 1, color = 1 });
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string jsonResponse = string.Empty;
try {
jsonResponse = client.UploadString("https://api.pingen.com/document/send/id/30/token/MYTOKEN", jsonRequest);
// parse json and handle it
} catch (Exception e) {
WebException we = e as WebException;
if (we != null && we.Response != null) {
var res = we.Response.GetResponseStream();
if (res != null) jsonResponse = new StreamReader(res).ReadToEnd();
}
// parse json (if available) and handle error
}
}
public SendDocToPingenResponse SendDocToPingen(string pathToPdf, bool sendViaPost = false) {
if (string.IsNullOrEmpty(pathToPdf)) throw new ArgumentException("pathToPdf");
if(!File.Exists(pathToPdf)) throw new ArgumentException(pathToPdf + "does not exist.");
byte[] rawdata = File.ReadAllBytes(pathToPdf);
string filename = Path.GetFileName(pathToPdf);
var body = new {
send = sendViaPost,
speed = 1,
color = 0,
duplex = 0,
rightaddress = 0,
envelope = 0
};
var jsonBody = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(body);
SendDocToPingenResponse result = null;
using (HttpClient client = new HttpClient()) {
var content = new MultipartFormDataContent() { };
content.Add(new StringContent(jsonBody), "data");
content.Add(new ByteArrayContent(rawdata), "file", filename);
string uri = $"https://api.pingen.com/document/upload/token/15.......";
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
try {
var resultObject = client.PostAsync(uri, content).Result;
var resultJson = resultObject.Content.ReadAsStringAsync().Result;
result = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<senddoctopingenresponse>(resultJson);
}
catch (Exception ex) {
/// somethign went wrong
}
return result;
}
}
public class SendDocToPingenResponse {
public bool error {
get;
set;
}
public int errorcode {
get;
set;
}
public string errormessage {
get;
set;
}
public int id {
get;
set;
}
}
</senddoctopingenresponse>
The Pingen PHP Library offers everything you need to integrate our API and send letters via Swiss Post. Pingen has already done the work for all PHP developers. Coming soon, we’ll release our SDKs for all other developers as well. 🚀
Our Post API offers much more than the classic API used by lettershops or mail service providers. With Pingen, you gain access to a fast-growing and international service that helps you send letters globally for the best price.
Already today, letters are being printed and sent locally in Switzerland, Germany, Austria, Holland and India.
Through our partnership with DHL, Pingen guarantees fast and reliable delivery to all other countries via air mail.
Pingen scales easily and is fail-safe due to our cloud and multi-site letter printing infrastructure.
With Pingen, you can also send letters via email, S3, Dropbox, Google Drive, OneDrive, or directly from services such as Odoo, ServiceNow, and more.
Thanks to our international presence and partnership with the Swiss Post, Pingen offers the fastest delivery at the most attractive prices.
Pingen offers a wide range of practical and innovative features for sending letters efficiently – locally and internationally!
Take a look at our Post API’s documentation and see how easy it is to integrate postal letters via Swiss Post into your software solution!