# Update rule


[API catalog](/reference/api/) · [AI Governance overview](/reference/api/ai-governance/latest/) · [Product manual](https://docs.docker.com/ai/sandboxes/governance/) · [OpenAPI specification](/reference/api/ai-governance/api.yaml)

API version: 1



`PATCH /orgs/{org_name}/governance/policies/{policy_id}/rules/{rule_id}`

Partially updates a rule. Only fields present in the request body are
updated; absent fields are left unchanged. Returns the rule in both its
old and new states.

Changing `actions` across domains (for example, from network actions to
filesystem actions) is rejected. Changes may take up to five minutes to
reach developer machines.


## Connection and access

[API connection and authentication guidance](/reference/api/ai-governance/latest/#authentication)


Server: `https://hub.docker.com/v2`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
[
  {
    "bearerAuth": []
  }
]
```
## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request PATCH \
  --header "Authorization: Bearer ${TOKEN}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "resources": [
    "research.mitre.org"
  ]
}' \
  'https://hub.docker.com/v2/orgs/<ORG_NAME>/governance/policies/<POLICY_ID>/rules/<RULE_ID>'
```

## Parameters

### org_name

Location: path. Required: yes.

Docker Hub organization name.

```json
{
  "description": "Docker Hub organization name.",
  "examples": {
    "default": {
      "value": "my-org"
    }
  },
  "in": "path",
  "name": "org_name",
  "pointer": "/paths/~1orgs~1{org_name}~1governance~1policies~1{policy_id}~1rules~1{rule_id}/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### policy_id

Location: path. Required: yes.

Unique policy identifier.

```json
{
  "description": "Unique policy identifier.",
  "examples": {
    "default": {
      "value": "pol_06evsmp24r1pg71cm8500546pkbn"
    }
  },
  "in": "path",
  "name": "policy_id",
  "pointer": "/paths/~1orgs~1{org_name}~1governance~1policies~1{policy_id}~1rules~1{rule_id}/parameters/1",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### rule_id

Location: path. Required: yes.

Unique rule identifier within the policy.

```json
{
  "description": "Unique rule identifier within the policy.",
  "examples": {
    "default": {
      "value": "rule_06evsm9qjm1pdsk0a8nkfaxy7jna"
    }
  },
  "in": "path",
  "name": "rule_id",
  "pointer": "/paths/~1orgs~1{org_name}~1governance~1policies~1{policy_id}~1rules~1{rule_id}/parameters/2",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

## Request and responses

### Request  application/json

Fields to update. Absent fields are left unchanged.


Schema:

```json
{
  "$ref": "#/components/schemas/UpdateRuleRequest"
}
```




default:
```json
{
  "resources": [
    "research.mitre.org"
  ]
}
```


### Response 200 application/json

Rule updated, returns old and new states.


Schema:

```json
{
  "$ref": "#/components/schemas/UpdateRuleResponse"
}
```




default:
```json
{
  "new": {
    "actions": [
      "connect:tcp",
      "connect:udp"
    ],
    "decision": "allow",
    "id": "rule_06evsm9qjm1pdsk0a8nkfaxy7jna",
    "name": "allow research mirrors",
    "resources": [
      "research.mitre.org"
    ]
  },
  "old": {
    "actions": [
      "connect:tcp",
      "connect:udp"
    ],
    "decision": "allow",
    "id": "rule_06evsm9qjm1pdsk0a8nkfaxy7jna",
    "name": "allow research mirrors",
    "resources": [
      "research.mitre.org",
      "cve.mitre.org"
    ]
  }
}
```


### Response 400 application/json

Bad request


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```




default:
```json
{
  "error": {
    "code": "invalid_argument",
    "message": "name is required"
  }
}
```


### Response 401 application/json

Missing or invalid credentials


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```




default:
```json
{
  "error": {
    "code": "unauthenticated",
    "message": "unauthenticated"
  }
}
```


### Response 403 application/json

Caller lacks the required permission for this org, or the org is not entitled to use governance.



Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```




default:
```json
{
  "error": {
    "code": "permission_denied",
    "message": "permission denied"
  }
}
```


### Response 404 application/json

Not found


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```




default:
```json
{
  "error": {
    "code": "not_found",
    "message": "policy not found"
  }
}
```


### Response 409 application/json

Conflict


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```




default:
```json
{
  "error": {
    "code": "conflict",
    "message": "policy name already in use"
  }
}
```


### Response 500 application/json

Internal server error


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```




default:
```json
{
  "error": {
    "code": "internal",
    "message": "internal error"
  }
}
```


## Complete operation contract

```json
{
  "description": "Partially updates a rule. Only fields present in the request body are\nupdated; absent fields are left unchanged. Returns the rule in both its\nold and new states.\n\nChanging `actions` across domains (for example, from network actions to\nfilesystem actions) is rejected. Changes may take up to five minutes to\nreach developer machines.\n",
  "operationId": "updateRule",
  "requestBody": {
    "content": {
      "application/json": {
        "examples": {
          "default": {
            "value": {
              "resources": [
                "research.mitre.org"
              ]
            }
          }
        },
        "schema": {
          "$ref": "#/components/schemas/UpdateRuleRequest"
        }
      }
    },
    "description": "Fields to update. Absent fields are left unchanged.",
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "examples": {
            "default": {
              "value": {
                "new": {
                  "actions": [
                    "connect:tcp",
                    "connect:udp"
                  ],
                  "decision": "allow",
                  "id": "rule_06evsm9qjm1pdsk0a8nkfaxy7jna",
                  "name": "allow research mirrors",
                  "resources": [
                    "research.mitre.org"
                  ]
                },
                "old": {
                  "actions": [
                    "connect:tcp",
                    "connect:udp"
                  ],
                  "decision": "allow",
                  "id": "rule_06evsm9qjm1pdsk0a8nkfaxy7jna",
                  "name": "allow research mirrors",
                  "resources": [
                    "research.mitre.org",
                    "cve.mitre.org"
                  ]
                }
              }
            }
          },
          "schema": {
            "$ref": "#/components/schemas/UpdateRuleResponse"
          }
        }
      },
      "description": "Rule updated, returns old and new states."
    },
    "400": {
      "$ref": "#/components/responses/InvalidArgument"
    },
    "401": {
      "$ref": "#/components/responses/Unauthenticated"
    },
    "403": {
      "$ref": "#/components/responses/PermissionDenied"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    },
    "409": {
      "$ref": "#/components/responses/Conflict"
    },
    "500": {
      "$ref": "#/components/responses/InternalError"
    }
  },
  "summary": "Update rule",
  "tags": [
    "rules"
  ]
}
```

## Referenced schemas

- `#/components/responses/Conflict`

- `#/components/responses/InternalError`

- `#/components/responses/InvalidArgument`

- `#/components/responses/NotFound`

- `#/components/responses/PermissionDenied`

- `#/components/responses/Unauthenticated`

- [#/components/schemas/UpdateRuleRequest](/reference/api/ai-governance/latest/schemas/UpdateRuleRequest/)

- [#/components/schemas/UpdateRuleResponse](/reference/api/ai-governance/latest/schemas/UpdateRuleResponse/)




