# Create a new FAQ inside knowledge base

POST https://services.leadconnectorhq.com/knowledge-bases/faqs

Creates a new question-and-answer entry in a knowledge base.
WHEN TO USE: use this when you need to add a brand-new FAQ; use update to change an existing one; use list to see current FAQs.
RETURNS: success and the created FAQ, including its server-assigned id.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `knowledge-bases.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/knowledge-bases/faqs": {
      "post": {
        "summary": "Create a new FAQ inside knowledge base",
        "operationId": "createANewFaqInsideKnowledgeBase",
        "description": "Creates a new question-and-answer entry in a knowledge base.\nWHEN TO USE: use this when you need to add a brand-new FAQ; use update to change an existing one; use list to see current FAQs.\nRETURNS: success and the created FAQ, including its server-assigned id.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddFaqDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "FAQ created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateFaqResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "knowledge-bases.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "AddFaqDTO": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "location ID as string",
            "example": "HqDZpF8GH3qvgJTmKCoL"
          },
          "question": {
            "type": "string",
            "description": "faq question as a string",
            "example": "What is the capital of France?"
          },
          "answer": {
            "type": "string",
            "description": "faq answer as a string",
            "example": "The capital of France is Paris."
          },
          "knowledgeBaseId": {
            "type": "string",
            "description": "knowledge base ID as string",
            "example": "710KoEzy793Fxubft0bc"
          }
        },
        "required": [
          "locationId",
          "question",
          "answer",
          "knowledgeBaseId"
        ],
        "title": "AddFaqDTO"
      },
      "CreateFaqResponseDTO": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success status of the operation",
            "example": true
          },
          "faq": {
            "description": "Created FAQ details",
            "example": {},
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "FAQ ID as string",
                    "example": "3rzeElC1FOVY91veVBkp"
                  },
                  "question": {
                    "type": "string",
                    "description": "FAQ question",
                    "example": "What is 1+2?"
                  },
                  "questionLowerCase": {
                    "type": "string",
                    "description": "FAQ question in lowercase",
                    "example": "what is 1+2?"
                  },
                  "answer": {
                    "type": "string",
                    "description": "FAQ answer",
                    "example": "3"
                  },
                  "knowledgeBaseId": {
                    "type": "string",
                    "description": "Knowledge base ID",
                    "example": "I1rITlYLJofFosIqC4Np"
                  },
                  "locationId": {
                    "type": "string",
                    "description": "Location ID",
                    "example": "qIyivCmsuEOSnyoFYEej"
                  },
                  "trainedUrlId": {
                    "type": "string",
                    "description": "Trained URL ID",
                    "example": "688e6b6d8a1887e6d94d1475"
                  },
                  "deleted": {
                    "type": "boolean",
                    "description": "Whether the FAQ is deleted",
                    "example": false
                  },
                  "createdAt": {
                    "type": "string",
                    "description": "Date when FAQ was created",
                    "example": "2025-08-02T19:47:57.243Z"
                  },
                  "updatedAt": {
                    "type": "string",
                    "description": "Date when FAQ was last updated",
                    "example": "2025-08-02T19:47:57.243Z"
                  }
                },
                "required": [
                  "id",
                  "question",
                  "questionLowerCase",
                  "answer",
                  "knowledgeBaseId",
                  "locationId",
                  "trainedUrlId",
                  "deleted",
                  "createdAt",
                  "updatedAt"
                ],
                "title": "FaqResponseDTO"
              }
            ]
          }
        },
        "required": [
          "success",
          "faq"
        ],
        "title": "CreateFaqResponseDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code",
            "example": 500
          },
          "message": {
            "type": "string",
            "description": "Error message",
            "example": "Internal Server Error"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/knowledge-bases/faqs' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "HqDZpF8GH3qvgJTmKCoL",
  "question": "What is the capital of France?",
  "answer": "The capital of France is Paris.",
  "knowledgeBaseId": "710KoEzy793Fxubft0bc"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "HqDZpF8GH3qvgJTmKCoL",
      "question": "What is the capital of France?",
      "answer": "The capital of France is Paris.",
      "knowledgeBaseId": "710KoEzy793Fxubft0bc"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/knowledge-bases/faqs', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/knowledge-bases/faqs"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "locationId": "HqDZpF8GH3qvgJTmKCoL",
    "question": "What is the capital of France?",
    "answer": "The capital of France is Paris.",
    "knowledgeBaseId": "710KoEzy793Fxubft0bc"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/knowledge-bases/faqs',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "HqDZpF8GH3qvgJTmKCoL",
  "question": "What is the capital of France?",
  "answer": "The capital of France is Paris.",
  "knowledgeBaseId": "710KoEzy793Fxubft0bc"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/knowledge-bases/faqs")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"HqDZpF8GH3qvgJTmKCoL\",\"question\":\"What is the capital of France?\",\"answer\":\"The capital of France is Paris.\",\"knowledgeBaseId\":\"710KoEzy793Fxubft0bc\"}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/knowledge-bases/faqs"
  payload := strings.NewReader(`{
  "locationId": "HqDZpF8GH3qvgJTmKCoL",
  "question": "What is the capital of France?",
  "answer": "The capital of France is Paris.",
  "knowledgeBaseId": "710KoEzy793Fxubft0bc"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/knowledge-bases/faqs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "locationId": "HqDZpF8GH3qvgJTmKCoL",
  "question": "What is the capital of France?",
  "answer": "The capital of France is Paris.",
  "knowledgeBaseId": "710KoEzy793Fxubft0bc"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "locationId": "HqDZpF8GH3qvgJTmKCoL",
  "question": "What is the capital of France?",
  "answer": "The capital of France is Paris.",
  "knowledgeBaseId": "710KoEzy793Fxubft0bc"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/knowledge-bases/faqs' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
