# Validate Workflow Definition

> Preflight canonical workflow JSON against save, audit, and public API rules. This operation does not persist anything. A definition that fails validation still returns HTTP 200 with ``viable=false`` and machine-actionable findings.

Source: [https://genhealth.ai/docs/workflows/api-reference/v1/workflow-developer-api/validate-workflow-definition](https://genhealth.ai/docs/workflows/api-reference/v1/workflow-developer-api/validate-workflow-definition)

## Endpoint

`POST /developer/v1/workflows/validate`

## Authentication

Send a GenHealth credential in the `Authorization` header:

```http
Authorization: Bearer <YOUR_API_KEY>
Accept: application/json
```

Required scopes: `workflow:read`

## Parameters

This endpoint has no request parameters.

## Request body

Required. JSON request body.

Schema: `WorkflowDefinitionValidationRequest`.

## Request examples

### cURL

```curl
curl --request POST \
  --url 'https://api.umpa.genhealth.ai/developer/v1/workflows/validate' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "definition": {
    "kind": "genhealth.workflow_definition",
    "schema_version": 1,
    "workflow": {
      "config": {
        "example_key": "…"
      },
      "description": "string",
      "edges": [
        {
          "id": "…",
          "source_node_id": "…",
          "source_output": "…",
          "target_input": "…",
          "target_node_id": "…"
        }
      ],
      "name": "string",
      "nodes": [
        {
          "config": "…",
          "default_value": "…",
          "error_strategy": "…",
          "id": "…",
          "name": "…",
          "position": "…",
          "retry_config": "…",
          "type": "…"
        }
      ],
      "route": "string",
      "trigger": {
        "config": {
          "run_fields": [
            {
              "default": false,
              "key": "dry_run",
              "type": "boolean"
            },
            {
              "key": "limit",
              "required": true,
              "type": "number"
            }
          ]
        },
        "type": "manual"
      }
    }
  }
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.umpa.genhealth.ai/developer/v1/workflows/validate', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <YOUR_API_KEY>',
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "definition": {
      "kind": "genhealth.workflow_definition",
      "schema_version": 1,
      "workflow": {
        "config": {
          "example_key": "…"
        },
        "description": "string",
        "edges": [
          {
            "id": "…",
            "source_node_id": "…",
            "source_output": "…",
            "target_input": "…",
            "target_node_id": "…"
          }
        ],
        "name": "string",
        "nodes": [
          {
            "config": "…",
            "default_value": "…",
            "error_strategy": "…",
            "id": "…",
            "name": "…",
            "position": "…",
            "retry_config": "…",
            "type": "…"
          }
        ],
        "route": "string",
        "trigger": {
          "config": {
            "run_fields": [
              {
                "default": false,
                "key": "dry_run",
                "type": "boolean"
              },
              {
                "key": "limit",
                "required": true,
                "type": "number"
              }
            ]
          },
          "type": "manual"
        }
      }
    }
  }),
});

const data = await response.json();
```

### Python

```python
import json

payload = json.loads(r'''{
  "definition": {
    "kind": "genhealth.workflow_definition",
    "schema_version": 1,
    "workflow": {
      "config": {
        "example_key": "…"
      },
      "description": "string",
      "edges": [
        {
          "id": "…",
          "source_node_id": "…",
          "source_output": "…",
          "target_input": "…",
          "target_node_id": "…"
        }
      ],
      "name": "string",
      "nodes": [
        {
          "config": "…",
          "default_value": "…",
          "error_strategy": "…",
          "id": "…",
          "name": "…",
          "position": "…",
          "retry_config": "…",
          "type": "…"
        }
      ],
      "route": "string",
      "trigger": {
        "config": {
          "run_fields": [
            {
              "default": false,
              "key": "dry_run",
              "type": "boolean"
            },
            {
              "key": "limit",
              "required": true,
              "type": "number"
            }
          ]
        },
        "type": "manual"
      }
    }
  }
}''')

import requests

response = requests.post(
    'https://api.umpa.genhealth.ai/developer/v1/workflows/validate',
    headers={
        'Authorization': 'Bearer <YOUR_API_KEY>',
        'Accept': 'application/json',
        'Content-Type': 'application/json',
    },
    json=payload,
)

data = response.json()
```

## Responses

| Status | Description |
| --- | --- |
| 200 | Successful Response |
| 422 | Validation Error |

### 200 response example

```json
{
  "findings": [
    {
      "category": "string",
      "code": "99213",
      "details": {
        "example_key": "string"
      },
      "edge": {
        "example_key": "string"
      },
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "message": "string",
      "node_ids": [
        "string"
      ],
      "severity": "blocking"
    }
  ],
  "graph_valid": true,
  "policy_valid": true,
  "readiness": "blocked",
  "runtime_notes": [
    {
      "category": "string",
      "code": "99213",
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "message": "string",
      "node_ids": [
        "string"
      ],
      "suggestion": "string"
    }
  ],
  "runtime_verified": false,
  "schema_errors": [
    {
      "code": "99213",
      "message": "string",
      "path": "string"
    }
  ],
  "schema_valid": true
}
```

### 422 response example

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```
