Custom Mappings
Custom Mappings can be used to enforce specific corrections or capitalization for the following purposes:
- Brand voice: Ensure that a consistent, on-brand style is used in all outward communication.
- Compliance: If there is a specific way to communicate an issue, or if certain terms should be flagged, custom mappings can help.
- Other use cases: Company or industry-specific jargon, product names, or unusual capitalization.
Custom Mapping GET
Request Parameters
import requests
key = '<api-key>'
url = f'https://api.sapling.ai/api/v1/custom_mapping?key={key}'
try:
resp = requests.get(url)
resp_json = resp.json()
if 200 <= resp.status_code < 300:
print('Custom mapping: ', resp_json)
else:
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/custom_mapping?key=<key>
HTTP method: GET
<key>: String
32-character API key
Response Parameters
JSON array of custom mapping entries under key custom_mappings
.
Custom mapping entry structure:
{
"id": <str, UUID>, // Opaque id, used for deletion
"entry": <str>, // Word to match
"mapping": <str>, // Word to suggest as replacement
"case_sensitive": <bool> // true or false
"created_at": <str, date> // e.g. "Wed, 07 Oct 2020 21:15:47 GMT"
"updated_at": <str, date> // e.g. "Wed, 07 Oct 2020 21:15:47 GMT"
}
Custom Mapping POST
Request Parameters
import requests
key = '<api-key>'
url = 'https://api.sapling.ai/api/v1/custom_mapping'
data = {
'key': key,
'entry': 'foobazbar',
'mapping': 'foobarbaz',
'case_sensitive': False,
}
try:
resp = requests.post(url, json=data)
resp_json = resp.json()
if 200 <= resp.status_code < 300:
print('Entry: ', resp_json)
else:
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/custom_mapping
HTTP method: POST
key: String
32-character API key
entry: String
Word to match.
There are currently a couple types of regular expression-like options:
^
and$
match the start and end of a sentence, respectively. Example:^the
will only matchthe
at the start of a sentence and can be used to enforce capitalization.#
will match a number; example:Gate #
will match inBoarding is at Gate 5
.
mapping: String
Word to suggest for a match.
You can use #
in the resulting expression to substitute a number back in.
case_sensitive: Boolean
Whether match is case-sensitive or not. If not case-sensitive, lower case and title case will both match.
description: Optional String
The description will be shown when the edit is suggested to the end user. If a description field is specified, the user will not have the option to ignore the edit.
Response Parameters
JSON, Created Custom Mapping Entry Custom Mapping Entry Structure:
{
"id": <str, UUID>, // Opaque id, used for deletion
"entry": <str>, // Word to match
"mapping": <str>, // Word to suggest as replacement
"case_sensitive": <bool> // true or false
"created_at": <str, date> // e.g. "Wed, 07 Oct 2020 21:15:47 GMT"
"updated_at": <str, date> // e.g. "Wed, 07 Oct 2020 21:15:47 GMT"
}
Custom Mapping DELETE
Request Parameters
import requests
key = '<api-key>'
entry_id = '<CUSTOM_MAPPING_ID>'
url = f'https://api.sapling.ai/api/v1/custom_mapping/{entry_id}'
data = {
'key': key,
}
try:
resp = requests.delete(url, json=data)
if 200 <= resp.status_code < 300:
print('Success')
else:
resp_json = resp.json()
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/custom_mapping/<custom_mapping_id>
HTTP method: DELETE
<custom_mapping_id>: String (UUID)
ID of custom mapping.
key: String
32-character API key
Response Parameters
Empty, HTTP status code 204.