> For a complete page index of the Captain API documentation, fetch https://docs.filesearch.dev/llms.txt?excludeSpec=true

# Validate Parsing Script

POST https://api.filesearch.dev/v2/parsing-scripts/validate
Content-Type: multipart/form-data

Validate a JavaScript parsing script without running it against real data.

Upload your .js file as multipart/form-data under the `file` field. The
endpoint runs the same V8 sandbox that `json_handler` uses at indexing
time, so a script that validates here will work when you index files.

Checks:
1. JavaScript syntax parses cleanly
2. Script exports a default function

Returns HTTP 200 for both valid and invalid scripts — `valid: false` is
a business-logic result, not an HTTP error. 4xx/5xx responses indicate
auth failures, malformed requests, or service unavailability.

Reference: https://docs.filesearch.dev/reference/indexing/parsing-scripts/validate

## Request

### Headers

- `authorization` (string, optional, nullable)

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required) — The .js parsing script file to validate.

## Response

### 200

Successful Response

- `valid` (boolean, required) — True if the script passes all validation checks
- `error` (string, optional, nullable) — Human-readable error message when valid=false. Null when valid=true.
- `error_type` (string, optional, nullable) — Error category when valid=false: 'syntax_error', 'no_export'. Null when valid=true.

## Errors

### 400 Bad Request Error

Malformed request — empty upload or missing X-Organization-ID header.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

### 401 Unauthorized Error

Missing or invalid API key.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

### 403 Forbidden Error

API key does not belong to the organization, or trial/billing limits exceeded.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

### 413 Content Too Large Error

Script file exceeds 1000000 bytes.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

### 503 Service Unavailable Error

Validation service temporarily unavailable (py_mini_racer not installed).

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

## Examples

**Request**

```json
{
  "file": "<file: string>"
}
```

**Response**

```json
{
  "valid": true,
  "error": "string",
  "error_type": "string"
}
```

**SDK Code**

```python
import json
import requests
import uuid

BASE_URL = "https://api.filesearch.dev"
API_KEY = "your_api_key"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Idempotency-Key": str(uuid.uuid4()),
}

response = requests.post(
    f"{BASE_URL}/v2/parsing-scripts/validate",
    headers=headers,
    timeout=30.0
)

print(json.dumps(response.json(), indent=2))
```

```typescript
const BASE_URL = "https://api.filesearch.dev";

const API_KEY = "your_api_key";

const headers = {
  Authorization: `Bearer ${API_KEY}`,
  "Idempotency-Key": crypto.randomUUID(),
};

const response = await fetch(`${BASE_URL}/v2/parsing-scripts/validate`, {
  method: "POST",
  headers,
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
```