> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Retrieve a Test Definition

> Get a test definition by ID or name

# Retrieve a Test Definition

Get a single test definition by its unique ID or name.

## Get by ID

**id** `string` *required*

UUID of the test definition to retrieve.

**fields** `string`

Comma-separated list of fields to include, for example `owners`.

**include** `string` (default: non-deleted)

Include `all`, `deleted`, or `non-deleted` entities.

## Get by Name

Use `GET /v1/dataQuality/testDefinitions/name/{name}` to retrieve by name.

**name** `string` *required*

Name of the test definition, for example `columnValueLengthsToBeBetween`.

**fields** `string`

Comma-separated list of fields to include: `owners`.

**include** `string` (default: non-deleted)

Include `all`, `deleted`, or `non-deleted` entities.

```python GET /v1/dataQuality/testDefinitions/{id} theme={null}
from metadata.sdk import configure
from metadata.sdk.entities import TestDefinitions

configure(
    host="https://your-company.open-metadata.org/api",
    jwt_token="your-jwt-token"
)

# Get by ID
td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d")
print(f"{td.name.root}: {getattr(td.description, 'root', td.description)}")

# Get by ID with fields
td = TestDefinitions.retrieve(
    "a636d153-f1e8-45be-86d3-52aa6b71730d",
    fields=["owners"]
)

# Get by name
td = TestDefinitions.retrieve_by_name("columnValueLengthsToBeBetween")
print(f"Entity type: {td.entityType}")
print(f"Parameters: {[p.name for p in td.parameterDefinition]}")
```

```java GET /v1/dataQuality/testDefinitions/{id} theme={null}
// client is an initialized OpenMetadataClient.
var testDefinition = client.testDefinitions().get("a636d153-f1e8-45be-86d3-52aa6b71730d");

// Get by fully qualified name
var testDefinitionByName = client.testDefinitions().getByName("columnValueLengthsToBeBetween");
```

```bash GET /v1/dataQuality/testDefinitions/{id} theme={null}
# Get by ID
curl "{base_url}/api/v1/dataQuality/testDefinitions/a636d153-f1e8-45be-86d3-52aa6b71730d" \
  -H "Authorization: Bearer {access_token}"

# Get by name
curl "{base_url}/api/v1/dataQuality/testDefinitions/name/columnValueLengthsToBeBetween" \
  -H "Authorization: Bearer {access_token}"

# With fields
curl "{base_url}/api/v1/dataQuality/testDefinitions/name/columnValueLengthsToBeBetween?fields=owners" \
  -H "Authorization: Bearer {access_token}"
```

```json Response theme={null}
{
  "id": "a636d153-f1e8-45be-86d3-52aa6b71730d",
  "name": "columnValueLengthsToBeBetween",
  "displayName": "Column Value Lengths To Be Between",
  "fullyQualifiedName": "columnValueLengthsToBeBetween",
  "description": "This test definition validates that the lengths of column values are between a specified range...",
  "version": 0.1,
  "updatedAt": 1769982618104,
  "updatedBy": "admin",
  "testPlatforms": ["OpenMetadata"],
  "supportedDataTypes": ["STRING", "VARCHAR", "CHAR", "TEXT"],
  "parameterDefinition": [
    {
      "name": "minLength",
      "dataType": "INT",
      "required": false,
      "description": "The min length"
    },
    {
      "name": "maxLength",
      "dataType": "INT",
      "required": false,
      "description": "The max length"
    }
  ],
  "entityType": "COLUMN",
  "provider": "system",
  "deleted": false
}
```

***

## Returns

Returns a test definition object with all requested fields populated.

## Response

**id** `string`

Unique identifier for the test definition (UUID format).

**name** `string`

Test definition name.

**fullyQualifiedName** `string`

Fully qualified name (same as name for test definitions).

**displayName** `string`

Human-readable display name.

**description** `string`

Description of what the test validates.

**entityType** `string`

Target entity type: `TABLE` or `COLUMN`.

**testPlatforms** `array`

Supported test platforms.

**supportedDataTypes** `array`

Data types this test can be applied to.

**parameterDefinition** `array`

Parameters accepted by this test definition.

**properties**

**name** `string`

Parameter name.

**dataType** `string`

Data type of the parameter.

**required** `boolean`

Whether this parameter is required.

**description** `string`

Description of the parameter.

**provider** `string`

Whether the definition is `system` (built-in) or `user` (custom).

**version** `number`

Version number for the entity.

**owners** `array`

List of owners. Only included when `fields` contains `owners`.

***

## Error Handling

| Code | Error Type | Description |
| - | - | - |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN` | User lacks permission to view this test definition |
| `404` | `NOT_FOUND` | Test definition with given ID or name does not exist |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.