Tags
๐ท๏ธ Tags
Section titled โ๐ท๏ธ TagsโTags are used in Hatchgrid to categorize and organize content, particularly for newsletter subscribers. Tags allow for flexible segmentation of your audience, enabling targeted communication.
๐งฉ Structure
Section titled โ๐งฉ StructureโA tag typically includes:
id: A UUID.workspaceId: The workspace to which it belongs.name: Human-readable name (e.g., โVIPโ, โNew Subscribersโ).color: Hexadecimal color code in #RRGGBB format.
๐ Creating a Tag
Section titled โ๐ Creating a TagโTo create a new tag, the client issues a PUT request to the /api/workspace/{workspaceId}/tag/{tagId} endpoint.
The workspaceId must be provided in the URL path, and clients should not include it in the request body. The server validates the workspaceId from the path against the userโs authenticated session and will reject requests that do not match.
PUT /api/workspace/c15b9d43-8f47-4f4f-b8e9-9e9b8b8d4a5b/tag/f2c29da7-9c6c-4a6b-9a0e-8d7f6e5e4d3cContent-Type: application/json
{ "name": "My First Tag", "color": "#FF0000"}๐ Listing Tags
Section titled โ๐ Listing TagsโTo retrieve all tags for a workspace, the client issues a GET request to the /api/workspace/{workspaceId}/tag endpoint.
GET /api/workspace/c15b9d43-8f47-4f4f-b8e9-9e9b8b8d4a5b/tagAccept: application/json๐ Assigning Tags to Subscribers
Section titled โ๐ Assigning Tags to SubscribersโTo assign a tag to one or more subscribers, you can update the tag and include the subscribers property with a list of subscriber emails.
PUT /api/workspace/{workspaceId}/tag/{tagId}/updateContent-Type: application/json
{ "name": "Updated Tag Name", "color": "#0000FF", "subscribers": [ "subscriber1@example.com", "subscriber2@example.com" ]}This will associate the tag with the provided subscribers. If the subscribers do not exist, they will be created.