Create a segment
curl --request POST \
--url https://api.semilattice.ai/v1/user-models/{user_model_id}/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"filters": {},
"description": ""
}
'import requests
url = "https://api.semilattice.ai/v1/user-models/{user_model_id}/segments"
payload = {
"name": "<string>",
"filters": {},
"description": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', filters: {}, description: ''})
};
fetch('https://api.semilattice.ai/v1/user-models/{user_model_id}/segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.semilattice.ai/v1/user-models/{user_model_id}/segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'filters' => [
],
'description' => ''
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.semilattice.ai/v1/user-models/{user_model_id}/segments"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"filters\": {},\n \"description\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.semilattice.ai/v1/user-models/{user_model_id}/segments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"filters\": {},\n \"description\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.semilattice.ai/v1/user-models/{user_model_id}/segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"filters\": {},\n \"description\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}User Models
Create a segment
Cut a segment out of a user model: the simulated users whose attributes match every filter. It joins your user models and runs like any other. A segment needs at least 100 simulated users; when the filters match fewer, the 400 says how many matched and nothing is created. It is shared with your organisation, or only you without one.
POST
/
v1
/
user-models
/
{user_model_id}
/
segments
Create a segment
curl --request POST \
--url https://api.semilattice.ai/v1/user-models/{user_model_id}/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"filters": {},
"description": ""
}
'import requests
url = "https://api.semilattice.ai/v1/user-models/{user_model_id}/segments"
payload = {
"name": "<string>",
"filters": {},
"description": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', filters: {}, description: ''})
};
fetch('https://api.semilattice.ai/v1/user-models/{user_model_id}/segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.semilattice.ai/v1/user-models/{user_model_id}/segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'filters' => [
],
'description' => ''
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.semilattice.ai/v1/user-models/{user_model_id}/segments"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"filters\": {},\n \"description\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.semilattice.ai/v1/user-models/{user_model_id}/segments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"filters\": {},\n \"description\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.semilattice.ai/v1/user-models/{user_model_id}/segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"filters\": {},\n \"description\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Body
application/json
Each attribute mapped to the values to keep, using exact values from /v1/user-models/{id}/attributes, e.g. {"age": ["45-54", "55-64"], "location": ["london"]}. A simulated user is in the segment when their value is one of the listed values for every attribute given.
Show child attributes
Show child attributes
Response
Successful Response