Create Policy
curl --request POST \
--url https://www.corgea.app/api/v1/policies \
--header 'CORGEA-TOKEN: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "<string>",
"name": "<string>",
"cwes": [
"<string>"
],
"excludes": [
"<string>"
],
"projects": [
"<string>"
],
"active": true,
"instruction_type": "overwrite",
"glob_pattern": "<string>",
"guidance_text": "<string>"
}
'import requests
url = "https://www.corgea.app/api/v1/policies"
payload = {
"description": "<string>",
"name": "<string>",
"cwes": ["<string>"],
"excludes": ["<string>"],
"projects": ["<string>"],
"active": True,
"instruction_type": "overwrite",
"glob_pattern": "<string>",
"guidance_text": "<string>"
}
headers = {
"CORGEA-TOKEN": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'CORGEA-TOKEN': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
description: '<string>',
name: '<string>',
cwes: ['<string>'],
excludes: ['<string>'],
projects: ['<string>'],
active: true,
instruction_type: 'overwrite',
glob_pattern: '<string>',
guidance_text: '<string>'
})
};
fetch('https://www.corgea.app/api/v1/policies', 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://www.corgea.app/api/v1/policies",
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([
'description' => '<string>',
'name' => '<string>',
'cwes' => [
'<string>'
],
'excludes' => [
'<string>'
],
'projects' => [
'<string>'
],
'active' => true,
'instruction_type' => 'overwrite',
'glob_pattern' => '<string>',
'guidance_text' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"CORGEA-TOKEN: <api-key>",
"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://www.corgea.app/api/v1/policies"
payload := strings.NewReader("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"cwes\": [\n \"<string>\"\n ],\n \"excludes\": [\n \"<string>\"\n ],\n \"projects\": [\n \"<string>\"\n ],\n \"active\": true,\n \"instruction_type\": \"overwrite\",\n \"glob_pattern\": \"<string>\",\n \"guidance_text\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("CORGEA-TOKEN", "<api-key>")
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://www.corgea.app/api/v1/policies")
.header("CORGEA-TOKEN", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"cwes\": [\n \"<string>\"\n ],\n \"excludes\": [\n \"<string>\"\n ],\n \"projects\": [\n \"<string>\"\n ],\n \"active\": true,\n \"instruction_type\": \"overwrite\",\n \"glob_pattern\": \"<string>\",\n \"guidance_text\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.corgea.app/api/v1/policies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["CORGEA-TOKEN"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"cwes\": [\n \"<string>\"\n ],\n \"excludes\": [\n \"<string>\"\n ],\n \"projects\": [\n \"<string>\"\n ],\n \"active\": true,\n \"instruction_type\": \"overwrite\",\n \"glob_pattern\": \"<string>\",\n \"guidance_text\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"policy": {
"id": 123,
"description": "<string>",
"cwes": [
"<string>"
],
"excludes": [
"<string>"
],
"projects": [
"<string>"
],
"company": 123,
"active": true,
"approved": true,
"approved_by": 123,
"created_at": "2023-11-07T05:31:56Z",
"glob_pattern": "<string>",
"source_type": "Web",
"repo_policy_file": 123,
"name": "<string>",
"guidance_text": "<string>",
"version": 123,
"archived": true,
"parent_policy": 123,
"read_only": true,
"created_by_corgea": true
}
}{
"error": "Invalid JSON body"
}{
"error": "Missing or invalid authorization header"
}{
"error": "Permission denied"
}{
"error": "A policy with this name already exists"
}Policies
Create Policy
Create a policy for the authenticated user’s company.
POST
/
policies
Create Policy
curl --request POST \
--url https://www.corgea.app/api/v1/policies \
--header 'CORGEA-TOKEN: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "<string>",
"name": "<string>",
"cwes": [
"<string>"
],
"excludes": [
"<string>"
],
"projects": [
"<string>"
],
"active": true,
"instruction_type": "overwrite",
"glob_pattern": "<string>",
"guidance_text": "<string>"
}
'import requests
url = "https://www.corgea.app/api/v1/policies"
payload = {
"description": "<string>",
"name": "<string>",
"cwes": ["<string>"],
"excludes": ["<string>"],
"projects": ["<string>"],
"active": True,
"instruction_type": "overwrite",
"glob_pattern": "<string>",
"guidance_text": "<string>"
}
headers = {
"CORGEA-TOKEN": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'CORGEA-TOKEN': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
description: '<string>',
name: '<string>',
cwes: ['<string>'],
excludes: ['<string>'],
projects: ['<string>'],
active: true,
instruction_type: 'overwrite',
glob_pattern: '<string>',
guidance_text: '<string>'
})
};
fetch('https://www.corgea.app/api/v1/policies', 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://www.corgea.app/api/v1/policies",
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([
'description' => '<string>',
'name' => '<string>',
'cwes' => [
'<string>'
],
'excludes' => [
'<string>'
],
'projects' => [
'<string>'
],
'active' => true,
'instruction_type' => 'overwrite',
'glob_pattern' => '<string>',
'guidance_text' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"CORGEA-TOKEN: <api-key>",
"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://www.corgea.app/api/v1/policies"
payload := strings.NewReader("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"cwes\": [\n \"<string>\"\n ],\n \"excludes\": [\n \"<string>\"\n ],\n \"projects\": [\n \"<string>\"\n ],\n \"active\": true,\n \"instruction_type\": \"overwrite\",\n \"glob_pattern\": \"<string>\",\n \"guidance_text\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("CORGEA-TOKEN", "<api-key>")
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://www.corgea.app/api/v1/policies")
.header("CORGEA-TOKEN", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"cwes\": [\n \"<string>\"\n ],\n \"excludes\": [\n \"<string>\"\n ],\n \"projects\": [\n \"<string>\"\n ],\n \"active\": true,\n \"instruction_type\": \"overwrite\",\n \"glob_pattern\": \"<string>\",\n \"guidance_text\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.corgea.app/api/v1/policies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["CORGEA-TOKEN"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"cwes\": [\n \"<string>\"\n ],\n \"excludes\": [\n \"<string>\"\n ],\n \"projects\": [\n \"<string>\"\n ],\n \"active\": true,\n \"instruction_type\": \"overwrite\",\n \"glob_pattern\": \"<string>\",\n \"guidance_text\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"policy": {
"id": 123,
"description": "<string>",
"cwes": [
"<string>"
],
"excludes": [
"<string>"
],
"projects": [
"<string>"
],
"company": 123,
"active": true,
"approved": true,
"approved_by": 123,
"created_at": "2023-11-07T05:31:56Z",
"glob_pattern": "<string>",
"source_type": "Web",
"repo_policy_file": 123,
"name": "<string>",
"guidance_text": "<string>",
"version": 123,
"archived": true,
"parent_policy": 123,
"read_only": true,
"created_by_corgea": true
}
}{
"error": "Invalid JSON body"
}{
"error": "Missing or invalid authorization header"
}{
"error": "Permission denied"
}{
"error": "A policy with this name already exists"
}Authorizations
CorgeaTokenBearerAuth
API key for authentication
Body
application/json
Available options:
BLAST, scan, false_positive, fix Minimum string length:
10Minimum string length:
3Project names or IDs that scope the policy. Empty or null creates a company-wide policy.
Available options:
overwrite, append Maximum string length:
255Maximum string length:
3000Response
Policy created successfully
Show child attributes
Show child attributes
Was this page helpful?
⌘I
