POST /customers/:id/attributes

Assigns the specified customer a collection of custom non-standard attributes. These attributes are displayed on the Invisible Collector site and can later be used to customize the notifications sent to this customer.

Common use cases may include:

New attributes will be added. Existing attributes will be updated.

This request is idempotent and fails if empty keys or values are provided.

curl -XPOST \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer 7b53d640bc79eb1c076603a5e65aa0d266623ced13525d8ea84e06eaf704a5b6" \
  https://api.invisiblecollector.com/customers/061d2feb-81c2-4694-a74a-13cecbe7d2ce/attributes  \
  --data '...'
require "net/https"
require "uri"
require "json"

uri = URI.parse("https://api.invisiblecollector.com/customers/061d2feb-81c2-4694-a74a-13cecbe7d2ce/attributes")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer 4a415cc660e67d8f4d26d5a7f390183a86fc3a4524ded78dc2448e86c48b2739'
request.body = data.to_json

response = http.request(request)
import com.ic.invisiblecollector.IcApiFacade;

IcApiFacade apiFacade = new IcApiFacade("56a73507b66cd761caae7547ef2a66fc3a393746ba4bb9a91e303fcb3ceefb98");

String customerId = ...
Map<String, String> customerAttributes = new TreeMap<>();
... //set attributes
Map<String, String> upToDateAttributes = apiFacade.getCustomerFacade().setCustomerAttributes(customerId, customerAttributes);

using InvisibleCollectorLib;
using InvisibleCollectorLib.Model;

var ic = new InvisibleCollector("56a73507b66cd761caae7547ef2a66fc3a393746ba4bb9a91e303fcb3ceefb98");
string customerId = ... ;
var newAttributes = new Dictionary<string, string> {
  { "attribute-1", "value-1" }
}
IDictionary<string, string> updatedCustomerAttributes = await ic.SetCustomerAttributesAsync(customerId, newAttributes);
iC, err := ic.NewInvisibleCollector("56a73507b66cd761caae7547ef2a66fc3a393746ba4bb9a91e303fcb3ceefb98", ic.InvisibleCollectorUri)

attributes := map[string]string{
  "go-attr-1": "go-val-1",
  "go-attr-3": "go-val-2",
}

var channel = make(chan ic.AttributesPair)
go iC.SetCustomerAttributes(channel, aCustomerModel.Id(), attributes)
p := <-channel

fmt.Println(p.Attributes)

This request can receive the following JSON data:

{
  "new_name_1": "attribute_1",
  "new_name_2": "attribute_2"
}

This request will return, for example, the following JSON response:

{
  "existing_name_1": "old_attribute_1",
  "new_name_1": "attribute_1",
  "new_name_2": "attribute_2"
}

Endpoint

POST https://api.invisiblecollector.com/customers/:id/attributes

Request body

The request is simply a map of key-value pairs.

Response body

The response is a map of all custom attributes this customer has.

Errors

This endpoint may return the following errors

HTTP Code Description
401 Unauthorized Invalid credentials were supplied
404 Not found The user doesn’t have any customer registered with that specific id.
422 Unprocessable Entity The request is syntactically correct but not a valid document JSON object or one the sanity checks failed

Feedback

If you have a question that needs an answer, please contact support.