---
title: "checkOrgPolicyDiff"
---

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

# checkOrgPolicyDiff

Path: Forge API › policies

`POST /orgs/{org_id}/policy-diffs`

List what a draft file allows or denies in a repo that the live policies don't, for every member who isn't an owner, member by member: the repo's resources, then the records you can read, limit of them a page, each record change with a count and examples of that page's records. Updates are compared on records as they stand and creates not at all, so simulate a proposed edit. Pass next_cursor back as cursor for the next page. A draft with policy_id stands in for that policy alone, as a new version of it would; a draft without one joins the live policies as a new policy. Needs readPolicies and readMembers on the org.

## Path parameters

- `org_id` (`checkOrgPolicyDiff.path.org_id`; string, required)
  - pattern: `^org_[0-7][0-9a-hjkmnp-tv-z]{25}$`

## Request body

_Required._

- `repo_id` (`checkOrgPolicyDiff.repo_id`; string, required)
  - pattern: `^repo_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `draft` (`checkOrgPolicyDiff.draft`; object, required)
  - `source` (`checkOrgPolicyDiff.draft.source`; string, required)
    - minLength: `1`
  - `repo_id` (`checkOrgPolicyDiff.draft.repo_id`; string, optional)
    - pattern: `^repo_[0-7][0-9a-hjkmnp-tv-z]{25}$`
  - `policy_id` (`checkOrgPolicyDiff.draft.policy_id`; string, optional)
    - pattern: `^policy_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `branch` (`checkOrgPolicyDiff.branch`; string, optional)
  - minLength: `1`
- `cursor` (`checkOrgPolicyDiff.cursor`; string, optional)
  - minLength: `1`
- `limit` (`checkOrgPolicyDiff.limit`; integer, optional)
  - maximum: `200` · minimum: `1`

## Example request

```json
{
  "repo_id": "string",
  "draft": {
    "source": "string",
    "repo_id": "string",
    "policy_id": "string"
  },
  "branch": "string",
  "cursor": "string",
  "limit": 1
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/orgs/<org_id>/policy-diffs' \
  --header 'Content-Type: application/json' \
  --data '
{
  "repo_id": "string",
  "draft": {
    "source": "string",
    "repo_id": "string",
    "policy_id": "string"
  },
  "branch": "string",
  "cursor": "string",
  "limit": 1
}
'
```

### TypeScript

```typescript
const url = '<base-url>/orgs/<org_id>/policy-diffs';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    repo_id: 'string',
    draft: {source: 'string', repo_id: 'string', policy_id: 'string'},
    branch: 'string',
    cursor: 'string',
    limit: 1
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/orgs/<org_id>/policy-diffs"

payload = {
    "repo_id": "string",
    "draft": {
        "source": "string",
        "repo_id": "string",
        "policy_id": "string"
    },
    "branch": "string",
    "cursor": "string",
    "limit": 1
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Success

#### Example

```json
{
  "data": [
    {
      "user_id": "string",
      "action": "string",
      "change": "allowed",
      "resource": {
        "kind": "model",
        "model_api_name": "string",
        "records": 1,
        "examples": [
          "string"
        ]
      }
    }
  ],
  "next_cursor": "string"
}
```

- `data` (`checkOrgPolicyDiff.response.200.data`; array of object, required)
  - `user_id` (`checkOrgPolicyDiff.response.200.data.user_id`; string, required)
    - pattern: `^(?:user|extension)_[0-7][0-9a-hjkmnp-tv-z]{25}$`
  - `action` (`checkOrgPolicyDiff.response.200.data.action`; string, required)
    - pattern: `^[a-z][A-Za-z]*$`
  - `change` (`checkOrgPolicyDiff.response.200.data.change`; string, required)
    - one of `"allowed"`, `"denied"`
  - `resource` (`checkOrgPolicyDiff.response.200.data.resource`; DiffedResource, required)
    - any of the following:
      - `object`
        - `kind` (`checkOrgPolicyDiff.response.200.data.resource.1.kind`; string, required)
          - one of `"model"`
        - `model_api_name` (`checkOrgPolicyDiff.response.200.data.resource.1.model_api_name`; string, required)
          - minLength: `1`
        - `records` (`checkOrgPolicyDiff.response.200.data.resource.1.records`; integer, required)
          - maximum: `9007199254740991`
        - `examples` (`checkOrgPolicyDiff.response.200.data.resource.1.examples`; array of string, required)
          - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
      - `object`
        - `kind` (`checkOrgPolicyDiff.response.200.data.resource.2.kind`; string, required)
          - one of `"schema"`
        - `model_api_name` (`checkOrgPolicyDiff.response.200.data.resource.2.model_api_name`; string, required)
          - minLength: `1`
      - `object`
        - `kind` (`checkOrgPolicyDiff.response.200.data.resource.3.kind`; string, required)
          - one of `"repo"`, `"agentInstructions"`, `"agentSkills"`
      - `object`
        - `kind` (`checkOrgPolicyDiff.response.200.data.resource.4.kind`; string, required)
          - one of `"extension"`, `"installation"`
        - `extension` (`checkOrgPolicyDiff.response.200.data.resource.4.extension`; string, required)
          - maxLength: `129` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$`
- `next_cursor` (`checkOrgPolicyDiff.response.200.next_cursor`; any of, required)
  - any of the following: `PageCursor`, `null`

### 400

InvalidCursor | InvalidRequest | RequestBodyTooDeep

#### Example

```json
{
  "_tag": "InvalidCursor",
  "reason": "string"
}
```

Any of the following:

- `InvalidCursorEncoded`
  - `_tag` (`InvalidCursorEncoded._tag`; string, required)
    - one of `"InvalidCursor"`
  - `reason` (`InvalidCursorEncoded.reason`; string, required)
    - minLength: `1`
- `InvalidRequestEncoded`
  - `_tag` (`InvalidRequestEncoded._tag`; string, required)
    - one of `"InvalidRequest"`
  - `part` (`InvalidRequestEncoded.part`; string, required)
    - one of `"path"`, `"query"`, `"headers"`, `"body"`
  - `issues` (`InvalidRequestEncoded.issues`; array of object, required)
    - `path` (`InvalidRequestEncoded.issues.path`; array\<any of\>, required)
      - any of the following: `string`, `integer`
    - `message` (`InvalidRequestEncoded.issues.message`; string, required)
- `RequestBodyTooDeepEncoded`
  - `_tag` (`RequestBodyTooDeepEncoded._tag`; string, required)
    - one of `"RequestBodyTooDeep"`
  - `max_depth` (`RequestBodyTooDeepEncoded.max_depth`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`

### 401

InvalidCredentials

#### Example

```json
{
  "_tag": "InvalidCredentials"
}
```

- `_tag` (`checkOrgPolicyDiff.response.401._tag`; string, required)
  - one of `"InvalidCredentials"`

### 403

Forbidden | ForbiddenOrigin | RequiresPersonalSession | RunBranchRequired

#### Example

```json
{
  "_tag": "Forbidden",
  "message": "string"
}
```

Any of the following:

- `ForbiddenEncoded`
  - `_tag` (`ForbiddenEncoded._tag`; string, required)
    - one of `"Forbidden"`
  - `message` (`ForbiddenEncoded.message`; string, required)
- `ForbiddenOriginEncoded`
  - `_tag` (`ForbiddenOriginEncoded._tag`; string, required)
    - one of `"ForbiddenOrigin"`
- `RequiresPersonalSessionEncoded`
  - `_tag` (`RequiresPersonalSessionEncoded._tag`; string, required)
    - one of `"RequiresPersonalSession"`
- `RunBranchRequiredEncoded`
  - `_tag` (`RunBranchRequiredEncoded._tag`; string, required)
    - one of `"RunBranchRequired"`
  - `branch` (`RunBranchRequiredEncoded.branch`; string, required)
    - minLength: `1`
  - `message` (`RunBranchRequiredEncoded.message`; string, required)

### 404

OrgNotFound | RepoNotFound | PolicyNotFound | BranchNotFound

#### Example

```json
{
  "_tag": "OrgNotFound"
}
```

Any of the following:

- `OrgNotFoundEncoded`
  - `_tag` (`OrgNotFoundEncoded._tag`; string, required)
    - one of `"OrgNotFound"`
- `RepoNotFoundEncoded`
  - `_tag` (`RepoNotFoundEncoded._tag`; string, required)
    - one of `"RepoNotFound"`
- `PolicyNotFoundEncoded`
  - `_tag` (`PolicyNotFoundEncoded._tag`; string, required)
    - one of `"PolicyNotFound"`
- `BranchNotFoundEncoded`
  - `_tag` (`BranchNotFoundEncoded._tag`; string, required)
    - one of `"BranchNotFound"`
  - `branch` (`BranchNotFoundEncoded.branch`; string, required)
    - minLength: `1`

### 409

PolicyLevelMismatch

#### Example

```json
{
  "_tag": "PolicyLevelMismatch"
}
```

- `_tag` (`checkOrgPolicyDiff.response.409._tag`; string, required)
  - one of `"PolicyLevelMismatch"`

### 413

RequestBodyTooLarge

#### Example

```json
{
  "_tag": "RequestBodyTooLarge",
  "max_bytes": -9007199254740991
}
```

- `_tag` (`checkOrgPolicyDiff.response.413._tag`; string, required)
  - one of `"RequestBodyTooLarge"`
- `max_bytes` (`checkOrgPolicyDiff.response.413.max_bytes`; integer, required)
  - maximum: `9007199254740991` · minimum: `-9007199254740991`

### 422

PolicyInvalid

#### Example

```json
{
  "_tag": "PolicyInvalid",
  "problems": [
    {
      "severity": "error",
      "code": "syntax",
      "message": "string",
      "fix": "string",
      "location": {
        "line": -9007199254740991,
        "column": -9007199254740991
      },
      "policy": "string",
      "statement": -9007199254740991,
      "term": [
        0
      ]
    }
  ]
}
```

- `_tag` (`checkOrgPolicyDiff.response.422._tag`; string, required)
  - one of `"PolicyInvalid"`
- `problems` (`checkOrgPolicyDiff.response.422.problems`; array of object, required)
  - `severity` (`checkOrgPolicyDiff.response.422.problems.severity`; string, required)
    - one of `"error"`, `"warning"`
  - `code` (`checkOrgPolicyDiff.response.422.problems.code`; string, required)
    - one of `"syntax"`, `"unsupported"`, `"truthiness"`, `"duplicate"`, `"unknownModel"`, `"unknownField"`, `"unknownAction"`, `"unknownExtension"`, `"unknownTool"`, `"unknownWorkflow"`, `"unknownSchedule"`, `"unknownTrigger"`, `"unknownGroup"`, `"unknownRepo"`, `"notAReference"`, `"noRecord"`, `"crossRepo"`, `"repoAllow"`, `"orgActionInRepo"`, `"repoModelInOrgPolicy"`
  - `message` (`checkOrgPolicyDiff.response.422.problems.message`; string, required)
  - `fix` (`checkOrgPolicyDiff.response.422.problems.fix`; any of, required)
    - any of the following: `string`, `null`
  - `location` (`checkOrgPolicyDiff.response.422.problems.location`; any of, required)
    - any of the following:
      - `object`
        - `line` (`checkOrgPolicyDiff.response.422.problems.location.1.line`; integer, required)
          - maximum: `9007199254740991` · minimum: `-9007199254740991`
        - `column` (`checkOrgPolicyDiff.response.422.problems.location.1.column`; integer, required)
          - maximum: `9007199254740991` · minimum: `-9007199254740991`
      - `null`
  - `policy` (`checkOrgPolicyDiff.response.422.problems.policy`; any of, required)
    - any of the following: `string`, `null`
  - `statement` (`checkOrgPolicyDiff.response.422.problems.statement`; any of, required)
    - any of the following: `integer`, `null`
  - `term` (`checkOrgPolicyDiff.response.422.problems.term`; any of, required)
    - any of the following: `array<integer>`, `null`

### 429

RateLimited

#### Example

```json
{
  "_tag": "RateLimited"
}
```

- `_tag` (`checkOrgPolicyDiff.response.429._tag`; string, required)
  - one of `"RateLimited"`

### 500

OrgFailure | RepoFailure

#### Example

```json
{
  "_tag": "OrgFailure",
  "reason": "string"
}
```

Every option has:

- `reason` (`<option>.reason`; string, required)

Any of the following, each adding:

- `OrgFailureEncoded`
  - `_tag` (`OrgFailureEncoded._tag`; string, required)
    - one of `"OrgFailure"`
- `RepoFailureEncoded`
  - `_tag` (`RepoFailureEncoded._tag`; string, required)
    - one of `"RepoFailure"`

### 503

SessionUnavailable | RateLimitUnavailable

#### Example

```json
{
  "_tag": "SessionUnavailable"
}
```

Any of the following:

- `SessionUnavailableEncoded`
  - `_tag` (`SessionUnavailableEncoded._tag`; string, required)
    - one of `"SessionUnavailable"`
- `RateLimitUnavailableEncoded`
  - `_tag` (`RateLimitUnavailableEncoded._tag`; string, required)
    - one of `"RateLimitUnavailable"`


Source: https://buildrforge.com/docs/api/check-org-policy-diff/index.md
