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
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"
   }
}