> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events/use-cases.md).

# Use Cases

## About

A Use Case groups [Vision Events](/deployment/monitoring-and-analytics/vision-events.md) that share a common purpose and custom metadata structure, and every event belongs to exactly one Use Case. Organizing events this way makes it easy to filter and compare data across cameras, devices, and locations that report the same fields. This page explains when to use one Use Case versus several, and how to create and manage them.

## Web App

### Use Cases

A Use Case groups Vision Events that share a common purpose and custom metadata structure. Every event belongs to exactly one Use Case. Events in the same Use Case typically share the same metadata fields, making it easy to filter and compare data across different sources.

#### When to Use One vs. Multiple Use Cases

**Put events in the same Use Case** when they share similar custom metadata fields even if they come from different locations, cameras, or devices. For example, a "Defect Detection" Use Case might receive events from multiple factories, but all events include `line_id`, `shift`, and `part_number`.

**Create separate Use Cases** when the metadata structure is fundamentally different. For example:

* **Assembly Line QA** - tracks `line_id`, `shift`, `part_number`
* **Warehouse Inventory** - tracks `aisle`, `shelf`, `item_type`
* **Construction Site Safety** - tracks `zone`, `alert_type`, `contractor`

#### Create a Use Case

**Via the Agent**

The [Roboflow Agent](https://docs.roboflow.com/agents/agents/roboflow-agent) creates Use Cases automatically when it builds a Workflow with Vision Events. It picks an existing Use Case if one fits, or creates a new one based on your described use case. You can also ask the Agent directly to set up a new Use Case.

**In the Dashboard**

1. Navigate to **Vision Events** in the left sidebar of your workspace
2. Click **+ Create Use Case**
3. Enter a name for the Use Case

<figure><img src="/files/3Tm2XnvfeJH33Cxsf3D3" alt="" width="375"><figcaption></figcaption></figure>

You can also create Use Cases via the REST API, see [Manage Use Cases Programmatically](#manage-use-cases-programmatically).

#### View Use Cases

**In the Dashboard**

The Vision Events page displays a table of all your Use Cases, showing:

* Use Case name
* Total event count
* Last event timestamp
* Event types in use

**Via the API**

Retrieve all Use Cases in your workspace:

```bash
curl -X GET "https://api.roboflow.com/vision-events/use-cases" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

See the [Vision Events API Reference](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events#http-api) for the full response format.

#### Manage Use Cases Programmatically

In addition to the dashboard, you can create, rename, archive, and unarchive Use Cases via the REST API. These endpoints require an API key with the `vision-events:manage` scope (unrestricted workspace API keys have access by default).

**Create a Use Case**

```bash
curl -X POST "https://api.roboflow.com/vision-events/use-cases" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{ "name": "assembly-line-qa" }'
```

**Rename a Use Case**

```bash
curl -X PUT "https://api.roboflow.com/vision-events/use-cases/USE_CASE_ID" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{ "name": "assembly-line-qa-v2" }'
```

**Archive or Unarchive a Use Case**

```bash
curl -X POST "https://api.roboflow.com/vision-events/use-cases/USE_CASE_ID/archive" \
  -H "Authorization: Bearer YOUR_API_KEY"

curl -X POST "https://api.roboflow.com/vision-events/use-cases/USE_CASE_ID/unarchive" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

#### Archive a Use Case

Use Cases can be archived from the dashboard when they are no longer needed. Archived Use Cases and their events remain accessible but are hidden from the default view. Click **View archived use cases** at the bottom of the Use Cases table to see them.\ <br>

<figure><img src="/files/9L4xxIyY25Dw2fkXN6KB" alt=""><figcaption></figcaption></figure>

#### Custom Metadata Schema

After events are sent to a Use Case, the system infers a metadata schema based on the fields and value types observed. You can retrieve the inferred schema for a Use Case to understand what keys and value types are in use:

```bash
curl -X GET "https://api.roboflow.com/vision-events/custom-metadata-schema/assembly-line-qa" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Example response:**

```json
{
  "useCaseId": "assembly-line-qa",
  "fields": {
    "line_id": { "types": ["string"] },
    "shift": { "types": ["string"] },
    "temperature": { "types": ["number"] },
    "is_priority": { "types": ["boolean"] }
  }
}
```

See the [Vision Events API Reference](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events#http-api) for full details.

## HTTP API

### Create a Use Case

Create a new use case in your workspace. Use cases help you organize vision events by deployment context (e.g., "Manufacturing Line 1", "Warehouse Inventory").

**Required scope:** `vision-events:manage`

{% openapi src="/files/sCDP9kVopV4JkkRK7GDd" path="/vision-events/use-cases" method="post" %}
[openapi.yaml](https://1583372177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-dfdc1702ad3d1a62ad0a661e9609f6bbe2fc8d4c%2Fopenapi.yaml?alt=media)
{% endopenapi %}

#### Request Body Parameters

* **`name`** (string, required): A name for the use case. Must be between 1 and 256 characters. The name is trimmed of leading/trailing whitespace and must be unique within the workspace.

#### Example Request

```bash
curl -X POST "https://api.roboflow.com/vision-events/use-cases" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Manufacturing Line 1"
  }'
```

#### Example Response

{% tabs %}
{% tab title="201" %}

```json
{
  "id": "a1b3c8e1",
  "name": "Manufacturing Line 1"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "A solution with this name already exists"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "Insufficient permissions for this resource."
}
```

{% endtab %}
{% endtabs %}

#### Notes

* New use cases are created with an `active` status by default.
* Use case names must be unique within a workspace. Attempting to create a use case with the same name as an existing one will return a `400` error.
* After creating a use case, you can reference its `id` as the `useCaseId` when [creating vision events](/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#http-api).

### Update a Use Case

Update the name or status of an existing use case.

**Required scope:** `vision-events:manage`

{% openapi src="/files/sCDP9kVopV4JkkRK7GDd" path="/vision-events/use-cases/{useCaseId}" method="put" %}
[openapi.yaml](https://1583372177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-dfdc1702ad3d1a62ad0a661e9609f6bbe2fc8d4c%2Fopenapi.yaml?alt=media)
{% endopenapi %}

#### Path Parameters

* **`useCaseId`** (string, required): The ID of the use case to update.

#### Request Body Parameters

At least one of the following fields must be provided:

* **`name`** (string, optional): A new name for the use case. Must be between 1 and 256 characters. Must be unique within the workspace.
* **`status`** (string, optional): The new status. One of `active` or `inactive`.

#### Example Request

```bash
curl -X PUT "https://api.roboflow.com/vision-events/use-cases/a1b3c8e1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Manufacturing Line 2"
  }'
```

#### Example Response

{% tabs %}
{% tab title="200" %}

```json
{
  "id": "a1b3c8e1",
  "name": "Manufacturing Line 2"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "A solution with this name already exists"
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "error": "Solution not found"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "Insufficient permissions for this resource."
}
```

{% endtab %}
{% endtabs %}

### List Use Cases

List all use cases that have recorded vision events in your workspace. To learn how to create and manage use cases, see the [Use Cases documentation](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events/use-cases).

**Required scope:** `vision-events:read` or `device:read`

{% openapi src="/files/sCDP9kVopV4JkkRK7GDd" path="/vision-events/use-cases" method="get" %}
[openapi.yaml](https://1583372177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-dfdc1702ad3d1a62ad0a661e9609f6bbe2fc8d4c%2Fopenapi.yaml?alt=media)
{% endopenapi %}

#### Query Parameters

* **`status`** (string, optional): Filter by use case status. One of `active` or `inactive`. Defaults to `active`.

#### Example Request

```bash
curl "https://api.roboflow.com/vision-events/use-cases" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

#### Example Response

{% tabs %}
{% tab title="200" %}

```json
{
  "useCases": [
    {
      "id": "a1b3c8e1",
      "name": "Manufacturing Line 1",
      "status": "active",
      "workspaceId": "my-workspace",
      "createdAt": "2024-01-10T08:00:00.000Z",
      "updatedAt": "2024-01-15T10:30:00.000Z"
    },
    {
      "id": "d4e5f6a7",
      "name": "Warehouse Inventory",
      "status": "active",
      "workspaceId": "my-workspace",
      "createdAt": "2024-01-12T14:00:00.000Z",
      "updatedAt": "2024-01-15T09:00:00.000Z"
    }
  ],
  "lookbackDays": 14
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "Insufficient permissions for this resource."
}
```

{% endtab %}
{% endtabs %}

### Archive a Use Case

Archive a use case by setting its status to `inactive`. Archived use cases are hidden from listings by default and will reject new event ingestion.

**Required scope:** `vision-events:manage`

{% openapi src="/files/sCDP9kVopV4JkkRK7GDd" path="/vision-events/use-cases/{useCaseId}/archive" method="post" %}
[openapi.yaml](https://1583372177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-dfdc1702ad3d1a62ad0a661e9609f6bbe2fc8d4c%2Fopenapi.yaml?alt=media)
{% endopenapi %}

#### Path Parameters

* **`useCaseId`** (string, required): The ID of the use case to archive.

#### Example Request

```bash
curl -X POST "https://api.roboflow.com/vision-events/use-cases/a1b3c8e1/archive" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

#### Example Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "error": "Solution not found"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "Insufficient permissions for this resource."
}
```

{% endtab %}
{% endtabs %}

#### Notes

* Archiving is a soft delete. The use case and its events are preserved but hidden from active listings.
* To view archived use cases, use the [List Use Cases](#http-api) endpoint with `status=inactive`.
* You can restore an archived use case using the [Unarchive a Use Case](#http-api) endpoint.

### Unarchive a Use Case

Restore a previously archived use case by setting its status back to `active`.

**Required scope:** `vision-events:manage`

{% openapi src="/files/sCDP9kVopV4JkkRK7GDd" path="/vision-events/use-cases/{useCaseId}/unarchive" method="post" %}
[openapi.yaml](https://1583372177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-dfdc1702ad3d1a62ad0a661e9609f6bbe2fc8d4c%2Fopenapi.yaml?alt=media)
{% endopenapi %}

#### Path Parameters

* **`useCaseId`** (string, required): The ID of the use case to unarchive.

#### Example Request

```bash
curl -X POST "https://api.roboflow.com/vision-events/use-cases/a1b3c8e1/unarchive" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

#### Example Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Solution is not archived"
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "error": "Solution not found"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "Insufficient permissions for this resource."
}
```

{% endtab %}
{% endtabs %}

#### Notes

* Only use cases with an `inactive` status can be unarchived. Attempting to unarchive an already active use case will return a `400` error.
* Once unarchived, the use case will appear in active listings and accept new event ingestion again.

## Python SDK

Each vision event is associated with a use case. The Python SDK provides methods to create, list, rename, archive, and unarchive use cases.

### List Use Cases

```python
import roboflow

roboflow.login()

rf = roboflow.Roboflow()
ws = rf.workspace()

result = ws.list_vision_event_use_cases()

for uc in result["useCases"]:
    print(uc["id"], uc["name"], uc.get("status"))
```

You can filter by status:

```python
# List only active use cases
result = ws.list_vision_event_use_cases(status="active")
```

### Create a Use Case

```python
result = ws.create_vision_event_use_case("manufacturing-qa")
use_case_id = result["id"]
print(f"Created use case: {use_case_id}")
```

### Rename a Use Case

```python
ws.rename_vision_event_use_case("a1b3c8e1", "updated-name")
```

### Archive a Use Case

```python
ws.archive_vision_event_use_case("a1b3c8e1")
```

### Unarchive a Use Case

```python
ws.unarchive_vision_event_use_case("a1b3c8e1")
```

For more details on use case management, see the [REST API reference](#http-api).
