We will configure an integration to fetch user data from the Uhuu Developer Mock API. The setup allows us to dynamically pull user details into our templates by specifying an endpoint with parameters.
New Integration
Navigate to the Integrations tab and click on New Integration. Name your integration (e.g., "User API") to proceed.
Configure the API Endpoint
Set up the API request details:
- Method: Choose the request method (e.g.,
GET
). - API URL: Enter the endpoint URL with a dynamic parameter (e.g.,
https://developer.uhuu.io/api/mock/users/{{id}}
).
This structure allows you to define placeholders (e.g., {{id}}
) for data to be dynamically fetched based on user input.
https://developer.uhuu.io/api/mock/users/{{id}}
Example JSON Response
Here's a sample of user data returned by the API:
/* Response from https://developer.uhuu.io/api/mock/users/3 */
{
"id": 3,
"company": "Matterhorn Solutions",
"first_name": "Noah",
"last_name": "Schneider",
"city": "Bern",
"street_address": "Kramgasse 49",
"postal_code": "3000"
}
Bind Integration to Template
In the Template Settings for your document, go to the Integration tab:
- Select Integration: Choose the integration you created (e.g., "User API").
- Bind to: Define the data field in your template payload to which the API data will map (e.g.,
user
).
Click Save to apply the integration, enabling your template to fetch user data dynamically.
Creating the Document
When generating a document, the system will prompt for the User ID. Enter an ID to fetch the corresponding user data from the API and populate the template.
Document Creation Lifecycle
When users create documents, they will be prompted to enter optional parameters (e.g., the user’s id
). Uhuu then executes the following steps:
- Construct Endpoint URL: Fills in optional parameters to build the endpoint URL.
- Fetch Data: Requests data from the specified endpoint.
- Render Template: Populates the template with the fetched data to generate the document.
- Editable Form: Generates an editable form, enabling users to update data as needed.
- Document Update: Re-creates the document with any user changes.
This integration allows smooth document generation by connecting data directly to Uhuu templates and streamlining the update and creation process.