Introduction
For your automated deployment pipeline you will need to manage your Snapshots. Most of the APIs necessary for the deployment pipeline are pretty straightforward, however, updating an Endpoint with a new Snapshot is a bit more involved. This article will guide you through the necessary steps.
Prerequisites
You will need the following two things from the Cognigy UI:
API Key
You will need an API key to use the APIs, you can generate one in your profile section in the UI.
Project ID
You can find the project / Agent id by using the three dot menu of the Agent:
API Requests
Please note that you will need to update the base URL depending on your environment. We are using the Cognigy Trial environment for this article. The X-API-Key header needs to have your API key as the value.
Retrieving the Endpoint ID
To retrieve the Endpoint ID you will first need to GET all Endpoints of the project/Agent using the following API request:
https://api-trial.cognigy.ai/openapi#get-/v2.0/endpoints
The Endpoint ID is then the last bit of the _links.self.href , which is 61ee80ad6680c5cd63c014f6 in this case.
Retrieving the Snapshot ID
To retrieve the Snapshot ID you will first need to GET all Snapshots of the project/Agent using the following API request:
https://api-trial.cognigy.ai/openapi#get-/v2.0/snapshots
We can simply use the snapshotId value, which is 6320659db5769a376e1143d4 in this case.
Retrieving the Flow ID
We need to specify the Flow reference ID later on, so we need to GET it from the Snapshot. It can be done with the following API request, based on the Snapshot ID from the last step, please note that we filter by the Flow resource type:
https://api-trial.cognigy.ai/openapi#get-/v2.0/snapshots/-snapshotId-/resources
In this case we need the referenceId of the Flow, which is 580a85f1-b725-4033-a5b6-ad9587dd1b71 in our case.
Updating the Endpoint
Now that we have the Endpoint ID, the Snapshot ID and the Flow reference ID we can finally update the Endpoint accordingly using the following PATCH API request:
https://api-trial.cognigy.ai/openapi#patch-/v2.0/endpoints/-endpointId-
We have now successfully updated the Endpoint via API:
Comments
0 comments