Expire a document on a certain date

Discover how to let your document self-expire at a specified date

In this guide, you’ll see how to utilize the expiration at a certain date functionality Inkit Render has. If you would like to follow along with the guide, you will need an API request testing tool. You can use any tool you prefer, but we recommend Insomnia and Postman.

However, what you will learn here can also directly be implemented in your codebase or technical processes.

After reading this guide, you should have a document that expires on a date you wish. For testing purposes, we recommend you select the next day. Read on.

Prerequisites:

  • You know how to create a PDF document from an HTML file with the Inkit Render API
  • You have a mock request tool like Postman or Insomnia installed
  • You have created an API key with the appropriate permissions

Read more about:

Before you start

Make sure you have all the necessary data at hand to send a create request. If you’re unsure about any of this, read the prerequisites or use the sample data provided in this guide.
Particularly, take a look at the request data requirements topic and the generate a document from an HTML file topic.

Generating a document that expires on a specific date

Proceed by following the steps outlined here.

  1. Have an API key ready with the Renders.create permission.
  2. Get your API key value.
  3. Open your request testing tool and create a new POST request
  4. Put the API key in your request headers under the header name ‘X-Inkit-API-Token’
  5. Build your JSON request by providing an encoded base64 HTML string, the measurement unit, the document its width, and the document its height.

The encoded HTML document is a sample document. Feel free to use it or use your own.

{
     "html": "PGh0bWw+dGVzdCAgPC9odG1sPg==",
     "unit": "in",
     "width": 8.5,
     "height": 11
}
  1. Add the expire_at field to it and include the date at which you want your document to expire. Make sure your date is ISO formatted. We’ve used the date and time: “2021-12-01T15:00:00Z”

This means the document will expire on the 1st of December, at 3 pm UTC time, this year.

Your request should look like this now:

{
     "html": "PGh0bWw+dGVzdCAgPC9odG1sPg==",
     "unit": "in",
     "width": 8.5,
     "height": 11,
     "expire_at": "2021-12-01T15:00:00Z"
}
  1. Send your request. If you have received a 201 response code, then your request was a success.

Use the endpoint: https://api.inkit.com/v1/render

Good job! You’ve created a document that expires at a specific date of your choosing. Remember, for easy testing, pick a close date (or even an hour from now) to expire at. That way you’ll quickly see if you’ve done it right.


Did this page help you?