Pull a PDF from the API
Discover how to pull and view your generated documents from the Inkit Render API
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.
Prerequisites:
- 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:
Getting ready to pull a document from the API
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:
rend_1a2b3h45j6k7h4kSfeAoe4
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.
Pull a document from the API
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:
https://api.inkit.com/v1/render/YourDocumentID/pdf
To continue with the previous example ID, you want to put your ID after "render/" and before "/pdf"
You would get:
https://api.inkit.com/v1/render/rend_1a2b3h45j6k7h4kSfeAoe4/pdf
- 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 over 1 year ago