# Favorites service

Creating favorites allows users to pin specific resources (i.e. assets, workbooks, etc.) as favorites for quick access within search pages throughout the application for themselves.

OpenAPI file: [`FavoritesService.json`](https://dev.nominal.io/api/_downloads/d5088ef761f3aa8d40062e9024ec1573/FavoritesService.json)

## Endpoints

### Get favorites list

GET `/scout/v2/favorites/workspace/{workspaceRid}`

Retrieves the favorites list for the current user in the specified workspace.

Path parameters

`workspaceRid` string (RID) required
:   ​

Query parameters

`resourceTypes` array of string, one of `ASSET`, `RUN`, `NOTEBOOK`, `NOTEBOOK_TEMPLATE`, `CHECKLIST`, `SAVED_VIEW`, `PROCEDURE`, `PLAN`
:   The resource types to include in the favorites list. If none are provided, all resource types will be included.

Response

`favorites` array of [`FavoriteResource`](https://dev.nominal.io/api/rest/favorites-service.md#favoriteresource)
:   ​

    **asset**

    Set `type` to `"asset"`.

    `asset` string (RID)
    :   ​

    **run**

    Set `type` to `"run"`.

    `run` string (RID)
    :   ​

    **notebook**

    Set `type` to `"notebook"`.

    `notebook` string (RID)
    :   ​

    **notebookTemplate**

    Set `type` to `"notebookTemplate"`.

    `notebookTemplate` string (RID)
    :   ​

    **checklist**

    Set `type` to `"checklist"`.

    `checklist` string (RID)
    :   ​

    **savedView**

    Set `type` to `"savedView"`.

    `savedView` string (RID)
    :   ​

    **procedure**

    Set `type` to `"procedure"`.

    `procedure` string (RID)
    :   ​

    **plan**

    Set `type` to `"plan"`.

    `plan` string (RID)
    :   ​

Request

**curl**

```shell
curl "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>" \
  -H "Authorization: Bearer <api key>"
```

**requests**

```python
import requests

response = requests.get(
    "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>",
    headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
```

**httpx**

```python
import httpx

response = httpx.get(
    "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>",
    headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
```

**aiohttp**

```python
import asyncio

import aiohttp

async def main() -> None:
    async with aiohttp.ClientSession() as session:
        async with session.get(
            "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>",
            headers={"Authorization": "Bearer <api key>"},
        ) as response:
            response.raise_for_status()
            print(await response.json())

asyncio.run(main())
```

Response: `200`

```json
{
  "favorites": [
    {
      "type": "asset",
      "asset": "<asset rid>"
    }
  ]
}
```

### Set favorites list

PUT `/scout/v2/favorites/workspace/{workspaceRid}`

Overwrites the favorites list for the current user in the specified workspace.

Path parameters

`workspaceRid` string (RID) required
:   ​

Body

`resources` array of [`FavoriteResource`](https://dev.nominal.io/api/rest/favorites-service.md#favoriteresource)
:   The resources to set as the user’s favorites. Note that the provided list will overwrite all the user’s previous favorites.

    **asset**

    Set `type` to `"asset"`.

    `asset` string (RID)
    :   ​

    **run**

    Set `type` to `"run"`.

    `run` string (RID)
    :   ​

    **notebook**

    Set `type` to `"notebook"`.

    `notebook` string (RID)
    :   ​

    **notebookTemplate**

    Set `type` to `"notebookTemplate"`.

    `notebookTemplate` string (RID)
    :   ​

    **checklist**

    Set `type` to `"checklist"`.

    `checklist` string (RID)
    :   ​

    **savedView**

    Set `type` to `"savedView"`.

    `savedView` string (RID)
    :   ​

    **procedure**

    Set `type` to `"procedure"`.

    `procedure` string (RID)
    :   ​

    **plan**

    Set `type` to `"plan"`.

    `plan` string (RID)
    :   ​

Response

`favorites` array of [`FavoriteResource`](https://dev.nominal.io/api/rest/favorites-service.md#favoriteresource)
:   ​

    **asset**

    Set `type` to `"asset"`.

    `asset` string (RID)
    :   ​

    **run**

    Set `type` to `"run"`.

    `run` string (RID)
    :   ​

    **notebook**

    Set `type` to `"notebook"`.

    `notebook` string (RID)
    :   ​

    **notebookTemplate**

    Set `type` to `"notebookTemplate"`.

    `notebookTemplate` string (RID)
    :   ​

    **checklist**

    Set `type` to `"checklist"`.

    `checklist` string (RID)
    :   ​

    **savedView**

    Set `type` to `"savedView"`.

    `savedView` string (RID)
    :   ​

    **procedure**

    Set `type` to `"procedure"`.

    `procedure` string (RID)
    :   ​

    **plan**

    Set `type` to `"plan"`.

    `plan` string (RID)
    :   ​

Request

**curl**

```shell
curl -X PUT "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>" \
  -H "Authorization: Bearer <api key>" \
  -H "Content-Type: application/json" \
  --data '{
  "resources": [
    {
      "type": "asset",
      "asset": "<asset rid>"
    }
  ]
}'
```

**requests**

```python
import requests

response = requests.put(
    "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>",
    headers={"Authorization": "Bearer <api key>"},
    json={"resources": [{"type": "asset", "asset": "<asset rid>"}]},
)
response.raise_for_status()
print(response.json())
```

**httpx**

```python
import httpx

response = httpx.put(
    "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>",
    headers={"Authorization": "Bearer <api key>"},
    json={"resources": [{"type": "asset", "asset": "<asset rid>"}]},
)
response.raise_for_status()
print(response.json())
```

**aiohttp**

```python
import asyncio

import aiohttp

async def main() -> None:
    async with aiohttp.ClientSession() as session:
        async with session.put(
            "https://api.gov.nominal.io/api/scout/v2/favorites/workspace/<workspace rid>",
            headers={"Authorization": "Bearer <api key>"},
            json={"resources": [{"type": "asset", "asset": "<asset rid>"}]},
        ) as response:
            response.raise_for_status()
            print(await response.json())

asyncio.run(main())
```

Response: `200`

```json
{
  "favorites": [
    {
      "type": "asset",
      "asset": "<asset rid>"
    }
  ]
}
```

## Errors

[Errors](https://dev.nominal.io/api/legacy.md#errors) shows how these errors are sent.

Each error’s `errorName` is `Favorites:` followed by its name below.

| Status | Name | Notes |
| --- | --- | --- |
| 400 | `DuplicateResourcesError` |  |
| 404 | `ResourcesNotFoundError` |  |

## Types

### FavoriteResource

Set `type` to the name of one of the other fields, and set only that field.

`asset` string (RID)
:   ​

`run` string (RID)
:   ​

`notebook` string (RID)
:   ​

`notebookTemplate` string (RID)
:   ​

`checklist` string (RID)
:   ​

`savedView` string (RID)
:   ​

`procedure` string (RID)
:   ​

`plan` string (RID)
:   ​

Page design based on [Scalar](https://scalar.com), MIT License.
