Skip to Content
APIEndpointsUpdate prompt markets

Update prompt markets

Changes which markets one or more prompts are tracked in. Each entry in updates replaces that prompt’s markets entirely — there is no add/remove, only “these are the markets now”.

Quota is checked once, as a net delta over the whole batch, not per prompt: shrinking one prompt’s markets in the same call can offset growing another’s, so a customer sitting at their limit can still tidy up. A net reduction is never refused. That is also why this is bulk-shaped only — a single-prompt version could not offer that guarantee.

Requires the write:prompts scope, and the workspace must be enabled for API writes.

PATCH /v1/brands/{brand_id}/prompts/countries

Authorization

HeaderTypeRequired
AuthorizationBearer asky_sk_…required
Idempotency-Keystringrequired

Path parameters

ParameterTypeRequiredDescription
brand_iduuidrequiredFrom List brands

Body

application/json

FieldTypeRequiredDescription
updatesobject[], 1-500requiredOne entry per prompt to update
updates[].prompt_iduuidrequiredFrom List prompts
updates[].country_codesstring[], 1-20requiredReplaces the prompt’s markets. A prompt must keep at least one

Request

curl --request PATCH \ --url 'https://api.askylabs.com/v1/brands/242546de-4cee-4a7d-952e-f6aa60c63ef8/prompts/countries' \ --header 'Authorization: Bearer <api-key>' \ --header 'Idempotency-Key: 5b0e77d2-13a9-4f6a-8ce1-9a3f5e21c0aa' \ --header 'Content-Type: application/json' \ --data '{"updates": [{"prompt_id": "7c2f5a91-3b8e-4d06-9a44-1e7b30c9f852", "country_codes": ["US", "GB"]}]}'

Response

{ "data": { "updated_prompt_ids": ["7c2f5a91-3b8e-4d06-9a44-1e7b30c9f852"], "net_change": 1, "quota": { "limit": 200, "used": 149, "remaining": 51 } }, "request_id": "req_5c1e93f8a2074b6dbf30" }

Response fields

FieldTypeDescription
data.updated_prompt_idsuuid[]required
data.net_changeintegerrequired. Slots gained (positive), freed (negative), or 0. Each market is one slot
data.quotaobjectPresent only when net_change was positive
data.quota.limitinteger | nullYour plan’s active-prompt limit, null if unlimited
data.quota.usedintegerIncluding this batch
data.quota.remainingintegerWhat is left after this call
request_idstringrequired. Also returned as the x-request-id header. Quote it when contacting support

Errors

StatusCodeWhen
400invalid_requestupdates is empty, over 500 entries, contains a duplicate prompt_id, a prompt_id not found for this brand, an empty or over-20 country_codes, or an unsupported market code (the message names it and suggests the real one, e.g. UK -> GB)
401invalid_tokenThe key is missing, malformed, or does not exist
403insufficient_scopeThe key does not carry write:prompts
403plan_requiredThis workspace is not enabled for API writes
403quota_exceededThe net change would exceed your active-prompt allowance. Nothing is updated
404not_foundThe brand does not exist, or this key is not allowed to reach it
429rate_limitedOver 60 requests per minute
503service_unavailableYour allowance could not be checked. Nothing is updated. Retry shortly

Notes

Quota is a net delta across the whole batch, checked once. Growing one prompt from 1 to 3 markets while shrinking another from 2 to 1 is a net change of +1, not +2 — the reduction is folded into the same check. A batch that is a net reduction or zero is never refused, even at 0 remaining allowance.

Validation is all-or-nothing. A prompt_id not found for this brand, a duplicate id in the same batch, or an unsupported market code refuses the entire call and names the offender. Nothing is written unless every entry validates.

This replaces markets, it does not add or remove one. Send the complete new list for each prompt, including any markets you want to keep. To add SE to a prompt already tracking US, GB, send ["US", "GB", "SE"].

No re-execution is triggered. Adding a market does not run the prompt in that market immediately — it starts being measured on the next scheduled run, the same as the app.

Last updated on