# create\_metric

Create a metric (goal) in a project. Requires mcp:write and the existing metric create policy.

Create a metric (goal) in a project. Requires mcp:write and the existing metric create policy.

## Permissions

```json
{
  "scope": "mcp:read and mcp:write",
  "role": "The existing entity create/update policy must allow this user; the mcp:write scope alone is insufficient.",
  "plan": "The billing account must have the MCP entitlement. Writes also require a writable billing mode and applicable entity limits.",
  "team": "The OAuth connection is approved for exactly one Team. Other team_id values cannot change the tenant."
}
```

## Input

```json
{
  "properties": {
    "project_id": {
      "description": "Project ID in the authenticated team",
      "type": "integer"
    },
    "name": {
      "description": "Metric name",
      "maxLength": 255,
      "type": "string"
    },
    "type": {
      "description": "Metric type",
      "enum": [
        "average-per-user",
        "rate-per-user",
        "average-per-session",
        "rate-per-session"
      ],
      "type": "string"
    },
    "winning_direction": {
      "description": "Whether an increase or a decrease is a win",
      "enum": [
        "increasing",
        "decreasing"
      ],
      "type": "string"
    },
    "description": {
      "description": "Optional description",
      "type": "string"
    }
  },
  "type": "object",
  "required": [
    "project_id",
    "name",
    "type",
    "winning_direction"
  ]
}
```

## Output

```json
{
  "type": "object",
  "properties": {
    "created": {
      "type": "boolean",
      "const": true
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "project_id": {
          "type": [
            "integer",
            "null"
          ]
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "average-per-user",
            "rate-per-user",
            "average-per-session",
            "rate-per-session",
            null
          ]
        },
        "winning_direction": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "increasing",
            "decreasing",
            null
          ]
        }
      },
      "required": [
        "id",
        "project_id",
        "name",
        "description",
        "type",
        "winning_direction"
      ]
    }
  },
  "required": [
    "created",
    "data"
  ]
}
```

## Examples

### Request arguments

```json
{
  "project_id": 1,
  "name": "Checkout conversion",
  "type": "rate-per-user",
  "winning_direction": "increasing"
}
```

### Result

```json
{
  "created": true,
  "data": {
    "id": 101,
    "project_id": 1,
    "name": "Checkout conversion",
    "description": null,
    "type": "average-per-user",
    "winning_direction": "increasing"
  }
}
```

## Errors

```json
[
  {
    "status": 401,
    "description": "Missing, expired, or revoked OAuth access token."
  },
  {
    "status": 403,
    "description": "Missing MCP scope, team membership, plan entitlement, or user permission."
  },
  {
    "status": 404,
    "description": "The MCP server is disabled."
  },
  {
    "status": 429,
    "description": "Rate limited; honor Retry-After before retrying."
  },
  {
    "description": "Tool execution or validation failures are MCP error results. Inspect isError; a successful HTTP status alone does not indicate a successful tool call."
  }
]
```

An expired or revoked OAuth connection cannot connect. A missing scope, role, feature entitlement, or team access prevents the operation. See [MCP setup](https://conversionlab.app/docs/developer/mcp-setup).
