# Search Attachments

Use a Search Attachments node in your Flow to list and filter the attachments stored against records of the specified Object Type. You can filter results by file size range, upload date, and content type. To configure a Search Attachments node in the Flow Editor, drag it from the Palette to the Workspace canvas, then double-click the node to open and configure its behavior.

{% stepper %}
{% step %}

### Provide an optional **Name** for the node.

* By default a Search Attachments node will be shown with a label of "search attachments", but the value you provide in the Name field will replace it in the Flow Editor UI making your flow easier to read and understand.
  {% endstep %}

{% step %}

### Select a **Type Id** for the node — the Object Type that has Records with which you want to use attachments, specified using one of several options.

* *type* - choose this option for a dropdown that includes the Display Names of the Object Types you have created in your Contextual tenant.
* *string* - choose the string option, and type in a string for the Object Type ID, using *type* is recommended instead of string
* *msg.* - choose this option to specify a path in the msg. object that contains the Object Type ID value
* *env variable* - Environmental Variables are a feature of Agents in Contextual. Any Environmental Variables that you define as Label/Value pairs for an Agent that is sending events to a Flow, will be available to the Flow, simply type the Label of the Environmental Variable from which you want to use the value.
  {% endstep %}

{% step %}

### Specify a required **Page Size** to limit the number of attachment results returned to your flow.

{% endstep %}

{% step %}

### Optionally enable **Include Total** to include a total count of all matching attachments alongside the paged results.

{% endstep %}

{% step %}

### Optionally specify an **Object Id** to scope the search to attachments on a specific record.

* Use *string or* *msg.*
* Leave empty to search across attachments for all records of the specified type
  {% endstep %}

{% step %}

### Configure the **Size** filter to narrow results by file size.

* Choose *All* to return attachments regardless of size
* Choose a comparison operator (`>`, `>=`, `=`, `<`, `<=`) to filter relative to a single size value
* Choose *Range* to filter to a size window — specify a **From** value and a **To** value
* Size values can be sourced from *msg.* or entered as a literal number, each with a unit: *B*, *KiB*, *MiB*, or *GiB*
  {% endstep %}

{% step %}

### Configure the **Date** filter to narrow results by upload date.

* Choose *All* to return attachments regardless of when they were uploaded
* Choose a comparison operator (`>`, `>=`, `=`, `<`, `<=`) to filter relative to a single date value
* Choose *Range* to filter to a specific upload date window — specify a **From** date and a **To** date
  {% endstep %}

{% step %}

### Configure the **Content Types** filter to narrow results to specific MIME types.

* Add one or more content type values (e.g. `application/pdf`, `image/jpeg`) using *string*, *msg.*, *flow.*, *global.*, or *env variable* sources
* Leave empty to return attachments of any content type
  {% endstep %}

{% step %}

### Choose a **Filter Mode** for combining multiple active filters.

* *AND* — all active filters must match for an attachment to be included in results
* *OR* — any active filter matching is sufficient for an attachment to be included in results
  {% endstep %}

{% step %}

### Optionally configure advanced **Search**, **Filter**, and **Fields** inputs for more complex queries.

* When both Basic (size, date, content type) and Advanced inputs are populated for the same criteria, the Advanced inputs take precedence.
  {% endstep %}

{% step %}

### Specify the **Output** msg. object path to store the search results, e.g. `msg.payload`.

{% endstep %}
{% endstepper %}

When the Search Attachments node is included in the path of your flow, it will query and return matching attachment metadata as configured.
