Skip to main content


Sapling's autocomplete provides predictions of the next few characters or words given the current context in a particular editable. The predictions are based on the previous text.

Example: a possible completion for the context, Let us know if   might be you need anything else.

Try it out

Request Completion POST

Sample Code

curl -X POST \
-H "Content-Type: application/json" \
-d '{
"query":"Hi how are",
"session_id": "test session",

Sample Response

"output":" you",
"query":"Hi how are"

Request Parameters

HTTP method: POST

JSON parameters:

key: String
32-character API key

session_id: String
Unique name or UUID of document or portion of text that is being checked.

query: String
Text that should be autocompleted.

Response Parameters

The Autocomplete endpoint returns JSON with parameters documented below:

output: String
Predicted completion. For example, for the query Hi, how are, the predicted completion should be you (with a leading space).

query: String
Actual query used to generate completion (may be a truncated version of request query).

hash: String (UUID)
Opaque ID of completion for use with accept event.

Accept Completion POST

Use this API endpoint to have Sapling adapt its system over time.

Each suggested completion has an completion UUID. You can pass this information back to Sapling to indicate the completion was used. For each unique completion UUID, use the accept endpoint up to once.

Request Parameters<completion_id>/accept

HTTP method: POST

<completion_id>: String (UUID)
ID of completion returned from a Completion POST.

Here's a sample request body:

"key": "<api-key>",
"context": {
"query": "Hi how are",
"completion": " you"
"session_id": "Test Document UUID"

Note that the query and completion arguments are required.

Response Parameters

Will return error or {"result": "success"}.