Expire a document after a certain number of views

Generate a document that self-expires after any pre-specified number of views

This topic lets you learn how to create a self-expiring PDF document with the Inkit Render API. To successfully follow along, you will need an API request testing tool. We recommend testing with either Insomnia (our choice) or Postman (often used as well.)

If you want, you can also implement the knowledge gained from this topic into your codebase right off the bat.

At the end of this guide, you should have created a sample PDF document that expires after viewing it a couple of times. You should also know how to implement it into your technical processes. Let’s start.


  • 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 after N amount of views

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’
  1. Add the correct endpoint: https://api.inkit.com/v1/render

  2. 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_after_n_views field to it and include a number of your choosing. We used one, meaning the document will expire after one view.

Your request should look like this now:

     "html": "PGh0bWw+dGVzdCAgPC9odG1sPg==",
     "unit": "in",
     "width": 8.5,
     "height": 11,
     "expire_after_n_views": 1
  1. Send your request. If you have received a 201 response code, then your request was a success.

Well done, you should now have a document that expires after one view (or any other number).

Testing if the document self-expires

Now that you have created your document, you may wish to test it. To do so, all you have to do is send a GET request to the API with your document ID.

Did this page help you?