# Validate task YAML without saving

> Source: https://docs.clonepartner.com/api-reference/tasks/validate-task-yaml/

`POST /api/tasks/validate`

Validate task YAML without saving

**Operation ID:** `validateTaskYaml`

## Authentication

### Option 1

- **BearerAuth** (`http bearer`)
  API key token. Create via POST /api/api-keys. Format: `envoy_<hex>`

### Option 2

- **CookieAuth** (`apiKey`)
  Session cookie set after login + TOTP verification

## Request body

The request body is required.

### `application/json`

- Type: `object`
- Properties:
  - `yaml_content` (`string`, `required`)

## Success responses

### 200

Validation result

**Content type:** `application/json`

- Type: `object`
- Properties:
  - `valid` (`boolean`)
  - `step_count` (`integer`)
  - `connectors` (`array<string>`)
    - Items:
      - Type: `string`
  - `issues` (`array<object>`)
    - Items:
      - Type: `object`
      - Properties:
        - `severity` (`string`)
        - `message` (`string`)
        - `step` (`string`)
        - `field` (`string`)

## Error responses

### 400

Validation error

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "VALIDATION_ERROR",
  "message": "Invalid input"
}
```

## Examples

### cURL

```bash
curl --request POST \
  --url 'https://your-envoy.example.com/api/tasks/validate' \
  --header 'Authorization: Bearer $API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "yaml_content": "string"
}'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/tasks/validate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "yaml_content": "string"
  }),
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
