Create or update policy
curl --request PUT \
--url https://app.kosli.com/api/v2/policies/{org} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'payload={
"comment": "Initial version",
"description": "Production environment policy",
"name": "production-policy",
"type": "env"
}' \
--form 'policy_file=<string>' \
--form policy_file.0='@example-file'import requests
url = "https://app.kosli.com/api/v2/policies/{org}"
files = { "policy_file.0": ("example-file", open("example-file", "rb")) }
payload = {
"payload": "{
\"comment\": \"Initial version\",
\"description\": \"Production environment policy\",
\"name\": \"production-policy\",
\"type\": \"env\"
}",
"policy_file": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.put(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('payload', '{
"comment": "Initial version",
"description": "Production environment policy",
"name": "production-policy",
"type": "env"
}');
form.append('policy_file', '<string>');
form.append('policy_file.0', '{
"fileName": "example-file"
}');
const options = {method: 'PUT', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://app.kosli.com/api/v2/policies/{org}', 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://app.kosli.com/api/v2/policies/{org}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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://app.kosli.com/api/v2/policies/{org}"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://app.kosli.com/api/v2/policies/{org}")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.kosli.com/api/v2/policies/{org}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"archived": false,
"consuming_envs": [
"production"
],
"created_at": 1633123456,
"created_by": "John Doe",
"description": "Production environment policy",
"events": [
{
"data": {
"version": 1
},
"timestamp": 1633123456,
"type": "policy_created",
"user": "John Doe"
}
],
"last_modified_at": 1633123456,
"name": "production-policy",
"versions": [
{
"comment": "Initial version",
"created_by": "John Doe",
"policy_yaml": "_schema: https://kosli.com/schemas/policy/environment/v1\n\nartifacts:\n provenance:\n required: false",
"timestamp": 1633123456,
"version": 1
}
]
}{
"archived": false,
"consuming_envs": [
"production"
],
"created_at": 1633123456,
"created_by": "John Doe",
"description": "Production environment policy",
"events": [
{
"data": {
"version": 1
},
"timestamp": 1633123456,
"type": "policy_created",
"user": "John Doe"
}
],
"last_modified_at": 1633123456,
"name": "production-policy",
"versions": [
{
"comment": "Initial version",
"created_by": "John Doe",
"policy_yaml": "_schema: https://kosli.com/schemas/policy/environment/v1\n\nartifacts:\n provenance:\n required: false",
"timestamp": 1633123456,
"version": 1
}
]
}{
"errors": {
"email": "Field must be a valid email address",
"name": "Field cannot be empty"
},
"message": "Input payload validation failed"
}{
"message": "File size exceeds 10MB limit"
}Create or update policy
Create or update a Policy in an organization.
PUT
/
policies
/
{org}
Create or update policy
curl --request PUT \
--url https://app.kosli.com/api/v2/policies/{org} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'payload={
"comment": "Initial version",
"description": "Production environment policy",
"name": "production-policy",
"type": "env"
}' \
--form 'policy_file=<string>' \
--form policy_file.0='@example-file'import requests
url = "https://app.kosli.com/api/v2/policies/{org}"
files = { "policy_file.0": ("example-file", open("example-file", "rb")) }
payload = {
"payload": "{
\"comment\": \"Initial version\",
\"description\": \"Production environment policy\",
\"name\": \"production-policy\",
\"type\": \"env\"
}",
"policy_file": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.put(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('payload', '{
"comment": "Initial version",
"description": "Production environment policy",
"name": "production-policy",
"type": "env"
}');
form.append('policy_file', '<string>');
form.append('policy_file.0', '{
"fileName": "example-file"
}');
const options = {method: 'PUT', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://app.kosli.com/api/v2/policies/{org}', 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://app.kosli.com/api/v2/policies/{org}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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://app.kosli.com/api/v2/policies/{org}"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://app.kosli.com/api/v2/policies/{org}")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.kosli.com/api/v2/policies/{org}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n{\r\n \"comment\": \"Initial version\",\r\n \"description\": \"Production environment policy\",\r\n \"name\": \"production-policy\",\r\n \"type\": \"env\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"policy_file.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"archived": false,
"consuming_envs": [
"production"
],
"created_at": 1633123456,
"created_by": "John Doe",
"description": "Production environment policy",
"events": [
{
"data": {
"version": 1
},
"timestamp": 1633123456,
"type": "policy_created",
"user": "John Doe"
}
],
"last_modified_at": 1633123456,
"name": "production-policy",
"versions": [
{
"comment": "Initial version",
"created_by": "John Doe",
"policy_yaml": "_schema: https://kosli.com/schemas/policy/environment/v1\n\nartifacts:\n provenance:\n required: false",
"timestamp": 1633123456,
"version": 1
}
]
}{
"archived": false,
"consuming_envs": [
"production"
],
"created_at": 1633123456,
"created_by": "John Doe",
"description": "Production environment policy",
"events": [
{
"data": {
"version": 1
},
"timestamp": 1633123456,
"type": "policy_created",
"user": "John Doe"
}
],
"last_modified_at": 1633123456,
"name": "production-policy",
"versions": [
{
"comment": "Initial version",
"created_by": "John Doe",
"policy_yaml": "_schema: https://kosli.com/schemas/policy/environment/v1\n\nartifacts:\n provenance:\n required: false",
"timestamp": 1633123456,
"version": 1
}
]
}{
"errors": {
"email": "Field must be a valid email address",
"name": "Field cannot be empty"
},
"message": "Input payload validation failed"
}{
"message": "File size exceeds 10MB limit"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
multipart/form-data
Response
Update Success
Response model for a policy
This represents the response structure when retrieving, creating or updating a policy.
Last modified on August 24, 2026
⌘I