# Insert Workflow Node After

> Insert one node after an existing draft node and optionally rewire its targets.

Source: [https://genhealth.ai/docs/workflows/api-reference/v1/workflow-developer-api/insert-workflow-node-after](https://genhealth.ai/docs/workflows/api-reference/v1/workflow-developer-api/insert-workflow-node-after)

## Endpoint

`POST /developer/v1/workflows/{definition_id}/nodes/after`

## 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: `WorkflowNodeInsertAfterRequest`.

## Request examples

### cURL

```curl
curl --request POST \
  --url 'https://api.umpa.genhealth.ai/developer/v1/workflows/{definition_id}/nodes/after' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "after_node_id": "string",
  "node": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "type": "string",
    "name": "string",
    "config": {
      "example_key": "string"
    },
    "position": [
      1
    ],
    "error_strategy": "fail",
    "retry_config": {
      "example_key": "string"
    },
    "default_value": {
      "example_key": "string"
    }
  },
  "source_output": "default",
  "target_input": "default",
  "rewire_existing_targets": true
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.umpa.genhealth.ai/developer/v1/workflows/{definition_id}/nodes/after', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <YOUR_API_KEY>',
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "after_node_id": "string",
    "node": {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "type": "string",
      "name": "string",
      "config": {
        "example_key": "string"
      },
      "position": [
        1
      ],
      "error_strategy": "fail",
      "retry_config": {
        "example_key": "string"
      },
      "default_value": {
        "example_key": "string"
      }
    },
    "source_output": "default",
    "target_input": "default",
    "rewire_existing_targets": true
  }),
});

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

### Python

```python
import json

payload = json.loads(r'''{
  "after_node_id": "string",
  "node": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "type": "string",
    "name": "string",
    "config": {
      "example_key": "string"
    },
    "position": [
      1
    ],
    "error_strategy": "fail",
    "retry_config": {
      "example_key": "string"
    },
    "default_value": {
      "example_key": "string"
    }
  },
  "source_output": "default",
  "target_input": "default",
  "rewire_existing_targets": true
}''')

import requests

response = requests.post(
    'https://api.umpa.genhealth.ai/developer/v1/workflows/{definition_id}/nodes/after',
    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,
  "error": "string",
  "error_category": "string",
  "retryable": true,
  "definition_id": "string",
  "version_id": "string",
  "node_id": "string",
  "node_name": "string"
}
```

### 422 response example

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