Adding User Tags

POST https://api.hivemoderation.com/api/v1/user_tags/add

Add one or more tags to a patron. If the patron does not exist, they will be created automatically.


Example Request

curl -X POST https://api.hivemoderation.com/api/v1/user_tags/add
-H "Authorization: token <API_KEY>"
-H "Content-Type: application/json"
-d '{
"patron_id": "user_abc123",
"user_tags_api_fields": ["vip", "newsletter"]
}'

Request Headers

HeaderTypeRequiredDescription
AuthorizationstringYesAPI key from Hive Moderation Dashboard (per-application).
Content-TypestringYesSubmit JSON data in the request body.

Request Body Parameters

ParameterTypeRequiredDescription
patron_idstringYesThe unique identifier for the patron.
user_tags_api_fieldsarrayYesArray of tag api_field strings to add.

Notes:

  • If a tag api_field does not exist in the application, it will be reported under failed, not added.
  • If a tag is already on the patron, it will be reported under pre_existing, not added. No duplicate is created.
  • If the patron does not exist, they will be created before tags are applied.
  • Response messages now reflect all possible dynamic outcomes (see table below).

Responses

Response Fields

FieldTypeAlways ReturnedDescription
messagestringYesHuman-readable result summary.
patron_idstringYesThe patron ID provided in the request.
added_tag_idsarrayYesTag IDs successfully added to the patron.
pre_existing_tag_idsarrayYesapi_fields already associated with the patron, not duplicated.
failedarrayYesapi_fields that could not be processed, including error message.

Updated Response Messages

/user_tags/add

ScenarioMessage
All tags added successfullySuccessfully added tags to patron.
Added + some already existSuccessfully added tags to patron. Some tags may already exist on patron.
Added + some failedSome tags were added. Some tags failed to add.
Added + some already exist + some failedSome tags were added. Some tags may already exist on patron. Some tags failed to add.
All tags already existNo tags were added. All tags already exist on patron.
All tags already exist + some failedNo tags were added. Some tags may already exist on patron. Some tags failed to add.
All tags failed to addNo tags were added. All tags failed to add.

/user_tags/remove

ScenarioMessage
All tags removed successfullySuccessfully removed tags from patron.
Removed + some don't existSuccessfully removed tags from patron. Some tags may not exist on patron.
Removed + some failedSome tags were removed. Some tags failed to remove.
Removed + some don't exist + some failedSome tags were removed. Some tags may not exist on patron. Some tags failed to remove.
All tags don't existNo tags were removed. All tags do not exist on patron.
All tags don't exist + some failedNo tags were removed. Some tags do not exist on patron. Some tags failed to remove.
All tags failed to removeNo tags were removed. All tags failed to remove.

Example Success

{
  "message": "Successfully added tags to patron. Some tags may already exist on patron.",
  "patron_id": "user_abc123",
  "added_tag_ids": ["vip"],
  "pre_existing_tag_ids": ["newsletter"],
  "failed": []
}

Example Error Response

{
  "error": true,
  "status": 400,
  "error_code": "PARAM_REQUIRED",
  "message": "user_tags_api_fields is required.",
  "show_alert": false
}

Common Errors

Status CodeError CodeDescription
400PARAM_REQUIREDA required parameter is missing or empty.
400INVALID_PATRONNo patron matches the provided patron_id (remove endpoint only).
403INVALID_API_KEYNo application matches the provided API key.