Skip to Content
APIEndpointsCreate tag

Create tag

Creates a tag. Tags are cross-cutting labels applied to prompts and to competitors from one brand-level pool, and their ids are the values for the tag_id filter on the reads.

The slug is derived from the name and must be unique within the brand. You cannot set it directly: a tag created here and a tag created in the app must be indistinguishable afterwards.

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

POST /v1/brands/{brand_id}/tags

Authorization

HeaderTypeRequired
AuthorizationBearer asky_sk_…required
Idempotency-Keystringrequired

Path parameters

ParameterTypeRequiredDescription
brand_iduuidrequiredFrom List brands

Query parameters

None.

Any parameter you pass returns 400 invalid_request naming the offending key.

Body

application/json

FieldTypeRequiredDescription
namestring, 1–64 charsrequiredMust contain at least one letter or number. Its derived slug must be unique in the brand
colorstring | nulloptionalHex value like #4F46E5. Rendered as the tag chip
descriptionstring | null, up to 200 charsoptional

Request

curl --request POST \ --url 'https://api.askylabs.com/v1/brands/242546de-4cee-4a7d-952e-f6aa60c63ef8/tags' \ --header 'Authorization: Bearer <api-key>' \ --header 'Idempotency-Key: <unique-per-attempt>' \ --header 'Content-Type: application/json' \ --data '{"name":"Bottom funnel","color":"#4F46E5"}'

Response

{ "data": { "tag": { "id": "9f2c1d84-6b31-4a2e-9c77-1e5b0a3f8d42", "name": "Bottom funnel", "slug": "bottom-funnel", "color": "#4F46E5", "description": null } }, "request_id": "req_7d21b0af59c34e18b6ac" }

Response fields

FieldTypeDescription
data.tag.iduuidrequired. Use it as a tag_id filter value, or to assign the tag
data.tag.namestringrequired
data.tag.slugstringrequired. Derived from the name, unique per brand
data.tag.colorstring | nullrequired
data.tag.descriptionstring | nullrequired
request_idstringrequired. Also returned as the x-request-id header

Errors

StatusCodeWhen
400invalid_requestUnknown field, empty name, a name with no letters or numbers, or a colour that is not hex
401invalid_tokenThe key is missing, malformed, or does not exist
403insufficient_scopeThe key does not carry write:tags
403plan_requiredThis workspace is not enabled for API writes
404not_foundThe brand does not exist, or this key is not allowed to reach it
409conflictAnother tag in this brand already has that slug
429rate_limitedOver 60 requests per minute

Notes

One pool, two kinds of thing. The same tag can label prompts and competitors. Apply it with Set prompt tags or Set competitor tags.

Slugs are derived, not supplied. "Bottom funnel" and "bottom-funnel" collide, and the second returns 409.

Idempotency-Key is required. Reuse it when retrying an attempt and the original response is replayed rather than a second tag being created. See Idempotency.

Last updated on