# Try it!

If after reading the documentation you  want to try the Subscription API, we have prepared a
demo environment that anyone can access. Authentication is required, but any token
that you pass should work, so no need to get a User or Application key in advance.

To show how this environment works, we will use Postman, but you can use any other REST client.

The URL where this API can be located is: `https://16abf815-424c-413e-b92d-6c6f8fc633cd.remockly.com/intelligence/api`. Keep in mind that
for real production environments, the URL typically ends with `/intelligence/api` and not `/api`.

## 1. Create a new HTTP Request

Let's start this Tutorial by creating a new HTTP Request in Postman (File > New > HTTP Request). Make sure that you have
selected a GET operation and paste the URL for the API next to it: `https://16abf815-424c-413e-b92d-6c6f8fc633cd.remockly.com/intelligence/api`.

![Create a new HTTP Request](/assets/mock-step1.a2d6032743d2d7ddaa4c957eac4d54246350eac78464761b5a776d164e8eca88.527729fc.png)

## 2. Configure authentication

Let's say we have our User API Key which is
`NASDYUmYxMjItNmJJHuNYSdn7FkLThhasdhj89jM2ODVmOio090sadjkdkVnRFV3VVBtZ1jksadb8olJWXMSDHUASDik3UE5j`. Go to Postman
and use this key for the Authentication header.
Click on `Authorization` and select `Bearer Token` for the Type. For the token, paste the above key.

![Configure authentication](/assets/mock-step2.639caa743ba3d49f625a341eb4629a616b7d47b4c13c2e51e3bdb54dc60b019d.527729fc.png)

## 3. Get the list of Knowledge Models

Now we should be ready to start getting some information such as the full list of Knowledge Models. For that,
you need to add '/knowledge-models' at the end of the URL. As we can see, there is one Knowledge Model with the id
`open-purchase-requisition.purchase-requisition-km` and named `Purchase Requisition KM`. As we can tell by the name, this
Knowledge Model is giving us information about Purchases that happened in the company.

![Get list of Knowledge Models](/assets/mock-step3.76f688efe99b5c49be4b6f5065bea41e71f8e5b72d64d52180a5b4332acbcce5.527729fc.png)

## 4. Get triggers for a Knowledge Model

Imagine you want to retrieve all the triggers within a Knowledge Model. This is possible just adding the Knowledge Model id,
for example `open-purchase-requisition.purchase-requisition-km-base` and later appending `/triggers` to the URL.

![Get the triggers for a knowledge model](/assets/mock-step9.c3a946703dd532ee8f30c5e8cbcd4a9dcae0379f87bedfe0c3c2399c66c2073c.527729fc.png)

## 5. Creating a new subscription

Once you know the id of the trigger you want to use to create a subscription, you can create a new subscription just adding the
trigger id `abc-123-bad-123` to the previous URL. Ensure also the URL is requesting a new subscription appending `subscriptions` to the end of the URI.

Do not forget to give a name to the subscription, and a valid callback URI, and the system will return to you the id for that new
subscription.

![Creating a new subscription](/assets/mock-step10.731e954674cd8663e1627875672a6716036e563f24e1c3c5d748a50867556515.527729fc.png)

## 6. Get the list of subscriptions

Once you created the subscription, you can get all the subscriptions in the system, it is useful for example to check the status of your
subscriptions, just in case any of them is failing, or it is paused or suspended.

Also, the `id` of the subscription is something important to know, since that information is required for updating, pausing, resuming, unsubscribing and
the manual fetching of the data.

![Get all the subscriptions](/assets/mock-step11.caac6eaf677927a45b1292e84592b4be61d644fa5715054bcc278eb36e0ed90e.527729fc.png)

## 7. Update a subscription

If you have the id of a subscription, you can perform an update to change its name or its callback URI. Just ensure you append the `id` `abc-123-bad-123`
to the `subscriptions` URI, and define a valid name and a valid callback URI.

![Updating a subscription](/assets/mock-step12.819bf7f853e38fdcbfd6819674d079f114e322552fd288f4ea8b61ace31fd4a8.527729fc.png)

## 8. Pause a subscription

If you have the id of a subscription, you can pause it to stop receiving events. Just ensure you append the `id` `abc-123-bad-123`
to the `subscriptions` URI, and also append to the command `pause` at the end

![Pausing a subscription](/assets/mock-step13.4a117c067bcd26202155109b5b28453549d15846322db4bac42fe1706af805cd.527729fc.png)

## 9. Resume a subscription

If you have the id of a paused subscription, you can resume it to start receiving events. Just ensure you append the `id` `abc-123-bad-123`
to the `subscriptions` URI, and also append to the command `resume` at the end

![Resuming a subscription](/assets/mock-step14.35b8e79a8ce2693b13786da3991fe549c35d1a61bb21ad59081d786bd61f7049.527729fc.png)

## 10. Unsubscribe

If you have the id of a paused subscription, you can unsubscribe it to remove the subscription from the system. Just ensure you append the `id` `abc-123-bad-123`
to the `subscriptions` URI.

![Unsubscribe](/assets/mock-step15.f6d620e0862e165bb0417f809db5d842c336ddf1be989b618dd790cb026df0cf.527729fc.png)

## 11. Get unsent events of a failing subscription manually

In case of a failing subscription, it is possible to get the unsent events manually.

Just ensure that you have the `id` `abc-123-bad-123` of the failing subscription, and include the `events` path to the `subscriptions` URI.

![Get events manually](/assets/mock-step16.9752db17cc55f8c666dca065b480343d99e66768e4f74047c1c4b5d3711cf965.527729fc.png)

Keep in mind that this is just a simple demo. Features like Filter, Filter Expressions and many others are not supported.
However, we expect you now have a better understanding of how to use the Knowledge Model API. If you want to become more familiar with the API,
we recommend you to have a look at our [Tutorials](/process-intelligence-apis/knowledge-model-api/tutorials/learning/exploring-schema).