curl --request POST \
--url https://api.opal.dev/v1/opal-scripts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "MFA check",
"script_type": "REQUEST_REVIEW",
"owner_id": "7c86c85d-0651-43e2-a748-d69d658418e8"
}
'import requests
url = "https://api.opal.dev/v1/opal-scripts"
payload = {
"name": "MFA check",
"script_type": "REQUEST_REVIEW",
"owner_id": "7c86c85d-0651-43e2-a748-d69d658418e8"
}
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({
name: 'MFA check',
script_type: 'REQUEST_REVIEW',
owner_id: '7c86c85d-0651-43e2-a748-d69d658418e8'
})
};
fetch('https://api.opal.dev/v1/opal-scripts', 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/opal-scripts",
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([
'name' => 'MFA check',
'script_type' => 'REQUEST_REVIEW',
'owner_id' => '7c86c85d-0651-43e2-a748-d69d658418e8'
]),
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/opal-scripts"
payload := strings.NewReader("{\n \"name\": \"MFA check\",\n \"script_type\": \"REQUEST_REVIEW\",\n \"owner_id\": \"7c86c85d-0651-43e2-a748-d69d658418e8\"\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/opal-scripts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"MFA check\",\n \"script_type\": \"REQUEST_REVIEW\",\n \"owner_id\": \"7c86c85d-0651-43e2-a748-d69d658418e8\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.opal.dev/v1/opal-scripts")
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 \"name\": \"MFA check\",\n \"script_type\": \"REQUEST_REVIEW\",\n \"owner_id\": \"7c86c85d-0651-43e2-a748-d69d658418e8\"\n}"
response = http.request(request)
puts response.read_body{
"opal_script_id": "32acc112-21ff-4669-91c2-21e27683eaa1",
"name": "MFA check",
"script_type": "REQUEST_REVIEW",
"version": 3
}Create OpalScript
Creates a new OpalScript.
curl --request POST \
--url https://api.opal.dev/v1/opal-scripts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "MFA check",
"script_type": "REQUEST_REVIEW",
"owner_id": "7c86c85d-0651-43e2-a748-d69d658418e8"
}
'import requests
url = "https://api.opal.dev/v1/opal-scripts"
payload = {
"name": "MFA check",
"script_type": "REQUEST_REVIEW",
"owner_id": "7c86c85d-0651-43e2-a748-d69d658418e8"
}
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({
name: 'MFA check',
script_type: 'REQUEST_REVIEW',
owner_id: '7c86c85d-0651-43e2-a748-d69d658418e8'
})
};
fetch('https://api.opal.dev/v1/opal-scripts', 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/opal-scripts",
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([
'name' => 'MFA check',
'script_type' => 'REQUEST_REVIEW',
'owner_id' => '7c86c85d-0651-43e2-a748-d69d658418e8'
]),
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/opal-scripts"
payload := strings.NewReader("{\n \"name\": \"MFA check\",\n \"script_type\": \"REQUEST_REVIEW\",\n \"owner_id\": \"7c86c85d-0651-43e2-a748-d69d658418e8\"\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/opal-scripts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"MFA check\",\n \"script_type\": \"REQUEST_REVIEW\",\n \"owner_id\": \"7c86c85d-0651-43e2-a748-d69d658418e8\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.opal.dev/v1/opal-scripts")
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 \"name\": \"MFA check\",\n \"script_type\": \"REQUEST_REVIEW\",\n \"owner_id\": \"7c86c85d-0651-43e2-a748-d69d658418e8\"\n}"
response = http.request(request)
puts response.read_body{
"opal_script_id": "32acc112-21ff-4669-91c2-21e27683eaa1",
"name": "MFA check",
"script_type": "REQUEST_REVIEW",
"version": 3
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Information for creating an OpalScript.
The name of the OpalScript.
"MFA check"
The kind of automation an OpalScript performs.
REQUEST_REVIEW, REQUEST_DELEGATION_CONDITION, CONTEXT_PROVIDER "REQUEST_REVIEW"
The source of the OpalScript.
The owner of the service user Opal provisions for a REQUEST_REVIEW script. Required for that script type and ignored for the others, which have no reviewer identity.
"7c86c85d-0651-43e2-a748-d69d658418e8"
Response
The created OpalScript.
OpalScript Object
Description
The OpalScript object represents an OpalScript: a Starlark script that
automates part of Opal's access lifecycle.
The ID of the OpalScript.
"32acc112-21ff-4669-91c2-21e27683eaa1"
The name of the OpalScript.
"MFA check"
The kind of automation an OpalScript performs.
REQUEST_REVIEW, REQUEST_DELEGATION_CONDITION, CONTEXT_PROVIDER "REQUEST_REVIEW"
The source of the OpalScript's latest version.
The version number of the OpalScript's latest version.
3
The date the OpalScript was last updated.
Was this page helpful?