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

# Create asset policy

> Create a new asset policy that automatically takes action on assets matching defined conditions. Supported actions: alert (send notifications), delete (remove assets), set_label (add labels), and remove_label (remove labels).

<Note>
  The `policy_type` determines which fields are required:

  | Policy Type       | Required Fields       |
  | ----------------- | --------------------- |
  | `alert` (default) | `alerting_config_ids` |
  | `delete`          | —                     |
  | `set_label`       | `labels`              |
  | `remove_label`    | `labels`              |

  **Conditions:** Multiple filters in the `policies` object use AND logic — all conditions must match for the policy to apply.

  **Scope:** Set `apply_to_existing` to `true` to apply the policy to existing matching assets immediately. When `false` (default), the policy only acts on newly discovered assets.
</Note>

## Example Requests

### Create a delete policy for noisy assets

```bash theme={null}
curl -X POST "https://api.projectdiscovery.io/v1/asset/policy" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Remove 401 webhooks",
    "policy_type": "delete",
    "policies": {
      "host": "www.webhook.office.com",
      "status_code": "401"
    },
    "apply_to_existing": true
  }'
```

### Create an alert policy for sensitive ports

```bash theme={null}
curl -X POST "https://api.projectdiscovery.io/v1/asset/policy" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Alert on sensitive ports",
    "policy_type": "alert",
    "policies": {
      "port": "22,3306,5432,6379"
    },
    "alerting_config_ids": ["your-alerting-config-id"],
    "apply_to_existing": false
  }'
```

### Create a labeling policy

```bash theme={null}
curl -X POST "https://api.projectdiscovery.io/v1/asset/policy" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Tag WordPress sites",
    "policy_type": "set_label",
    "policies": {
      "technologies": "WordPress"
    },
    "labels": ["cms", "wordpress"],
    "apply_to_existing": true
  }'
```

## Related Resources

* [Asset Policies Guide](/cloud/assets/asset-policies) - Feature overview with walkthrough


## OpenAPI

````yaml post /v1/asset/policy
openapi: 3.1.0
info:
  title: PDCP API
  version: '1.0'
  summary: ProjectDiscovery Cloud Platform
  description: >-
    For more details, checkout
    https://docs.projectdiscovery.io/api-reference/editor/scan
servers:
  - url: https://api.projectdiscovery.io
    description: Production
  - url: https://api.dev.projectdiscovery.io
    description: Development
  - url: http://localhost:8085
    description: Localhost
security:
  - X-API-Key: []
paths:
  /v1/asset/policy:
    post:
      tags: []
      summary: Create asset policy
      description: >-
        Create a new asset policy that automatically takes action on assets
        matching defined conditions. Supported actions: alert (send
        notifications), delete (remove assets), set_label (add labels), and
        remove_label (remove labels).
      operationId: post-v1-asset-policy
      requestBody:
        $ref: '#/components/requestBodies/CreateAssetPolicyRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  id:
                    type: string
                    description: Unique identifier of the created policy
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '500':
          $ref: '#/components/responses/ErrorResponse'
        default:
          description: Default
components:
  requestBodies:
    CreateAssetPolicyRequest:
      content:
        application/json:
          schema:
            type: object
            required:
              - policies
            properties:
              policies:
                $ref: '#/components/schemas/AssetFilters'
              name:
                type: string
                description: Display name for the policy. Auto-generated if not provided.
              policy_type:
                $ref: '#/components/schemas/AssetPolicyType'
              alerting_config_ids:
                type: array
                description: >-
                  List of alerting configuration IDs (required when policy_type
                  is 'alert')
                items:
                  type: string
              labels:
                type: array
                description: >-
                  List of labels to apply/remove (required when policy_type is
                  'set_label' or 'remove_label')
                items:
                  type: string
              enumeration_ids:
                type: array
                description: >-
                  Optional list of enumeration IDs to scope this policy to
                  specific enumerations
                items:
                  type: string
              apply_to_existing:
                type: boolean
                default: false
                description: >-
                  When true, the policy action is applied to existing assets
                  that match the conditions in addition to future assets. When
                  false (default), the policy only applies to newly discovered
                  assets.
  responses:
    ErrorResponse:
      description: Example response
      content:
        application/json:
          schema:
            type: object
            required:
              - message
            properties:
              message:
                type: string
              kind:
                type: string
              code:
                type: string
              error:
                type: string
              error_id:
                type: string
              param:
                type: string
              status:
                type: integer
  schemas:
    AssetFilters:
      title: AssetFilters
      type: object
      additionalProperties: false
      properties:
        is_tech:
          type: boolean
          description: Return records that have technologies
        is_favicon:
          type: boolean
          description: Return the records that have favicon
        is_new:
          type: boolean
          description: Filter by new content
        labels:
          type: string
          description: Filter by comma separated labels, e.g-> labels=p1,p2
        host:
          type: string
          description: Filter by comma separated hosts, e.g-> host=p1,p2
        port:
          type: string
          description: Filter by comma separated ports, e.g-> port=p1,p2
        status_code:
          type: string
          description: Filter by comma separated status codes, e.g-> status_code=p1,p2
        content_length:
          type: string
          description: >-
            Filter by comma separated content lengths, e.g->
            content_length=p1,p2
        title:
          type: string
          description: Filter by comma separated titles, e.g-> title=p1,p2
        domain:
          type: array
          description: >-
            Filter by comma separated domain names, e.g->
            domain=domain1.com,domain2.com
          items:
            type: string
        cname:
          type: string
          description: Filter by comma separated cnames, e.g-> cname=p1,p2
        technologies:
          type: string
          description: Filter by comma separated technologies, e.g-> technologies=p1,p2
        ip:
          type: string
          description: Filter by comma separated ips, e.g-> ip=p1,p2
        is_screenshot:
          type: boolean
          description: Return the records with screenshots
        time:
          $ref: '#/components/schemas/TimeRangeQueryParameter'
          description: Filter by time range
        start_date:
          type: string
          format: date
          description: Filter by start date
        end_date:
          type: string
          format: date
          description: Filter by end date
        custom_filter:
          type: string
          description: Filter by custom filter. Double encode the query string.
        search:
          type: string
          description: Search on the content name
        enumeration_ids:
          type: array
          items:
            type: string
          description: Filter by enumeration ids
        only_dns:
          type: boolean
          description: Query only dns FQDN records
        only_ip:
          type: boolean
          description: Query only dns IP records
    AssetPolicyType:
      title: AssetPolicyType
      type: string
      enum:
        - alert
        - delete
        - set_label
        - remove_label
      description: Type of action to perform when policy matches assets
    TimeRangeQueryParameter:
      title: TimeRangeQueryParameter
      type: string
      enum:
        - last_day
        - last_week
        - last_month
        - last_3_months
        - last_6_months
        - last_12_months
        - all_time
  securitySchemes:
    X-API-Key:
      name: X-API-Key
      type: apiKey
      in: header

````