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

# Create Matching Policy (Beta)

> Create a matching policy in the tenant the caller is acting in and return it. A matching policy refines which events match the identifiers it is assigned to; `type` selects the kind of policy and the shape of `value`. A new policy applies to no identifier until it is assigned with `POST /matching-policies/{policy_uuid}/assignments`. Responds 409 `MATCHING_POLICY_ALREADY_EXISTS` when the tenant already has a policy with the same type and value, 422 `INVALID_MATCHING_POLICY` when the value is rejected (for example too many keywords or an invalid Lucene query), and 403 `UNAUTHORIZED_ACCESS` when the account lacks the permission or feature required by the `ASTP_COOKIES`, `ASTP_DOMAIN` or `LOOKALIKE_STRATEGIES` type.

&#x20;Required API key permission: **Write Tenant**

> [!NOTE]
>
> The Create Matching Policy endpoint is still in beta and is subject to change.


## OpenAPI

````yaml firework-v4-openapi post /firework/v4/matching-policies
openapi: 3.1.0
info:
  title: Firework API
  version: v4
servers:
  - url: https://api.flare.io
security:
  - BearerAuth: []
tags:
  - name: Audit Logs
    description: Audit trail of actions performed in the platform.
  - name: Credentials
    description: >-
      Leaked credentials: search across all sources or within a tenant, and
      remediate or ignore them.
  - name: Entities
    description: >-
      Threat intelligence entities such as actors, chat channels, forum threads
      and domains, and the relations between them.
  - name: Events
    description: >-
      Events collected by Flare: global search, tenant and identifier feeds,
      event details, actions and saved feed views.
  - name: Identifiers
    description: >-
      Identifiers are the assets a tenant monitors, such as domains, keywords
      and email addresses. Includes recommendations and authorization of
      sensitive identifiers.
  - name: Matching Policies
    description: >-
      Matching policies refine which events match identifiers. Manage policies
      and their assignment to identifiers.
  - name: Sandbox
    description: File uploads and their sandbox analysis.
  - name: Threat Flow
    description: >-
      Threat Flow intelligence requests, generated reports and conversation
      summaries.
paths:
  /firework/v4/matching-policies:
    post:
      tags:
        - Matching Policies
      summary: Create a matching policy
      description: >-
        Create a matching policy in the tenant the caller is acting in and
        return it. A matching policy refines which events match the identifiers
        it is assigned to; `type` selects the kind of policy and the shape of
        `value`. A new policy applies to no identifier until it is assigned with
        `POST /matching-policies/{policy_uuid}/assignments`. Responds 409
        `MATCHING_POLICY_ALREADY_EXISTS` when the tenant already has a policy
        with the same type and value, 422 `INVALID_MATCHING_POLICY` when the
        value is rejected (for example too many keywords or an invalid Lucene
        query), and 403 `UNAUTHORIZED_ACCESS` when the account lacks the
        permission or feature required by the `ASTP_COOKIES`, `ASTP_DOMAIN` or
        `LOOKALIKE_STRATEGIES` type.
      operationId: create_matching_policy_matching_policies_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/CreateIncludedKeywordsBody'
                - $ref: '#/components/schemas/CreateExcludedKeywordsBody'
                - $ref: '#/components/schemas/CreateLuceneQueryBody'
                - $ref: '#/components/schemas/CreateAstpCookiesBody'
                - $ref: '#/components/schemas/CreateAstpDomainBody'
                - $ref: '#/components/schemas/CreateLookalikeStrategiesBody'
              title: Body
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MatchingPolicyPayload'
        '401':
          description: UNAUTHORIZED
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    properties:
                      code:
                        type: string
                        enum:
                          - UNAUTHORIZED
                      data:
                        anyOf:
                          - additionalProperties: true
                            type: object
                          - type: 'null'
                        title: Data
                      message:
                        anyOf:
                          - type: string
                          - items: {}
                            type: array
                          - type: 'null'
                        title: Message
                    required:
                      - code
                      - data
                      - message
                    title: HTTPError
                    type: object
                required:
                  - error
        '403':
          description: FORBIDDEN, UNAUTHORIZED_ACCESS
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    properties:
                      code:
                        type: string
                        enum:
                          - FORBIDDEN
                          - UNAUTHORIZED_ACCESS
                      data:
                        anyOf:
                          - additionalProperties: true
                            type: object
                          - type: 'null'
                        title: Data
                      message:
                        anyOf:
                          - type: string
                          - items: {}
                            type: array
                          - type: 'null'
                        title: Message
                    required:
                      - code
                      - data
                      - message
                    title: HTTPError
                    type: object
                required:
                  - error
        '404':
          description: NOT_FOUND
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    properties:
                      code:
                        type: string
                        enum:
                          - NOT_FOUND
                      data:
                        anyOf:
                          - additionalProperties: true
                            type: object
                          - type: 'null'
                        title: Data
                      message:
                        anyOf:
                          - type: string
                          - items: {}
                            type: array
                          - type: 'null'
                        title: Message
                    required:
                      - code
                      - data
                      - message
                    title: HTTPError
                    type: object
                required:
                  - error
        '409':
          description: MATCHING_POLICY_ALREADY_EXISTS
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    properties:
                      code:
                        type: string
                        enum:
                          - MATCHING_POLICY_ALREADY_EXISTS
                      data:
                        anyOf:
                          - additionalProperties: true
                            type: object
                          - type: 'null'
                        title: Data
                      message:
                        anyOf:
                          - type: string
                          - items: {}
                            type: array
                          - type: 'null'
                        title: Message
                    required:
                      - code
                      - data
                      - message
                    title: HTTPError
                    type: object
                required:
                  - error
        '422':
          description: INVALID_MATCHING_POLICY
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    properties:
                      code:
                        type: string
                        enum:
                          - INVALID_MATCHING_POLICY
                      data:
                        anyOf:
                          - additionalProperties: true
                            type: object
                          - type: 'null'
                        title: Data
                      message:
                        anyOf:
                          - type: string
                          - items: {}
                            type: array
                          - type: 'null'
                        title: Message
                    required:
                      - code
                      - data
                      - message
                    title: HTTPError
                    type: object
                required:
                  - error
components:
  schemas:
    CreateIncludedKeywordsBody:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: The name of the matching policy
        type:
          type: string
          const: INCLUDED_KEYWORDS
          title: Type
          description: 'Policy type: events must contain at least one of the keywords.'
        value:
          $ref: '#/components/schemas/KeywordsValue'
          description: The value of the matching policy in the form of keywords
      type: object
      required:
        - name
        - type
        - value
      title: CreateIncludedKeywordsBody
    CreateExcludedKeywordsBody:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: The name of the matching policy
        type:
          type: string
          const: EXCLUDED_KEYWORDS
          title: Type
          description: 'Policy type: events containing any of the keywords are excluded.'
        value:
          $ref: '#/components/schemas/KeywordsValue'
          description: The value of the matching policy in the form of keywords
      type: object
      required:
        - name
        - type
        - value
      title: CreateExcludedKeywordsBody
    CreateLuceneQueryBody:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: The name of the matching policy
        type:
          type: string
          const: LUCENE_QUERY
          title: Type
          description: 'Policy type: events must also match the Lucene query.'
        value:
          $ref: '#/components/schemas/LuceneValue'
          description: The value of the matching policy in the form of a Lucene query
      type: object
      required:
        - name
        - type
        - value
      title: CreateLuceneQueryBody
    CreateAstpCookiesBody:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: The name of the matching policy
        type:
          type: string
          const: ASTP_COOKIES
          title: Type
          description: 'Policy type: cookie names to monitor on domain identifiers.'
        value:
          $ref: '#/components/schemas/AstpCookiesValue'
          description: The value of the matching policy in the form of cookie names
      type: object
      required:
        - name
        - type
        - value
      title: CreateAstpCookiesBody
    CreateAstpDomainBody:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: The name of the matching policy
        type:
          type: string
          const: ASTP_DOMAIN
          title: Type
          description: 'Policy type: how leaked credentials match domain identifiers.'
        value:
          $ref: '#/components/schemas/AstpDomainValue'
          description: The value of the matching policy in the form of a domain match mode
      type: object
      required:
        - name
        - type
        - value
      title: CreateAstpDomainBody
    CreateLookalikeStrategiesBody:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: The name of the matching policy
        type:
          type: string
          const: LOOKALIKE_STRATEGIES
          title: Type
          description: 'Policy type: lookalike domain strategies to keep.'
        value:
          $ref: '#/components/schemas/LookalikeMatchStrategiesValue'
          description: >-
            The value of the matching policy in the form of lookalike domain
            strategies
      type: object
      required:
        - name
        - type
        - value
      title: CreateLookalikeStrategiesBody
    MatchingPolicyPayload:
      properties:
        uuid:
          type: string
          format: uuid4
          title: Uuid
          description: The UUID of the matching policy
        name:
          type: string
          title: Name
          description: The name of the matching policy
        policy_type:
          $ref: '#/components/schemas/MatchingPolicyType'
          description: The type of the matching policy
        value:
          $ref: '#/components/schemas/PolicyReadValue'
          description: The value of the matching policy depending on its type
        created_at:
          type: string
          format: date-time
          title: Created At
          description: The date and time the matching policy was created
        last_updated_at:
          type: string
          format: date-time
          title: Last Updated At
          description: The date and time the matching policy was last updated
      type: object
      required:
        - uuid
        - name
        - policy_type
        - value
        - created_at
        - last_updated_at
      title: MatchingPolicyPayload
    KeywordsValue:
      properties:
        keywords:
          items:
            type: string
          type: array
          title: Keywords
          description: The keywords of the matching policy, at most 50.
      type: object
      required:
        - keywords
      title: KeywordsValue
    LuceneValue:
      properties:
        query:
          type: string
          title: Query
          description: The lucene query of the matching policy
      type: object
      required:
        - query
      title: LuceneValue
    AstpCookiesValue:
      properties:
        cookie_names:
          items:
            type: string
          type: array
          title: Cookie Names
          description: The cookie names to monitor, from 1 to 20 names
        match_subdomains:
          type: boolean
          title: Match Subdomains
          description: >-
            Whether this policy will be applied to monitor subdomains of the
            assigned domain identifiers
          default: false
      type: object
      required:
        - cookie_names
      title: AstpCookiesValue
    AstpDomainValue:
      properties:
        match_mode:
          $ref: '#/components/schemas/DomainMatchMode'
          description: >-
            The domain match mode for this policy: whether leaked credentials
            match the domain identifier on the email domain, on the
            authentication domain, or on either
          default: email_domain_only
      type: object
      title: AstpDomainValue
    LookalikeMatchStrategiesValue:
      properties:
        match_strategies:
          items:
            $ref: '#/components/schemas/Heuristic'
          type: array
          title: Match Strategies
          description: >-
            The lookalike domain match strategies to monitor: at least one, and
            `various` is not accepted
      type: object
      required:
        - match_strategies
      title: LookalikeMatchStrategiesValue
    MatchingPolicyType:
      type: string
      enum:
        - INCLUDED_KEYWORDS
        - EXCLUDED_KEYWORDS
        - LUCENE_QUERY
        - ASTP_COOKIES
        - ASTP_DOMAIN
        - LOOKALIKE_STRATEGIES
      title: MatchingPolicyType
    PolicyReadValue:
      anyOf:
        - $ref: '#/components/schemas/KeywordsValue'
        - $ref: '#/components/schemas/LuceneValue'
        - $ref: '#/components/schemas/AstpCookiesReadValue'
        - $ref: '#/components/schemas/AstpDomainValue'
        - $ref: '#/components/schemas/LookalikeMatchStrategiesValue'
    DomainMatchMode:
      type: string
      enum:
        - email_domain_only
        - auth_domain_and_email_domain
        - auth_domain_only
      title: DomainMatchMode
    Heuristic:
      type: string
      enum:
        - addition
        - bitsquatting
        - cyrillic
        - dictionary
        - ends-with
        - homoglyph
        - hyphenation
        - insertion
        - omission
        - plural
        - repetition
        - replacement
        - starts-with
        - subdomain
        - tld-swap
        - transposition
        - various
        - vowel-swap
      title: Heuristic
    AstpCookiesReadValue:
      properties:
        cookie_names:
          items:
            type: string
          type: array
          title: Cookie Names
          description: The cookie names to monitor, from 1 to 20 names
        match_subdomains:
          type: boolean
          title: Match Subdomains
          description: >-
            Whether this policy will be applied to monitor subdomains of the
            assigned domain identifiers
          default: false
        match_prefix:
          type: boolean
          title: Match Prefix
          description: >-
            Whether the cookie names are matched as prefixes rather than
            exactly. Read-only: it cannot be set through this API.
          default: false
      type: object
      required:
        - cookie_names
      title: AstpCookiesReadValue
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.