1. Add a user with SSO

Add a user with SSO

Similar to add-collaborator. You can add a user with SSO by using the sso_id property. The sso_id is the unique identifier of the user in your system. You can use this identifier to identify the user in Storyblok.

spaces/:space_id/collaborators/

Path Parameters

  • :space_id

    required number

    Numeric id of a space

Request Body Properties

  • sso_id

    string

    The unique identifier of the user in your system, can be an email required

  • email

    string

    Email that will be used in the space interface for collaborator or collaborator SSO ID required

  • role

    string

    Role name of the collaborator, could be admin, editor or custom roles, which is set to id and set to multi if you have more than one role required

  • space_role_id

    number

    Numeric id of the space role connected with collaborators, usually null with more than one collaborator required

Request
curl "https://mapi.storyblok.com/v1/spaces/656/collaborators/" \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_OAUTH_TOKEN" \
  -d "\"collaborator\": {\"sso_id\": \"123456789\",\"role\": \"editor\",\"space_role_id\": 18,\"email\": \"api@storyblok.com\"}"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.post('/spaces/656/collaborators/', "collaborator": {
    "sso_id": "123456789",
    "role": "editor",
    "space_role_id": 18,
    "email": "api@storyblok.com"
  })
  .then(response => {
    console.log(response)
  }).catch(error => { 
    console.log(error)
  })
Request
$client = new \Storyblok\Client('YOUR_STORYBLOK_SPACE_ACCESS_TOKEN');

$payload = "collaborator" =>  [
    "sso_id" =>  "123456789",
    "role" =>  "editor",
    "space_role_id" =>  18,
    "email" =>  "api@storyblok.com"
  ];

$client->post('/spaces/656/collaborators/', $payload)->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')

payload = "collaborator" =>  {
    "sso_id" =>  "123456789",
    "role" =>  "editor",
    "space_role_id" =>  18,
    "email" =>  "api@storyblok.com"
  }

client.post('/spaces/656/collaborators/', payload)
Request
HttpResponse<String> response = Unirest.post("https://mapi.storyblok.com/v1/spaces/656/collaborators/")
  .header("Content-Type", "application/json")
  .header("Authorization", "YOUR_OAUTH_TOKEN")
  .body("\"collaborator\": {\"sso_id\": \"123456789\",\"role\": \"editor\",\"space_role_id\": 18,\"email\": \"api@storyblok.com\"}")
  .asString();
Request
var client = new RestClient("https://mapi.storyblok.com/v1/spaces/656/collaborators/");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
request.AddParameter("application/json", "\"collaborator\": {\"sso_id\": \"123456789\",\"role\": \"editor\",\"space_role_id\": 18,\"email\": \"api@storyblok.com\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Request
import Foundation

let headers = [
  "Content-Type": "application/json",
  "Authorization": "YOUR_OAUTH_TOKEN"
]

let postData = NSData(data: "\"collaborator\": {\"sso_id\": \"123456789\",\"role\": \"editor\",\"space_role_id\": 18,\"email\": \"api@storyblok.com\"}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://mapi.storyblok.com/v1/spaces/656/collaborators/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)

request.method = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
Request
import requests

url = "https://mapi.storyblok.com/v1/spaces/656/collaborators/"

querystring = {}

payload = "\"collaborator\": {\"sso_id\": \"123456789\",\"role\": \"editor\",\"space_role_id\": 18,\"email\": \"api@storyblok.com\"}"
headers = {
  'Content-Type': "application/json",
  'Authorization': "YOUR_OAUTH_TOKEN"
}

response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

print(response.text)
Example Object
{
   "collaborator":{
      "user":null,
      "role":"editor",
      "user_id":null,
      "permissions":[
         
      ],
      "allowed_path":"",
      "field_permissions":"",
      "id":110236,
      "space_role_id":35053,
      "invitation":{
         "email":{
            "SSO Id"
         },
         "expires_at":"2022-09-29T00:51:35.074Z"
      },
      "space_role_ids":[
         // ...
      ],
      "space_id":175323
   }
}