Skip to content

Add a synonym

POST
/v1/apps/{appId}/synonyms
curl --request POST \
--url https://api.shoofai.com/v1/apps/demo-store/synonyms \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: 4f1c2a9e-7b1d-4c0e-9a51-2d3f6b8e0c47' \
--header 'x-shoof-api-key: <x-shoof-api-key>' \
--data '{ "terms": [ "sofa", "couch", "settee" ] }'

Adds one synonym. The body is the synonym, or {"synonym": {...}}. The response has its id.

appId
required
string

The app’s id, shown in the dashboard (for example ali-sport-goods). demo-store is the public demo app.

Example

demo-store
Idempotency-Key
string
>= 1 characters <= 255 characters /^[\x21-\x7e]+$/

A unique value, such as a UUID, that makes retrying this request safe. The first request with a key runs; for 24 hours a retry with the same key and the same body gets the first response again, with Idempotent-Replayed: true, and doesn’t run a second time. The same key with a different body is refused (409 idempotency_key_reused), and so is a retry while the first request is still running (409 idempotency_key_in_use). Keys belong to the app. Only successful responses are kept: after an error the key is free again.

Example

4f1c2a9e-7b1d-4c0e-9a51-2d3f6b8e0c47
Media typeapplication/json
object
id
string
<= 64 characters
kind

synonym: the terms all match each other. oneway: input also finds the terms, not the reverse.

string
default: synonym
Allowed values: synonym oneway
input

The word that also finds the terms (oneway only).

string
terms
required

At least two for a synonym.

Array<string>
>= 1 items <= 50 items

Example

{
"terms": [
"sofa",
"couch",
"settee"
]
}

The saved synonym, with its id.

Media typeapplication/json
object
synonym
object
id
string
<= 64 characters
kind

synonym: the terms all match each other. oneway: input also finds the terms, not the reverse.

string
default: synonym
Allowed values: synonym oneway
input

The word that also finds the terms (oneway only).

string
terms
required

At least two for a synonym.

Array<string>
>= 1 items <= 50 items

Example

{
"synonym": {
"kind": "synonym"
}
}

The request is invalid (bad_request). details lists each problem with its path.

Media typeapplication/json
object
error
required
object
code
required

A stable, machine-readable code.

string
message
required

A human-readable explanation.

string
details

More about the error, such as the validation problems.

Example

{
"error": {
"code": "bad_request",
"message": "Invalid request",
"details": [
{
"path": "hitsPerPage",
"message": "Must be 100 or less"
}
]
}
}

The month’s quota and the workspace’s prepaid balance are both used up, or the plan’s limit is reached (quota_exceeded). Every plan has hard limits; nothing is served first and billed later. Buying a pack in Billing adds to the balance.

Media typeapplication/json
object
error
required
object
code
required

A stable, machine-readable code.

string
message
required

A human-readable explanation.

string
details

More about the error, such as the validation problems.

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": "example"
}
}

The Idempotency-Key was used for a different request (idempotency_key_reused), or the first request with it is still running (idempotency_key_in_use).

Media typeapplication/json
object
error
required
object
code
required

A stable, machine-readable code.

string
message
required

A human-readable explanation.

string
details

More about the error, such as the validation problems.

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": "example"
}
}

Too many requests in this window (rate_limited). Wait Retry-After seconds, then retry.

Media typeapplication/json
object
error
required
object
code
required

A stable, machine-readable code.

string
message
required

A human-readable explanation.

string
details

More about the error, such as the validation problems.

Example

{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded"
}
}
Retry-After
integer

Seconds to wait before retrying. Sent with every 429.

RateLimit
string

What’s left in the window (IETF draft-ietf-httpapi-ratelimit-headers): the bucket’s name, r the requests left and t the seconds until the window resets. Sent on every response.

Example
"search";r=597;t=43
RateLimit-Policy
string

The bucket’s quota q per window of w seconds. Sent on every response.

Example
"search";q=600;w=60
RateLimit-Limit
integer

The requests allowed per window (the older form of RateLimit-Policy).

RateLimit-Remaining
integer

The requests left in the window.

RateLimit-Reset
integer

Seconds until the window resets.