# Replace Developer Workflow Draft From Json

> Replace the complete draft graph from canonical JSON without publishing it.

Source: [https://genhealth.ai/docs/workflows/api-reference/v1/workflow-developer-api/replace-developer-workflow-draft-from-json](https://genhealth.ai/docs/workflows/api-reference/v1/workflow-developer-api/replace-developer-workflow-draft-from-json)

## Endpoint

`POST /developer/v1/workflows/{definition_id}/draft/from-json`

## Authentication

Send a GenHealth credential in the `Authorization` header:

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

Required scopes: `workflow:write`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `definition_id` | path | string | Yes | No description provided. |

## Request body

Required. JSON request body.

Schema: `WorkflowImportEnvelope`.

## Request examples

### cURL

```curl
curl --request POST \
  --url 'https://api.umpa.genhealth.ai/developer/v1/workflows/{definition_id}/draft/from-json' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "kind": "genhealth.workflow_definition",
  "schema_version": 1,
  "workflow": {
    "name": "string",
    "description": "string",
    "route": "string",
    "trigger": {
      "example_key": "string"
    },
    "config": {
      "example_key": "string"
    },
    "nodes": [
      {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "type": "string",
        "name": "string",
        "config": {
          "example_key": "string"
        },
        "position": [
          "…"
        ],
        "error_strategy": "fail",
        "retry_config": {
          "example_key": "…"
        },
        "default_value": {
          "example_key": "…"
        }
      }
    ],
    "edges": [
      {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "source_node_id": "string",
        "source_output": "default",
        "target_node_id": "string",
        "target_input": "default"
      }
    ]
  }
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.umpa.genhealth.ai/developer/v1/workflows/{definition_id}/draft/from-json', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <YOUR_API_KEY>',
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "kind": "genhealth.workflow_definition",
    "schema_version": 1,
    "workflow": {
      "name": "string",
      "description": "string",
      "route": "string",
      "trigger": {
        "example_key": "string"
      },
      "config": {
        "example_key": "string"
      },
      "nodes": [
        {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "string",
          "name": "string",
          "config": {
            "example_key": "string"
          },
          "position": [
            "…"
          ],
          "error_strategy": "fail",
          "retry_config": {
            "example_key": "…"
          },
          "default_value": {
            "example_key": "…"
          }
        }
      ],
      "edges": [
        {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "source_node_id": "string",
          "source_output": "default",
          "target_node_id": "string",
          "target_input": "default"
        }
      ]
    }
  }),
});

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

### Python

```python
import json

payload = json.loads(r'''{
  "kind": "genhealth.workflow_definition",
  "schema_version": 1,
  "workflow": {
    "name": "string",
    "description": "string",
    "route": "string",
    "trigger": {
      "example_key": "string"
    },
    "config": {
      "example_key": "string"
    },
    "nodes": [
      {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "type": "string",
        "name": "string",
        "config": {
          "example_key": "string"
        },
        "position": [
          "…"
        ],
        "error_strategy": "fail",
        "retry_config": {
          "example_key": "…"
        },
        "default_value": {
          "example_key": "…"
        }
      }
    ],
    "edges": [
      {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "source_node_id": "string",
        "source_output": "default",
        "target_node_id": "string",
        "target_input": "default"
      }
    ]
  }
}''')

import requests

response = requests.post(
    'https://api.umpa.genhealth.ai/developer/v1/workflows/{definition_id}/draft/from-json',
    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
{
  "workflow": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "string",
    "description": "string",
    "status": "open",
    "nodes": [],
    "edges": [],
    "trigger": {
      "example_key": "string"
    }
  },
  "warnings": [
    {
      "node_id": "string",
      "code": "99213",
      "message": "string"
    }
  ]
}
```

### 422 response example

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