Create declaration on a control
Create a declaration for a specific control and return the persisted record
https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarationscurl --request POST \
--url 'https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{"extra":{"key":"string"},"isReadyForReview":true,"statement":"string","subjectLine":"string","submittedBy":"string"}'const response = await fetch("https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
})
});
const data = await response.json();interface Declaration {
appliedPolicyControlId?: number;
attachmentCid?: string[];
cid?: string;
createdAt?: string;
extra?: Record<string, unknown>;
fileAttachments?: Record<string, unknown>[];
id?: number;
isAutomated?: boolean;
isReadyForReview?: boolean;
statement?: string;
subjectLine?: string;
submittedAt?: string;
submittedBy?: string;
submittedByDid?: string;
updatedAt?: string;
}
const response = await fetch("https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
})
});
if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
const data: Declaration = await response.json();import requests
response = requests.post(
"https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations",
headers={
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
},
json={
"extra": {
"key": "string",
},
"isReadyForReview": True,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string",
},
)
response.raise_for_status()
print(response.json())package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}`)
req, err := http.NewRequest(http.MethodPost, "https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status, string(data))
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}
"""))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "<token>");
request.Content = new StringContent("""
{
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}
""", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init('https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}
JSON,
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status . " " . $response . PHP_EOL;require "net/http"
uri = URI("https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = <<~'JSON'
{
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
http.request(request)
end
puts "#{response.code} #{response.body}"// Cargo.toml dependencies: reqwest (features "json"), serde_json, tokio (features "full")
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = reqwest::Client::new()
.post("https://localhost:10001/api/v1/projects/{projectId}/policies/{appliedPolicyId}/controls/{appliedPolicyControlId}/declarations")
.header("Authorization", "Bearer <token>")
.json(&json!({
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}))
.send()
.await?;
println!("{} {}", response.status(), response.text().await?);
Ok(())
}Authorizations
BearerAuth· API key in header "Authorization" — Type "Bearer" followed by a space and JWT token.
Parameters
Path parameters
| Name | Type | Description |
|---|---|---|
projectIdrequired | string | Project ID, UUID (urn:uuid optional), or slug:my-project |
appliedPolicyIdrequired | string | Applied policy ID, slug:my-policy, or urn:cid:bafy... |
appliedPolicyControlIdrequired | string | Applied policy control ID, code:AC-1, or urn:cid:bafy... |
Request bodyrequired
Declaration data
extraobjectHashed into the CID; not stored
Show properties
Map of
stringisReadyForReviewbooleanNeeds submit_controls_for_review
statementstringsubjectLinestringsubmittedBystringDefaults to the caller identity
{
"extra": {
"key": "string"
},
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedBy": "string"
}Responses
201Created declaration
appliedPolicyControlIdintegerread-onlyTaken from the path on create
attachmentCidstring[]read-onlyDerived from the uploaded bytes; not stored
cidstringread-onlyAssigned by the Integrity Service
createdAtstring<date-time>read-onlyextraobjectHashed into the CID; not stored
Show properties
Map of
stringfileAttachmentscore.FileAttachment[]read-onlyUpload via the with-file endpoint
Show properties
Array of
core.FileAttachmentassessmentDeclarationIdintegerAssessmentDeclarationID is set instead when the file belongs to an agent assessment's declaration
cidstringcontentTypestringdeclarationIdintegerdescriptionstringfileNamestringidintegerisPublicbooleanretentionExpiresstring<date-time>reviewIdintegersizeBytesintegerstoragePathstringuploadedAtstring<date-time>uploadedBystringuploadedByDidstringread-onlyVerifiable actor; uploadedBy is the label
idintegerread-onlyisAutomatedbooleanread-onlyTrue for indicator-generated only
isReadyForReviewbooleanNeeds submit_controls_for_review
statementstringsubjectLinestringsubmittedAtstring<date-time>read-onlysubmittedBystringDefaults to the caller identity
submittedByDidstringread-onlyVerifiable actor; submittedBy is the label
updatedAtstring<date-time>read-only
{
"appliedPolicyControlId": 0,
"attachmentCid": [
"string"
],
"cid": "string",
"createdAt": "2025-01-01T00:00:00Z",
"extra": {
"key": "string"
},
"fileAttachments": [
{
"assessmentDeclarationId": 0,
"cid": "string",
"contentType": "string",
"declarationId": 0,
"description": "string",
"fileName": "string",
"id": 0,
"isPublic": true,
"retentionExpires": "2025-01-01T00:00:00Z",
"reviewId": 0,
"sizeBytes": 0,
"storagePath": "string",
"uploadedAt": "2025-01-01T00:00:00Z",
"uploadedBy": "string"
}
],
"id": 0,
"isAutomated": true,
"isReadyForReview": true,
"statement": "string",
"subjectLine": "string",
"submittedAt": "2025-01-01T00:00:00Z",
"submittedBy": "string",
"submittedByDid": "string",
"updatedAt": "2025-01-01T00:00:00Z"
}400Bad request - Invalid IDs or request body
errorstring
{
"error": "Invalid request body"
}401Unauthorized - Authentication required
errorstring
{
"error": "Invalid request body"
}403Forbidden - Insufficient permissions to create declarations
errorstring
{
"error": "Invalid request body"
}404Not found - Unknown or mismatched identifier
errorstring
{
"error": "Invalid request body"
}500Internal server error
errorstring
{
"error": "Invalid request body"
}