Create a single postcard


https://dash.stannp.com/api/v1/postcards/create

Parameters

size mandatory Either "A5", "A6" or "A5-ENV".
Download our A6 design guide.
Download our A5 design guide.
Download our enveloped A5 design guide.
test optional If test is set to true then a sample PDF file will be produced but the item will never be dispatched and no charge will be taken.
template optional An ID of a template already set up on the platform. Otherwise use front and back parameters.
recipient mandatory Either an ID of an existing recipient or a new recipient array.
eg: recipient[title], recipient[company], recipient[firstname], recipient[lastname], recipient[address1], recipient[address2], recipient[town], recipient[postcode], recipient[country] and recipient[*] to use any custom data.
front optional An image for the front. This can be either a URL, a file or a base64 encoded string. This must be supplied if a template is not being used. Supported file types are JPG or PDF.
back optional An image for the back. This can be either a URL, a file or a base64 encoded string. Supported file types are JPG or PDF.
message optional A message on the back of the card. If using a back image this message will be overlaid on top
signature optional An image which will be placed in the signature location. The image can be either a URL or a file or a base64 encoded string. This must be a JPG file with a 768 x 118 pixels resolution
padding optional A white border is added to the front of the postcard by default. You can set padding = 0 to remove the border if you want an edge to edge design.
post_unverified optional Default is true. If set to false then we will not post the item if the recipient address could not be verified.
addons optional Use addon codes to upgrade your postcard. eg:
STOCK_350_UNCOATED to upgrade your paper stock to a thicker premium stock. Custom codes can be requested for bespoke postcards.
tags optional Comma separated tags which are for your reference which you can search by in reporting.
Request
$ curl https://dash.stannp.com/api/v1/postcards/create \
-u {API_KEY}: \
-d "size=A6" \
-d "test=true" \
-d "front=https://www.stannp.com/assets/samples/a6-postcard-front.jpg" \
-d "message=hello world" \
-d "signature=https://www.stannp.com/assets/samples/signature-example.jpg" \
-d "recipient[title]=Mr" \
-d "recipient[firstname]=John" \
-d "recipient[lastname]=Smith" \
-d "recipient[address1]=123 Sample Street" \
-d "recipient[address2]=Sampleland" \
-d "recipient[town]=Sampletown" \
-d "recipient[postcode]=AB12 3CD" \
-d "recipient[country]=GB"
define("API_KEY","YOUR API KEY");
$postdata = http_build_query(
  array(
  	'test' => "true",
  	'size' => "A6",
  	'front' => "https://www.stannp.com/assets/samples/a6-postcard-front.jpg",
  	'message' => "hello world",
        'signature' => "https://www.stannp.com/assets/samples/signature-example.jpg",
  	'recipient[title]' => "John",   
  	'recipient[firstname]' => "John",
  	'recipient[lastname]' => "Smith",
  	'recipient[address1]' => "Unit 1 Willow Tree Court",
  	'recipient[address2]' => "Roundswell Business Park",
  	'recipient[city]' => "Barnstaple",
  	'recipient[postcode]' => "EX31 3TD",
  	'recipient[country]' => "GB"
  )
);
$opts = array('http' => array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$result = file_get_contents("https://dash.stannp.com/api/v1/postcards/create?api_key=".API_KEY, false, $context);
$response = json_decode($result,true);
print_r($response);
Response
{
   "success":true,
   "data":{
      "pdf":"https://www.stannp.com/assets/samples/a6-postcard-sample.pdf"
   }
}

Get a single postcard


https://dash.stannp.com/api/v1/postcards/get/:id
Request
$ curl https://dash.stannp.com/api/v1/postcards/get/16818210?api_key={API_KEY}
{
   "success":true,
   "data":
   {
        "id": "16818210",
        "timestamp": "2019-02-13 00:14:04",
        "status": "cancelled",
        "type": "postcard",
        "format": "A5",
        "pdf_file": "https://dash.stannp.com/api/v1/storage/get/port/1550016843/pdfs/15500168437775c63614bd88b1-d26cc45469-A5-K5aZSp.pdf",
        "dispatched": null,
        "country": "GB",
        "cost": "0.00",
        "insert_pdf": null,
        "insert_size": null,
        "addons": "",
        "tags": "",
        "postcode": "EX31 1JZ",
        "address": "Unit 12 Taw Trade Park"
   }
}

Cancel a postcard

You can cancel a postcard if we havn't started processing it yet.

https://dash.stannp.com/api/v1/postcards/cancel

Parameters

id mandatory The id of the mailpiece item.
Request
$ curl https://dash.stannp.com/api/v1/postcards/cancel \
-u {API_KEY}: \
-d "id=12345"
define("API_KEY","YOUR API KEY");
$postdata = http_build_query(
array(
  'id' => "12345"
)
);
$opts = array('http' => array(
'method'  => 'POST',
'header'  => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context  = stream_context_create($opts);
$result = file_get_contents("https://dash.stannp.com/api/v1/postcards/cancel?api_key=".API_KEY, false, $context);
$response = json_decode($result,true);
print_r($response);
Response
{
"success":true
}