Everything about Letters
We support pdf
, docx
and doc
files. Contact us to add support for any other file type. If you're using docx
or doc
files, you'll need to convert the file first using our uploads endpoint with the querystring parameter convert=post
e.g. POST https://rest.clicksend.com/v3/uploads?convert=post
. This will return a URL to the converted pdf file that can be used in the /post/letters/send
endpoint.
Follow our Letter specification guide to ensure correct sending and letter template information.
With this option, you can use an existing URL to a pdf
document. For example, you might generate the pdf
on your server.
When using an existing url make sure that it is publicly accessible as it will not work if it is private.
With this option, you can use the /uploads endpoint to upload the document. The /uploads
endpoint returns a URL that can be used in the /post/letters/send
endpoint.
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
file_url | string | true | none | URL of file to send |
address_name | string | true | none | Name of address |
address_line_1 | string | true | none | First line of address |
address_line_2 | string | true | none | Second line of address |
address_city | string | true | none | City |
address_state | string | true | none | State |
address_postal_code | string | true | none | Postal code |
address_country | string | true | none | Country |
return_address_id | integer(int32) | true | none | ID of return address to use |
schedule | integer(int32) | false | none | When to send letter (0/null=now) |
template_used | integer(int1) | false | none | Whether using our letter template. Flag value must be 1 for yes or 0 for no. |
duplex | integer(int1) | false | none | Whether letter is duplex. Flag value must be 1 for yes or 0 for no. |
colour | integer(int1) | false | none | Whether letter is in colour. Flag value must be 1 for yes or 0 for no. |
priority_post | integer(int1) | false | none | Whether letter is priority, Flag value must be 1 for yes or 0 for no. |
source | string | false | none | Source being sent from |
Refer to Status Codes for definitions of HTTP status code responses.
Successful response
{- "file_url": "{{fileUrl}}",
- "template_used": 1,
- "colour": 0,
- "duplex": 1,
- "recipients": [
- {
- "address_name": "test",
- "address_city": "test",
- "address_state": "test",
- "address_postal_code": "6000",
- "address_country": "AU",
- "address_line_1": "1 test street",
- "return_address_id": "{{addressId}}"
}
]
}
{- "http_code": 200,
- "response_code": "SUCCESS",
- "response_msg": "Letters queued for delivery.",
- "data": {
- "recipients": [
- {
- "user_id": 1,
- "subaccount_id": 1,
- "message_id": "A00A1066-BBAE-432B-9B2D-E88969B12C46",
- "address_name": "John Smith",
- "address_line_1": "Address 1",
- "address_line_2": "",
- "address_city": "CITY",
- "address_state": "State",
- "address_postal_code": "123456",
- "address_country": "AU",
- "return_address_id": 1,
- "custom_string": "kn0ChLhwn6",
- "schedule": 1449573604,
- "source": ".rest.v3",
- "colour": 1,
- "duplex": 0,
- "post_pages": 7,
- "post_price": "13.4200",
- "priority_post": 0,
- "date_added": 1459131623,
- "status": "SUCCESS",
- "_return_address": {
- "return_address_id": 1,
- "user_id": 1,
- "address_name": "John Smith",
- "address_line_1": "Maritime Avenue",
- "address_line_2": "",
- "address_city": "Flynn",
- "address_state": "WA",
- "address_postal_code": 6302,
- "address_country": "AU"
}, - "_api_username": "my_api_username"
}
], - "_currency": {
- "currency_name_short": "AUD",
- "currency_prefix_d": "$",
- "currency_prefix_c": "c",
- "currency_name_long": "Australian Dollars"
}
}
}
Calculate letter price
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
file_url | string | true | none | URL of file to send |
address_name | string | true | none | Name of address |
address_line_1 | string | true | none | First line of address |
address_line_2 | string | true | none | Second line of address |
address_city | string | true | none | City |
address_state | string | true | none | State |
address_postal_code | string | true | none | Postal code |
address_country | string | true | none | Country |
return_address_id | integer(int32) | true | none | ID of return address to use |
schedule | integer(int32) | false | none | When to send letter (0/null=now) |
template_used | integer(int1) | false | none | Whether using our letter template. Flag value must be 1 for yes or 0 for no. |
duplex | integer(int1) | false | none | Whether letter is duplex. Flag value must be 1 for yes or 0 for no. |
colour | integer(int1) | false | none | Whether letter is in colour. Flag value must be 1 for yes or 0 for no. |
priority_post | integer(int1) | false | none | Whether letter is priority. Flag value must be 1 for yes or 0 for no. |
source | string | false | none | Source being sent from |
Refer to Status Codes for definitions of HTTP status code responses.
Successful response
{- "template_used": 0,
- "duplex": 0,
- "colour": 0,
- "source": "test",
- "recipients": [
- {
- "address_name": "test",
- "address_city": "test",
- "address_state": "test",
- "address_postal_code": "6000",
- "address_country": "AU",
- "address_line_1": "1 test street",
- "return_address_id": "1154"
}
]
}
{- "http_code": 200,
- "response_code": "SUCCESS",
- "response_msg": "Here are some results.",
- "data": {
- "total_price": 1.87,
- "total_cost": 1,
- "recipients": [
- {
- "user_id": 1,
- "subaccount_id": 1,
- "message_id": "06FAD39C-78FD-4D2F-B606-9846D1979F35",
- "address_name": "John Smith",
- "address_line_1": "131",
- "address_line_2": "Scheuvront Drive",
- "address_city": "DENVER",
- "address_state": "CO",
- "address_postal_code": 80202,
- "address_country": "AU",
- "return_address_id": 1,
- "schedule": 1449573604,
- "post_pages": 3,
- "post_price": "1.8700",
- "priority_post": 0,
- "date_added": 1449662203,
- "status": "SUCCESS"
}
]
}
}
Detects address in uploaded file.
The detect-address
endpoint accepts either a letter in PDF format or an address string and attempts to convert it to a standard address format. Note that the PDF should be in standard address format, having the recipient's name and address listed at the top.
The endpoint accepts two types of data: 1. A PDF file in base64
encoding. In this case, submit the base64
-encoded PDF file contents in the content
field of the request body. 2. An address string. In this case, submit the address in a string using the address
field of the request body.
Parameter | In | Type | Required | Description |
---|---|---|---|---|
convert | query | string | true | none |
content | body | string | true | Base64-encoded file contents |
Refer to Status Codes for definitions of HTTP status code responses.
Successful response
{- "content": "Q29udGVudHMgb2YgZmlsZQ=="
}
{- "http_code": 200,
- "response_code": "SUCCESS",
- "response_msg": "Here is your result.",
- "data": {
- "address_name": "John Doe",
- "address_line_1": "123 Main Street",
- "address_line_2": "",
- "address_city": "Perth",
- "address_state": "WA",
- "address_postal_code": "6000",
- "address_country": "AU"
}
}
Cancel scheduled letter
Parameter | In | Type | Required | Description |
---|---|---|---|---|
message_id | query | string | true | Message ID of the scheduled letter that is to be cancelled. |
Refer to Status Codes for definitions of HTTP status code responses.
Successful response
{- "http_code": 200,
- "response_code": "SUCCESS",
- "response_msg": "Scheduled letter has been cancelled.",
- "data": true
}
Get all letter history
Parameter | In | Type | Required | Description |
---|---|---|---|---|
page | query | integer(int32) | false | Page number |
limit | query | integer(int32) | false | Number of records per page |
Refer to Status Codes for definitions of HTTP status code responses.
Successful response
curl --include \ --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \ 'https://rest.clicksend.com/v3/post/letters/history'
{- "http_code": 200,
- "response_code": "SUCCESS",
- "response_msg": "Here is your history.",
- "data": {
- "total": 2,
- "per_page": 15,
- "current_page": 1,
- "last_page": 1,
- "next_page_url": null,
- "prev_page_url": null,
- "from": 1,
- "to": 2,
- "data": [
- {
- "user_id": 1,
- "subaccount_id": 1,
- "message_id": "06FAD39C-78FD-4D2F-B606-9846D1979F35",
- "address_name": "John Smith",
- "address_line_1": "131",
- "address_line_2": "Scheuvront Drive",
- "address_city": "DENVER",
- "address_state": "CO",
- "address_postal_code": 80202,
- "address_country": "AU",
- "return_address_id": 1,
- "schedule": 1449573604,
- "post_pages": 3,
- "post_price": "1.8700",
- "priority_post": 0,
- "date_added": 1449662203,
- "status": "SUCCESS"
}
]
}
}
export letter history
Parameter | In | Type | Required | Description |
---|---|---|---|---|
filename | query | string | true | Filename to export to |
Refer to Status Codes for definitions of HTTP status code responses.
Successful response
curl --include \ --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \ 'https://rest.clicksend.com/v3/post/letters/history/export?filename={filename}'
{- "http_code": 200,
- "response_code": "SUCCESS",
- "response_msg": "Download your file here.",
}