Create a single postcard


URL_API_USpostcards/create

Parameters

size mandatory Either "4x6" or "6x9".
Download our 4x6 design guide.
Download our 6x9 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[city], recipient[state], recipient[zipcode], 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.
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 URL_API_USpostcards/create \
-u {API_KEY}: \
-d "size=4x6" \
-d "test=true" \
-d "front=https://www.stannp.com/assets/samples/4X6-SAMPLE.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]=Doe" \
-d "recipient[address1]=123 Sample Street" \
-d "recipient[city]=Sampletown" \
-d "recipient[state]=NY" \
-d "recipient[zipcode]=12345" \
-d "recipient[country]=US"
define("API_KEY","YOUR API KEY");
$postdata = http_build_query(
  array(
  	'test' => "true",
  	'size' => "4x6",
  	'front' => "https://www.stannp.com/assets/samples/4X6-SAMPLE.jpg",
  	'message' => "hello world",
        'signature' => "https://www.stannp.com/assets/samples/signature-example.jpg",
  	'recipient[title]' => "John",   
  	'recipient[firstname]' => "John",
  	'recipient[lastname]' => "Doe",
  	'recipient[address1]' => "123 Sample Street",
  	'recipient[city]' => "Sampletown",
  	'recipient[state]' => "NY",
  	'recipient[zipcode]' => "12345",
  	'recipient[country]' => "US"
  )
);
$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("URL_API_USpostcards/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/4x6-postcard-sample.pdf"
   }
}

Get a single postcard


URL_API_USpostcards/get/:id
Request
$ curl URL_API_USpostcards/get/16818211?api_key={API_KEY}
{
   "success":true,
   "data":
   {
        "id": "16818211",
        "timestamp": "2019-10-30 00:14:04",
        "status": "cancelled",
        "type": "postcard",
        "format": "4x6",
        "pdf_file": "https://dash.stannp.com/api/v1/storage/get/port/1550016843/pdfs/15500168437775c63614bd88b1-d26cc45469-A5-K5aZSp.pdf",
        "dispatched": null,
        "country": "US",
        "cost": "0.00",
        "addons": "",
        "tags": "",
        "postcode": "12345",
        "address": "123 Sample Street"
   }
}

Cancel a postcard

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

URL_API_USpostcards/cancel

Parameters

id mandatory The id of the mailpiece item.
Request
$ curl URL_API_USpostcards/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("URL_API_USpostcards/cancel?api_key=".API_KEY, false, $context);
$response = json_decode($result,true);
print_r($response);
Response
{
"success":true
}