curl --request POST \
--url 'https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "2179873",
"anonymous_id": "403fb18e-98ff-434d-8585-726fabf5ed37",
"variant_name": "Treatment_Group",
"timestamp": "2022-01-23T12:34:56-08:00"
}
'import requests
url = "https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key="
payload = {
"user_id": "2179873",
"anonymous_id": "403fb18e-98ff-434d-8585-726fabf5ed37",
"variant_name": "Treatment_Group",
"timestamp": "2022-01-23T12:34:56-08:00"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
user_id: '2179873',
anonymous_id: '403fb18e-98ff-434d-8585-726fabf5ed37',
variant_name: 'Treatment_Group',
timestamp: '2022-01-23T12:34:56-08:00'
})
};
fetch('https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=', 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.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=",
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([
'user_id' => '2179873',
'anonymous_id' => '403fb18e-98ff-434d-8585-726fabf5ed37',
'variant_name' => 'Treatment_Group',
'timestamp' => '2022-01-23T12:34:56-08:00'
]),
CURLOPT_HTTPHEADER => [
"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.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key="
payload := strings.NewReader("{\n \"user_id\": \"2179873\",\n \"anonymous_id\": \"403fb18e-98ff-434d-8585-726fabf5ed37\",\n \"variant_name\": \"Treatment_Group\",\n \"timestamp\": \"2022-01-23T12:34:56-08:00\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"2179873\",\n \"anonymous_id\": \"403fb18e-98ff-434d-8585-726fabf5ed37\",\n \"variant_name\": \"Treatment_Group\",\n \"timestamp\": \"2022-01-23T12:34:56-08:00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"2179873\",\n \"anonymous_id\": \"403fb18e-98ff-434d-8585-726fabf5ed37\",\n \"variant_name\": \"Treatment_Group\",\n \"timestamp\": \"2022-01-23T12:34:56-08:00\"\n}"
response = http.request(request)
puts response.read_body{
"took": 50,
"in_experiment": true,
"variant": {
"id": "59769b89-5f1f-46d5-a4fa-a583ebd2f7fd",
"name": "Treatment_Group",
"slug": "Treatment_Group",
"status": "Active",
"configuration": {
"model": "A"
}
}
}{
"message": "api_key is invalid. Please check your api_key in Dojo."
}{
"message": "Variant is not found. Please check your variant_name."
}{
"message": "Request schema error. See \"data.errors\" for details",
"data": {
"errors": [
{
"loc": [
"body",
35
],
"msg": "Expecting ',' delimiter: line 3 column 5 (char 35)",
"type": "value_error.jsondecode"
}
]
}
}Send Experiment Event
curl --request POST \
--url 'https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "2179873",
"anonymous_id": "403fb18e-98ff-434d-8585-726fabf5ed37",
"variant_name": "Treatment_Group",
"timestamp": "2022-01-23T12:34:56-08:00"
}
'import requests
url = "https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key="
payload = {
"user_id": "2179873",
"anonymous_id": "403fb18e-98ff-434d-8585-726fabf5ed37",
"variant_name": "Treatment_Group",
"timestamp": "2022-01-23T12:34:56-08:00"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
user_id: '2179873',
anonymous_id: '403fb18e-98ff-434d-8585-726fabf5ed37',
variant_name: 'Treatment_Group',
timestamp: '2022-01-23T12:34:56-08:00'
})
};
fetch('https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=', 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.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=",
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([
'user_id' => '2179873',
'anonymous_id' => '403fb18e-98ff-434d-8585-726fabf5ed37',
'variant_name' => 'Treatment_Group',
'timestamp' => '2022-01-23T12:34:56-08:00'
]),
CURLOPT_HTTPHEADER => [
"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.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key="
payload := strings.NewReader("{\n \"user_id\": \"2179873\",\n \"anonymous_id\": \"403fb18e-98ff-434d-8585-726fabf5ed37\",\n \"variant_name\": \"Treatment_Group\",\n \"timestamp\": \"2022-01-23T12:34:56-08:00\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"2179873\",\n \"anonymous_id\": \"403fb18e-98ff-434d-8585-726fabf5ed37\",\n \"variant_name\": \"Treatment_Group\",\n \"timestamp\": \"2022-01-23T12:34:56-08:00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.askmiso.com/v1/experiments/{experiment_id_or_slug}/events?api_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"2179873\",\n \"anonymous_id\": \"403fb18e-98ff-434d-8585-726fabf5ed37\",\n \"variant_name\": \"Treatment_Group\",\n \"timestamp\": \"2022-01-23T12:34:56-08:00\"\n}"
response = http.request(request)
puts response.read_body{
"took": 50,
"in_experiment": true,
"variant": {
"id": "59769b89-5f1f-46d5-a4fa-a583ebd2f7fd",
"name": "Treatment_Group",
"slug": "Treatment_Group",
"status": "Active",
"configuration": {
"model": "A"
}
}
}{
"message": "api_key is invalid. Please check your api_key in Dojo."
}{
"message": "Variant is not found. Please check your variant_name."
}{
"message": "Request schema error. See \"data.errors\" for details",
"data": {
"errors": [
{
"loc": [
"body",
35
],
"msg": "Expecting ',' delimiter: line 3 column 5 (char 35)",
"type": "value_error.jsondecode"
}
]
}
}Authorizations
Your secret API key is used to access every Miso API endpoint. You should secure this key and only use it on a backend server. Never leave this key in your client-side JavaScript code. If the private key is compromised, you can revoke it in Dojo and get a new one.
Specify your secret key in the api_key query parameter. For example:
POST /v1/users?api_key=039c501ac8dfcac91c6f05601cee876e1cc07e17
Body
Identifies the signed-in user who performed the interaction.
"2179873"
A pseudo-unique substitute for the User Id
"403fb18e-98ff-434d-8585-726fabf5ed37"
Set the variant_name if you want to assign a user to a specific variant. Most of the time, you don't need to pass this field. Instead, the system will automatically assign a variant for this user.
"Treatment_Group"
The time the user is assigned to the variant group. If not set, current time will be used.
"2022-01-23T12:34:56-08:00"