This quickstart will guide you through sending your first UK postal letter via the Intelliprint API using HTML or plain text content. This is the simplest way to get started with Intelliprint’s hybrid mail service.
Time to complete: ~5 minutes
What you’ll build
You’ll create a simple letter with:
- HTML-formatted content
- One recipient address
- Confirmation to send immediately
Prerequisites
SDK Installation (Optional)
While you can use raw HTTP requests, we recommend installing our SDK:composer require Intelliprint/intelliprint-php
Step 1: Create Your First Letter
Create a print job with HTML content and send it to one recipient.
Use testmode: true while testing - you won’t be charged and the letter won’t actually be sent!
import Intelliprint from 'intelliprint';
const ip = Intelliprint('your-api-key-here');
const printJob = await ip.prints.create({
// Test mode - not charged, not sent
testmode: true,
// HTML content for your letter
content: `
<h1>Welcome to Intelliprint!</h1>
<p>Dear Customer,</p>
<p>Thank you for your recent purchase. We're excited to have you as part of our community.</p>
<p>If you have any questions, please don't hesitate to contact us.</p>
<p>Best regards,<br>The Acme Team</p>
`,
// Recipient address
recipients: [{
address: {
name: 'John Doe',
line: '123 Main Street, Anytown',
postcode: 'SW1A 1AA',
country: 'GB' // ISO 3166-1 alpha-2 country code
}
}],
// Confirm immediately to send
confirmed: true
});
console.log('✓ Print job created!');
console.log('ID:', printJob.id);
console.log('Status:', printJob.letters[0].status);
console.log('Pages:', printJob.pages);
Success! Your letter has been created and submitted for printing.
Step 2: Understand the Response
The API returns a complete print job object:
{
"id": "print_abc123",
"object": "print",
"testmode": true,
"confirmed": true,
"type": "letter",
"pages": 1,
"sheets": 1,
"letters": [{
"id": "letter_xyz789",
"status": "draft", // "waiting_to_print" in live mode
"pages": 1,
"envelope": "c5",
"address": {
"name": "John Doe",
"line": "123 Main Street, Anytown",
"postcode": "SW1A 1AA",
"country": "GB"
},
"cost": {
"amount": 45000000, // £0.45 (divide by 100000000)
"tax": 9000000, // £0.09 VAT
"after_tax": 54000000, // £0.54 total
"currency": "GBP"
}
}],
"cost": {
"amount": 45000000,
"tax": 9000000,
"after_tax": 54000000,
"currency": "GBP"
},
"created": 1761955200
}
Cost precision: All cost values use 8 decimal places. Divide by 100000000 to get the GBP amount.
Example: 54000000 / 100000000 = £0.54Learn more about costs →
Step 3: Verify Your Letter
You can retrieve the PDF preview of your letter:
// Retrieve the print job to get PDF URL
const printJob = await ip.prints.retrieve('print_abc123');
// Access the PDF preview (valid for 1 hour)
const pdfUrl = printJob.letters[0].pdf;
console.log('PDF preview:', pdfUrl);
You can also view your test print job in the Intelliprint dashboard where you can download the PDF and see all details.
Step 4: Send for Real
Once you’re happy with the test, remove testmode to send a real letter:
const printJob = await ip.prints.create({
testmode: false, // or omit this line (defaults to false)
content: '<h1>Welcome!</h1><p>...</p>',
recipients: [{
address: {
name: 'John Doe',
line: '123 Main Street, Anytown',
postcode: 'SW1A 1AA',
country: 'GB'
}
}],
confirmed: true
});
Live mode charges your account - Make sure you’re ready to send before setting testmode: false or confirmed: true!
The content field supports standard HTML:
<!-- Headings -->
<h1>Main Heading</h1>
<h2>Subheading</h2>
<!-- Paragraphs -->
<p>Regular paragraph text.</p>
<!-- Lists -->
<ul>
<li>Bullet point 1</li>
<li>Bullet point 2</li>
</ul>
<ol>
<li>Numbered item 1</li>
<li>Numbered item 2</li>
</ol>
<!-- Formatting -->
<strong>Bold text</strong>
<em>Italic text</em>
<u>Underlined text</u>
<!-- Styling -->
<p style="color: red; font-size: 18px;">Styled text</p>
<!-- Tables -->
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Sending to Multiple Recipients
To send the same letter to multiple recipients, pass an array:
const printJob = await ip.prints.create({
testmode: true,
content: '<h1>Welcome!</h1>',
recipients: [
{
address: {
name: 'John Doe',
line: '123 Main St, London',
postcode: 'SW1A 1AA',
country: 'GB'
}
},
{
address: {
name: 'Jane Smith',
line: '456 High St, Manchester',
postcode: 'M1 1AA',
country: 'GB'
}
}
],
confirmed: true
});
console.log(`Sending to ${printJob.letters.length} recipients`);
Double-Sided Printing
Save costs by printing on both sides of the paper. This is only available for letters, not postcards.
Cost savings: Double-sided printing reduces the number of physical sheets, lowering your costs. For example, 4 pages single-sided = 4 sheets, but 4 pages double-sided = 2 sheets.
Automatic Double-Sided
Print all pages double-sided automatically:
const printJob = await ip.prints.create({
testmode: true,
content: '<h1>Page 1</h1><p>Front side content...</p><h1>Page 2</h1><p>Back side content...</p>',
recipients: [{
address: {
name: 'John Doe',
line: '123 Main St, London',
postcode: 'SW1A 1AA',
country: 'GB'
}
}],
// Enable double-sided printing
printing: {
double_sided: 'yes'
},
confirmed: true
});
console.log('Pages:', printJob.pages); // e.g., 4 pages
console.log('Sheets:', printJob.sheets); // e.g., 2 sheets (double-sided)
Selective Double-Sided (Mixed Mode)
Print only specific pages double-sided:
const printJob = await ip.prints.create({
testmode: true,
content: '<h1>Page 1</h1><p>...</p><h1>Page 2</h1><p>...</p><h1>Page 3</h1><p>...</p><h1>Page 4</h1><p>...</p>',
recipients: [{address: {/* ... */}}],
// Mixed double-sided printing
printing: {
double_sided: 'mixed',
double_sided_specific_pages: [0, 2] // Pages 1 and 3 (0-indexed)
},
confirmed: true
});
// Result: Pages 0 and 2 are double-sided, pages 1 and 3 are single-sided
Page indexing: Pages are 0-indexed (first page = 0, second page = 1, etc.). Make sure to account for this when specifying double_sided_specific_pages.
Double-Sided Options
| Option | Value | Description |
|---|
| Single-sided (default) | "no" | All pages printed on separate sheets |
| Double-sided | "yes" | All pages printed double-sided |
| Mixed | "mixed" | Specify which pages via double_sided_specific_pages |
Use case for mixed mode: You might want the first page (coversheet) single-sided for visual impact, but subsequent pages double-sided to save costs.
Next Steps