ActiveCampaign Forum

Trying to add a user to a tag not working... Ruby


Here is my code… I create a contact
new_client = ‘
new_tag = ‘

headers = {
“Api-token” => api_key,
“Content-Type” => “application/json”,
“Accept” => “application/json”

user =, headers: headers, body: query.to_json)
user_id = user[“contact”][“id”]

tag = {
“contactTag”: {
“contact”: user_id,
“tag”: “98”

user =, headers: headers, body: tag.to_json)

Error I get
=> #<HTTParty::Response:0x7ff91b4806e0 parsed_response=nil, @response=#<Net::HTTPNotFound 404 Not Found readbody=true>, @headers={“date”=>[“Wed, 05 Jun 2019 17:35:23 GMT”], “content-type”=>[“application/json”], “content-length”=>[“0”], “connection”=>[“close”], “set-cookie”=>["__cfduid=d675eb3935843fd503c7169b1ab5758191559756123; expires=Thu, 04-Jun-20 17:35:23 GMT; path=/;; HttpOnly", “PHPSESSID=vffmkia61anma5bh0pvc8kc1m5; path=/; HttpOnly”, “em_acp_globalauth_cookie=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/;”, “em_acp_globalauth_cookie=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/;”, “em_acp_globalauth_cookie=769fef5b-2916-40d8-aeda-e6def821c83b; path=/;; secure; httponly”], “expires”=>[“Thu, 19 Nov 1981 08:52:00 GMT”], “cache-control”=>[“no-store, no-cache, must-revalidate, post-check=0, pre-check=0”], “pragma”=>[“no-cache”], “expect-ct”=>[“max-age=604800, report-uri=“””], “server”=>[“cloudflare”], “cf-ray”=>[“4e23e71aca34d27e-DFW”]}>

What am I doing wrong? It correctly adds the user but when I try to insert a tag within the user it fails… and the TagId exists…


It looks as though you have a type in the new_tag url:
new_tag = ‘’

(the c is missing in contactTags

I hope this helps