---
sidebar_label: Associate a policy with an action
doc_id: b7a60e33-0aa0-43bd-b47d-f96f4949319a
description: >-
  Link policies to approval actions for automated evaluation of conditions
  against entity metadata.
keywords:
  - policy association
  - approval action
  - policy evaluation
  - API integration
  - conditional approval
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Associate a policy with an action

:::warning Upcoming deprecation

Policies will be deprecated in favor of [checklists](/docs/approvals/checklists). Start any new guardrail as a checklist. If you want to migrate policies to checklists, [reach out to the nullplatform team](/docs/support).

:::

## Linking a policy to an approval action

Next, let's link the newly created policy to the approval action so that when a policy is evaluated against an approval action, each condition is checked.

To do this, you'll need to send a [POST request](/docs/api/approval-action-associate-policy) to associate the policy with the action. 

In the request, you'll need to send:
- the approval action ID as a path parameter (e.g.,`98765`).
- the policy ID in the request body (e.g., `12345`).

#### Example request

<Tabs
defaultValue="link-policy-cli"
values={[
{ label: 'CLI', value: 'link-policy-cli' },
{ label: 'cURL', value: 'link-policy-curl' },
]}>

<TabItem value="link-policy-cli">

```bash
np approval action policy create
  --id 98765
  --body '{
    "policy_id": 12345
  }'
```

</TabItem>
<TabItem value="link-policy-curl">

```bash
curl -L -X POST 'https://api.nullplatform.com/approval/action/98765/policy' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <token>' \
-d '{
  "policy_id": 12345
}'
```

</TabItem>
</Tabs>


A successful response (200 OK) confirms the association.

--- 

## How policy evaluation works

Once you've linked your policy to an approval action, nullplatform evaluates it against relevant entity data. Each condition in the policy is checked against real-time metadata to determine whether the approval should proceed.

Below is an example of how this evaluation process works in practice.

```json title="Policy evaluation example"
{
    "id": 12345,
    "name": "Enforce coverage, security, and scaling for deployments",
    "conditions": {
        "build.metadata.coverage": { "$gte": 80 },
        "build.metadata.security.issues": { "$lte": 4 },
        "scope.capabilities.auto_scaling": true,
        "$or": [
            { "scope.dimensions.environment": "dev" },
            { "scope.dimensions.environment": "qa" }
        ]
    },
    "evaluations": [
        {
            "criteria": {
                "build.metadata.coverage": { "$gte": 80 }
            },
            "result": "met"
        },
        {
            "criteria": {
                "build.metadata.security.issues": { "$lte": 4 }
            },
            "result": "not_met"
        },
        {
            "criteria": {
                "scope.capabilities.auto_scaling": true
            },
            "result": "met"
        },
        {
            "criteria": {
                "$or": [
                    { "scope.dimensions.environment": "dev" },
                    { "scope.dimensions.environment": "qa" }
                ]
            },
            "result": "met"
        }
    ],
    "passed": false
}
```
**What's evaluated here:**

- Coverage (≥ 80%) → `"met"`
  → The condition was satisfied.
- Security issues (≤ 4) → `"not_met"`
  → The condition was not met (perhaps there were more than 4 security issues).
- Auto-scaling enabled → `"met"`
  → The resource supports auto-scaling.
- Environment (dev or qa) → `"met"`
  → The deployment was in `"dev"` or `"qa"`.


Since at least one condition **was not met**, the overall policy evaluation **failed** (`"passed": false`).

## What's next

Your approval setup is complete. From here you can:

- [Check the status of approval requests](/docs/approvals/approval-requests#checking-request-status) to monitor pending decisions and execution outcomes.
- [Set up approval notifications](/docs/approvals/set-up-notifications) if you haven't already, to keep reviewers informed in real time.
