---
title: "List default constraint."
method: GET
path: "/api/v2/constraints"
tags: ["constraint"]
---

# List default constraint.

`GET /api/v2/constraints`

## Request

- The document declares no server URL.
- Auth: API key in header `Authorization`
- TypeScript: <https://skmtc.dev/kubermatic/apis/kubermatic-kubernetes-platform-api/docs/api/v2/constraints/get.ts> (a function with typed inputs; its response is checked against the schema)

## Response `200`

Constraint

- Constraint[]
  - `labels` object
  - `name` string
  - `spec` ConstraintSpec
    - `constraintType` string: ConstraintType specifies the type of gatekeeper constraint that the constraint applies to
    - `disabled` boolean: Disabled is the flag for disabling OPA constraints
    - `match` Match: Match contains the constraint to resource matching data
      - `excludedNamespaces` string[]: ExcludedNamespaces is a list of namespace names. If defined, a constraint will only apply to resources not in a listed namespace.
      - `kinds` Kind[]: Kinds accepts a list of objects with apiGroups and kinds fields that list the groups/kinds of objects to which the constraint will apply. If multiple groups/kinds objects are specified, only one match is needed for the resource to be in scope
        - `apiGroups` string[]: APIGroups specifies the APIGroups of the resources
        - `kinds` string[]: Kinds specifies the kinds of the resources
      - `labelSelector` LabelSelector: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects. +structType=atomic
        - `matchExpressions` LabelSelectorRequirement[]: matchExpressions is a list of label selector requirements. The requirements are ANDed. +optional
          - `key` string: key is the label key that the selector applies to. +patchMergeKey=key +patchStrategy=merge
          - `operator` string
          - `values` string[]: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. +optional
        - `matchLabels` object: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. +optional
      - `namespaceSelector` LabelSelector: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects. +structType=atomic
        - `matchExpressions` LabelSelectorRequirement[]: matchExpressions is a list of label selector requirements. The requirements are ANDed. +optional
          - `key` string: key is the label key that the selector applies to. +patchMergeKey=key +patchStrategy=merge
          - `operator` string
          - `values` string[]: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. +optional
        - `matchLabels` object: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. +optional
      - `namespaces` string[]: Namespaces is a list of namespace names. If defined, a constraint will only apply to resources in a listed namespace.
      - `scope` string: Scope accepts *, Cluster, or Namespaced which determines if cluster-scoped and/or namesapced-scoped resources are selected. (defaults to *)
    - `parameters` Parameters
    - `selector` ConstraintSelector: ConstraintSelector is the object holding the cluster selection filters
      - `labelSelector` LabelSelector: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects. +structType=atomic
        - `matchExpressions` LabelSelectorRequirement[]: matchExpressions is a list of label selector requirements. The requirements are ANDed. +optional
          - `key` string: key is the label key that the selector applies to. +patchMergeKey=key +patchStrategy=merge
          - `operator` string
          - `values` string[]: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. +optional
        - `matchLabels` object: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. +optional
      - `providers` string[]: Providers is a list of cloud providers to which the Constraint applies to. Empty means all providers are selected.
  - `status` ConstraintStatus: ConstraintStatus represents a constraint status which holds audit info
    - `auditTimestamp` string
    - `enforcement` string
    - `synced` boolean
    - `violations` Violation[]
      - `enforcementAction` string
      - `kind` string
      - `message` string
      - `name` string
      - `namespace` string

## Other responses

- `401`: EmptyResponse is a empty response
- `403`: EmptyResponse is a empty response
- `default`: errorResponse

---

[API](https://skmtc.dev/kubermatic/apis/kubermatic-kubernetes-platform-api.md) - [All operations](https://skmtc.dev/kubermatic/apis/kubermatic-kubernetes-platform-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kubermatic/apis/kubermatic-kubernetes-platform-api/revisions/815b9bf19db5?raw)
