Tags
Create site-wide tags, then assign them to items.
Tags belong to the site; assignments belong to artifacts. Create the tag once, then assign it wherever it applies.
| Endpoint | What it does |
|---|---|
| GET /api/v1/site/{site}/tags/ | List the site's tags, paginated |
| POST /api/v1/site/{site}/tags/ | Create a tag. name is required |
| GET /api/v1/site/{site}/tags/{tag_slug}/ | Read one tag |
| POST /api/v1/site/{site}/tags/{tag_slug}/ | Rename it |
| DELETE /api/v1/site/{site}/tags/{tag_slug}/ | Delete it everywhere |
| GET /api/v1/site/{site}/artifacts/{slug}/tags/ | List the tags on one artifact |
| POST /api/v1/site/{site}/artifacts/{slug}/tags/ | Assign a tag. tag is required |
| DELETE /api/v1/site/{site}/artifacts/{slug}/tags/{tag_slug}/ | Remove it from that artifact |
Request
curl -X POST -H "Authorization: Token $ENINE_TOKEN" -H "Content-Type: application/json" \
-d '{"name": "Case Study"}' \
https://e9sites.com/api/v1/site/mysite.e9sites.com/tags/
curl -X POST -H "Authorization: Token $ENINE_TOKEN" -H "Content-Type: application/json" \
-d '{"tag": "case-study"}' \
https://e9sites.com/api/v1/site/mysite.e9sites.com/artifacts/web-design/tags/
import os
import requests
headers = {"Authorization": f"Token {os.environ['ENINE_TOKEN']}"}
base = "https://e9sites.com/api/v1/site/mysite.e9sites.com"
tag = requests.post(f"{base}/tags/", json={"name": "Case Study"}, headers=headers).json()
requests.post(f"{base}/artifacts/web-design/tags/", json={"tag": tag["slug"]}, headers=headers)
Creating a tag whose name already exists returns 409. Assigning the same tag twice is safe -- you get the existing assignment back rather than an error.