# createTool

```graphql
mutation CreateTool($projectReference: String!, $input: CreateToolInput!) {
  createTool(projectReference: $projectReference, input: $input) {
    id
    name
    description
    sourcePath
    source
    editMode
    sourceOnlyReasons
  }
}
```

Create a project tool source file in the project source or a preview branch so project agents can call it; returns the tool source document. Requires project.agents.write.

## Arguments

| Name                     | Type             | Required | Description                                                               |
| ------------------------ | ---------------- | -------- | ------------------------------------------------------------------------- |
| `projectReference`       | String!          | Yes      |                                                                           |
| `input`                  | CreateToolInput! | Yes      |                                                                           |
| `input.id`               | String!          | Yes      | Becomes the file name and the tool id.                                    |
| `input.description`      | String           |          |                                                                           |
| `input.sourceTargetKind` | WriteTargetKind  |          | The source to write; default project. One of `project`, `preview_branch`. |
| `input.targetBranchId`   | ID               |          | Required with the kind preview\_branch.                                   |

## Variables

```json
{
  "projectReference": "string",
  "input": {
    "id": "a"
  }
}
```

## Responses

| Status | Description                         |
| ------ | ----------------------------------- |
| 200    | The ToolSource! in data.createTool. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation CreateTool($projectReference: String!, $input: CreateToolInput!) {\n  createTool(projectReference: $projectReference, input: $input) {\n    id\n    name\n    description\n    sourcePath\n    source\n    editMode\n    sourceOnlyReasons\n  }\n}",
  "variables": {
    "projectReference": "string",
    "input": {
      "id": "a"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createTool": {
      "id": "string",
      "name": "string",
      "description": "string",
      "sourcePath": "string",
      "source": "string",
      "editMode": "structured",
      "sourceOnlyReasons": [
        "string"
      ]
    }
  }
}
```
