⚠️ This documentation pertains to a preview endpoint. This feature is not yet ready for API consumption and may change.
For inquiries or feedback, please contact us at Glean.

Detect and answer questions

post/ask

Classify a query as information seeking or not. If so, generate an AI answer and/or provide relevant documents. Useful for integrating into existing chat interfaces.

SecurityBearerAuth
Request
header Parameters
X-Glean-Auth-Type
string

Auth type being used to access the endpoint (should be non-empty only for global tokens).

X-Scio-Actas
string <email>

Email address of a user on whose behalf the request is intended to be made (should be non-empty only for global tokens).

Request Body schema: application/json

Ask request

required
object (SearchRequest)
object (AskExperimentalMetadata)
backend
string

Which backend to use to fulfill the requests.

Enum: Description
SEARCH

Issue a search request and return a search result.

CHAT

Issue a chat request and return a generated response.

chatApplicationId
string

The ID of the application this request originates from, used to determine the configuration of underlying chat processes when invoking the CHAT backend. This should correspond to the ID set during admin setup. If not specified, the default chat experience will be used.

detectOnly
boolean

Whether to apply only question detection and not answering.

Array of objects or objects or objects (DocumentSpec)
Deprecated

A list of Glean Document IDs to be excluded when retrieving documents. Note that, currently, it only supports exclusion of one Glean Documnet ID based spec. If multiple specifications are provided only the first Glean Document ID based spec is excluded and the remaining specs are ignored.

object (ChatRestrictionFilters)
object (ChatRestrictionFilters)
operators
string

Search operators to append to the query

Responses
200

OK

Response Schema: application/json
isQuestion
required
boolean

Whether or not the query was a question.

object (ChatResponse)

A single response from the /chat backend.

question
string

The part of the query which was used as a question for search

object (SearchResponse)
400

Invalid request

401

Not Authorized

403

Forbidden

422

Invalid Query

429

Too Many Requests

Request samples
application/json
{
  • "detectOnly": true,
  • "AskExperimentalMetadata": {
    • "QueryHasMentions": true,
    • "QueryIsLengthAppropriate": true,
    • "QueryIsAnswerable": true
    },
  • "searchRequest": {
    • "trackingToken": "trackingToken",
    • "query": "vacation policy",
    • "pageSize": 10,
    • "requestOptions": {
      • "facetFilters": [
        • {
          • "fieldName": "type",
          • "values": [
            • {
              • "value": "article",
              • "relationType": "EQUALS"
              },
            • {
              • "value": "document",
              • "relationType": "EQUALS"
              }
            ]
          },
        • {
          • "fieldName": "department",
          • "values": [
            • {
              • "value": "engineering",
              • "relationType": "EQUALS"
              }
            ]
          }
        ]
      }
    },
  • "excludedDocumentSpecs": [
    • {
      • "url": "string"
      }
    ],
  • "operators": "string",
  • "backend": "SEARCH",
  • "chatApplicationId": "string",
  • "inclusions": {
    • "containerSpecs": [
      • {
        • "url": "string"
        }
      ],
    • "documentSpecs": [
      • {
        • "url": "string"
        }
      ],
    • "datasourceInstances": [
      • "string"
      ]
    },
  • "exclusions": {
    • "containerSpecs": [
      • {
        • "url": "string"
        }
      ],
    • "documentSpecs": [
      • {
        • "url": "string"
        }
      ],
    • "datasourceInstances": [
      • "string"
      ]
    }
}
Response samples
application/json
{
  • "isQuestion": true,
  • "question": "string",
  • "searchResponse": {
    • "trackingToken": "trackingToken",
    • "suggestedSpellCorrectedQuery": "suggestedSpellCorrectedQuery",
    • "hasMoreResults": true,
    • "errorInfo": {
      • "errorMessages": [
        • {
          • "source": "gmail",
          • "errorMessage": "invalid token"
          },
        • {
          • "source": "slack",
          • "errorMessage": "expired token"
          }
        ]
      },
    • "requestID": "5e345ae500ff0befa2b9d1a3ba0001737e7363696f312d323535323137000171756572792d656e64706f696e743a323032303031333074313830343032000100",
    • "results": [
      • {
        • "snippets": [
          • {
            • "snippet": "snippet",
            • "mimeType": "mimeType"
            }
          ],
        • "metadata": {
          • "container": "container",
          • "createTime": "2000-01-23T04:56:07.000Z",
          • "datasource": "datasource",
          • "author": {
            • "name": "name"
            },
          • "documentId": "documentId",
          • "updateTime": "2000-01-23T04:56:07.000Z",
          • "mimeType": "mimeType",
          • "objectType": "objectType"
          },
        • "title": "title",
        },
      • {
        • "snippets": [
          • {
            • "snippet": "snippet",
            • "mimeType": "mimeType"
            }
          ],
        • "metadata": {
          • "container": "container",
          • "createTime": "2000-01-23T04:56:07.000Z",
          • "datasource": "datasource",
          • "author": {
            • "name": "name"
            },
          • "documentId": "documentId",
          • "updateTime": "2000-01-23T04:56:07.000Z",
          • "mimeType": "mimeType",
          • "objectType": "objectType"
          },
        • "title": "title",
        }
      ],
    • "facetResults": [
      • {
        • "buckets": [
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            },
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            }
          ],
        • "sourceName": "sourceName",
        • "operatorName": "operatorName",
        • "objectType": "objectType"
        },
      • {
        • "buckets": [
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            },
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            }
          ],
        • "sourceName": "sourceName",
        • "operatorName": "operatorName",
        • "objectType": "objectType"
        }
      ],
    • "rewrittenQuery": "rewrittenQuery",
    • "rewrittenFacetFilters": [
      • {
        • "fieldName": "fieldName",
        • "values": [
          • "fieldValues",
          • "fieldValues"
          ]
        },
      • {
        • "fieldName": "fieldName",
        • "values": [
          • "fieldValues",
          • "fieldValues"
          ]
        }
      ]
    },
  • "chatResponse": {
    • "messages": [
      • {
        • "agentConfig": {
          • "agent": "DEFAULT",
          • "mode": "DEFAULT"
          },
        • "author": "USER",
        • "citations": [
          • {
            • "trackingToken": "string",
            • "sourceDocument": {
              • "id": "string",
              • "datasource": "string",
              • "connectorType": "API_CRAWL",
              • "docType": "string",
              • "content": {
                • "fullTextList": [ ]
                },
              • "containerDocument": { },
              • "parentDocument": { },
              • "title": "string",
              • "url": "string",
              • "metadata": {
                • "container": "container",
                • "parentId": "JIRA_EN-1337",
                • "createTime": "2000-01-23T04:56:07.000Z",
                • "datasource": "datasource",
                • "author": {
                  • "name": "name"
                  },
                • "documentId": "documentId",
                • "updateTime": "2000-01-23T04:56:07.000Z",
                • "mimeType": "mimeType",
                • "objectType": "Feature Request",
                • "components": [
                  • "Backend",
                  • "Networking"
                  ],
                • "status": [
                  • "Done"
                  ],
                • "customData": {
                  • "someCustomField": "someCustomValue"
                  }
                },
              • "sections": [
                • null
                ]
              },
            • "sourceFile": {
              • "id": "FILE_1234",
              • "url": "www.google.com",
              • "name": "sample.pdf",
              • "metadata": {
                • "status": null,
                • "uploadTime": null,
                • "processedSize": null,
                • "failureReason": null,
                • "mimeType": null
                }
              },
            • "sourcePerson": {
              • "name": "George Clooney",
              • "obfuscatedId": "abc123"
              },
            • "referenceRanges": [
              • {
                • "textRange": null,
                • "snippets": [ ]
                }
              ]
            }
          ],
        • "uploadedFileIds": [
          • "string"
          ],
        • "fragments": [
          • {
            • "structuredResults": [
              • {
                • "document": null,
                • "person": null,
                • "customer": null,
                • "team": null,
                • "customEntity": null,
                • "answer": null,
                • "extractedQnA": null,
                • "app": null,
                • "collection": null,
                • "answerBoard": null,
                • "code": null,
                • "shortcut": null,
                • "querySuggestions": null,
                • "relatedDocuments": [ ],
                • "relatedQuestion": null,
                • "disambiguation": null,
                • "snippets": [ ],
                • "trackingToken": null,
                • "prominence": null,
                • "source": null
                }
              ],
            • "trackingToken": "string",
            • "text": "string",
            • "querySuggestion": {
              • "query": "app:github type:pull author:mortimer",
              • "label": "Mortimer's PRs",
              • "datasource": "github"
              },
            • "file": {
              • "id": "FILE_1234",
              • "url": "www.google.com",
              • "name": "sample.pdf",
              • "metadata": {
                • "status": null,
                • "uploadTime": null,
                • "processedSize": null,
                • "failureReason": null,
                • "mimeType": null
                }
              },
            • "action": {
              • "metadata": {
                • "type": null,
                • "name": null,
                • "displayName": null,
                • "toolId": null,
                • "displayDescription": null,
                • "logoUrl": null,
                • "objectName": null,
                • "knowledgeType": null,
                • "createdBy": null,
                • "lastUpdatedBy": null,
                • "createdAt": null,
                • "lastUpdatedAt": null,
                • "writeActionType": null,
                • "auth": null,
                • "permissions": null
                },
              • "parameters": {
                • "property1": null,
                • "property2": null
                }
              }
            }
          ],
        • "ts": "string",
        • "messageId": "string",
        • "messageTrackingToken": "string",
        • "messageType": "UPDATE",
        • "hasMoreFragments": true
        }
      ],
    • "chatId": "string",
    • "followUpPrompts": [
      • "string"
      ],
    • "backendTimeMillis": 1100,
    • "chatSessionTrackingToken": "string"
    }
}