> For the complete documentation index, see [llms.txt](https://docs.saas.haut.ai/haut.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.saas.haut.ai/haut.ai/developers/saas-api-overview/api-for-algorithm-applications.md).

# API for Algorithm Applications

This page contains description of algorithms applications management via API.

Algorithms is an AI core functionality of Haut.AI products. Algorithms enable AI image analysis. Algorithms are organized into **Applications**, that combine one or more algorithms.

[What is algorithm application?](/haut.ai/haut.ai-features/algorithms.md)

## What can you do?

* [List available algorithms applications](#list-available-applications)
* [Attach algorithms application to dataset](#attach-application-to-dataset)

***

## List available applications

{% openapi src="/files/YmTvOjpvwq9jx4lAuJV9" path="/api/v1/companies/{company\_id}/applications/" method="get" %}
[openapi.json](https://245161714-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWxBX_zB4FnflOpyBGO%2Fuploads%2FRF3DdAp7DPLxOGdzKdfj%2Fopenapi.json?alt=media\&token=805fe368-c61f-4e86-bf72-e2de9d7d6e61)
{% endopenapi %}

***

## Attach algorithms application to dataset

{% openapi src="/files/YmTvOjpvwq9jx4lAuJV9" path="/api/v1/companies/{company\_id}/applications/{tech\_name}/attach-to-dataset/" method="post" %}
[openapi.json](https://245161714-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWxBX_zB4FnflOpyBGO%2Fuploads%2FRF3DdAp7DPLxOGdzKdfj%2Fopenapi.json?alt=media\&token=805fe368-c61f-4e86-bf72-e2de9d7d6e61)
{% endopenapi %}

#### Example: Attaching Face Skin Metrics 2.0

For simplicity, let’s consider one of the most commonly used applications: **Face Skin Metrics 2.0**. This application is identified by its `tech_name`: `face_skin_metrics_2.0`. The `tech_name` is used in the API to specify which application you want to work with.

***

## Applications dependencies

Some applications have dependencies on others. If you try to attach an application that requires another to be attached (but it isn’t), you will receive an error.

**Example**: If you try to attach the **Recommendation Engine** without first attaching the **Face Skin Metrics 2.0** application, you'll receive an error response indicating the unmet dependency.

### Example Error Response:

If you attempt to attach the **Recommendation Engine** without having **Face Skin Metrics 2.0** attached to the dataset, the API will return an error like this:

```json
{
  "type": "validation_error",
  "errors": [
    {
      "code": "missing_dependencies",
      "detail": "Missing dependencies.",
      "attr": null,
      "extra": {
        "missing_application_tech_names": [
          "face_skin_metrics_2.0"
        ],
        "missing_algorithms": []
      }
    }
  ]
}
```

When you encounter an error due to missing dependencies while attaching an algorithm application, you have two ways to resolve this issue:

**1. Attach Dependent Applications Explicitly:**

* You can manually attach the required dependencies by making API requests for each application that needs to be attached before the primary one.
* This requires knowing the dependencies ahead of time and attaching them in the correct order.

**2. Use `resolve_dependencies=true`:**

* A simpler method is to resend the **POST `/runs/ TODO: UPDATE method`** request with the query parameter `resolve_dependencies=true`. This will automatically handle and attach any required dependencies for you.
* This option ensures that the API will resolve all necessary dependencies without you having to manually attach them.

#### Which Method to Use?

* **Explicit Attachment**: Use this if you prefer full control over the attachment process and know exactly what dependencies are required.
* **`resolve_dependencies=true`**: Use this for convenience, as it automates the process of attaching dependencies without needing to track them manually.

#### Example Workflow:

1. **Error Handling**: If you try to attach an application and receive a dependency error:
   * Manually attach the required applications **or**
   * Resend the request with `resolve_dependencies=true`.

This flexibility allows you to manage application dependencies based on your preferred workflow.

***

## Detach algorithms applications

Not possible :(

***

## Reattach algorithms applications

Just attach the applicaiton again.

***

## Enable/disable algorithms for attached algorithms applications

Reattach application and set `enabled_algorithms` key to a list of tech names of algorithms.

You can retrieve all possible algorithms included in application from the response of [Get application info](#get-application-info) method.

<details>

<summary>Example of enabled algorithms value</summary>

```bash
curl -X POST \
    https://saas.haut.ai/api/v1/companies/{company_id}/applications/face_skin_metrics_2.0/attach-to-dataset/ \
    -H "Authorization: Bearer {token}" \
    -H "Content-Type: application/json" \
    -d '{"enabled_algorithms": ["selfie_v2.age", "selfie_v2.quality", "selfie_v2.lines", "selfie_v2.redness"]}'
    
```

</details>

***

{% hint style="warning" %}
Not a Haut.AI client yet?
{% endhint %}

<a href="https://haut.ai/book-a-demo?utm_source=referral&#x26;utm_medium=saas_docs&#x26;utm_campaign=Docs_SaaS_HautAI" class="button primary" data-icon="user-vneck">Book a demo</a> <a href="https://haut.ai/product/ai-skin-analysis?utm_source=referral&#x26;utm_medium=saas_docs&#x26;utm_campaign=Docs_SaaS_HautAI" class="button secondary" data-icon="external-link">Platform overview on haut.ai</a>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.saas.haut.ai/haut.ai/developers/saas-api-overview/api-for-algorithm-applications.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
