By reading this topic, you'll learn how to pull your generated PDFs from the API. While we use Insomnia's request testing tool in this end-to-end tutorial, the process is the same for doing so from code.
At the end of this guide, you should be able to replicate these steps and implement them on your own in your programming language of choice. Let's begin.
- You have generated a PDF document
- You have the ID of this generated document
- You have a mock request tool like Postman or Insomnia available (or have your development environment set up to send requests)
- Your API key has the appropriate permissions (Renders.retrieve)
- Your API key has access to your folder if it is a private folder
Read more about:
Before pulling a generated PDF from the API, you must have a few things set up and ready. Therefore, we have created this small overview for you to check to follow along with this guide successfully.
- Make sure you have generated a PDF and have saved its ID from the response message.
Your document ID will have the format of: "rend_" plus 22 non-spaced alphanumeric characters concatenated to it. So, for example, it may look like:
Have this ID at the ready.
- Ensure your API key to have the appropriate permissions. You need to have the Renders.retrieve permission.
Read more about assigning roles and permissions to an API key here
- Optional: If you have placed your document in a private folder, make sure to share this folder with your API key.
Now that you are set up and ready to go, we can pull your document from the API. Make sure you have your document ID and API request testing software open.
Again, we are using Insomnia, but you are free to use what you prefer.
Proceed by following these steps:
- Open your API request testing software and create a new GET request
- Specify that you want to send a request to the following endpoint:
To continue with the previous example ID, you want to put your ID after "render/" and before "/pdf"
You would get:
- Put your API key in your request headers under the parameter name "X-Inkit-API-Token"
- Send your request. You should receive a 200 OK response code.
You should now have sent your GET request to the API, and you should have your rendered PDF returned to you.
If you are getting an unauthorized error, make sure to check if the API key you used has the appropriate permissions. Also, check if your folder is shared with the user role the API key operates under – at least if you are using a private folder.
Congratulations, you have now pulled your first rendered PDF from the Inkit Render API.
Updated about 1 month ago