Segments

A segment is a useful way to group multiple actors together. You can segment users or any other actor. Common user segments can be: Beta users, Staff,...


Endpoints

GET/projects/{projectId}/segments

List segments of a project

List segments of a project

Path parameters

  • Name
    projectId
    Type
    string
    Description
    Required The project id

Query parameters

  • Name
    before
    Type
    string
    Description
    Show results before this cursor
  • Name
    after
    Type
    string
    Description
    Show results after this cursor

Request

GET
/projects/{projectId}/segments
const options = {method: 'GET', headers: {Authorization: 'Bearer YOUR_API_KEY'}};

fetch('https://api.groundcontrol.sh/projects/P091PL4M90ZWQUZ0/segments', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Response

{
  "data": [
    {
      "id": "example",
      "name": "example",
      "description": "example",
      "createdAt": "example",
      "latestActors": [
        {
          "actorId": "example",
          "imageURL": "example",
          "name": "example",
          "createdAt": "example"
        }
      ]
    }
  ],
  "pagination": {
    "before": "YWJjZDEyMzQ1Njc4OTB4eXo=",
    "after": "MTIzNGFiY2RlZmdoaWprbG1ubw=="
  }
}

GET/projects/{projectId}/segments/{segmentId}

Retrieve a segment

List segments of a project

Path parameters

  • Name
    projectId
    Type
    string
    Description
    Required The project id
  • Name
    segmentId
    Type
    string
    Description
    Required The segment id

Request

GET
/projects/{projectId}/segments/{segmentId}
const options = {method: 'GET', headers: {Authorization: 'Bearer YOUR_API_KEY'}};

fetch('https://api.groundcontrol.sh/projects/P091PL4M90ZWQUZ0/segments/S091PL4M90ZWQUZ0', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Response

{
  "id": "example",
  "name": "example",
  "description": "example",
  "createdAt": "example",
  "latestActors": [
    {
      "actorId": "example",
      "imageURL": "example",
      "name": "example",
      "createdAt": "example"
    }
  ]
}

POST/projects/{projectId}/segments

Create a segment

Create a new segment

Path parameters

  • Name
    projectId
    Type
    string
    Description
    Required The project id

Request body

  • Name
    name
    Type
    string
    Description
    Project name
  • Name
    description
    Type
    string
    Description
    The segment description

Request

POST
/projects/{projectId}/segments
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
  body: '{"name":"example","description":"example"}'
};

fetch('https://api.groundcontrol.sh/projects/P091PL4M90ZWQUZ0/segments', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Response

{
  "id": "example",
  "name": "example",
  "description": "example",
  "createdAt": "example",
  "latestActors": [
    {
      "actorId": "example",
      "imageURL": "example",
      "name": "example",
      "createdAt": "example"
    }
  ]
}

PATCH/projects/{projectId}/segments/{segmentId}

Update a segment

Update a segment

Path parameters

  • Name
    projectId
    Type
    string
    Description
    Required The project id
  • Name
    segmentId
    Type
    string
    Description
    Required The segment id

Request body

  • Name
    name
    Type
    string
    Description
    Segment name
  • Name
    description
    Type
    string
    Description
    Segment description
  • Name
    addActors
    Type
    array of strings
    Description
    Actors to add
  • Name
    removeActors
    Type
    array of strings
    Description
    Actors to remove

Request

PATCH
/projects/{projectId}/segments/{segmentId}
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
  body: '{"name":"example","description":"example","addActors":["example"],"removeActors":["example"]}'
};

fetch('https://api.groundcontrol.sh/projects/P091PL4M90ZWQUZ0/segments/S091PL4M90ZWQUZ0', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Response

{
  "id": "example",
  "name": "example",
  "description": "example",
  "createdAt": "example",
  "latestActors": [
    {
      "actorId": "example",
      "imageURL": "example",
      "name": "example",
      "createdAt": "example"
    }
  ]
}

GET/projects/{projectId}/flags/{flagName}/segments

List segments for a flag

List segments a flag is enabled for

Path parameters

  • Name
    projectId
    Type
    string
    Description
    Required The project id
  • Name
    flagName
    Type
    string
    Description
    Required The flag name

Query parameters

  • Name
    before
    Type
    string
    Description
    Show results before this cursor
  • Name
    after
    Type
    string
    Description
    Show results after this cursor

Request

GET
/projects/{projectId}/flags/{flagName}/segments
const options = {method: 'GET', headers: {Authorization: 'Bearer YOUR_API_KEY'}};

fetch('https://api.groundcontrol.sh/projects/P091PL4M90ZWQUZ0/flags/my-flag/segments', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Response

{
  "data": [
    {
      "id": "example",
      "name": "example",
      "description": "example",
      "createdAt": "example",
      "latestActors": [
        {
          "actorId": "example",
          "imageURL": "example",
          "name": "example",
          "createdAt": "example"
        }
      ]
    }
  ],
  "pagination": {
    "before": "YWJjZDEyMzQ1Njc4OTB4eXo=",
    "after": "MTIzNGFiY2RlZmdoaWprbG1ubw=="
  }
}

GET/projects/{projectId}/actors/{actorId}/segments

List segments for an actor

List segments where an actor is added

Path parameters

  • Name
    projectId
    Type
    string
    Description
    Required The project id
  • Name
    actorId
    Type
    string
    Description
    Required The actor id

Query parameters

  • Name
    before
    Type
    string
    Description
    Show results before this cursor
  • Name
    after
    Type
    string
    Description
    Show results after this cursor

Request

GET
/projects/{projectId}/actors/{actorId}/segments
const options = {method: 'GET', headers: {Authorization: 'Bearer YOUR_API_KEY'}};

fetch('https://api.groundcontrol.sh/projects/P091PL4M90ZWQUZ0/actors/user:1234/segments', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Response

{
  "data": [
    {
      "id": "example",
      "name": "example",
      "description": "example",
      "createdAt": "example",
      "latestActors": [
        {
          "actorId": "example",
          "imageURL": "example",
          "name": "example",
          "createdAt": "example"
        }
      ]
    }
  ],
  "pagination": {
    "before": "YWJjZDEyMzQ1Njc4OTB4eXo=",
    "after": "MTIzNGFiY2RlZmdoaWprbG1ubw=="
  }
}