

# CreatePackageDecision

Evaluates one package against the service-managed malicious-package baseline and the calling account's policies, and records an immutable decision. Call it before installing a package to learn whether to allow or deny it.

## Request Syntax
<a name="API_CreatePackageDecision_RequestSyntax"></a>

```
POST /supplychain/package-decisions HTTP/1.1
Content-type: application/json

{
   "clientToken": "{{string}}",
   "purl": "{{string}}"
}
```

## URI Request Parameters
<a name="API_CreatePackageDecision_RequestParameters"></a>

The request does not use any URI parameters.

## Request Body
<a name="API_CreatePackageDecision_RequestBody"></a>

The request accepts the following data in JSON format.

 ** [clientToken](#API_CreatePackageDecision_RequestSyntax) **   <a name="continuum-CreatePackageDecision-request-clientToken"></a>
Idempotency token. Generated SDKs fill it automatically. Within one hour, the same token with the same parameters returns the original decision, and the same token with different parameters returns ValidationException. Requests without a token are rejected with ValidationException.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 128.  
Pattern: `[!-~]+`   
Required: No

 ** [purl](#API_CreatePackageDecision_RequestSyntax) **   <a name="continuum-CreatePackageDecision-request-purl"></a>
The package URL (purl) of the package version to evaluate, such as `pkg:npm/lodash@4.17.21`.  
Type: String  
Length Constraints: Minimum length of 7. Maximum length of 4096.  
Pattern: `pkg:[a-z][a-z0-9-\.]+/.*`   
Required: Yes

## Response Syntax
<a name="API_CreatePackageDecision_ResponseSyntax"></a>

```
HTTP/1.1 200
Content-type: application/json

{
   "canonicalPurl": "string",
   "decisionId": "string",
   "enforcementAction": "string",
   "enforcementMode": "string",
   "evaluatedAction": "string",
   "reason": "string"
}
```

## Response Elements
<a name="API_CreatePackageDecision_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [canonicalPurl](#API_CreatePackageDecision_ResponseSyntax) **   <a name="continuum-CreatePackageDecision-response-canonicalPurl"></a>
The package URL (purl) that was evaluated, as accepted by the service.  
Type: String  
Length Constraints: Minimum length of 7. Maximum length of 4096.  
Pattern: `pkg:[a-z][a-z0-9-\.]+/.*` 

 ** [decisionId](#API_CreatePackageDecision_ResponseSyntax) **   <a name="continuum-CreatePackageDecision-response-decisionId"></a>
The ID of the decision. Use it with GetPackageDecision and ListDecisionEvidence.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[a-z0-9]+` 

 ** [enforcementAction](#API_CreatePackageDecision_ResponseSyntax) **   <a name="continuum-CreatePackageDecision-response-enforcementAction"></a>
The action to take. It differs from evaluatedAction only when enforcementMode is AUDIT: evaluatedAction is then DENY and enforcementAction is ALLOW.  
Type: String  
Valid Values: `ALLOW | DENY` 

 ** [enforcementMode](#API_CreatePackageDecision_ResponseSyntax) **   <a name="continuum-CreatePackageDecision-response-enforcementMode"></a>
The strongest enforcement mode among matches that a policy exception didn't suppress: ENFORCE for the malicious-package baseline or an enforced rule, AUDIT for an audit-mode rule. NONE when there is no such match, including when policy exceptions suppressed every match.  
Type: String  
Valid Values: `NONE | AUDIT | ENFORCE` 

 ** [evaluatedAction](#API_CreatePackageDecision_ResponseSyntax) **   <a name="continuum-CreatePackageDecision-response-evaluatedAction"></a>
The result of policy evaluation: DENY when the malicious-package baseline or a deny rule matched and no policy exception suppressed it, otherwise ALLOW.  
Type: String  
Valid Values: `ALLOW | DENY` 

 ** [reason](#API_CreatePackageDecision_ResponseSyntax) **   <a name="continuum-CreatePackageDecision-response-reason"></a>
Why the decision was made.  
Type: String  
Valid Values: `NO_DENY_MATCH | MALICIOUS_PACKAGE | POLICY_RULE_MATCHED` 

## Errors
<a name="API_CreatePackageDecision_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** AccessDeniedException **   
You don't have permission to perform this action. Verify that your IAM policy includes the required permissions.    
 ** message **   
Error description.
HTTP Status Code: 403

 ** InternalServerException **   
An unexpected error occurred on the server. Try the request again.    
 ** message **   
Error description.
HTTP Status Code: 500

 ** ThrottlingException **   
The request was denied due to request throttling.    
 ** message **   
Description of the throttling error.
HTTP Status Code: 429

 ** ValidationException **   
The request isn't valid. Check the request parameters and try again.    
 ** fieldList **   
The fields that failed validation, if the failure is about specific fields.  
 ** message **   
Error description.
HTTP Status Code: 400

## See Also
<a name="API_CreatePackageDecision_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/continuum-2022-07-26/CreatePackageDecision) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/continuum-2022-07-26/CreatePackageDecision) 