Idempotent Requests
Our API supports an optional idempotency key for safely retrying requests without performing a repeat operation. If a request is idempotent, we will return the original response body with a 409
HTTP status. We match the body of the request so only identical requests will be treated as idempotent.
Request
import requests
data = {
"test": "true",\n "idempotency_key": "e367c03e-3082-4c8e-b647-d6810761dcd4",\n "background": "https://www.stannp.com/assets/samples/letter-heading.webp",\n "pages": "Hello {firstname}, <br><br>This is my first letter.",\n "recipient[title]": "Mr",\n "recipient[firstname]": "John",\n "recipient[lastname]": "Smith",\n "recipient[address1]": "123 Sample Street",\n "recipient[address2]": "Sampleland",\n "recipient[town]": "Sampletown",\n "recipient[postcode]": "AB12 3CD",\n "recipient[country]": "US",\n
}
response = requests.post("https://api-us1.stannp.com/v1/letters/create?api_key={API_KEY}", data=data)
print(response.text)
Response
{ "success": true, "data": { "pdf": "https:\/\/www.stannp.com\/assets\/samples\/letter-sample.pdf", "id": "0", "created": "2020-12-17T15:42:22+00:00", "format": "letter", "cost": "0.78", "status": "test" } }