curl --request POST \
--url https://use.hoop.dev/api/resources \
--header 'Content-Type: */*' \
--data '
{
"env_vars": {},
"name": "my-resource",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"attributes": [
"production",
"pii"
],
"command": [
"/bin/bash"
],
"secret": {},
"subtype": "postgres"
}
],
"subtype": "mysql"
}
'import requests
url = "https://use.hoop.dev/api/resources"
payload = {
"env_vars": {},
"name": "my-resource",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"attributes": ["production", "pii"],
"command": ["/bin/bash"],
"secret": {},
"subtype": "postgres"
}
],
"subtype": "mysql"
}
headers = {"Content-Type": "*/*"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '*/*'},
body: JSON.stringify({
env_vars: {},
name: 'my-resource',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
roles: [
{
name: 'pgdemo',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
attributes: ['production', 'pii'],
command: ['/bin/bash'],
secret: {},
subtype: 'postgres'
}
],
subtype: 'mysql'
})
};
fetch('https://use.hoop.dev/api/resources', 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://use.hoop.dev/api/resources",
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([
'env_vars' => [
],
'name' => 'my-resource',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'roles' => [
[
'name' => 'pgdemo',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'attributes' => [
'production',
'pii'
],
'command' => [
'/bin/bash'
],
'secret' => [
],
'subtype' => 'postgres'
]
],
'subtype' => 'mysql'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: */*"
],
]);
$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://use.hoop.dev/api/resources"
payload := strings.NewReader("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"attributes\": [\n \"production\",\n \"pii\"\n ],\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ],\n \"subtype\": \"mysql\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://use.hoop.dev/api/resources")
.header("Content-Type", "*/*")
.body("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"attributes\": [\n \"production\",\n \"pii\"\n ],\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ],\n \"subtype\": \"mysql\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://use.hoop.dev/api/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '*/*'
request.body = "{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"attributes\": [\n \"production\",\n \"pii\"\n ],\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ],\n \"subtype\": \"mysql\"\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"created_at": "2024-07-25T15:56:35.317601Z",
"env_vars": {},
"id": "15B5A2FD-0706-4A47-B1CF-B93CCFC5B3D7",
"name": "my-resource",
"roles": [
{
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"name": "pgdemo",
"type": "database",
"access_max_duration": 3600,
"attributes": [
"production",
"pii"
],
"command": [
"/bin/bash"
],
"connection_tags": {
"environment": "prod",
"tier": "frontend"
},
"default_database": "<string>",
"force_approve_groups": [
"sre-team"
],
"guardrail_rules": [
"5701046A-7B7A-4A78-ABB0-A24C95E6FE54",
"B19BBA55-8646-4D94-A40A-C3AFE2F4BAFD"
],
"id": "5364ec99-653b-41ba-8165-67236e894990",
"jira_issue_template_id": "B19BBA55-8646-4D94-A40A-C3AFE2F4BAFD",
"jit_access_duration_sec": 1800,
"managed_attributes": [
"hoop_protection_profile-soc2_type2"
],
"managed_by": "",
"mandatory_metadata_fields": [
"environment",
"tier"
],
"min_review_approvals": 2,
"redact_enabled": true,
"redact_types": [
"EMAIL_ADDRESS"
],
"resource_name": "pgdemo",
"reviewers": [
"dba-group"
],
"secret": {},
"secrets_updated_at": "2025-01-15T10:30:00Z",
"subtype": "postgres",
"tags": [
"prod"
]
}
],
"subtype": "mysql",
"type": "database",
"updated_at": "2024-07-25T15:56:35.317601Z"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}Creates a resource
Creates a resource for the organization.
curl --request POST \
--url https://use.hoop.dev/api/resources \
--header 'Content-Type: */*' \
--data '
{
"env_vars": {},
"name": "my-resource",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"attributes": [
"production",
"pii"
],
"command": [
"/bin/bash"
],
"secret": {},
"subtype": "postgres"
}
],
"subtype": "mysql"
}
'import requests
url = "https://use.hoop.dev/api/resources"
payload = {
"env_vars": {},
"name": "my-resource",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"attributes": ["production", "pii"],
"command": ["/bin/bash"],
"secret": {},
"subtype": "postgres"
}
],
"subtype": "mysql"
}
headers = {"Content-Type": "*/*"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '*/*'},
body: JSON.stringify({
env_vars: {},
name: 'my-resource',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
roles: [
{
name: 'pgdemo',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
attributes: ['production', 'pii'],
command: ['/bin/bash'],
secret: {},
subtype: 'postgres'
}
],
subtype: 'mysql'
})
};
fetch('https://use.hoop.dev/api/resources', 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://use.hoop.dev/api/resources",
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([
'env_vars' => [
],
'name' => 'my-resource',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'roles' => [
[
'name' => 'pgdemo',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'attributes' => [
'production',
'pii'
],
'command' => [
'/bin/bash'
],
'secret' => [
],
'subtype' => 'postgres'
]
],
'subtype' => 'mysql'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: */*"
],
]);
$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://use.hoop.dev/api/resources"
payload := strings.NewReader("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"attributes\": [\n \"production\",\n \"pii\"\n ],\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ],\n \"subtype\": \"mysql\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://use.hoop.dev/api/resources")
.header("Content-Type", "*/*")
.body("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"attributes\": [\n \"production\",\n \"pii\"\n ],\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ],\n \"subtype\": \"mysql\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://use.hoop.dev/api/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '*/*'
request.body = "{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"attributes\": [\n \"production\",\n \"pii\"\n ],\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ],\n \"subtype\": \"mysql\"\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"created_at": "2024-07-25T15:56:35.317601Z",
"env_vars": {},
"id": "15B5A2FD-0706-4A47-B1CF-B93CCFC5B3D7",
"name": "my-resource",
"roles": [
{
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"name": "pgdemo",
"type": "database",
"access_max_duration": 3600,
"attributes": [
"production",
"pii"
],
"command": [
"/bin/bash"
],
"connection_tags": {
"environment": "prod",
"tier": "frontend"
},
"default_database": "<string>",
"force_approve_groups": [
"sre-team"
],
"guardrail_rules": [
"5701046A-7B7A-4A78-ABB0-A24C95E6FE54",
"B19BBA55-8646-4D94-A40A-C3AFE2F4BAFD"
],
"id": "5364ec99-653b-41ba-8165-67236e894990",
"jira_issue_template_id": "B19BBA55-8646-4D94-A40A-C3AFE2F4BAFD",
"jit_access_duration_sec": 1800,
"managed_attributes": [
"hoop_protection_profile-soc2_type2"
],
"managed_by": "",
"mandatory_metadata_fields": [
"environment",
"tier"
],
"min_review_approvals": 2,
"redact_enabled": true,
"redact_types": [
"EMAIL_ADDRESS"
],
"resource_name": "pgdemo",
"reviewers": [
"dba-group"
],
"secret": {},
"secrets_updated_at": "2025-01-15T10:30:00Z",
"subtype": "postgres",
"tags": [
"prod"
]
}
],
"subtype": "mysql",
"type": "database",
"updated_at": "2024-07-25T15:56:35.317601Z"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}Body
The request body resource
The resource environment variables
Show child attributes
Show child attributes
The resource name
"my-resource"
The resource type
"database"
The agent associated with this resource
"1837453e-01fc-46f3-9e4c-dcf22d395393"
The roles associated with this resource
Show child attributes
Show child attributes
The resource subtype (optional; defaults to the value of 'type' when omitted)
"mysql"
Response
Created
The agent associated with this resource
"1837453e-01fc-46f3-9e4c-dcf22d395393"
The time the resource was created
"2024-07-25T15:56:35.317601Z"
The resource environment variables
Show child attributes
Show child attributes
The resource ID
"15B5A2FD-0706-4A47-B1CF-B93CCFC5B3D7"
The resource name
"my-resource"
Connections (roles) associated with this resource
Show child attributes
Show child attributes
The resource subtype
"mysql"
The resource type
"database"
The time the resource was updated
"2024-07-25T15:56:35.317601Z"
Was this page helpful?