Create a single postcard
This request will create a postcard and perform a mail merge to put the address and any variable data in place.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/postcards/create?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
request.AddParameter("test", "true");
request.AddParameter("size", "A6");
request.AddParameter("front", "https://www.stannp.com/assets/samples/a6-postcard-front.webp");
request.AddParameter("back", "https://www.stannp.com/assets/samples/signature-example.webp");
request.AddParameter("message", "hello world");
request.AddParameter("recipient[title]", "Mr");
request.AddParameter("recipient[firstname]", "John");
request.AddParameter("recipient[lastname]", "Smith");
request.AddParameter("recipient[address1]", "123 Sample Street");
request.AddParameter("recipient[city]", "Sampletown");
request.AddParameter("recipient[postcode]", "AB12 3CD");
request.AddParameter("recipient[country]", "GB");
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\/a6-postcard-sample.pdf", "id": "0", "created": "2020-12-17T15:42:22+00:00", "format": "A6", "cost": "0.78", "status": "test" } }
Get a single postcard
Obtain the mailpiece object for the postcard id specified.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/postcards/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": "16818211", "timestamp": "2019-10-30 00:14:04", "status": "cancelled", "type": "postcard", "format": "A6", "pdf_file": "https:\/\/dash.stannp.com\/api\/v1\/storage\/get\/port\/1550016843\/pdfs\/sample.pdf", "dispatched": null, "country": "GB", "cost": "0.00", "addons": "", "tags": "", "postcode": "AB12 3CD", "address": "123 Sample Street" } }
Cancel a postcard
You can cancel a postcard if we haven't started processing it yet.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/postcards/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 }