# 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": {
      "name": "string",
      "description": "string",
      "route": "string",
      "trigger": {
        "example_key": "…"
      },
      "config": {
        "example_key": "…"
      },
      "nodes": [
        {
          "id": "…",
          "type": "…",
          "name": "…",
          "config": "…",
          "position": "…",
          "error_strategy": "…",
          "retry_config": "…",
          "default_value": "…"
        }
      ],
      "edges": [
        {
          "id": "…",
          "source_node_id": "…",
          "source_output": "…",
          "target_node_id": "…",
          "target_input": "…"
        }
      ]
    }
  }
}'
```

### 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": {
        "name": "string",
        "description": "string",
        "route": "string",
        "trigger": {
          "example_key": "…"
        },
        "config": {
          "example_key": "…"
        },
        "nodes": [
          {
            "id": "…",
            "type": "…",
            "name": "…",
            "config": "…",
            "position": "…",
            "error_strategy": "…",
            "retry_config": "…",
            "default_value": "…"
          }
        ],
        "edges": [
          {
            "id": "…",
            "source_node_id": "…",
            "source_output": "…",
            "target_node_id": "…",
            "target_input": "…"
          }
        ]
      }
    }
  }),
});

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

### Python

```python
import json

payload = json.loads(r'''{
  "definition": {
    "kind": "genhealth.workflow_definition",
    "schema_version": 1,
    "workflow": {
      "name": "string",
      "description": "string",
      "route": "string",
      "trigger": {
        "example_key": "…"
      },
      "config": {
        "example_key": "…"
      },
      "nodes": [
        {
          "id": "…",
          "type": "…",
          "name": "…",
          "config": "…",
          "position": "…",
          "error_strategy": "…",
          "retry_config": "…",
          "default_value": "…"
        }
      ],
      "edges": [
        {
          "id": "…",
          "source_node_id": "…",
          "source_output": "…",
          "target_node_id": "…",
          "target_input": "…"
        }
      ]
    }
  }
}''')

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
{
  "success": true,
  "schema_valid": true,
  "graph_valid": true,
  "policy_valid": true,
  "workflow_valid": true,
  "viable": true,
  "readiness": "blocked",
  "runtime_verified": false
}
```

### 422 response example

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