Apply policy to a project
POST
/api/v1/projects/{projectId}/policies/{policyId}
const
url
=
'
https://localhost:10001/api/v1/projects/1/policies/1
'
;
const
options
= {
method:
'
POST
'
,
headers: {Authorization:
'
'
,
'
Content-Type
'
:
'
application/json
'
},
body:
'
{"name":"example"}
'
}
;
try
{
const
response
= await
fetch
(url
,
options);
const
data
= await
response
.
json
();
console
.
log
(data);
}
catch
(error) {
console
.
error
(error);
}
curl
--request
POST
\
--url
https://localhost:10001/api/v1/projects/1/policies/1
\
--header
'
Authorization:
'
\
--header
'
Content-Type: application/json
'
\
--data
'
{ "name": "example" }
'
Link a policy to a specific project instance and return the created project policy
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”
projectId
required
integer
Project ID
policyId
required
integer
Policy ID
Request Body
Section titled “Request Body ”Request body with policy name
Media type
application/json
object
name
string
Example generated
{
"name"
:
"
example
"
}
Responses
Section titled “ Responses ”Created project policy
Media type
application/json
object
appliedAt
string
appliedBy
string
archivedAt
string
archivedBy
string
cid
string
createdAt
string
id
integer
isArchived
boolean
isReapplied
boolean
name
string
policyId
integer
projectId
integer
slug
string
status
string
subjectCid
string
updatedAt
string
Example generated
{
"appliedAt"
:
"
example
"
,
"appliedBy"
:
"
example
"
,
"archivedAt"
:
"
example
"
,
"archivedBy"
:
"
example
"
,
"cid"
:
"
example
"
,
"createdAt"
:
"
example
"
,
"id"
:
1
,
"isArchived"
:
true
,
"isReapplied"
:
true
,
"name"
:
"
example
"
,
"policyId"
:
1
,
"projectId"
:
1
,
"slug"
:
"
example
"
,
"status"
:
"
example
"
,
"subjectCid"
:
"
example
"
,
"updatedAt"
:
"
example
"
}
Bad request - Invalid project ID, policy ID, or request body
Media type
application/json
object
key
additional properties
string
Example generated
{
"additionalProperty"
:
"
example
"
}
Unauthorized - Authentication required
Media type
application/json
object
key
additional properties
string
Example generated
{
"additionalProperty"
:
"
example
"
}
Forbidden - No project access or insufficient permissions
Media type
application/json
object
key
additional properties
string
Example generated
{
"additionalProperty"
:
"
example
"
}
Project or policy not found
Media type
application/json
object
key
additional properties
string
Example generated
{
"additionalProperty"
:
"
example
"
}
Policy already applied to project
Media type
application/json
object
key
additional properties
string
Example generated
{
"additionalProperty"
:
"
example
"
}
Internal server error
Media type
application/json
object
key
additional properties
string
Example generated
{
"additionalProperty"
:
"
example
"
}