Update an enrichment
const url = 'https://api.usesonora.com/v1/enrichment-configs/example';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"title":"example","description":"example","prompt":"example","outputType":"short_text","options":["example"],"multiple":true,"dataSources":["meetings"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://api.usesonora.com/v1/enrichment-configs/example \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "title": "example", "description": "example", "prompt": "example", "outputType": "short_text", "options": [ "example" ], "multiple": true, "dataSources": [ "meetings" ] }'Change an enrichment’s settings, as an edit in Sonora does: the change is a new version, its id stays the same, and values already worked out keep the settings they were worked out under until the next run. An enrichment Sonora built from something other than a prompt only takes title and description. Send If-Match with the ETag you read to refuse the change if someone edited it in between.
Requires the enrichments:manage scope. API keys only.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The enrichment’s id.
Header Parameters
Section titled “Header Parameters”The ETag from your last read. If the resource has changed since, nothing is written and the call answers 412 precondition_failed. Without it, the last write wins.
Request Bodyrequired
Section titled “Request Bodyrequired”The settings to change. A field you leave out is kept, and a value equal to the current one is not a change.
object
The question the AI answers for each customer, in plain language (Markdown is fine): What is the main reason this account might not renew?
What the value is: short_text/long_text a string, number a number, score 1–10 (10 strongest), boolean, date YYYY-MM-DD, email, url, or select one of options (a list of them with multiple).
select only, and required for it: the 2–10 values it picks from.
select only: a value is a list of options rather than one. Defaults to false.
What the AI may read to answer: the customer’s meetings, emails, notes, issues, feature_requests, product_usage, ecsat and engagement, or web_search. A run usually costs 1 credit per customer, or 4 with web_search, which also needs web search on your plan. emails is read with the access of the person who made the enrichment, so only one someone made in Sonora takes it: one created through the API has no owner.
Responses
Section titled “Responses”The enrichment, as saved.
An enrichment: a field Sonora’s AI fills in on each record, from your calls, emails and tickets.
object
Stable across edits to the enrichment: the configId its values carry.
The kind of record it describes. Only customer today.
What the value is: short_text/long_text a string, number a number, score 1–10 (10 strongest), boolean, date YYYY-MM-DD, email, url, or select one of options (a list of them with multiple).
select only: whether a value is a list of options.
When the enrichment was last edited.
object
This resource’s canonical URL on the API host.
Example
{ "entityType": "customer", "outputType": "short_text"}Headers
Section titled “Headers”A fingerprint of the enrichment’s current version. Send it back as If-Match to update only if nobody has edited it since.
invalid_json: The request body is not valid JSON.
invalid_request: A parameter or body field is missing, malformed or unknown; details.issues names each.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}unauthorized: The Authorization header is missing, or the key is invalid, revoked or expired.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}insufficient_scope: The key or token lacks the scope this endpoint needs, and details.required names it; or an OAuth access token called an endpoint only an API key can.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}enrichment_config_not_found: No enrichment with that id, or not one a key can read.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}enrichment_config_busy: The enrichment was being edited at the same moment, so nothing changed. Retry the call.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}precondition_failed: The resource changed since the ETag that If-Match names. Read it again, then retry.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}payload_too_large: The request body is too large; details.maxBytes gives the limit.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}invalid_fields: A field’s value can’t be saved, so nothing was; details.issues names each field and why.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}rate_limited: Too many requests for this key; retry after Retry-After seconds.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}internal_error: Something went wrong on Sonora’s side. Retry, and quote requestId if it persists.
The one error shape every endpoint answers with.
object
object
Stable snake_case code to branch on; see the error table.
For humans; may change.
object
Quote it when asking for help.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": { "additionalProperty": "example" }, "requestId": "example" }}Try it
Try it runs the reference's read endpoints, and this one changes data, so it needs an API key with the enrichments:manage scope. Create a key in Sonora under Settings → API and call it from your own code.