> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opigno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a taxonomy term

To create a new taxonomy term, `createTaxonomyTerm` mutation should be used.
If a parent should be set, an appropriate term can be found with [`getTaxonomyTermByName` query](/OpignoEnterpriseAPI/Taxonomy/GetTaxonomyTerm)

<Note>
  **Note:** vocabulary will not be created with an API, it should be created on the site manually.
</Note>

**Access policy:**

* The API user context should have permission to create a taxonomy term in the given vocabulary.
  Otherwise, access denied response will be returned.
* The given vocabulary should exist on the site.
* If parent ID is not 0, a term with this ID should exist.

The only argument that can be used in this mutation is `termData` that is the object with the following properties:

| Argument     | Type     | Description                                                                                      | Default |
| :----------- | :------- | :----------------------------------------------------------------------------------------------- | :------ |
| `vocabulary` | `String` | Required. Represents a machine name of the taxonomy vocabulary to create a term.                 | —       |
| `name`       | `String` | Required. A name (label) of the taxonomy term that should be created.                            | —       |
| `parentId`   | `ID`     | The parent term ID. By default the term will be created without a parent, as a first-level item. | 0       |

For example, let's create a new term in *LP Domain* vocabulary under the *"Onboarding"* item.

<CodeGroup>
  ```filename GraphQL [expandable] theme={null}
  mutation createTaxonomyTerm {
    createTaxonomyTerm(termData: {
      vocabulary: "lp_domain",
      name: "API domain",
      parentId: "9"
    }) {
      errors
      response {
        id
        name
        parent {
          id
          name
        }
        vocabulary
        weight
      }
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "createTaxonomyTerm": {
        "errors": [],
        "response": {
          "id": "11",
          "name": "API domain",
          "parent": {
            "id": "9",
            "name": "Onboarding"
          },
          "vocabulary": "lp_domain",
          "weight": 0
        }
      }
    }
  }
  ```
</CodeGroup>

After the mutation execution, the term should be created in the given vocabulary.

**Before:**

<img style={{ borderRadius:"0.3rem" }} src="https://mintcdn.com/connect-i/duHonZHPe3F63_yi/images/before-term-creation.png?fit=max&auto=format&n=duHonZHPe3F63_yi&q=85&s=8a7b7581ee87a4a8cb331bc933230745" alt="Before term creation" title="Before term creation" width="2430" height="936" data-path="images/before-term-creation.png" />

**After:**

<img style={{ borderRadius:"0.3rem" }} src="https://mintcdn.com/connect-i/duHonZHPe3F63_yi/images/after-term-creation.png?fit=max&auto=format&n=duHonZHPe3F63_yi&q=85&s=3a37e79f6854a3df5ad4842b31c6c162" alt="After term creation" title="After term creation" width="2439" height="1051" data-path="images/after-term-creation.png" />
