# Create a new evaluator

Create a new evaluator: a built-in one, a custom code evaluator (`type: "code"`) or one that wraps a workflow (`type: "workflow"`)

> Page: https://langwatch.ai/docs/api-reference/evaluators-config/create-evaluators
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/evaluators-config/create-evaluators.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`POST https://app.langwatch.ai/api/v1/evaluators`

## Authentication

### project_api_key

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Request body (required)

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "name": {"type":"string","minLength":1,"maxLength":255},
    "type": {
      "default": "evaluator",
      "description": "The kind of evaluator. \"evaluator\" (the default) is a built-in type named by config.evaluatorType; \"code\" is a custom Python evaluator whose config carries code and inputs; \"workflow\" wraps the workflow named by workflowId.",
      "type": "string",
      "enum": ["evaluator","code","workflow"]
    },
    "config": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {},
      "description": "For a built-in evaluator: { evaluatorType, settings }. For a code evaluator: { code, inputs: [{ identifier, type }] }; outputs are the fixed passed, score, label and details. For a workflow evaluator: {}."
    },
    "workflowId": {
      "description": "The workflow a \"workflow\" evaluator wraps. Only for type \"workflow\".",
      "type": "string",
      "minLength": 1
    }
  },
  "required": ["name","config"]
}
```

## Request example

```bash
curl --request POST \
  --url 'https://app.langwatch.ai/api/v1/evaluators' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"name":"string","type":"evaluator","config":{},"workflowId":"string"}'
```

## Responses

### 200

Success

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "id": {"type":"string"},
    "projectId": {"type":"string"},
    "name": {"type":"string"},
    "slug": {"type":["string","null"]},
    "type": {"type":"string"},
    "config": {
      "anyOf": [
        {
          "type": "object",
          "propertyNames": {"type":"string"},
          "additionalProperties": {}
        },
        {"type":"null"}
      ]
    },
    "workflowId": {"type":["string","null"]},
    "copiedFromEvaluatorId": {"type":["string","null"]},
    "createdAt": {"type":"string","format":"date-time"},
    "updatedAt": {"type":"string","format":"date-time"},
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "identifier": {"type":"string"},
          "type": {"type":"string"},
          "optional": {"type":"boolean"}
        },
        "required": ["identifier","type"],
        "additionalProperties": false
      }
    },
    "outputFields": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "identifier": {"type":"string"},
          "type": {"type":"string"},
          "optional": {"type":"boolean"}
        },
        "required": ["identifier","type"],
        "additionalProperties": false
      }
    },
    "workflowName": {"type":"string"},
    "workflowIcon": {"type":"string"},
    "version": {
      "anyOf": [
        {"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},
        {"type":"null"}
      ],
      "description": "The version this response shows: the latest, unless a label or a version was asked for."
    },
    "labels": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {"type":"string"},
          "version": {"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}
        },
        "required": ["label","version"],
        "additionalProperties": false
      },
      "description": "The deploy labels the evaluator carries, such as production, and the version each points at."
    },
    "createdBy": {
      "anyOf": [
        {
          "type": "object",
          "properties": {"id":{"type":"string"},"name":{"type":["string","null"]}},
          "required": ["id","name"],
          "additionalProperties": false
        },
        {"type":"null"}
      ],
      "description": "The user who created the evaluator. Null when an API key created it, or it predates creators being recorded."
    },
    "updatedBy": {
      "anyOf": [
        {
          "type": "object",
          "properties": {"id":{"type":"string"},"name":{"type":["string","null"]}},
          "required": ["id","name"],
          "additionalProperties": false
        },
        {"type":"null"}
      ],
      "description": "The user who changed the evaluator last. Null when an API key changed it."
    },
    "platformUrl": {"type":"string","format":"uri"}
  },
  "required": [
    "id",
    "projectId",
    "name",
    "slug",
    "type",
    "config",
    "workflowId",
    "copiedFromEvaluatorId",
    "createdAt",
    "updatedAt",
    "fields",
    "outputFields",
    "version",
    "labels",
    "createdBy",
    "updatedBy",
    "platformUrl"
  ],
  "additionalProperties": false
}
```

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
