curl --request POST \
--url https://api.opal.dev/v1/resources/{resource_id}/users/{user_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"duration_minutes": 60,
"access_level_remote_id": "arn:aws:iam::590304332660:role/AdministratorAccess"
}
'import requests
url = "https://api.opal.dev/v1/resources/{resource_id}/users/{user_id}"
payload = {
"duration_minutes": 60,
"access_level_remote_id": "arn:aws:iam::590304332660:role/AdministratorAccess"
}
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({
duration_minutes: 60,
access_level_remote_id: 'arn:aws:iam::590304332660:role/AdministratorAccess'
})
};
fetch('https://api.opal.dev/v1/resources/{resource_id}/users/{user_id}', 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.opal.dev/v1/resources/{resource_id}/users/{user_id}",
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([
'duration_minutes' => 60,
'access_level_remote_id' => 'arn:aws:iam::590304332660:role/AdministratorAccess'
]),
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://api.opal.dev/v1/resources/{resource_id}/users/{user_id}"
payload := strings.NewReader("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"arn:aws:iam::590304332660:role/AdministratorAccess\"\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://api.opal.dev/v1/resources/{resource_id}/users/{user_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"arn:aws:iam::590304332660:role/AdministratorAccess\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.opal.dev/v1/resources/{resource_id}/users/{user_id}")
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 \"duration_minutes\": 60,\n \"access_level_remote_id\": \"arn:aws:iam::590304332660:role/AdministratorAccess\"\n}"
response = http.request(request)
puts response.read_body{
"full_name": "Jake Barnes",
"user_id": "29827fb8-f2dd-4e80-9576-28e31e9934ac",
"resource_id": "1b978423-db0a-4037-a4cf-f79c60cb67b3",
"expiration_date": "2022-01-23T04:56:07.000Z",
"email": "jake@company.dev"
}Adds a user to this resource.
curl --request POST \
--url https://api.opal.dev/v1/resources/{resource_id}/users/{user_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"duration_minutes": 60,
"access_level_remote_id": "arn:aws:iam::590304332660:role/AdministratorAccess"
}
'import requests
url = "https://api.opal.dev/v1/resources/{resource_id}/users/{user_id}"
payload = {
"duration_minutes": 60,
"access_level_remote_id": "arn:aws:iam::590304332660:role/AdministratorAccess"
}
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({
duration_minutes: 60,
access_level_remote_id: 'arn:aws:iam::590304332660:role/AdministratorAccess'
})
};
fetch('https://api.opal.dev/v1/resources/{resource_id}/users/{user_id}', 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.opal.dev/v1/resources/{resource_id}/users/{user_id}",
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([
'duration_minutes' => 60,
'access_level_remote_id' => 'arn:aws:iam::590304332660:role/AdministratorAccess'
]),
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://api.opal.dev/v1/resources/{resource_id}/users/{user_id}"
payload := strings.NewReader("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"arn:aws:iam::590304332660:role/AdministratorAccess\"\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://api.opal.dev/v1/resources/{resource_id}/users/{user_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"arn:aws:iam::590304332660:role/AdministratorAccess\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.opal.dev/v1/resources/{resource_id}/users/{user_id}")
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 \"duration_minutes\": 60,\n \"access_level_remote_id\": \"arn:aws:iam::590304332660:role/AdministratorAccess\"\n}"
response = http.request(request)
puts response.read_body{
"full_name": "Jake Barnes",
"user_id": "29827fb8-f2dd-4e80-9576-28e31e9934ac",
"resource_id": "1b978423-db0a-4037-a4cf-f79c60cb67b3",
"expiration_date": "2022-01-23T04:56:07.000Z",
"email": "jake@company.dev"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the resource.
The ID of the user to add.
Query Parameters
The duration for which the resource can be accessed (in minutes). Use 0 to set to indefinite.
x <= 525960The remote ID of the access level to grant to this user. If omitted, the default access level remote ID value (empty string) is used.
Body
The duration for which the resource can be accessed (in minutes). Use 0 to set to indefinite.
x <= 52596060
The remote ID of the access level to grant to this user. If omitted, the default access level remote ID value (empty string) is used.
"arn:aws:iam::590304332660:role/AdministratorAccess"
Response
The ResourceUser that was created.
Resource User Object
Description
The ResourceUser object is used to represent a user with direct access to a resource.
The ID of the resource.
"1b978423-db0a-4037-a4cf-f79c60cb67b3"
The ID of the user.
"29827fb8-f2dd-4e80-9576-28e31e9934ac"
Access Level Object
Description
The AccessLevel object is used to represent the level of access that a principal has. The "default" access
level is a AccessLevel object whose fields are all empty strings.
Usage Example
View the AccessLevel of a resource/user or resource/group pair to see the level of access granted to the resource.
Show child attributes
Show child attributes
{
"access_level_name": "AdminRole",
"access_level_remote_id": "arn:aws:iam::590304332660:role/AdministratorAccess"
}
The user's full name.
"Jake Barnes"
The user's email.
"jake@company.dev"
The day and time the user's access will expire.
"2022-01-23T04:56:07.000Z"
Was this page helpful?