Create Access Request
Create an access request for a role. The request will go through the configured approval flow before access is provisioned.
curl --request POST \
--url https://public.api.serval.com/v2/access-requests \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"teamId": "<string>",
"roleId": "<string>",
"targetUserId": "<string>",
"accessMinutes": 123,
"businessJustification": "<string>",
"scheduledStartAt": "<string>"
}
'import requests
url = "https://public.api.serval.com/v2/access-requests"
payload = {
"teamId": "<string>",
"roleId": "<string>",
"targetUserId": "<string>",
"accessMinutes": 123,
"businessJustification": "<string>",
"scheduledStartAt": "<string>"
}
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({
teamId: '<string>',
roleId: '<string>',
targetUserId: '<string>',
accessMinutes: 123,
businessJustification: '<string>',
scheduledStartAt: '<string>'
})
};
fetch('https://public.api.serval.com/v2/access-requests', 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://public.api.serval.com/v2/access-requests",
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([
'teamId' => '<string>',
'roleId' => '<string>',
'targetUserId' => '<string>',
'accessMinutes' => 123,
'businessJustification' => '<string>',
'scheduledStartAt' => '<string>'
]),
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://public.api.serval.com/v2/access-requests"
payload := strings.NewReader("{\n \"teamId\": \"<string>\",\n \"roleId\": \"<string>\",\n \"targetUserId\": \"<string>\",\n \"accessMinutes\": 123,\n \"businessJustification\": \"<string>\",\n \"scheduledStartAt\": \"<string>\"\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://public.api.serval.com/v2/access-requests")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"teamId\": \"<string>\",\n \"roleId\": \"<string>\",\n \"targetUserId\": \"<string>\",\n \"accessMinutes\": 123,\n \"businessJustification\": \"<string>\",\n \"scheduledStartAt\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.api.serval.com/v2/access-requests")
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 \"teamId\": \"<string>\",\n \"roleId\": \"<string>\",\n \"targetUserId\": \"<string>\",\n \"accessMinutes\": 123,\n \"businessJustification\": \"<string>\",\n \"scheduledStartAt\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"teamId": "<string>",
"createdAt": "<string>",
"targetUserId": "<string>",
"requestedRoleId": "<string>",
"expiresAt": "<string>",
"linkedTicketId": "<string>",
"timeAllocations": [
{
"id": "<string>",
"createdAt": "<string>",
"requestedMinutes": 123,
"approvedMinutes": 123,
"businessJustification": "<string>",
"requestedByUserId": "<string>",
"linkedTicketId": "<string>",
"approvalRequestId": "<string>"
}
]
}
}{
"message": "<string>",
"detail": {
"type": "<string>",
"value": "<string>",
"debug": {}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The ID of the team. Required.
The ID of the role (entitlement) to request access for. Required.
The ID of the user to request access for. Defaults to the authenticated user if omitted.
The duration of access in minutes. Must not exceed the role's max_access_minutes. Required unless the role has no maximum duration.
A business justification for the access request. Required if the role's access policy requires justification.
An optional scheduled start time for provisioning (RFC3339 format). If omitted, access is provisioned immediately upon approval.
Response
Success
The created access request.
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://public.api.serval.com/v2/access-requests \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"teamId": "<string>",
"roleId": "<string>",
"targetUserId": "<string>",
"accessMinutes": 123,
"businessJustification": "<string>",
"scheduledStartAt": "<string>"
}
'import requests
url = "https://public.api.serval.com/v2/access-requests"
payload = {
"teamId": "<string>",
"roleId": "<string>",
"targetUserId": "<string>",
"accessMinutes": 123,
"businessJustification": "<string>",
"scheduledStartAt": "<string>"
}
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({
teamId: '<string>',
roleId: '<string>',
targetUserId: '<string>',
accessMinutes: 123,
businessJustification: '<string>',
scheduledStartAt: '<string>'
})
};
fetch('https://public.api.serval.com/v2/access-requests', 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://public.api.serval.com/v2/access-requests",
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([
'teamId' => '<string>',
'roleId' => '<string>',
'targetUserId' => '<string>',
'accessMinutes' => 123,
'businessJustification' => '<string>',
'scheduledStartAt' => '<string>'
]),
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://public.api.serval.com/v2/access-requests"
payload := strings.NewReader("{\n \"teamId\": \"<string>\",\n \"roleId\": \"<string>\",\n \"targetUserId\": \"<string>\",\n \"accessMinutes\": 123,\n \"businessJustification\": \"<string>\",\n \"scheduledStartAt\": \"<string>\"\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://public.api.serval.com/v2/access-requests")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"teamId\": \"<string>\",\n \"roleId\": \"<string>\",\n \"targetUserId\": \"<string>\",\n \"accessMinutes\": 123,\n \"businessJustification\": \"<string>\",\n \"scheduledStartAt\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.api.serval.com/v2/access-requests")
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 \"teamId\": \"<string>\",\n \"roleId\": \"<string>\",\n \"targetUserId\": \"<string>\",\n \"accessMinutes\": 123,\n \"businessJustification\": \"<string>\",\n \"scheduledStartAt\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"teamId": "<string>",
"createdAt": "<string>",
"targetUserId": "<string>",
"requestedRoleId": "<string>",
"expiresAt": "<string>",
"linkedTicketId": "<string>",
"timeAllocations": [
{
"id": "<string>",
"createdAt": "<string>",
"requestedMinutes": 123,
"approvedMinutes": 123,
"businessJustification": "<string>",
"requestedByUserId": "<string>",
"linkedTicketId": "<string>",
"approvalRequestId": "<string>"
}
]
}
}{
"message": "<string>",
"detail": {
"type": "<string>",
"value": "<string>",
"debug": {}
}
}
