Create a Single Letter
This request will create a letter and perform a mail merge to put the address and any variable data in place. You can specify a template or provide the content directly.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/letters/create?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
request.AddParameter("test", "1");
request.AddParameter("file", "https://www.stannp.com/assets/samples/letter-heading.pdf");
request.AddParameter("recipient[title]", "Mr");
request.AddParameter("recipient[firstname]", "John");
request.AddParameter("recipient[lastname]", "Doe");
request.AddParameter("recipient[address1]", "1234 Maple Street");
request.AddParameter("recipient[address2]", "Apt 101");
request.AddParameter("recipient[town]", "Toronto");
request.AddParameter("recipient[zipcode]", "M5G 1X8");
request.AddParameter("recipient[country]", "CA");
request.AddParameter("tags", "used.for.reporting");
request.AddParameter("addons", "first_class");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "success": true, "data": { "pdf": "https:\/\/www.stannp.com\/assets\/samples\/letter-sample-ca.pdf", "id": "1", "created": "2022-12-15T10:30:00+00:00", "format": "us-letter", "cost": "0.80", "status": "test" } }
Post a Letter (Already Mail Merged)
Post a single letter that already has an address on the PDF file. Use this endpoint if you have already mail-merged your letter and it meets our design guidelines.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/letters/post?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
request.AddParameter("test", "1");
request.AddParameter("country", "CA");
request.AddParameter("pdf", "https://www.stannp.com/assets/samples/letter-sample-ca.pdf");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "success": true, "data": { "pdf": "https:\/\/www.stannp.com\/assets\/samples\/letter-sample-ca-response.pdf", "id": "2", "created": "2022-12-15T11:00:00+00:00", "format": "letter", "cost": "0.85", "status": "test" } }
Get a Single Letter
Obtain the mailpiece object for the letter ID specified.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/letters/get/:id?api_key={API_KEY}");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "success": true, "data": { "id": "16818220", "timestamp": "2022-12-15 12:30:00", "status": "delivered", "type": "letter", "format": "A4", "pdf_file": "https:\/\/dash.stannp.com\/api\/v1\/storage\/get\/port\/16818220\/pdfs\/sample-letter-ca.pdf", "country": "CA", "cost": "0.00" } }
Cancel a Letter
Cancel a letter if it has not started processing yet.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/letters/cancel?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
request.AddParameter("id", "12345");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "success": true }