> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Filter Segment

> This API updates an existing filter segment by its ID.

<Note>
  This API endpoint does not currently support Team-level scoping. All segments generated using this call will be assigned to the Default Team automatically.
</Note>


## OpenAPI

````yaml /api/custom-segments/custom-segments.yaml patch /v3/custom-segments/{id}
openapi: 3.0.3
info:
  title: MoEngage Segments API
  description: >
    Use the MoEngage Segments API to create, update, and manage your file and
    filter segments.


    - **v2 API:** Manage File Segments and segment lifecycle
    (Archive/Unarchive).

    - **v3 API:** Create, read, update, and list filter-based Segments.
  version: '3.0'
servers:
  - url: https://api-{dc}.moengage.com
    description: MoEngage API Endpoint
    variables:
      dc:
        description: >-
          The ‘dc’ in the API Endpoint URL refers to the MoEngage Data Center
          (DC). MoEngage hosts each customer in a different DC. You can find
          your DC number and replace the value of ‘dc’ in the URL by referring
          to the DC and API endpoint mapping
          [here](/api/introduction#data-centers). Your MoEngage Data Center (DC)
          can be 01, 02, 03, 04, 05, 06, or 101.
        default: '01'
security:
  - basicAuth: []
tags:
  - name: File Segments
    description: >
      If you need to create segments by importing a large number of users, we
      recommend utilising the File segment API. This API allows you to easily
      generate a file segment by initiating a call to the file segment API
      endpoint. To proceed, you will need to compile a CSV file containing the
      relevant users (ensuring that the users are already present in MoEngage).
      It is essential to provide the public path of the file, which allows for
      downloading and identification of users in order to successfully create
      the file segment.


      Use the File Segment API to:

      * Create a new file segment

      * Add users to an existing segment

      * Remove users from an existing segment

      * Replace users from an existing segment
  - name: Manage Segments
    description: >
      Archiving and unarchiving through APIs makes it easy to retrieve and reuse
      segments whenever required for purposes such as A/B testing, maintaining
      regulatory compliance, and improving system performance.


      You can unarchive an archived segment to reuse it in campaigns and
      analysis without recreating it from scratch.
    x-mint:
      content: |

        <Warning>
          Archived segments will not be shown beyond 180 days.
        </Warning>
  - name: Filter Segments
    description: >
      If you need to create a segment based on the events or actions performed
      by your users on your application or website, the recommended approach is
      to use the filter segment API. With this API, you can create a segment by
      specifying the desired filter conditions.


      The filter segment API supports various operations, including create,
      update, get, and list, allowing you to effectively manage your segments
      based on specific criteria.
    x-mint:
      content: >
        ## Authentication

        Authentication is performed using Basic Auth. You must also provide the
        `MOE-APPKEY` header.


        ## Request Headers


        | Key | Required | Description |

        | :--- | :--- | :--- |

        | `Content-Type` | Yes | Set to `application/json`. |

        | `Authorization` | Yes | Basic Auth. `{"Authorization": "Basic
        Base64_ENCODED_WORKSPACEID_APIKEY="}` |

        | `MOE-APPKEY` | Yes | Your MoEngage App ID. Found in Settings ->
        Account -> APIs -> App ID. |
paths:
  /v3/custom-segments/{id}:
    patch:
      tags:
        - Filter Segments
      summary: Update Filter Segment
      description: This API updates an existing filter segment by its ID.
      operationId: updateFilterSegment
      parameters:
        - $ref: '#/components/parameters/AppKeyHeader'
        - $ref: '#/components/parameters/DbNameHeaderOptional'
        - $ref: '#/components/parameters/SegmentIdPath'
      requestBody:
        description: The updated filter definition for the segment.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilterSegmentUpdateRequestV3'
            example:
              name: segment_example_name_updated
              included_filters:
                filter_operator: and
                filters:
                  - filter_type: user_attributes
                    name: Name
                    data_type: string
                    operator: in
                    value:
                      - chandan
                    negate: false
                    case_sensitive: false
              updated_by: admin@example.com
      responses:
        '200':
          $ref: '#/components/responses/200_SegmentUpdatedV3'
        '400':
          $ref: '#/components/responses/400_FilterSegmentError'
        '401':
          $ref: '#/components/responses/401_FilterSegmentError'
        '403':
          $ref: '#/components/responses/403_FilterSegmentError'
        '404':
          $ref: '#/components/responses/404_FilterSegmentError'
        '409':
          $ref: '#/components/responses/409_FilterSegmentError'
        '412':
          $ref: '#/components/responses/412_FilterSegmentError'
        '413':
          $ref: '#/components/responses/413_FilterSegmentError'
        '429':
          $ref: '#/components/responses/429_FilterSegmentError'
        '500':
          $ref: '#/components/responses/500_FilterSegmentError'
components:
  parameters:
    AppKeyHeader:
      name: MOE-APPKEY
      in: header
      description: >
        This is the Workspace ID of your MoEngage account that must be passed
        with the request. You can find it in the MoEngage dashboard at
        **Settings** > **Account** > **APIs** > **Workspace ID (earlier app
        id)**.


        You can send `MOE-DBNAME` with your database name instead of this
        header. The request must include one of the two.
      required: true
      schema:
        type: string
    DbNameHeaderOptional:
      name: MOE-DBNAME
      in: header
      description: >
        Your MoEngage database name. Send this as an alternative to `MOE-APPKEY`
        when you identify the

        workspace by database name. Omit it when `MOE-APPKEY` is already
        present.
      required: false
      schema:
        type: string
    SegmentIdPath:
      name: id
      in: path
      description: The ID of the segment.
      required: true
      schema:
        type: string
  schemas:
    FilterSegmentUpdateRequestV3:
      type: object
      description: Request schema for updating an existing filter-based segment.
      properties:
        name:
          type: string
          description: A new unique name for the segment.
        included_filters:
          $ref: '#/components/schemas/FilterGroupV3'
          description: >-
            The updated filter criteria for inclusion. Users matching these
            filters will be part of the segment.
        excluded_filters:
          $ref: '#/components/schemas/FilterGroupV3'
          description: >
            Optional. The updated filter criteria for exclusion. Users matching
            these filters are removed from the

            included set even if they satisfy `included_filters`.
        updated_by:
          type: string
          format: email
          description: >-
            Email of the user performing the update (for example,
            admin@companyemail.com).
      required:
        - included_filters
    FilterGroupV3:
      type: object
      description: A logical grouping of filters.
      properties:
        filter_operator:
          type: string
          description: The logical operator to combine the filters.
          enum:
            - and
            - or
        filters:
          type: array
          items:
            $ref: '#/components/schemas/FilterV3'
      required:
        - filter_operator
        - filters
    FilterSegmentResponseV3:
      type: object
      description: Response schema for filter segment operations (create/update).
      properties:
        data:
          $ref: '#/components/schemas/FilterSegmentDataV3'
          description: Information about the segment.
        response_id:
          type: string
          description: A unique identifier for this API response.
        type:
          type: string
          description: The type of resource referenced in the response.
          example: custom_segment
    ErrorResponseV3:
      type: object
      description: Error response schema for client errors (4xx).
      properties:
        response_id:
          type: string
          description: A unique identifier for this API response.
        type:
          type: string
          description: The type of resource referenced in the response.
          example: custom_segment
        error:
          $ref: '#/components/schemas/ErrorDataV3'
          description: Details about the error that occurred.
    ConflictErrorResponseV3:
      type: object
      description: Error response schema for conflict errors (409).
      properties:
        response_id:
          type: string
          description: A unique identifier for this API response.
        type:
          type: string
          description: The type of resource referenced in the response.
          example: custom_segment
        error:
          $ref: '#/components/schemas/ConflictErrorDataV3'
          description: Details about the conflict that occurred.
    RateLimitErrorResponseV3:
      type: object
      description: Error response schema for rate limit errors (429).
      properties:
        response_id:
          type: string
          description: A unique identifier for this API response.
        type:
          type: string
          description: The type of resource referenced in the response.
          example: custom_segment
        error:
          $ref: '#/components/schemas/RateLimitErrorDataV3'
          description: Details about the rate limit breach.
    ServerErrorResponseV3:
      type: object
      description: Error response schema for server errors (5xx).
      properties:
        response_id:
          type: string
          description: A unique identifier for this API response.
        type:
          type: string
          description: The type of resource referenced in the response.
          example: custom_segment
        error:
          $ref: '#/components/schemas/ServerErrorDataV3'
          description: Details about the server error that occurred.
    FilterV3:
      description: >
        A single filter criterion. The `filter_type` field selects the filter
        kind:

        - `user_attributes` — filter by a user profile attribute

        - `actions` — filter by an event the user has or has not performed

        - `psychographic_event` — filter by affinity/behavioral patterns over an
        event

        - `custom_segments` — reference a saved segment by ID

        - `nested_filters` — AND/OR group container for combining other filters
      oneOf:
        - $ref: '#/components/schemas/AttributeFilterV3'
        - $ref: '#/components/schemas/ActionFilterV3'
        - $ref: '#/components/schemas/AffinityFilterV3'
        - $ref: '#/components/schemas/CustomSegmentFilterV3'
        - $ref: '#/components/schemas/NestedFiltersV3'
      discriminator:
        propertyName: filter_type
        mapping:
          user_attributes:
            $ref: '#/components/schemas/AttributeFilterV3'
          actions:
            $ref: '#/components/schemas/ActionFilterV3'
          psychographic_event:
            $ref: '#/components/schemas/AffinityFilterV3'
          custom_segments:
            $ref: '#/components/schemas/CustomSegmentFilterV3'
          nested_filters:
            $ref: '#/components/schemas/NestedFiltersV3'
    FilterSegmentDataV3:
      type: object
      description: Detailed information about a segment.
      properties:
        name:
          type: string
          description: The name of the segment.
        id:
          type: string
          description: The unique identifier of the segment.
        created_time:
          type: string
          format: date-time
          description: The timestamp when the segment was created (ISO 8601 format).
        updated_time:
          type: string
          format: date-time
          description: >-
            The timestamp when the segment was last updated (ISO 8601 format).
            The updated time can change due to internally running services.
        type:
          type: string
          description: >-
            The type of the segment. This is used for internal classification.
            Fixed value for filter-based segments.
          example: ELASTIC_SEARCH
        source:
          type: string
          description: >-
            The source of segment creation. Fixed value for API-created
            segments.
          example: API
        description:
          type: string
          description: A textual description summarizing the segment definition.
        included_filters:
          $ref: '#/components/schemas/FilterGroupResponseV3'
          description: The filter criteria used to include users in this segment.
        excluded_filters:
          $ref: '#/components/schemas/FilterGroupResponseV3'
          description: >-
            The filter criteria used to exclude users from this segment. Present
            when `excluded_filters` was used while creating or updating the
            segment.
    ErrorDataV3:
      type: object
      description: Error details for client errors (4xx).
      properties:
        code:
          type: string
          description: >-
            A short error code that provides a brief explanation of the error
            (e.g., 'Invalid Request', 'Authentication required').
        message:
          type: string
          description: A detailed error message describing why the request failed.
    ConflictErrorDataV3:
      type: object
      description: Error details for conflict errors (409).
      properties:
        code:
          type: string
          description: >-
            A short error code that provides a brief explanation of the error
            (e.g., 'Resource not created').
        message:
          type: string
          description: A detailed error message describing why the request failed.
        existing_cs_name:
          type: string
          description: The name of the existing segment that conflicts with the request.
        existing_cs_id:
          type: string
          description: The ID of the existing segment that conflicts with the request.
    RateLimitErrorDataV3:
      type: object
      description: Error details for rate limit errors (429).
      properties:
        code:
          type: string
          description: >-
            A short error code that provides a brief explanation of the error
            (e.g., 'Too Many Requests').
        message:
          type: string
          description: A detailed error message describing why the request failed.
        actual_count:
          type: integer
          description: >-
            (Active segment limit breaches only) The actual count of active
            segments.
        limit:
          type: integer
          description: (Active segment limit breaches only) The maximum allowed limit.
    ServerErrorDataV3:
      type: object
      description: Error details for server errors (5xx).
      properties:
        code:
          type: string
          description: >-
            A short error code indicating the type of server error (e.g.,
            'Internal Server Error').
        message:
          type: string
          description: >-
            A detailed error message. For server errors, this typically advises
            contacting MoEngage support.
    AttributeFilterV3:
      title: User Property Filter
      type: object
      description: >
        Filters users by a user profile attribute (`filter_type:
        "user_attributes"`).


        The required fields and shape of `value` depend on `data_type`:


        | `data_type` | Allowed `operator` values | Extra fields |

        |---|---|---|

        | `string` | `in`, `is`, `contains`, `startsWith`, `endsWith`,
        `containsInTheFollowing`, `startsWithInTheFollowing`,
        `endsWithInTheFollowing`, `exists` | `case_sensitive` |

        | `double` | `in`, `lessThan`, `greaterThan`, `between`, `exists` |
        `value1` when `operator` is `between` |

        | `bool` | `is`, `exists` | — |

        | `datetime` | `on`, `between`, `before`, `after`, `inTheLast`,
        `inTheNext`, `today`, `is`, `in`, `exists` | `value_type`; `value1` for
        `between`; `extract_type` for date-part filters |

        | `geopoint` | (implicit `around` — no `operator` in payload) | `value`
        (latitude), `value1` (longitude), `radius`, `negate` |

        | `array_string` | `in`, `contains`, `startsWith`, `endsWith`, `is`,
        `exists` | `case_sensitive`, `array_filter_type` (`any_of` or `all_of`)
        |

        | `array_double` | `in`, `lessThan`, `greaterThan`, `between`, `exists`
        | `array_filter_type` (`any_of` or `all_of`); `value1` for `between` |

        | `object` | N/A — uses `filter_operator` + `filters[]` |
        `filter_operator`, `filters` (no `operator`, `negate`, or `value`) |

        | `array_object` | N/A — uses `filter_operator` + `filters[]` |
        `filter_operator`, `filters` (no `operator`, `negate`, or `value`) |


        When `operator` is `exists`, omit `value`, `value1`, and `value_type`.


        The dashboard's "contains spaces" and "is empty" options have no
        matching payload operator.

        Send `operator: "contains"` with `value: " "` for contains spaces, and
        `operator: "is"`

        with `value: ""` for is empty.


        For cross-attribute comparison, set `is_dynamic_value: true`, set
        `dynamic_attribute_type` to the base type of the referenced attribute,
        and use a template string as `value`:
        `"{{MoeUserAttribute['attr_name']}}"`. For array types,
        `dynamic_attribute_type` is the element type (`array_string` →
        `"string"`, `array_double` → `"double"`). Cross-attribute comparison is
        not available for `object` or `array_object`, or for `double` and
        `array_double` when `operator` is `between`.
      properties:
        filter_type:
          type: string
          description: >
            Set to `user_attributes` for a User Property filter, or
            `action_attributes` for a filter

            inside an event's `attributes` block. Omit this key inside
            `psychographic_attributes`.
          enum:
            - user_attributes
            - action_attributes
        name:
          type: string
          description: >-
            The internal name of the user attribute (for example,
            `last_purchase_date`).
        data_type:
          type: string
          description: The data type of the attribute.
          enum:
            - string
            - double
            - bool
            - datetime
            - geopoint
            - array_string
            - array_double
            - object
            - array_object
        category:
          type: string
          description: >-
            The attribute group the attribute belongs to (for example, `Tracked
            Custom Attribute`). Always include this key.
        operator:
          type: string
          description: >
            The comparison operator. Allowed values depend on `data_type`.
            Omitted for `geopoint`, `object`, and `array_object`.
          enum:
            - is
            - in
            - contains
            - containsInTheFollowing
            - startsWith
            - startsWithInTheFollowing
            - endsWith
            - endsWithInTheFollowing
            - exists
            - lessThan
            - greaterThan
            - between
            - 'on'
            - before
            - after
            - inTheLast
            - inTheNext
            - today
        negate:
          type: boolean
          description: >-
            Set to `true` to invert the filter (NOT condition). Present for all
            data types except `object` and `array_object`, where it is omitted.
          default: false
        value:
          description: >
            The comparison value. Shape depends on `data_type` and `operator`:

            - Scalar for `is`, `on`, `before`, `after`, `lessThan`,
            `greaterThan`, `startsWith`, `endsWith`, `contains`, `inTheLast`,
            `inTheNext`.

            - Array for `in`, `containsInTheFollowing`,
            `startsWithInTheFollowing`, `endsWithInTheFollowing`.

            - Latitude (number) for `geopoint`.

            - Omit when `operator` is `exists` or `today`.

            - For dynamic cross-attribute comparison:
            `"{{MoeUserAttribute['attr_name']}}"` with `is_dynamic_value: true`.
          oneOf:
            - type: string
            - type: number
            - type: boolean
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: number
        value1:
          description: >
            The second bound for range comparisons:

            - Upper bound when `operator` is `between` (numeric and datetime
            types).

            - Longitude for `geopoint`.
          oneOf:
            - type: string
            - type: number
        case_sensitive:
          type: boolean
          description: >-
            Applies to `string` and `array_string`. Set to `true` for
            case-sensitive matching.
          default: false
        value_type:
          type: string
          description: >
            Applies to `datetime` only. Specifies whether `value` is an ISO 8601
            date string (`absolute`)

            or a relative offset in days/hours/months (`relative_past` for past
            values, `relative_future` for future values used with `after` and
            `inTheNext`).
          enum:
            - absolute
            - relative_past
            - relative_future
        extract_type:
          type: string
          description: >
            Applies to `datetime` only. Filters on a specific part of the date
            rather than the full timestamp. Omit this key to match on the full
            date.

            - `time_of_the_day` — hour of day (0–23)

            - `day_of_the_week` — weekday (0–6)

            - `day_of_the_month` — day (1–31)

            - `month_of_the_year` — month (1–12)

            - `date_month_of_the_year` — month and day as an `MM-DD` string, for
            example `"06-15"`
          enum:
            - time_of_the_day
            - day_of_the_week
            - day_of_the_month
            - month_of_the_year
            - date_month_of_the_year
        radius:
          type: number
          description: Applies to `geopoint` only. The search radius in meters.
        array_filter_type:
          type: string
          description: >
            Applies to `array_string` and `array_double`. Determines whether the
            user's array attribute

            must match any (`any_of`) or all (`all_of`) of the specified values.

            Segments built in the dashboard omit this field when `negate` is
            `true`; sending it alongside

            `negate: true` is also accepted.
          enum:
            - any_of
            - all_of
        filter_operator:
          type: string
          description: >-
            Applies to `object` and `array_object`. The logical operator
            combining the child `filters`.
          enum:
            - and
            - or
        filters:
          type: array
          description: >
            Applies to `object` and `array_object`. Each element is a User
            Property filter scoped to

            the child attributes of the parent object. Supports recursive
            nesting.


            For `array_object`: a user matches if at least one element of their
            array passes all the

            inner filters combined by `filter_operator`. The combinator scopes
            children within a single

            array element, not across elements.
          items:
            $ref: '#/components/schemas/AttributeFilterV3'
        is_dynamic_value:
          type: boolean
          description: >
            Set to `true` when `value` references another user attribute rather
            than a literal.

            Pair with `dynamic_attribute_type` to specify the base type of the
            referenced attribute.

            Use the template format `"{{MoeUserAttribute['<attr_name>']}}"` for
            `value`.


            Segment creation supports user attribute comparison only. Comparing
            against an event

            attribute or a business event attribute is available in campaign
            filters.


            For `datetime` with a dynamic value, `value_type` is forced to
            `absolute`.
          default: false
        dynamic_attribute_type:
          type: string
          description: >
            Required when `is_dynamic_value` is `true`. The base type of the
            referenced attribute.

            For array types, use the element type: `array_string` → `"string"`,
            `array_double` → `"double"`.
          enum:
            - string
            - double
            - bool
            - datetime
      required:
        - filter_type
        - name
        - data_type
    ActionFilterV3:
      title: User Behavior Filter
      type: object
      description: >
        Filters users based on whether they have or have not performed a
        specific event (`filter_type: "actions"`).


        Supports frequency conditions (`execution`), a time window
        (`primary_time_range`),

        event attribute sub-filters (`attributes`), and optional numeric
        aggregation (`aggregation_attributes`).


        Always include `attributes` even when empty: `{ "filter_operator":
        "and", "filters": [] }`.


        **Executed vs not-executed:**

        - `executed: true` → default `execution: { type: "atleast", count: 1 }`

        - `executed: false` → auto-set `execution: { type: "exactly", count: 0
        }`; aggregation disabled


        UI tense labels ("Has Executed", "Does Execute", "Executes") are
        display-only and do not affect the payload.
      properties:
        filter_type:
          type: string
          description: Must be `actions` for a User Behavior filter.
          enum:
            - actions
        action_name:
          type: string
          description: The internal name of the event to filter on.
        project_name:
          type: string
          description: >
            Optional. Portfolio (multi-project) workspaces only. Scopes the
            filter to a specific project,

            using that project's name. `moe_portfolio` is one of the available
            values and targets all

            projects. Omit this key in single-project workspaces.
        executed:
          type: boolean
          description: >-
            Set to `true` to match users who performed the event; `false` to
            match users who did not.
        execution:
          type: object
          description: >
            The frequency condition for the event.


            | `type` | Meaning | `count` required |

            |---|---|---|

            | `atleast` | At least N times (default when `executed: true`) | Yes
            (> 0) |

            | `exactly` | Exactly N times | Yes (> 0) |

            | `atmost` | At most N times | Yes (> 0) |

            | `firstTime` | For the first time only | No — omit `count`;
            aggregation disabled |

            | `lastTime` | For the last time only | No — omit `count`;
            aggregation disabled |
          properties:
            type:
              type: string
              enum:
                - atleast
                - exactly
                - atmost
                - firstTime
                - lastTime
            count:
              type: integer
              format: int32
              description: >-
                Required for `atleast`, `exactly`, and `atmost`. Must be greater
                than 0.
          required:
            - type
        primary_time_range:
          type: object
          description: >
            The time window during which the event must have been performed.


            | `type` | `value` shape | Needs `value1` | Notes |

            |---|---|---|---|

            | `inTheLast` | Integer count of `period_unit` | No | `value_type:
            relative_past` (locked) |

            | `between` | Start value (integer count or ISO date) | Yes (end
            value) | Both absolute and relative supported |

            | `on` | ISO date or integer count | No | Both supported |

            | `before` | ISO date or integer count | No | Both supported |

            | `after` | ISO 8601 date | No | `value_type: absolute` (locked) |


            The dashboard's calendar windows are not payload `type` values.
            Today, Yesterday, This week,

            Last week, This month, and Last month all map onto `type: "on"` with
            `value: 0` or `1`,

            `value_type: "relative_past"`, and `period_unit` set to `days`,
            `weeks`, or `months`.


            Absolute date formatting: `value` → `YYYY-MM-DDT00:00:00.000Z`;
            `value1` → `YYYY-MM-DDT23:59:59.999Z`.

            For `between`, `value1` must be greater than `value`. Relative
            values beyond the workspace

            retention setting return a warning rather than an error.


            Segments built in the dashboard store relative windows as `days` and
            `days1` rather than

            `value` and `period_unit`, and a response for one of those segments
            returns that form.
          properties:
            type:
              type: string
              enum:
                - inTheLast
                - between
                - 'on'
                - before
                - after
            value_type:
              type: string
              description: >-
                Whether `value` is an ISO 8601 date (`absolute`) or an integer
                offset (`relative_past`).
              enum:
                - absolute
                - relative_past
            value:
              description: >-
                Integer count of `period_unit` for relative ranges, or an ISO
                8601 date string for absolute ranges.
            value1:
              description: End bound for `between`. ISO 8601 date or integer count.
            period_unit:
              type: string
              description: >-
                The unit of time. Applies to `inTheLast`, and disambiguates the
                calendar windows mapped onto `on`.
              enum:
                - hours
                - days
                - weeks
                - months
          required:
            - type
            - value_type
        attributes:
          $ref: '#/components/schemas/ActionAttributeFilterGroupV3'
          description: >
            Sub-filters on the event's own attributes — for example, `purchase`
            where `product_category` is `Electronics`.

            Always include this key even when empty: `{ "filter_operator":
            "and", "filters": [] }`.
        aggregation_attributes:
          type: object
          description: >
            Optional aggregation block. Present only when using aggregation mode
            (sum/avg/min/max over a numeric event attribute).

            See `AggregationAttributeFilterV3` for constraints.
          properties:
            filter_operator:
              type: string
              enum:
                - and
                - or
            filters:
              type: array
              items:
                $ref: '#/components/schemas/AggregationAttributeFilterV3'
          required:
            - filter_operator
            - filters
      required:
        - filter_type
        - action_name
        - executed
        - execution
        - primary_time_range
        - attributes
    AffinityFilterV3:
      title: User Affinity Filter
      type: object
      description: >
        Filters users by affinity or psychographic patterns over an event
        (`filter_type: "psychographic_event"`).


        Use this to target users whose behavior leans toward a particular
        pattern — for example, users who most

        frequently purchase in a specific category (`predominant`), or users in
        the top 10% by spending (`top`).


        `primary_time_range` is required (unlike User Behavior filters, where it
        can be omitted).

        `psychographic_attributes` is required and must contain at least one
        filter defining what the affinity is about.


        **Affinity operator types:**

        | `operator_type` | Extra field | Meaning |

        |---|---|---|

        | `predominant` | — | User most frequently exhibits this affinity |

        | `minimum` | `percent_of_times` | User exhibits this affinity at least
        N% of the time |

        | `top` | `percent_of_users` | User is in the top N% by this affinity
        metric |

        | `bottom` | `percent_of_users` | User is in the bottom N% by this
        affinity metric |
      properties:
        filter_type:
          type: string
          enum:
            - psychographic_event
          description: Must be `psychographic_event` for a User Affinity filter.
        action_name:
          type: string
          description: The internal name of the event to evaluate affinity on.
        executed:
          type: boolean
          description: Whether the user has performed the event.
          default: true
        execution:
          type: object
          description: The frequency condition for the event.
          properties:
            type:
              type: string
              enum:
                - atleast
                - exactly
                - atmost
                - firstTime
                - lastTime
            count:
              type: integer
              description: >-
                Required for `atleast`, `exactly`, and `atmost`. Omit for
                `firstTime` and `lastTime`.
          required:
            - type
        operator_type:
          type: string
          description: The affinity matching mode.
          enum:
            - predominant
            - minimum
            - top
            - bottom
        percent_of_times:
          type: integer
          minimum: 1
          maximum: 100
          description: >-
            Required when `operator_type` is `minimum`. The minimum percentage
            of the time the affinity must be present.
        percent_of_users:
          type: integer
          minimum: 1
          maximum: 100
          description: >-
            Required when `operator_type` is `top` or `bottom`. The percentile
            threshold.
        psychographic_attributes:
          type: object
          description: >
            Defines what the affinity is about (for example, `product_category
            is "Electronics"`).

            At least one attribute filter is required.
          properties:
            filter_operator:
              type: string
              enum:
                - and
                - or
            filters:
              type: array
              items:
                $ref: '#/components/schemas/PsychographicAttributeFilterV3'
          required:
            - filter_operator
            - filters
        attributes:
          $ref: '#/components/schemas/ActionAttributeFilterGroupV3'
          description: >-
            Optional additional event-attribute filters to narrow which event
            occurrences count toward the affinity.
        primary_time_range:
          type: object
          description: >
            The time window over which affinity is evaluated. Required for
            affinity filters.


            This object uses a different shape from the User Behavior
            `primary_time_range`:

            - Relative windows (`value_type: relative_past`) use `days` (and
            `days1` as the second bound) instead of `value`/`value1`.

            - Absolute windows (`value_type: absolute`) use `from` and `to` ISO
            8601 dates.
          properties:
            type:
              type: string
              description: The type of time window.
            value_type:
              type: string
              enum:
                - absolute
                - relative_past
              description: >-
                Whether the window is expressed as relative day counts
                (`days`/`days1`) or absolute dates (`from`/`to`).
            days:
              type: integer
              description: Relative windows only. The number of days in the past.
            days1:
              type: integer
              description: >-
                Relative windows only. The second bound of the window, when
                applicable.
            from:
              type: string
              format: date-time
              description: Absolute windows only. The start date (ISO 8601).
            to:
              type: string
              format: date-time
              description: Absolute windows only. The end date (ISO 8601).
          required:
            - type
            - value_type
      required:
        - filter_type
        - action_name
        - executed
        - execution
        - operator_type
        - psychographic_attributes
        - primary_time_range
    CustomSegmentFilterV3:
      title: Custom Segment Filter
      type: object
      description: >
        References a saved MoEngage segment by ID (`filter_type:
        "custom_segments"`).


        Use this to include users who already belong to an existing segment —
        for example, a file segment,

        a previously created filter segment, or an analytics filter.


        Custom-file segments may be in a `pending` state while uploads are
        processing.
      properties:
        filter_type:
          type: string
          enum:
            - custom_segments
          description: Must be `custom_segments` for a Custom Segment filter.
        id:
          type: string
          description: The unique ID of the saved segment. Required.
        name:
          type: string
          description: >-
            Display label for the segment. The backend resolves the segment by
            `id`.
      required:
        - filter_type
        - id
    NestedFiltersV3:
      title: Nested Filters (AND/OR Group)
      type: object
      description: >
        A logical group container (`filter_type: "nested_filters"`) used to
        combine other filters with

        an `and` or `or` operator. Place a `nested_filters` block inside
        `included_filters` or `excluded_filters`

        to build complex boolean logic such as `(A AND B) OR (C AND D)`.


        Groups can nest to arbitrary depth. Every container at every level has
        its own `filter_operator` and `filters[]`.
      properties:
        filter_type:
          type: string
          enum:
            - nested_filters
          description: Must be `nested_filters` for a logical group container.
        filter_operator:
          type: string
          enum:
            - and
            - or
          description: The logical operator combining the filters in this group.
        filters:
          type: array
          description: >-
            The filters within this group. Each can be any filter type,
            including another `nested_filters` group.
          items:
            $ref: '#/components/schemas/FilterV3'
      required:
        - filter_type
        - filter_operator
        - filters
    FilterGroupResponseV3:
      type: object
      description: >-
        A logical grouping of filters as stored on the segment.


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_operator:
          type: string
          description: The logical operator to combine the filters.
          enum:
            - and
            - or
        filters:
          type: array
          items:
            $ref: '#/components/schemas/FilterResponseV3'
    ActionAttributeFilterGroupV3:
      type: object
      description: >-
        A logical grouping of attribute filters applied to an event's own
        attributes.
      properties:
        filter_operator:
          type: string
          description: The logical operator to combine the attribute filters.
          enum:
            - and
            - or
        filters:
          type: array
          description: >
            Attribute filters scoped to the event's properties. Each sets
            `filter_type` to

            `action_attributes` and `category` to `default`. The API omits
            `filter_type` when it

            echoes these filters back in a response.
          items:
            $ref: '#/components/schemas/AttributeFilterV3'
      required:
        - filter_operator
        - filters
    AggregationAttributeFilterV3:
      title: Aggregation Condition
      type: object
      description: >
        A single condition in the `aggregation_attributes` block of a User
        Behavior filter.

        Computes an aggregate (sum, avg, min, max, median) of a numeric event
        attribute and compares it to a threshold.


        The `aggregation_attributes` block holds exactly one condition.


        Only available when:

        - `executed: true`

        - `primary_time_range.type` is not `before` or `after` (unbounded
        windows are blocked)

        - `execution.type` is not `firstTime` or `lastTime`

        - The attribute has `data_type: double`
      properties:
        attribute_name:
          type: string
          description: The name of the numeric event attribute to aggregate.
        data_type:
          type: string
          enum:
            - double
          description: The data type of the aggregated attribute.
        aggregation_type:
          type: string
          enum:
            - sum
            - avg
            - min
            - max
            - median
          description: >-
            The aggregation function to apply across the user's matching event
            occurrences.
        operator:
          type: string
          enum:
            - is
            - between
            - lessThan
            - greaterThan
          description: >
            The comparison operator. Combine with `negate` to express the
            negative forms:

            `is` with `negate: true` is "is not equal to", and `between` with
            `negate: true` is "is not between".
        value:
          type: number
          description: The numeric threshold to compare the aggregated result against.
        value1:
          type: number
          description: The upper bound. Present only when `operator` is `between`.
        negate:
          type: boolean
          description: Set to `true` to invert the comparison.
          default: false
        is_dynamic_value:
          type: boolean
          description: >
            Set to `true` when `value` is a business event personalization token
            rather than a literal number.
          default: false
        comparator:
          type: string
          enum:
            - change
            - percentageChange
          description: >
            Compares the aggregate against an earlier window instead of a fixed
            threshold.

            Omit this key for a plain aggregate. When set, `base_time_range` is
            required.
        base_time_range:
          type: object
          description: >
            The earlier window to compare against. Required when `comparator` is
            set; omit it otherwise.


            Use `{ "type": "previousPeriod" }` to compare against the period
            immediately before

            `primary_time_range`, or `{ "type": "between", "value": "<start
            ISO>", "value1": "<end ISO>" }`

            for a fixed date range.
          properties:
            type:
              type: string
              enum:
                - previousPeriod
                - between
              description: The kind of base window.
            value:
              type: string
              format: date-time
              description: Start of the base window. Applies when `type` is `between`.
            value1:
              type: string
              format: date-time
              description: End of the base window. Applies when `type` is `between`.
          required:
            - type
      required:
        - attribute_name
        - data_type
        - aggregation_type
        - operator
        - value
    PsychographicAttributeFilterV3:
      title: Psychographic Attribute Filter
      type: object
      description: >
        An attribute filter used inside `psychographic_attributes` of a User
        Affinity filter.


        Psychographic attribute filters support a smaller surface than User
        Property filters:

        only the `string` and `double` data types are allowed, and only the
        operators listed below.

        They carry no `filter_type` key.


        Four time-based affinity filters are a special case: they use the
        attribute name

        `moe_user_datetime`, `category` `Time Attributes`, `data_type` `double`,
        and an `extract_type`

        of `time_of_the_day`, `day_of_the_week`, `day_of_the_month`, or
        `month_of_the_year`.
      properties:
        name:
          type: string
          description: >-
            The internal name of the event attribute the affinity is evaluated
            on.
        data_type:
          type: string
          description: >-
            The data type of the attribute. Only `string` and `double` are
            supported at the psychographic attribute level.
          enum:
            - string
            - double
        category:
          type: string
          description: The attribute group the attribute belongs to.
        operator:
          type: string
          description: The comparison operator. Allowed values depend on `data_type`.
          enum:
            - is
            - in
            - contains
            - startsWith
            - endsWith
            - exists
            - lessThan
            - greaterThan
            - between
        negate:
          type: boolean
          description: Set to `true` to invert the filter (NOT condition).
          default: false
        value:
          description: >
            The comparison value. Shape depends on `data_type` and `operator`.
            Omit when `operator` is `exists`.
          oneOf:
            - type: string
            - type: number
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: number
        value1:
          type: number
          description: The upper bound when `operator` is `between`.
        case_sensitive:
          type: boolean
          description: Applies to `string`. Set to `true` for case-sensitive matching.
          default: false
        extract_type:
          type: string
          description: >
            Applies to the four time-based affinity filters only, where `name`
            is `moe_user_datetime`

            and `category` is `Time Attributes`. Selects which part of the event
            timestamp to match on.
          enum:
            - time_of_the_day
            - day_of_the_week
            - day_of_the_month
            - month_of_the_year
      required:
        - name
        - data_type
    FilterResponseV3:
      description: >-
        A single stored filter criterion. The `filter_type` field selects the
        filter kind.


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      oneOf:
        - $ref: '#/components/schemas/AttributeFilterResponseV3'
        - $ref: '#/components/schemas/ActionFilterResponseV3'
        - $ref: '#/components/schemas/AffinityFilterResponseV3'
        - $ref: '#/components/schemas/CustomSegmentFilterResponseV3'
        - $ref: '#/components/schemas/NestedFiltersResponseV3'
      discriminator:
        propertyName: filter_type
        mapping:
          user_attributes:
            $ref: '#/components/schemas/AttributeFilterResponseV3'
          actions:
            $ref: '#/components/schemas/ActionFilterResponseV3'
          psychographic_event:
            $ref: '#/components/schemas/AffinityFilterResponseV3'
          custom_segments:
            $ref: '#/components/schemas/CustomSegmentFilterResponseV3'
          nested_filters:
            $ref: '#/components/schemas/NestedFiltersResponseV3'
    AttributeFilterResponseV3:
      title: User Property Filter
      type: object
      description: >-
        A stored user profile attribute filter (`filter_type:
        "user_attributes"`), or an event attribute filter inside an event's
        `attributes` block. The API omits `filter_type` on event attribute
        filters when it echoes them back.


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_type:
          type: string
          description: >-
            Present as `user_attributes` on user property filters. Omitted on
            event attribute filters.
          enum:
            - user_attributes
        name:
          type: string
          description: >-
            The internal name of the user attribute (for example,
            `last_purchase_date`).
        data_type:
          type: string
          description: The data type of the attribute.
          enum:
            - string
            - double
            - bool
            - datetime
            - geopoint
            - array_string
            - array_double
            - object
            - array_object
        category:
          type: string
          description: >-
            The attribute group the attribute belongs to (for example, `Tracked
            Custom Attribute`).
        operator:
          type: string
          description: The comparison operator.
          enum:
            - is
            - in
            - contains
            - containsInTheFollowing
            - startsWith
            - startsWithInTheFollowing
            - endsWith
            - endsWithInTheFollowing
            - exists
            - lessThan
            - greaterThan
            - between
            - true
            - before
            - after
            - inTheLast
            - inTheNext
            - today
        negate:
          type: boolean
          description: Set to `true` to invert the filter (NOT condition).
          default: false
        value:
          description: The comparison value.
          oneOf:
            - type: string
            - type: number
            - type: boolean
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: number
        value1:
          description: >-
            The second bound for range comparisons: - Upper bound when
            `operator` is `between` (numeric and datetime types). - Longitude
            for `geopoint`.
          oneOf:
            - type: string
            - type: number
        case_sensitive:
          type: boolean
          description: Applies to `string` and `array_string`.
          default: false
        value_type:
          type: string
          description: Applies to `datetime` only.
          enum:
            - absolute
            - relative_past
            - relative_future
        extract_type:
          type: string
          description: Applies to `datetime` only.
          enum:
            - time_of_the_day
            - day_of_the_week
            - day_of_the_month
            - month_of_the_year
            - date_month_of_the_year
        radius:
          type: number
          description: Applies to `geopoint` only.
        array_filter_type:
          type: string
          description: Applies to `array_string` and `array_double`.
          enum:
            - any_of
            - all_of
        filter_operator:
          type: string
          description: Applies to `object` and `array_object`.
          enum:
            - and
            - or
        filters:
          type: array
          description: Applies to `object` and `array_object`.
          items:
            $ref: '#/components/schemas/AttributeFilterResponseV3'
        is_dynamic_value:
          type: boolean
          description: >-
            Set to `true` when `value` references another user attribute rather
            than a literal.
          default: false
        dynamic_attribute_type:
          type: string
          description: Required when `is_dynamic_value` is `true`.
          enum:
            - string
            - double
            - bool
            - datetime
    ActionFilterResponseV3:
      title: User Behavior Filter
      type: object
      description: >-
        A stored event filter (`filter_type: "actions"`).


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_type:
          type: string
          description: Must be `actions` for a User Behavior filter.
          enum:
            - actions
        action_name:
          type: string
          description: The internal name of the event to filter on.
        project_name:
          type: string
          description: Optional.
        executed:
          type: boolean
          description: >-
            Set to `true` to match users who performed the event; `false` to
            match users who did not.
        execution:
          type: object
          description: The frequency condition for the event.
          properties:
            type:
              type: string
              enum:
                - atleast
                - exactly
                - atmost
                - firstTime
                - lastTime
            count:
              type: integer
              format: int32
              description: Required for `atleast`, `exactly`, and `atmost`.
        primary_time_range:
          type: object
          description: The time window during which the event must have been performed.
          properties:
            type:
              type: string
              enum:
                - inTheLast
                - between
                - true
                - before
                - after
            value_type:
              type: string
              description: >-
                Whether `value` is an ISO 8601 date (`absolute`) or an integer
                offset (`relative_past`).
              enum:
                - absolute
                - relative_past
            value:
              description: >-
                Integer count of `period_unit` for relative ranges, or an ISO
                8601 date string for absolute ranges.
            value1:
              description: End bound for `between`.
            period_unit:
              type: string
              description: The unit of time.
              enum:
                - hours
                - days
                - weeks
                - months
        attributes:
          $ref: '#/components/schemas/ActionAttributeFilterGroupResponseV3'
          description: >-
            Sub-filters on the event's own attributes — for example, `purchase`
            where `product_category` is `Electronics`.
        aggregation_attributes:
          type: object
          description: Optional aggregation block.
          properties:
            filter_operator:
              type: string
              enum:
                - and
                - or
            filters:
              type: array
              items:
                $ref: '#/components/schemas/AggregationAttributeFilterResponseV3'
    AffinityFilterResponseV3:
      title: User Affinity Filter
      type: object
      description: >-
        A stored affinity filter (`filter_type: "psychographic_event"`).


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_type:
          type: string
          enum:
            - psychographic_event
          description: Must be `psychographic_event` for a User Affinity filter.
        action_name:
          type: string
          description: The internal name of the event to evaluate affinity on.
        executed:
          type: boolean
          description: Whether the user has performed the event.
          default: true
        execution:
          type: object
          description: The frequency condition for the event.
          properties:
            type:
              type: string
              enum:
                - atleast
                - exactly
                - atmost
                - firstTime
                - lastTime
            count:
              type: integer
              description: Required for `atleast`, `exactly`, and `atmost`.
        operator_type:
          type: string
          description: The affinity matching mode.
          enum:
            - predominant
            - minimum
            - top
            - bottom
        percent_of_times:
          type: integer
          minimum: 1
          maximum: 100
          description: Required when `operator_type` is `minimum`.
        percent_of_users:
          type: integer
          minimum: 1
          maximum: 100
          description: Required when `operator_type` is `top` or `bottom`.
        psychographic_attributes:
          type: object
          description: >-
            Defines what the affinity is about (for example, `product_category
            is "Electronics"`).
          properties:
            filter_operator:
              type: string
              enum:
                - and
                - or
            filters:
              type: array
              items:
                $ref: '#/components/schemas/PsychographicAttributeFilterResponseV3'
        attributes:
          $ref: '#/components/schemas/ActionAttributeFilterGroupResponseV3'
          description: >-
            Optional additional event-attribute filters to narrow which event
            occurrences count toward the affinity.
        primary_time_range:
          type: object
          description: The time window over which affinity is evaluated.
          properties:
            type:
              type: string
              description: The type of time window.
            value_type:
              type: string
              enum:
                - absolute
                - relative_past
              description: >-
                Whether the window is expressed as relative day counts
                (`days`/`days1`) or absolute dates (`from`/`to`).
            days:
              type: integer
              description: Relative windows only.
            days1:
              type: integer
              description: Relative windows only.
            from:
              type: string
              format: date-time
              description: Absolute windows only.
            to:
              type: string
              format: date-time
              description: Absolute windows only.
    CustomSegmentFilterResponseV3:
      title: Custom Segment Filter
      type: object
      description: >-
        A stored reference to a saved segment (`filter_type:
        "custom_segments"`).


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_type:
          type: string
          enum:
            - custom_segments
          description: Must be `custom_segments` for a Custom Segment filter.
        id:
          type: string
          description: The unique ID of the saved segment.
        name:
          type: string
          description: Display label for the segment.
    NestedFiltersResponseV3:
      title: Nested Filters (AND/OR Group)
      type: object
      description: >-
        A stored AND/OR group container (`filter_type: "nested_filters"`).


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_type:
          type: string
          enum:
            - nested_filters
          description: Must be `nested_filters` for a logical group container.
        filter_operator:
          type: string
          enum:
            - and
            - or
          description: The logical operator combining the filters in this group.
        filters:
          type: array
          description: The filters within this group.
          items:
            $ref: '#/components/schemas/FilterResponseV3'
    ActionAttributeFilterGroupResponseV3:
      type: object
      description: >-
        Stored attribute filters scoped to an event's own properties.


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        filter_operator:
          type: string
          description: The logical operator to combine the attribute filters.
          enum:
            - and
            - or
        filters:
          type: array
          description: Attribute filters scoped to the event's properties.
          items:
            $ref: '#/components/schemas/AttributeFilterResponseV3'
    AggregationAttributeFilterResponseV3:
      title: Aggregation Condition
      type: object
      description: >-
        A stored aggregation condition on a numeric event attribute.


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        attribute_name:
          type: string
          description: The name of the numeric event attribute to aggregate.
        data_type:
          type: string
          enum:
            - double
          description: The data type of the aggregated attribute.
        aggregation_type:
          type: string
          enum:
            - sum
            - avg
            - min
            - max
            - median
          description: >-
            The aggregation function to apply across the user's matching event
            occurrences.
        operator:
          type: string
          enum:
            - is
            - between
            - lessThan
            - greaterThan
          description: The comparison operator.
        value:
          type: number
          description: The numeric threshold to compare the aggregated result against.
        value1:
          type: number
          description: The upper bound.
        negate:
          type: boolean
          description: Set to `true` to invert the comparison.
          default: false
        is_dynamic_value:
          type: boolean
          description: >-
            Set to `true` when `value` is a business event personalization token
            rather than a literal number.
          default: false
        comparator:
          type: string
          enum:
            - change
            - percentageChange
          description: >-
            Compares the aggregate against an earlier window instead of a fixed
            threshold.
        base_time_range:
          type: object
          description: The earlier window to compare against.
          properties:
            type:
              type: string
              enum:
                - previousPeriod
                - between
              description: The kind of base window.
            value:
              type: string
              format: date-time
              description: Start of the base window.
            value1:
              type: string
              format: date-time
              description: End of the base window.
    PsychographicAttributeFilterResponseV3:
      title: Psychographic Attribute Filter
      type: object
      description: >-
        A stored attribute filter inside `psychographic_attributes`.


        Fields mirror what was supplied when the segment was created or updated.
        See the Create Filter Segment request reference for the full field
        rules.
      properties:
        name:
          type: string
          description: >-
            The internal name of the event attribute the affinity is evaluated
            on.
        data_type:
          type: string
          description: The data type of the attribute.
          enum:
            - string
            - double
        category:
          type: string
          description: The attribute group the attribute belongs to.
        operator:
          type: string
          description: The comparison operator.
          enum:
            - is
            - in
            - contains
            - startsWith
            - endsWith
            - exists
            - lessThan
            - greaterThan
            - between
        negate:
          type: boolean
          description: Set to `true` to invert the filter (NOT condition).
          default: false
        value:
          description: The comparison value.
          oneOf:
            - type: string
            - type: number
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: number
        value1:
          type: number
          description: The upper bound when `operator` is `between`.
        case_sensitive:
          type: boolean
          description: Applies to `string`.
          default: false
        extract_type:
          type: string
          description: >-
            Applies to the four time-based affinity filters only, where `name`
            is `moe_user_datetime` and `category` is `Time Attributes`.
          enum:
            - time_of_the_day
            - day_of_the_week
            - day_of_the_month
            - month_of_the_year
  responses:
    200_SegmentUpdatedV3:
      description: >-
        Segment updated successfully. Returns the updated segment details
        including the new filter definition and metadata.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FilterSegmentResponseV3'
          example:
            data:
              name: your segment name
              id: your segment id
              created_time: '2022-12-20T06:21:44.112000'
              updated_time: '2022-12-20T06:21:44.160000'
              type: ELASTIC_SEARCH
              source: API
              description: >-
                Subscription Status 19Dec_7  is active  (case insensitive) AND
                Has executed Email Sent atleast 1 time in-between Feb 15, 2023
                and Feb 24, 2023
              included_filters:
                filter_operator: and
                filters:
                  - filter_type: user_attributes
                    name: Subscription Status 19Dec_7
                    data_type: string
                    operator: in
                    value:
                      - active
                    negate: false
                    case_sensitive: false
                  - filter_type: actions
                    attributes:
                      filter_operator: and
                      filters: []
                    executed: true
                    primary_time_range:
                      type: between
                      value: '2023-02-15T00:00:00.000Z'
                      value1: '2023-02-24T23:59:59.999Z'
                      value_type: absolute
                      period_unit: days
                    action_name: MOE_EMAIL_SENT
                    execution:
                      count: 1
                      type: atleast
            response_id: cNjnTEJw
            type: custom_segment
    400_FilterSegmentError:
      description: >-
        Bad Request. The request is invalid due to missing required parameters,
        invalid parameter format, or malformed request body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseV3'
          examples:
            invalidFormat:
              summary: Invalid Request Format
              value:
                response_id: xFyVHeOr
                type: custom_segment
                error:
                  code: Invalid request
                  message: >-
                    Invalid request format. Please check the documentation to
                    ensure that the request has been formed correctly.
            invalidName:
              summary: Invalid Segment Name
              value:
                response_id: XtVyUnlJ
                type: custom_segment
                error:
                  code: Invalid Request
                  message: >-
                    Invalid request. Please ensure that the filters are correct
                    and the custom-segment name doesn't contain HTML
                    characters/only whitespaces.
            invalidAppKey:
              summary: Invalid App Key/DB Name
              value:
                response_id: FkrgtCVr
                type: custom_segment
                error:
                  code: Request Error
                  message: >-
                    MoEngage Client not found. Please check values for headers -
                    MOE-APPKEY or MOE-DBNAME
    401_FilterSegmentError:
      description: >-
        Authentication Failure. The request failed authentication due to
        incorrect APP_KEY, APP_SECRET, or Authorization header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseV3'
          examples:
            secretMismatch:
              summary: APP_SECRET Key Mismatch
              value:
                response_id: SzFRAzwK
                type: custom_segment
                error:
                  code: Authentication required
                  message: >-
                    APP_SECRET key mismatch. Please login to the dashboard to
                    verify key
            invalidAppKey:
              summary: Invalid APP_KEY in Auth
              value:
                response_id: bUfoyyhN
                type: custom_segment
                error:
                  code: Authentication required
                  message: Invalid APP_KEY used in Authentication Header
    403_FilterSegmentError:
      description: >-
        Forbidden Operation. The requested operation is not allowed for this
        type of segment (e.g., updating file segments, archived segments, or
        internally created segments).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseV3'
          example:
            response_id: xuLAWeCN
            type: custom_segment
            error:
              code: Forbidden operation
              message: >-
                Update isn't supported for file-segments, internally created
                custom-segments, custom-segments imported from Analyze and
                archived custom-segments.
    404_FilterSegmentError:
      description: >-
        Entity Not Found. The custom segment with the specified ID or name does
        not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseV3'
          example:
            response_id: UAMMfmuU
            type: custom_segment
            error:
              code: Entity Not Found
              message: >-
                Custom segment not found with the given id:
                638a051185b6b50a018cacc
    409_FilterSegmentError:
      description: >-
        Conflict / Resource Not Created. A custom segment with the same name or
        filter definition already exists. Both the name and definition must be
        unique.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ConflictErrorResponseV3'
          examples:
            nameExists:
              summary: Name Already Exists
              value:
                response_id: flJhLXeo
                type: custom_segment
                error:
                  code: Resource not created
                  message: >-
                    Another custom-segment already exists with the same name:
                    api_test_8. Please change the custom-segment name.
            filterExists:
              summary: Filters Already Exist
              value:
                response_id: YbzjKmhl
                type: custom_segment
                error:
                  code: Resource not created
                  message: >-
                    Another custom-segment already exists containing the given
                    filters: api_test_multiple_cs2_re. Please reuse the same or
                    update the filters
                  existing_cs_name: api_test_multiple_cs2_re
                  existing_cs_id: 63a017e8d2460ae81a05bf5e
    412_FilterSegmentError:
      description: >-
        Precondition Failed (Cyclic Entity). A circular reference was detected
        in the custom segment definition.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseV3'
          example:
            response_id: acOcgPed
            type: custom_segment
            error:
              code: Cyclic Entity
              message: Circular reference detected in the custom segment definition.
    413_FilterSegmentError:
      description: >-
        Payload Too Large / Query Too Complex. The segment definition exceeds
        allowed limits (nesting levels, number of segments referenced, or total
        query size).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseV3'
          examples:
            tooManyNestingLevels:
              summary: Too Many Nesting Levels
              value:
                response_id: YbSUZzCZ
                type: custom_segment
                error:
                  code: Query has too many nesting levels
                  message: >-
                    The query has more than n levels of nesting. Please reduce
                    the segment nesting.
            tooManySegments:
              summary: Too Many Segments in Query
              value:
                response_id: BcvlFaav
                type: custom_segment
                error:
                  code: Too many segments in a query
                  message: >-
                    The query has more than n custom segments. Please reduce the
                    custom segments.
            queryLengthExceeded:
              summary: Query Length Limit Exceeded
              value:
                response_id: AQvmPUIS
                type: custom_segment
                error:
                  code: Query length limit exceeded
                  message: >-
                    The query is too large to execute. Please reduce the
                    filters.
    429_FilterSegmentError:
      description: >-
        Too Many Requests. The API rate limit has been exceeded, or the total
        number of active segments has reached the maximum allowed limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponseV3'
          examples:
            rateLimit:
              summary: API Rate Limit Breached
              value:
                response_id: OUUkHvcn
                type: custom_segment
                error:
                  code: Too Many Requests
                  message: 'API rate limit breached. Current limit: n/m mins'
            activeSegmentLimit:
              summary: Active Segment Limit Breached
              value:
                response_id: jfYkJWRB
                type: custom_segment
                error:
                  code: Too Many Requests
                  message: Total active segments limit breached. Request rejected!
                  actual_count: 1001
                  limit: 1000
    500_FilterSegmentError:
      description: >-
        Internal Server Error. An unexpected error occurred on the MoEngage
        server.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ServerErrorResponseV3'
          example:
            response_id: HKWwUkvM
            type: custom_segment
            error:
              code: Internal Server Error
              message: >-
                An unexpected error was encountered while processing this
                request. Please contact MoEngage Team
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >
        Authentication is done via Basic Auth. This requires a base64-encoded
        string of your credentials in the format 'username:password'.


        - **Username**: Use your MoEngage workspace ID (also known as the App
        ID). You can find it in the MoEngage dashboard at **Settings** >
        **Account** > **APIs** > **Workspace ID (earlier app id)**.

        - **Password**: Use your API Key, which you can find within the **Data**
        tile.


        For more information on authentication and getting your credentials,
        refer
        [here](https://www.moengage.com/docs/api/introduction#getting-your-credentials).

````