Create a letter
Create a letter from a template or content blocks. Set auto_send to print and post immediately.
curl --request POST \
--url https://api.yorlet.com/v1/letters \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"recipient": {
"customer": "<string>",
"owner": "<string>"
},
"auto_send": false,
"blocks": [
{
"type": "heading",
"content": "<string>"
}
],
"delivery_product": "standard",
"name": "<string>",
"template": "<string>",
"variables": {}
}
'import requests
url = "https://api.yorlet.com/v1/letters"
payload = {
"recipient": {
"customer": "<string>",
"owner": "<string>"
},
"auto_send": False,
"blocks": [
{
"type": "heading",
"content": "<string>"
}
],
"delivery_product": "standard",
"name": "<string>",
"template": "<string>",
"variables": {}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
recipient: {customer: '<string>', owner: '<string>'},
auto_send: false,
blocks: [{type: 'heading', content: '<string>'}],
delivery_product: 'standard',
name: '<string>',
template: '<string>',
variables: {}
})
};
fetch('https://api.yorlet.com/v1/letters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.yorlet.com/v1/letters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'recipient' => [
'customer' => '<string>',
'owner' => '<string>'
],
'auto_send' => false,
'blocks' => [
[
'type' => 'heading',
'content' => '<string>'
]
],
'delivery_product' => 'standard',
'name' => '<string>',
'template' => '<string>',
'variables' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.yorlet.com/v1/letters"
payload := strings.NewReader("{\n \"recipient\": {\n \"customer\": \"<string>\",\n \"owner\": \"<string>\"\n },\n \"auto_send\": false,\n \"blocks\": [\n {\n \"type\": \"heading\",\n \"content\": \"<string>\"\n }\n ],\n \"delivery_product\": \"standard\",\n \"name\": \"<string>\",\n \"template\": \"<string>\",\n \"variables\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.yorlet.com/v1/letters")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"recipient\": {\n \"customer\": \"<string>\",\n \"owner\": \"<string>\"\n },\n \"auto_send\": false,\n \"blocks\": [\n {\n \"type\": \"heading\",\n \"content\": \"<string>\"\n }\n ],\n \"delivery_product\": \"standard\",\n \"name\": \"<string>\",\n \"template\": \"<string>\",\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yorlet.com/v1/letters")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipient\": {\n \"customer\": \"<string>\",\n \"owner\": \"<string>\"\n },\n \"auto_send\": false,\n \"blocks\": [\n {\n \"type\": \"heading\",\n \"content\": \"<string>\"\n }\n ],\n \"delivery_product\": \"standard\",\n \"name\": \"<string>\",\n \"template\": \"<string>\",\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": 123,
"object": "letter",
"address_position": "left",
"blocks": [
{
"type": "heading",
"content": "<string>"
}
],
"customer": "<string>",
"delivery_error": "<string>",
"delivery_product": "standard",
"name": "<string>",
"owner": "<string>",
"page_count": 123,
"recipient_type": "customer",
"sent_at": 123,
"status": "draft",
"template": "<string>",
"tracking_number": "<string>",
"variables": {},
"account": "<string>",
"deleted": false
}Authorizations
API Key authentication. Use "Bearer YOUR_API_KEY".
Body
Who the letter is addressed to.
Show child attributes
Show child attributes
Which side of page 1 the recipient address window is printed on.
left, right If true, the letter is printed and posted immediately after creation.
Content blocks. Required when template is omitted; otherwise copied from the template.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Postage product used when the letter is sent.
standard, premium A name for this letter. Defaults to the template name.
The ID of a letter template to copy content from.
Values for the template custom variables, keyed by variable key.
Show child attributes
Show child attributes
Response
Returns the letter object if the request succeeded.
Unique identifier for the object.
Time at which the object was created. Measured in seconds since the Unix epoch.
letter Which side of page 1 the recipient address window is printed on.
left, right Content blocks that will be printed. Snapshotted from the template when one is used.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
The customer this letter is addressed to, when recipient_type is customer.
Why sending failed, if status is failed.
Postage product used when the letter is sent.
standard, premium A name for this letter. Defaults to the template name.
The owner this letter is addressed to, when recipient_type is owner.
Number of PDF pages in the letter, set when it is sent. Extra pages beyond the first are billed separately.
Who the letter is addressed to.
customer, owner Time at which the letter was submitted to for printing. Measured in seconds since the Unix epoch.
The current status of the letter.
draft, sending, sent, canceled, failed The letter template this letter was created from, if any.
Postal tracking number, when one is available.
Values for the template custom variables, keyed by variable key.
Show child attributes
Show child attributes
The account that the object belongs to. Only returned if the request is made with a valid Yorlet-Context header.
Only returned if the object has been deleted.
Was this page helpful?
curl --request POST \
--url https://api.yorlet.com/v1/letters \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"recipient": {
"customer": "<string>",
"owner": "<string>"
},
"auto_send": false,
"blocks": [
{
"type": "heading",
"content": "<string>"
}
],
"delivery_product": "standard",
"name": "<string>",
"template": "<string>",
"variables": {}
}
'import requests
url = "https://api.yorlet.com/v1/letters"
payload = {
"recipient": {
"customer": "<string>",
"owner": "<string>"
},
"auto_send": False,
"blocks": [
{
"type": "heading",
"content": "<string>"
}
],
"delivery_product": "standard",
"name": "<string>",
"template": "<string>",
"variables": {}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
recipient: {customer: '<string>', owner: '<string>'},
auto_send: false,
blocks: [{type: 'heading', content: '<string>'}],
delivery_product: 'standard',
name: '<string>',
template: '<string>',
variables: {}
})
};
fetch('https://api.yorlet.com/v1/letters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.yorlet.com/v1/letters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'recipient' => [
'customer' => '<string>',
'owner' => '<string>'
],
'auto_send' => false,
'blocks' => [
[
'type' => 'heading',
'content' => '<string>'
]
],
'delivery_product' => 'standard',
'name' => '<string>',
'template' => '<string>',
'variables' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.yorlet.com/v1/letters"
payload := strings.NewReader("{\n \"recipient\": {\n \"customer\": \"<string>\",\n \"owner\": \"<string>\"\n },\n \"auto_send\": false,\n \"blocks\": [\n {\n \"type\": \"heading\",\n \"content\": \"<string>\"\n }\n ],\n \"delivery_product\": \"standard\",\n \"name\": \"<string>\",\n \"template\": \"<string>\",\n \"variables\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.yorlet.com/v1/letters")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"recipient\": {\n \"customer\": \"<string>\",\n \"owner\": \"<string>\"\n },\n \"auto_send\": false,\n \"blocks\": [\n {\n \"type\": \"heading\",\n \"content\": \"<string>\"\n }\n ],\n \"delivery_product\": \"standard\",\n \"name\": \"<string>\",\n \"template\": \"<string>\",\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yorlet.com/v1/letters")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipient\": {\n \"customer\": \"<string>\",\n \"owner\": \"<string>\"\n },\n \"auto_send\": false,\n \"blocks\": [\n {\n \"type\": \"heading\",\n \"content\": \"<string>\"\n }\n ],\n \"delivery_product\": \"standard\",\n \"name\": \"<string>\",\n \"template\": \"<string>\",\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": 123,
"object": "letter",
"address_position": "left",
"blocks": [
{
"type": "heading",
"content": "<string>"
}
],
"customer": "<string>",
"delivery_error": "<string>",
"delivery_product": "standard",
"name": "<string>",
"owner": "<string>",
"page_count": 123,
"recipient_type": "customer",
"sent_at": 123,
"status": "draft",
"template": "<string>",
"tracking_number": "<string>",
"variables": {},
"account": "<string>",
"deleted": false
}