Updating a Knowledge Base via API

Although Flow XO will automatically sync data from your website on a regular basis, there may be times where you want to create or update knowledge base documents using your own workflows or processes. 

The following document management functions are available:

1. Creating a document in a knowledge base
2. Updating a document in a knowledge base
3. Listing knowledge bases
4. Listing documents within a knowledge base

Authorization

You must authorize all calls to the Flow XO API using your API key and an authorization header. Details can be found here:  https://support.flowxo.com/article/289-api-authorization

API Url

To use the Flow XO API, you will need to send HTTP requests to the following endpoint. The last part of the URL will depend on the method you are calling, but the base address is:

https://flowxo.com/api/knowledgeBases

Knowledge Bases

Listing all knowledge bases in your account

You get a list of all of your knowledge bases using the following API call:

GET https://flowxo.com/api/knowledgeBases

The result will look like this:

{
    "knowledgeBases": {
        "records": [
            {
                "id": "b4f0eb9a-24c4-11ee-bdee-37d6r2edef3f",
                "organizationId": "b5111692-99eb-11ed-a977-5bfd8b015fd8",
                "accountId": null,
                "name": "The Preparedness Experience",
                "description": "",
                "publishedAt": "2023-07-17T17:09:36.196+00:00",
                "createdAt": "2023-07-17T17:09:36.25017+00:00",
                "updatedAt": "2023-07-17T17:09:36.25017+00:00",
                "published": true,
                "type": "KNOWLEDGE_BASE",
                "documentStoreSources": {
                    "totalCount": 1
                }
            }
        ],
        "pagination": {
            "totalCount": 1,
            "page": 1,
            "totalPages": 1,
            "nextPage": null,
            "prevPage": null,
            "limit": 10,
            "offset": 0,
            "hasMore": false
        }
    }
}

To work with documents within a particular knowledge base, you will need the 'id' field for the knowledge base you want to work with. You can also find this in the UI as part of the URL when viewing a knowledge base:

Listing Documents

You can list all documents within a knowledge base using the following API call. Replace :knowledgeBaseId with the ID of the knowledge base you want to list documents for.

GET https://flowxo.com/api/knowledgeBases/:knowledgeBaseId/documents?page=1&perPage=100

The result will look like this:

{
    "records": [
        {
            "id": "18c8e1fa-1226-11ee-9c94-db8ca39268ad",
            "title": "My Document",
            "description": "a description of my document",
            "createdAt": "2023-07-02T20:21:59.044682+00:00",
            "updatedAt": "2023-07-02T20:27:21.441926+00:00",
            "runId": null,
            "source": "API",
            "sourceType": "ORIGINAL",
            "sourceId": null,
            "sourceDocumentId": null,
            "sourceUrl": "https://www.google.com",
            "tags": [],
            "contentType": null,
            "content": "There are two kinds of people, wet people and dry people. DryCo makes you dry. The competition makes you wet.",
            "publishedAt": "2023-07-02T20:27:21.152+00:00",
            "published": true,
            "documentStore": {
                "id": "051129b2-1916-11ee-8e57-576a0e19a60d",
                "name": "The Preparedness Experience"
            }
        },
        //...the rest if your documents
    ],
    "pagination": {
        "totalCount": 1,
        "page": 1,
        "totalPages": 1,
        "nextPage": null,
        "prevPage": null,
        "limit": 15,
        "offset": 0,
        "hasMore": false
    }
}


This results in a list of all the documents in the knowledge base. You can retrieve batches of documents using the pagination query parameters "page" and "perPage" as in the example above.

Listing a single document

You can retrieve the data of a single document by issuing a GET request:

GET https://flowxo.com/api/knowledgeBases/:knowledgeBaseId/documents/:documentId

The result will look like this:

 {
    "id": "18c221fa-1916-11ee-9c94-db8ca39268ad",
    "title": "Beep",
    "description": "bop bop",
    "createdAt": "2023-07-02T20:21:59.044682+00:00",
    "updatedAt": "2023-07-02T20:27:21.441926+00:00",
    "runId": null,
    "source": "API",
    "sourceType": "ORIGINAL",
    "sourceId": null,
    "sourceDocumentId": null,
    "sourceUrl": "https://www.google.com",
    "tags": [],
    "contentType": null,
    "content": "There are two kinds of people, wet people and dry people. DryCo makes you dry. The competition makes you wet.",
    "publishedAt": "2023-07-02T20:27:21.152+00:00",
    "published": true,
    "documentStore": {
        "id": "052329b2-1916-11ee-8e57-576a0e19a60d",
        "name": "The Preparedness Experience"
    }
}

Adding a new document to a knowledge base

You can add a new document to a knowledge base by issuing a POST request:

POST https://flowxo.com/api/knowledgeBases/:knowledgeBaseId/documents

With the following payload:

{
   "title":"Another new document",
   "description":"An optional description",
   "sourceUrl":"An optional URL referencing the original location on the internet of the document",
   "content":"The contents of your document",
   "publishedAt":"2023-10-11T10:48:15.00z",
   "source":"manual"
}

The result will look like this:

"882edd1e-685e-11ee-bcc4-bfa4ce3f3f88"

Notes: The result represents the identifier of your newly created document.

The 'publishedAt' field should be an ISO8601 formatted date string. If it is omitted, the document will not be considered published and not available in AI searches.


Updating an existing document

You can add update a document tin your knowledge base by issuing a PUT request:

PUT https://flowxo.com/api/knowledgeBases/:knowledgeBaseId/documents/:documentId

With the following payload:

{
   "title":"Another new document",
   "description":"An optional description",
   "sourceUrl":"An optional URL referencing the original location on the internet of the document",
   "content":"The contents of your document",
   "publishedAt":"2023-10-11T10:48:15.00z"
}<br>

The result will look like this:

"882edd1e-685e-11ee-bcc4-bfa4ce3f3f88"

Notes: The result represents the identifier of the updated document.

The 'publishedAt' field should be an ISO8601 formatted date string. If it is omitted, the document will not be considered published and not available in AI searches.

Deleting an existing document

You can add delete a document tin your knowledge base by issuing a DELETE request:

DELETE https://flowxo.com/api/knowledgeBases/:knowledgeBaseId/documents/:documentId 

That's It for now!

Please reach out support@flowxo.com with any questions or feedback!

Still need help? Contact Us Contact Us