# Collection (1:N) Check

The collection check algorithm is designed to check the presence of a person using a database of preloaded photos. A video fragment and/or a photo can be used as a source for comparison.

#### Prerequisites:

1. You're [authorized](/oz-knowledge/guides/developer-guide/api/oz-api/use-cases/authentication.md).
2. You have already [created a folder and added your media](/oz-knowledge/guides/developer-guide/api/oz-api/use-cases/uploading-media.md) marked by correct tags into this folder.
3. You have already uploaded a database of images for comparison. If not, please do it as described [here](/oz-knowledge/guides/developer-guide/api/oz-api/basic-scenarios/collection/collection-management-in-oz-api.md#how-to-create-a-collection).

#### Processing steps:

1\. Initiate the analysis: `POST/api/folders/{{folder_id}}/analyses/`

If you want to use a webhook for response, add it to the payload at this step, as described [here](/oz-knowledge/guides/developer-guide/api/oz-api/use-cases/using-a-webhook-to-get-results.md).

{% code title="request body" %}

```javascript
{
  "analyses": [{
    "type": "collection",
    "collection_id": "your_image_database_id",
    "source_media": ["1111aaaa-11aa-11aa-11aa-111111aaaaaa"] // // optional; omit to include all media from the folder
  }]
}
```

{% endcode %}

You'll need `analysis_id` or `folder_id` from response.

2\. If you use a webhook, just wait for it to return the information needed. Otherwise, initiate polling:

* `GET /api/analyses/{{analysis_id}}` – for the `analysis_id` you have from the previous step.
* `GET /api/folders/{{folder_id}}` – for all analyses performed on media in the folder with the `folder_id` you have from the previous step.&#x20;

Wait for the `resolution_status` and `resolution` fields to change the status to anything other than `PROCESSING` and treat this as a result.

If you want to know which person from your collection matched with the media you have uploaded, find the `collection` analysis in the response, check `results_media`, and retrieve `person_id`. This is the ID of the person who matched with the person in your media. To get the information about this person, use `GET /api/collections/{{collection_id}}/persons/{{person_id}}` with IDs of your collection and person.


---

# Agent Instructions: 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:

```
GET https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/api/oz-api/basic-scenarios/collection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
