Retrieve all cohorts
curl --request GET \
--url 'https://api.permutive.app/cohorts-api/v2/cohorts?k='import requests
url = "https://api.permutive.app/cohorts-api/v2/cohorts?k="
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.permutive.app/cohorts-api/v2/cohorts?k=', 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.permutive.app/cohorts-api/v2/cohorts?k=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.permutive.app/cohorts-api/v2/cohorts?k="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.permutive.app/cohorts-api/v2/cohorts?k=")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.permutive.app/cohorts-api/v2/cohorts?k=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": "38470a62-9837-4c86-bbf3-45dd6d52dd83",
"code": 12345,
"name": "Example Segment A",
"description": "This segment is an example for documentation purposes",
"tags": [
"tag_a",
"tag_b"
],
"state": "Enabled",
"workspace_id": "0bd63f73-6b67-4766-8c86-fa1d2cf87194",
"segment_type": "real_time",
"created_at": "2022-09-22T15:44:29.513211710Z",
"last_updated_at": "2022-09-22T15:44:29.513214670Z"
},
{
"id": "be1e0886-4a52-442f-89e5-6bf0ff652ac7",
"code": 23456,
"name": "Example Segment B",
"description": "This is a second segment for documentation purposes",
"tags": [],
"state": "Enabled",
"workspace_id": "0bd63f73-6b67-4766-8c86-fa1d2cf87194",
"segment_type": "real_time",
"live_audience_size": 10000,
"created_at": "2022-09-22T15:44:29.513246606Z",
"last_updated_at": "2022-09-22T15:44:29.513246784Z"
}
]{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"status_code": 400,
"status": "Bad Request",
"code": 1002,
"message": "The provided request body was not structured as expected.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7235#section-3.1",
"status_code": 401,
"status": "Unauthorized",
"code": 2005,
"message": "The supplied authentication is invalid.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.3",
"status_code": 403,
"status": "Forbidden",
"code": 2001,
"message": "The API key provided does not provide access to the request operation or resource.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.4",
"status_code": 404,
"status": "Not Found",
"code": 3000,
"message": "The requested resource does not exist.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.8",
"status_code": 409,
"status": "Conflict",
"code": 4000,
"message": "A resource with this identifier already exists.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.6.1",
"status_code": 500,
"status": "Internal Server Error",
"code": 5000,
"message": "An error of unspecified nature was encountered while processing your request. Feel free to get in touch with us at support@permutive.com referencing the Request ID.",
"docs": "https://developer.permutive.com/reference#errors"
}
}Cohorts API
Retrieve all cohorts
By default this endpoint returns all cohorts belonging to the workspace to which the supplied API key belongs, plus any cohorts inherited from parent workspaces in the organization hierarchy. If the API key has the required access level, it is also possible to return segments belonging to child workspaces below the requesting workspace in the organization hierarchy.
The queries defining the behaviour of the cohorts are not returned from this endpoint. To retrieve the query of a given cohort, use the ‘Retrieve individual cohort’ endpoint.
GET
/
v2
/
cohorts
Retrieve all cohorts
curl --request GET \
--url 'https://api.permutive.app/cohorts-api/v2/cohorts?k='import requests
url = "https://api.permutive.app/cohorts-api/v2/cohorts?k="
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.permutive.app/cohorts-api/v2/cohorts?k=', 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.permutive.app/cohorts-api/v2/cohorts?k=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.permutive.app/cohorts-api/v2/cohorts?k="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.permutive.app/cohorts-api/v2/cohorts?k=")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.permutive.app/cohorts-api/v2/cohorts?k=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": "38470a62-9837-4c86-bbf3-45dd6d52dd83",
"code": 12345,
"name": "Example Segment A",
"description": "This segment is an example for documentation purposes",
"tags": [
"tag_a",
"tag_b"
],
"state": "Enabled",
"workspace_id": "0bd63f73-6b67-4766-8c86-fa1d2cf87194",
"segment_type": "real_time",
"created_at": "2022-09-22T15:44:29.513211710Z",
"last_updated_at": "2022-09-22T15:44:29.513214670Z"
},
{
"id": "be1e0886-4a52-442f-89e5-6bf0ff652ac7",
"code": 23456,
"name": "Example Segment B",
"description": "This is a second segment for documentation purposes",
"tags": [],
"state": "Enabled",
"workspace_id": "0bd63f73-6b67-4766-8c86-fa1d2cf87194",
"segment_type": "real_time",
"live_audience_size": 10000,
"created_at": "2022-09-22T15:44:29.513246606Z",
"last_updated_at": "2022-09-22T15:44:29.513246784Z"
}
]{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"status_code": 400,
"status": "Bad Request",
"code": 1002,
"message": "The provided request body was not structured as expected.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7235#section-3.1",
"status_code": 401,
"status": "Unauthorized",
"code": 2005,
"message": "The supplied authentication is invalid.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.3",
"status_code": 403,
"status": "Forbidden",
"code": 2001,
"message": "The API key provided does not provide access to the request operation or resource.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.4",
"status_code": 404,
"status": "Not Found",
"code": 3000,
"message": "The requested resource does not exist.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.8",
"status_code": 409,
"status": "Conflict",
"code": 4000,
"message": "A resource with this identifier already exists.",
"docs": "https://developer.permutive.com/reference#errors"
}
}{
"request_id": "b887517b-99a2-4ae0-bc32-93d1fb13d1b7",
"error": {
"type": "https://tools.ietf.org/html/rfc7231#section-6.6.1",
"status_code": 500,
"status": "Internal Server Error",
"code": 5000,
"message": "An error of unspecified nature was encountered while processing your request. Feel free to get in touch with us at support@permutive.com referencing the Request ID.",
"docs": "https://developer.permutive.com/reference#errors"
}
}Authorizations
Query Parameters
Whether to return cohorts belonging to workspaces below the requesting workspace in the organization hierarchy. Defaults to false if not specified.
Response
List of cohorts in summary form (excluding query)
Available options:
Enabled, Disabled - Option 1
- Option 2
⌘I