Step 3: Create and scan a Cloud Environment for Google (API)
To send a request to the Snyk API to create and scan a Cloud Environment, you must provide the Google service account's email address and your project ID in the API request body.
Send the Snyk API request
Send a request to the Snyk API in the format below to create the Cloud Environment:
curl -X POST \
'https://api.snyk.io/rest/orgs/YOUR-ORGANIZATION-ID/cloud/environments?version=2022-12-21~beta' \
-H 'Authorization: token YOUR-API-TOKEN' \
-H 'Content-Type:application/vnd.api+json' -d '{
"data": {
"type": "environments",
"attributes": {
"options": {
"identity_provider": "YOUR-IDENTITY-PPROVIDER-URL"
"service_account_email": "YOUR-SERVICE-ACCOUNT-EMAIL",
"project_id": "YOUR-PROJECT-ID"
},
"kind": "google"
}
}
}'Understand the API response
The response is a JSON document containing details about your newly created Cloud Environment, for example:
Snyk automatically triggers a scan when an environment is created.
To check to see if your scan is finished, see Check to see if the scan is finished.
To re-scan an environment, see Scan a Cloud environment.
What's next?
You can now do the following:
View the cloud configuration issues Snyk finds. See Manage cloud issues.
Prioritize your vulnerabilities with cloud context.
Last updated
Was this helpful?

