Understanding and Adding Segments

Segments are a critical tool for reporting on what your users doing in Voxy. You can create as many custom segments as you want in order to pull data by groups. Segments can be used to group users that belong to the same location, users that started their course at the same time, or users that are associated with a teacher for example.
 
Users can belong to any number of segments you choose
 
To Create a Segment: POST /partners/segments/
 
Segments can be used to group users for reporting purposes. Examples: classes, levels, campus, plans, courses...
 
HTTP_METHOD:
POST
URL:
HEADERS:
{ 'AUTHORIZATION': 'Voxy ${API_KEY}:${REQUEST_SIGNATURE}'
}
BODY:
{'label':'nome-unico-do-segmento'}
 
RETURN: HTTP_STATUS=201 (created)
 
 
Note that labels (segment names) cannot contain special characters or accents.
 
 
Recall that the header AUTHORIZATION is a combination of strings in the following format "Voxy $API_KEY:$REQUEST_SIGNATURE"
where:
  1. $API_KEY is the API_KEY sent to the partner by e-mail (and used to identify the institution in Voxy)
  2. $REQUEST_SIGNATURE is a hash sha256 of
  3. $API_SECRET sent to the partner concatenated with the url_encode of all the key value pairs of the request data ordered alphabetically by key name
 
 
Here is an example of the calculation of $REQUEST_SIGNATURE in Python for this request:
 
api_secret = 'Mvp1co0erZK8U8sEbF6IqE54'
body_params = {'label':'nome-unico-do-segmento'}
 
def generate_signature(api_secret, body_params):
  to_hash = urlencode(sorted(body_params.items()))
  #expected for $to_hash: 'label=nome-unico-do-segmento'
  hashed = sha256(api_secret + to_hash)
  return hashed.hexdigest()
 
#SIGNATURE_TOKEN expected for this example: '083e019f649678162d5df14941ae7c96fe8ed1f3b333f38a73a6ee0432d60d38'
 
Adding a User to a Segment: POST  /partners/segments/${segment_label}/users/${external_user_id}
 
 
 
HTTP_METHOD:
POST
URL:
HEADERS:
{ 'AUTHORIZATION': 'Voxy ${API_KEY}:${REQUEST_SIGNATURE}'
}
BODY:
{}
 
 
RETURN: HTTP_STATUS = 201 (created)
 
 
In this case:
  1. ${segment_label} must be a valid segment already registered on Voxy through POST  /partners/segments/
  2. In this example: nome-unico-do-segmento
  3. ${external_user_id} must be a valid user already registered in Voxy through POST  /partners/users/${external_id}
  4. In this exemplo: 123456
 
 
 
Recall that the header AUTHORIZATION is a combination of strings in the following format "Voxy $API_KEY:$REQUEST_SIGNATURE"
where:
  1. $API_KEY is the API_KEY sent to the partner by e-mail (and used to identify the institution in Voxy)
  2. $REQUEST_SIGNATURE is a hash sha256 of
  3. $API_SECRET sent to the partner concatenated with the url_encode of all the key value pairs of the request data ordered alphabetically by key name
 
 
Here is an example of the calculation for the $ REQUEST_SIGNATURE in Python for this request:
 
api_secret = 'Mvp1co0erZK8U8sEbF6IqE54'
body_params = {}
 
def generate_signature(api_secret, body_params):
to_hash = urlencode(sorted(body_params.items()))
#expected for $to_hash: ''
hashed = sha256(api_secret + to_hash)
return hashed.hexdigest()
 
#SIGNATURE_TOKEN expected for this exemplo: '5c31e5c0145780b8b7534aafa8a23545ca61acd5ea6b6199e8bed34481e5d11e'
 
 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.