Management

Space Memberships

Space Membership is an object representing user membership in a Mode Space. A Space is a place for Mode users to gather reports related to a team, project, or common theme.

You can use the spaces membership resource to get information about or manage membership in a given Space.

Please note that an organization may have different types of Spaces depending on their Mode plan.

Space Membership object

Properties

token

required

string

member_token

required

string

member_type

required

string

member_id

required

string

email

string

_links

required

object

All resource responses contain a set of links that describe other related resources or actions that you can take on this resource. A link is comprised of two main pieces: its name (which describes its relationship to this resource) and its href (the URL of the related action or resource). All resources have at least a _self link which is the URL that will return a representation of this resource.

  • creator
  • member
  • self
  "token": "gbhnjuim5yb",
  "member_token": "fgbnhtum6j5h",
  "member_type": "in id commodo ipsum",
  "member_id": 1019,
  "email": "outer.space@example.com",
  {
    "_links": {
      "self": {
        "href": "dolore ex",
        "templated": false
      },
      "member": {
        "href": "eu non aute velit officia",
        "templated": false
      },
      "creator": {
        "href": "minim",
        "templated": false
      }
    },
  "_embedded": {}
}

Get a space membership

To retrieve information about a given member of a Space, send a GET request to the space memberships resource with a membership_token.

URL Params

account

required
string Account (Organization or User) username

space

required
string Space token

space_membership

required
string Space Membership token
Responses

200

SpaceMembership response

401

Unauthorized

404

Space Membership not found

GET /{account}/spaces/{space}/memberships/{space_membership}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}'
require 'http'

username = 'you_api_key'
password = 'you_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

List space memberships

To retrieve a list of all memberships in a given Space, send a GET request to the space memberships resource.

URL Params

account

required
string Account (Organization or User) username

space

required
string Space token
Responses

200

SpaceMembership collection response

400

Bad request

401

Unauthorized

404

Space not found

GET /{account}/spaces/{space}/memberships

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/spaces/{space}/memberships'
require 'http'

username = 'you_api_key'
password = 'you_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://modeanalytics.com/api/{account}/spaces/{space}/memberships')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{account}/spaces/{space}/memberships', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{account}/spaces/{space}/memberships',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Create a space membership

To add a user to a given Space, send a POST request to the space memberships resource.

URL Params

account

required
string Account (Organization or User) username

space

required
string Space token
POST Body Params

Object: membership

member_type

required
string The type of member, either "User" or "UserGroup"

Example: User

member_token

required
string The token of the member being added

Example: 2bd8236f8ae4

Responses

200

SpaceMembership response

400

Bad request

401

Unauthorized

404

Space not found

POST /{account}/spaces/{space}/memberships

curl --include \
     --request POST \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"space\": {
    \"space_type\": \"Excepteur dolor officia ex\",
    \"name\": \"irure eiusmod labore\",
    \"description\": \"est reprehenderit ad ullamco\"
  }
}" \
'https://modeanalytics.com/api/{organization}/spaces'
require 'http'

values = {
  space: {
    space_type: 'Excepteur dolor officia ex',
    name: 'irure eiusmod labore',
    description: 'est reprehenderit ad ullamco'
  }
}

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .post('https://modeanalytics.com/api/{organization}/spaces', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "space": {
      "space_type": "Excepteur dolor officia ex",
      "name": "irure eiusmod labore",
      "description": "est reprehenderit ad ullamco"
    }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/spaces', data=values, headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'POST',
  url: 'https://modeanalytics.com/api/{organization}/spaces',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{  \"space\": {    \"space_type\": \"Excepteur dolor officia ex\",    \"name\": \"irure eiusmod labore\",    \"description\": \"est reprehenderit ad ullamco\"  }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Delete a space membership

To remove a user from a Space, send a DELETE request to the space memberships resource.

URL Params

account

required
string Account (Organization or User) username

space

required
string Space token

space_membership

required
string Space Membership token
Responses

200

SpaceMembership response

401

Unauthorized

404

Space Membership not found

DELETE /{account}/spaces/{space}/memberships/{space_membership}

curl --include \
     --request DELETE \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}'
require 'http'

username = 'you_api_key'
password = 'you_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .delete('https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}', headers=headers)
request.get_method = lambda: 'DELETE'

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'DELETE',
  url: 'https://modeanalytics.com/api/{account}/spaces/{space}/memberships/{space_membership}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});