Import Policy
curl --request POST \
--url https://api.example.com/api/policies/import \
--header 'Content-Type: application/json' \
--data '
{
"source": "<string>",
"content": "<string>",
"filename": "<string>"
}
'import requests
url = "https://api.example.com/api/policies/import"
payload = {
"source": "<string>",
"content": "<string>",
"filename": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({source: '<string>', content: '<string>', filename: '<string>'})
};
fetch('https://api.example.com/api/policies/import', 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.example.com/api/policies/import",
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([
'source' => '<string>',
'content' => '<string>',
'filename' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/policies/import"
payload := strings.NewReader("{\n \"source\": \"<string>\",\n \"content\": \"<string>\",\n \"filename\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/policies/import")
.header("Content-Type", "application/json")
.body("{\n \"source\": \"<string>\",\n \"content\": \"<string>\",\n \"filename\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/policies/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"source\": \"<string>\",\n \"content\": \"<string>\",\n \"filename\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"import_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"message": "Import accepted. Poll GET /api/policies/import/{import_id} for results."
}
{
"error": "Missing required field: source"
}
{
"error": "Cannot extract text from document"
}
Custom Policies
Import Policy
Upload a policy document and extract custom rules using AI
POST
/
api
/
policies
/
import
Import Policy
curl --request POST \
--url https://api.example.com/api/policies/import \
--header 'Content-Type: application/json' \
--data '
{
"source": "<string>",
"content": "<string>",
"filename": "<string>"
}
'import requests
url = "https://api.example.com/api/policies/import"
payload = {
"source": "<string>",
"content": "<string>",
"filename": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({source: '<string>', content: '<string>', filename: '<string>'})
};
fetch('https://api.example.com/api/policies/import', 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.example.com/api/policies/import",
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([
'source' => '<string>',
'content' => '<string>',
'filename' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/policies/import"
payload := strings.NewReader("{\n \"source\": \"<string>\",\n \"content\": \"<string>\",\n \"filename\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/policies/import")
.header("Content-Type", "application/json")
.body("{\n \"source\": \"<string>\",\n \"content\": \"<string>\",\n \"filename\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/policies/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"source\": \"<string>\",\n \"content\": \"<string>\",\n \"filename\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"import_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"message": "Import accepted. Poll GET /api/policies/import/{import_id} for results."
}
{
"error": "Missing required field: source"
}
{
"error": "Cannot extract text from document"
}
Upload a policy document (file or plain text) and extract enforceable rules using AI. The endpoint returns immediately with a
processing status while rule extraction runs in the background. Poll Get Import Details to check when extraction is complete.
This endpoint sends the document inline in the request body (base64-encoded when
source is file), which is capped by API Gateway / Lambda
payload limits (a few MB after encoding). For large policy files, use the presigned upload flow
instead: Get Import Presigned URL →
upload to S3 → Start Import.Request Body
Content type indicator:
file for base64-encoded documents or text for plain text.The policy content. Base64-encoded document bytes when
source is file, or plain text when source is text.Original filename for reference (optional, used with
file source).Response
Unique identifier for the import. Use this to poll for status, view details, or activate rules.
Initial status:
processing. Poll the Get Import Details endpoint until status transitions to pending_review, no_rules_found, or failed.Human-readable message with next steps.
{
"import_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"message": "Import accepted. Poll GET /api/policies/import/{import_id} for results."
}
{
"error": "Missing required field: source"
}
{
"error": "Cannot extract text from document"
}
Status Lifecycle
| Status | Description |
|---|---|
processing | Import accepted, AI extraction in progress |
pending_review | Extraction complete, rules ready for review and activation |
no_rules_found | Extraction complete but no compliance rules were identified |
failed | Extraction failed (see error_message in Get Import Details) |
activated | All extracted rules have been activated |
partially_activated | Some rules activated, others still pending |
Example
DOC_BASE64=$(base64 -i compliance-policy.pdf)
# Submit the import
curl -X POST "https://{api-url}/api/policies/import" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"source\": \"file\",
\"content\": \"$DOC_BASE64\",
\"filename\": \"compliance-policy.pdf\"
}"
# Poll for results (returns 'processing' until extraction completes)
curl -X GET "https://{api-url}/api/policies/import/IMPORT_ID" \
-H "x-api-key: YOUR_API_KEY"
curl -X POST "https://{api-url}/api/policies/import" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": "text",
"content": "All marketing materials must include a risk disclosure. Performance claims require a 1-year, 5-year, and since-inception comparison to the benchmark."
}'
import requests
import base64
import time
API_KEY = "YOUR_API_KEY"
API_BASE = "https://{api-url}"
# Submit file import
with open("compliance-policy.pdf", "rb") as f:
doc_bytes = base64.b64encode(f.read()).decode()
response = requests.post(
f"{API_BASE}/api/policies/import",
headers={
"x-api-key": API_KEY,
"Content-Type": "application/json"
},
json={
"source": "file",
"content": doc_bytes,
"filename": "compliance-policy.pdf"
}
)
import_id = response.json()["import_id"]
print(f"Import ID: {import_id} — polling for results...")
# Poll until extraction completes
while True:
details = requests.get(
f"{API_BASE}/api/policies/import/{import_id}",
headers={"x-api-key": API_KEY}
).json()
if details["status"] != "processing":
break
time.sleep(3)
print(f"Status: {details['status']}")
if details.get("rule_count") is not None:
print(f"Rules extracted: {details['rule_count']}")
const fs = require('fs');
const axios = require('axios');
const API_KEY = 'YOUR_API_KEY';
const API_BASE = 'https://{api-url}';
const docBytes = fs.readFileSync('compliance-policy.pdf').toString('base64');
// Submit import
const { data } = await axios.post(
`${API_BASE}/api/policies/import`,
{
source: 'file',
content: docBytes,
filename: 'compliance-policy.pdf'
},
{
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
}
}
);
console.log(`Import ID: ${data.import_id} — polling for results...`);
// Poll until extraction completes
let details;
do {
await new Promise(r => setTimeout(r, 3000));
const res = await axios.get(
`${API_BASE}/api/policies/import/${data.import_id}`,
{ headers: { 'x-api-key': API_KEY } }
);
details = res.data;
} while (details.status === 'processing');
console.log(`Status: ${details.status}`);
if (details.rule_count != null) {
console.log(`Rules extracted: ${details.rule_count}`);
}
⌘I

