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

# N8N - Writer Assistant

> Create a basic N8N Flow for Writer Assistant Orders

## Step 1 - Authentication via API key

* Use an HTTP Request node and select the following options:
* Authentication: `Generic Credential Type`
* Generic Auth Type: `Header Auth`
* Header Auth: `Header Auth account`

<img src="https://mintcdn.com/snippetdigital/HSuWZ5eFnP-6yTnC/images/mintlify-api-auth-main-window.png?fit=max&auto=format&n=HSuWZ5eFnP-6yTnC&q=85&s=5546f24219cb0d282d5a31bafadb259a" alt="Authentication section in Mintlify" width="518" height="570" data-path="images/mintlify-api-auth-main-window.png" />

* Then click the `Edit Pencil icon` to open up the detail model to enter your API key:
* Then in the modal, add X-API-KEY: `kwi_sk_aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abc`

<img src="https://mintcdn.com/snippetdigital/HSuWZ5eFnP-6yTnC/images/mintlify-api-auth-main-window-detail.png?fit=max&auto=format&n=HSuWZ5eFnP-6yTnC&q=85&s=403a7b30690bc3507e2482e97e505030" alt="Authentication section in Mintlify" width="1093" height="690" data-path="images/mintlify-api-auth-main-window-detail.png" />

### Alternatively you can authenticate via username and password

* Use an HTTP Request node
* URL: `Keywordinsightsapi.keywordinsights.ai/authentication/login`
* Method: `POST`
* Body -> JSON: `{  "email": "<email>",  "password": "<password>"}`
  <img src="https://mintcdn.com/snippetdigital/HSuWZ5eFnP-6yTnC/images/mintlify-simple-auth.png?fit=max&auto=format&n=HSuWZ5eFnP-6yTnC&q=85&s=f69a0a6fff6cb28d5ea26c0c5d4f26f0" alt="Authentication section in Mintlify" width="1250" height="1452" data-path="images/mintlify-simple-auth.png" />

## Step 2 - Creating a Writer Assistant Order

* Ensure the output of the Auth node shows in the second node if you are using the legacy username and sandbox

<img src="https://mintcdn.com/snippetdigital/HSuWZ5eFnP-6yTnC/images/mintlify-content-brief-order-1.png?fit=max&auto=format&n=HSuWZ5eFnP-6yTnC&q=85&s=518ba084300e15571c8873b3067c698d" alt="Authentication section in Mintlify" width="1970" height="1446" data-path="images/mintlify-content-brief-order-1.png" />

* Paste the following json into the body,
  * `folder_id`: optional if you want the project placed in a specific folder
  * `secondary_keywords`: optional to provide more detail
  * `workflow_type`: NEW | OPTIMIZE | CONTENT\_BRIEF
* `keywords`: pass up to 25 keywords, in a comma separated list within the array brackets `[]`

### Workflow Type: NEW

```
{
  "folder_id": "",
  "keyword": "how to become a model",
  "language": "en",
  "location": "United States",
  "secondary_keywords": [],
  "workflow_type": "NEW"
}
```

### Workflow Type: CONTENT\_BRIEF

* `content_brief_order_id`: equired parameter of an existing content brief from which you plan to create a Writer Assistant Order

```
{
  "folder_id": "",
  "workflow_type": "CONTENT_BRIEF",
  "content_brief_order_id": "str"
}
```

### Workflow Type: OPTIMIZE

```
{
  "folder_id": "",
  "keyword": "news",
  "language": "en",
  "location": "United States",
  "workflow_type": "OPTIMIZE",
  "content_url": "https://www.bbc.com/...."
}
```

<img src="https://mintcdn.com/snippetdigital/h1E1V9bTG5af9fV0/images/mintlify-writer-assistant-1.png?fit=max&auto=format&n=h1E1V9bTG5af9fV0&q=85&s=3fbca34dec4a9dd2d4bd721977f9572d" alt="Body payload for Writer Assistant Orders" width="1130" height="1150" data-path="images/mintlify-writer-assistant-1.png" />
