POST/ users/ :id/ add_many_tags/
Add many tags
You can add a list of tags to a specific user.
Attributes
Optional unless marked required
- id
- A unique identifier for the contact which is given by User automatically.
- tag_names
- A list of tag names.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/users/:id/add_many_tags/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"tag_names": [
"Beta tester",
"Webinar"
]
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/users/:id/add_many_tags/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
tag_names: [
"Beta tester",
"Webinar",
],
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/users/:id/add_many_tags/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"tag_names" => [
"Beta tester",
"Webinar",
],
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/users/:id/add_many_tags/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"tag_names": [
"Beta tester",
"Webinar",
],
},
)
print(response.json())
Response examples
- 200 OK
- 400 Bad Request
- 404 Not Found
{"tag_names": ["Beta tester","Webinar"]}{"tag_names": ["This field is required."]}{
"detail": "No ClientUser matches the given query."
}
A 400 names tag_names with one of these messages:
| Message | When |
|---|---|
This field is required. | The body has no tag_names. |
This list may not be empty. | tag_names is an empty list. |
The 404 comes back when no contact has that ID. The body is checked first, so a wrong body answers 400 even for an ID no contact has. Tags the contact already has are accepted again: the response is 200 and lists them as sent.
Response fields
Fields returned in the 200 OK response body.
- tag_names
- A list of tag names.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.