Retrieving the Results PDF on the Server Side
Question
> We send the configuration to our CRM via a webhook. The JSON data contains an API endpoint in the pdf field for retrieving the results PDF. However, the endpoint appears to be accessible only from within the application. How can we retrieve the PDF on the server side and save it to the CRM record?
Answer
The endpoint behind the pdf field is not public. A call without authentication will fail—it only works from within the configurator because the user’s session is active there. For a server-side retrieval, you need a persistent API token.
Generate an API token
- Click the K3 logo in the upper-left corner to go to the administration interface.
- In the top-right corner, expand the menu next to your email address and select Profile.
- Toggle the Developer Mode switch on.
- Click New to generate a new API token.
You must provide this token for authentication every time you call the PDF endpoint. You can find the call details in the API documentation.
Alternative: Public Endpoint Without Customer Data
If the retrieved PDF does not need to contain any customer data, there is a second method that does not require a token. The endpoint
/cfg/{cfg}/pdf/{template?}
contains the data from the contact form and is therefore accessible only to authorized users. In addition, there is
/cfg/{cfg}/publicPdf/{template?}
This endpoint can be called without authentication, for example, directly from the webhook. The PDF generated this way contains only the configuration, no customer data. As soon as you need customer data in the PDF, you’ll need to use the API again with a token and the appropriate license.
Alternative Without Retrieving It Yourself
You can also have the PDF sent to your configurator’s internal email address and process it from there. This is particularly useful if the end customer is not supposed to receive the PDF immediately—for example, because they must first confirm a double opt-in. The PDF is then sent to the customer from your system once confirmation has been received.
A permanent API token belongs exclusively in server-side code. Do not embed it in web pages or JavaScript that the end customer can load.
Further Information
- Permanentes API-Token – Generating and Using Tokens
- Webhook einrichten – Transferring Configuration Data to an External System
- PDF gestalten – Structure and Content of the Result PDF
- E-Mail mit PDF verschicken – Internal and external emails upon configuration completion
Related Topics
- Download link for the PDF
- Transferring the configuration to the CRM
- API authentication