Share feedback
Answers are generated based on the documentation.

Create policy

POST/orgs/{org_name}/governance/policies
Creates a new policy with an empty rule set. Rules are added separately via the rules sub-resource.

Connection and access

API connection and authentication guidance

https://hub.docker.com/v2

Use one of these alternatives. Requirements within an alternative apply together.

  • bearerAuth

Parameters

org_name path Required

Docker Hub organization name.

Type: string

All schema constraints and annotations
{
  "type": "string"
}

Request and responses

Request

Policy name and optional scope.

application/json

Schema: CreatePolicyRequest

default

{
  "name": "Security Research — hardened",
  "scope": {
    "teams": [
      "d290f1ee-6c54-4b01-90e6-d701748f0851"
    ]
  }
}

Response 201

Policy created. Returns the new policy without its rule set.

application/json

Schema: Policy

default

{
  "created_at": "2026-04-22T00:00:00Z",
  "id": "pol_06evsmp24r1pg71cm8500546pkbn",
  "name": "Security Research — hardened",
  "org": "my-org",
  "scope": {
    "teams": [
      "d290f1ee-6c54-4b01-90e6-d701748f0851"
    ]
  },
  "updated_at": "2026-04-22T00:00:00Z"
}

Response 400

Bad request

application/json

Schema: Error

default

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

Response 401

Missing or invalid credentials

application/json

Schema: Error

default

{
  "error": {
    "code": "unauthenticated",
    "message": "unauthenticated"
  }
}

Response 403

Caller lacks the required permission for this org, the org is not entitled to use governance (permission_denied), or a creation limit has been reached (limit_exceeded): the org already has the maximum number of policies, or the policy already has the maximum number of rules.

application/json

Schema: Error

limit_exceeded

{
  "error": {
    "code": "limit_exceeded",
    "message": "organization has reached the maximum of 100 policies"
  }
}

permission_denied

{
  "error": {
    "code": "permission_denied",
    "message": "permission denied"
  }
}

Response 404

Not found

application/json

Schema: Error

default

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

Response 409

Conflict

application/json

Schema: Error

default

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

Response 500

Internal server error

application/json

Schema: Error

default

{
  "error": {
    "code": "internal",
    "message": "internal error"
  }
}

Referenced schemas

#/components/schemas/CreatePolicyRequest

#/components/schemas/Policy

Complete operation contract
{
  "description": "Creates a new policy with an empty rule set. Rules are added separately via the rules sub-resource.\n",
  "operationId": "createPolicy",
  "requestBody": {
    "content": {
      "application/json": {
        "examples": {
          "default": {
            "value": {
              "name": "Security Research — hardened",
              "scope": {
                "teams": [
                  "d290f1ee-6c54-4b01-90e6-d701748f0851"
                ]
              }
            }
          }
        },
        "schema": {
          "$ref": "#/components/schemas/CreatePolicyRequest"
        }
      }
    },
    "description": "Policy name and optional scope.",
    "required": true
  },
  "responses": {
    "201": {
      "content": {
        "application/json": {
          "examples": {
            "default": {
              "value": {
                "created_at": "2026-04-22T00:00:00Z",
                "id": "pol_06evsmp24r1pg71cm8500546pkbn",
                "name": "Security Research — hardened",
                "org": "my-org",
                "scope": {
                  "teams": [
                    "d290f1ee-6c54-4b01-90e6-d701748f0851"
                  ]
                },
                "updated_at": "2026-04-22T00:00:00Z"
              }
            }
          },
          "schema": {
            "$ref": "#/components/schemas/Policy"
          }
        }
      },
      "description": "Policy created. Returns the new policy without its rule set."
    },
    "400": {
      "$ref": "#/components/responses/InvalidArgument"
    },
    "401": {
      "$ref": "#/components/responses/Unauthenticated"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    },
    "409": {
      "$ref": "#/components/responses/Conflict"
    },
    "500": {
      "$ref": "#/components/responses/InternalError"
    }
  },
  "summary": "Create policy",
  "tags": [
    "policies"
  ]
}