Bulk add members to a workspace
curl --request POST \
--url https://openrouter.ai/api/v1/workspaces/{id}/members/add \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user_ids": [
"user_abc123",
"user_def456"
]
}
'import requests
url = "https://openrouter.ai/api/v1/workspaces/{id}/members/add"
payload = { "user_ids": ["user_abc123", "user_def456"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({user_ids: ['user_abc123', 'user_def456']})
};
fetch('https://openrouter.ai/api/v1/workspaces/{id}/members/add', 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://openrouter.ai/api/v1/workspaces/{id}/members/add",
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_ids' => [
'user_abc123',
'user_def456'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://openrouter.ai/api/v1/workspaces/{id}/members/add"
payload := strings.NewReader("{\n \"user_ids\": [\n \"user_abc123\",\n \"user_def456\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://openrouter.ai/api/v1/workspaces/{id}/members/add")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user_ids\": [\n \"user_abc123\",\n \"user_def456\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://openrouter.ai/api/v1/workspaces/{id}/members/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_ids\": [\n \"user_abc123\",\n \"user_def456\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"added_count": 1,
"data": [
{
"created_at": "2025-08-24T10:30:00Z",
"id": "660e8400-e29b-41d4-a716-446655440000",
"role": "member",
"user_id": "user_abc123",
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
}
]
}{
"error": {
"code": 400,
"message": "Invalid request parameters"
}
}{
"error": {
"code": 401,
"message": "Missing Authentication header"
}
}{
"error": {
"code": 403,
"message": "Only management keys can perform this operation"
}
}{
"error": {
"code": 404,
"message": "Resource not found"
}
}{
"error": {
"code": 500,
"message": "Internal Server Error"
}
}Workspaces
Bulk add members to a workspace
Add multiple organization members to a workspace. New members are assigned the workspace role that matches their organization role. Users who are already members of the workspace keep their current role and are not included in the response. Management key required.
POST
/
workspaces
/
{id}
/
members
/
add
Bulk add members to a workspace
curl --request POST \
--url https://openrouter.ai/api/v1/workspaces/{id}/members/add \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user_ids": [
"user_abc123",
"user_def456"
]
}
'import requests
url = "https://openrouter.ai/api/v1/workspaces/{id}/members/add"
payload = { "user_ids": ["user_abc123", "user_def456"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({user_ids: ['user_abc123', 'user_def456']})
};
fetch('https://openrouter.ai/api/v1/workspaces/{id}/members/add', 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://openrouter.ai/api/v1/workspaces/{id}/members/add",
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_ids' => [
'user_abc123',
'user_def456'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://openrouter.ai/api/v1/workspaces/{id}/members/add"
payload := strings.NewReader("{\n \"user_ids\": [\n \"user_abc123\",\n \"user_def456\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://openrouter.ai/api/v1/workspaces/{id}/members/add")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user_ids\": [\n \"user_abc123\",\n \"user_def456\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://openrouter.ai/api/v1/workspaces/{id}/members/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_ids\": [\n \"user_abc123\",\n \"user_def456\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"added_count": 1,
"data": [
{
"created_at": "2025-08-24T10:30:00Z",
"id": "660e8400-e29b-41d4-a716-446655440000",
"role": "member",
"user_id": "user_abc123",
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
}
]
}{
"error": {
"code": 400,
"message": "Invalid request parameters"
}
}{
"error": {
"code": 401,
"message": "Missing Authentication header"
}
}{
"error": {
"code": 403,
"message": "Only management keys can perform this operation"
}
}{
"error": {
"code": 404,
"message": "Resource not found"
}
}{
"error": {
"code": 500,
"message": "Internal Server Error"
}
}Authorizations
API key as bearer token in Authorization header
Path Parameters
The workspace ID (UUID) or slug
Minimum string length:
1Example:
"production"
Body
application/json
List of user IDs to add to the workspace. New members are assigned the workspace role that matches their organization role; users already in the workspace keep their current role.
Required array length:
1 - 100 elementsExample:
["user_abc123", "user_def456"]
Was this page helpful?