# Update ML Skill deployment using API

> To access the AI Center APIs:

To access the AI Center APIs:

1. Register an external application (one-time setup).
2. Generate an authentication token (renew upon expiry).
3. Make AI Center API calls.

:::note
The first two steps enforce access control by making sure your application is registered and authenticated. To access the application, you must register and authenticate the application. (step 1 and 2)
:::

## Registering an external application

To use these APIs, your app must register as an external application within the AI Center scope.

1. Go to the **Admin** page from the left navigation panel and select **External Applications**.
2. Select **+ Add Application** and give it a name, to add a new external application.
   :::note
   Only the confidential application type can access the AI Center APIs.
   :::
3. Select **Add scope** to enable the AI Center scope to the external application.
   * Choose AI Center API Access (preview) from the **Resource** drop-down.
   * Go to the **Application Scope** tab and choose the APIs you want to give access to external applications. In the following example you select all the APIs for simplicity.

     ![Screenshot of the Application Scope menu.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-the-edit-resource-menu-354591-5d71de15-db3d300c.webp)
4. A pop up with App ID and an App Secret confirms that the application was successfully added. Check the App ID and App Secret anytime from the **Edit External application**.
   :::note
   Use these credentials to generate an authentication token in the next step.
   :::

   ![Screenshot of the Application Successfully Added pop-up.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-the-application-successfully-added-pop-up-394358-666436bd-191e01aa.webp)

Check the [Managing external applications](https://docs.uipath.com/automation-cloud/docs/managing-external-applications) page for more information.

## Generating an authentication token

The external application must request an access token from the UiPath identity server for authentication and secure access.

:::note
The authentication token expires in one hour. After this time, you'll need to generate a new one.
:::

For simplicity, we use Postman in this tutorial. You can [register](https://www.postman.com/) 10 tokens for free and use their web interface, application, or any other tool.

Generate a POST request to the Identity Server [endpoint](https://cloud.uipath.com/identity_/connect/token) that includes the following in the body of the request:

* `client_id`: App ID from previous step.
* `client_secret`: App Secret from previous step.
* `grant_type`: client_credentials.

Select `application/x-www-form-urlencoded` as the content type if you're using Postman.

  ![Screenshot of the Body tab.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-the-body-tab-354599-d1c64f6e-4a50bb4b.webp)

This request creates an authentication token, used for AI Center API calls:

  ![Screenshot of an authentication token.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-the-access-token-example-in-the-body-tab-354603-09fa475c-08539302.webp)

You can also observe the permissions enabled for this external application.

Check the additional information on credentials and authentication tokens in the [External Applications (OAuth)](https://docs.uipath.com/automation-cloud/docs/setting-up-the-external-application#client-credentials) page.

## Making AI Center API calls

The API calls follow the [https://cloud.uipath.com/accountname/tenantname/aifabric_/ 10](https://cloud.uipath.com/accountname/tenantname/aifabric_/ai-helper/swagger-ui/index.html) structure, where `accountname` and `tenantname` are specific to your account.

Most APIs need the following information:

* `Account ID` and `Tenant ID`. Check the account and tenant details in the [profile information](https://docs.uipath.com/ai-fabric/v0/docs/using-ai-center#profile-information) section within the tenant.
* `Authorization`. The authorization field is populated with the authentication token generated in the previous step.

You can now access specific APIs.

In the ML Skills list, `sampleClassifierSkill` (used as an example) is currently in the Available state.

Use the AI Center APIs to:

* Find the ML Skill ID of sampleClassifierSkill.
* Stop (undeploy) the ML Skill.
* Start (redeploy) and verify status update.

### Find ML Skill details

With the `GET ML Skills` call, you can retrieve all the ML Skills in your account and tenant.

To find a specific ML Skill and get its details, include its name in the query: `GET /ai-deployer/v1/mlskills?name=sampleClassifierSkill`

In this case, we find the ML Skill id for the `sampleClassifierSkill`.

:::note
When using the authentication token, prefix it with `Bearer`.
:::

  ![Screenshot of the Headers tab.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-the-headers-tab-354615-504261a7-f9a7d41b.webp)

In the following response, the key fields are highlighted in yellow. Use the `ML Skill` id in the following `APIs` to modify the state:

  ![Screenshot of key fields highlighted in a response.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-key-fields-highlighted-in-a-response-514252-8d8e1175-35b5d08c.webp)

### Update ML Skill replicas

Use the `UPDATE ML Skill` call to modify the deployment configuration on a specific ML skill.

In the following example, we change the replica count by including the new number in the request body.

  ![Screenshot of a response.](https://dev-assets.cms.uipath.com/assets/images/ai-center/ai-center-screenshot-of-a-response-514247-2df1c225-8fb62d78.webp)
