This page contains code samples for the Google Spectrum Access System (SAS) Portal API.
Before you begin
For the following examples, ensure that you complete the following prerequisites:
-  Obtain a token with your service account 
 TOKEN=$(gcloud auth print-access-token).
- Set ${CLIENT_PROJECT}to the project ID of the Google Cloud project.
List current customers
-  Return all of the customers that the caller has access to: curl -X GET -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${TOKEN} " \"https://sasportal.googleapis.com/v1alpha1/customers" 
-  Save the customer name that is returned as a variable: CUSTOMER_NAME=customers/... 
Create a new device configuration
-  Set the ${FCCID}and${SN}of the device that you want to create:FCCID=f1 SN=sn1 
-  Create the device configuration: curl -X POST -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${TOKEN} " \ "https://sasportal.googleapis.com/v1alpha1/ ${CUSTOMER_NAME} /devices" \ -d "{ \"fcc_id\": \" $FCCID \", \"serial_number\": \" $SN \", \"preloaded_config\": { \"call_sign\": \"cs1\", \"category\": \"DEVICE_CATEGORY_A\"}}" The command returns a newly created device configuration. 
-  Save the device name as a variable: DEVICE_NAME=customers/.../devices/... 
List current devices
curl -X GET -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN " \ "https://sasportal.googleapis.com/v1alpha1/ ${CUSTOMER_NAME} /devices"
Retrieve devices by name
curl -X GET -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN " \ "https://sasportal.googleapis.com/v1alpha1/ ${DEVICE_NAME} "
Update an existing device
curl -X PATCH -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN " \ "https://sasportal.googleapis.com/v1alpha1/ ${DEVICE_NAME} " \
Validate your Certified Professional Installer (CPI) identity and certification
-  Generate the secret string: curl -X POST -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN " \ "https://sasportal.googleapis.com/v1alpha1/installer:generateSecret" \ -d "{}" The output is similar to the following: { "secret": "<generated secret>" }
-  Use the JSON Web Token format to encode the secret string into a JWT. 
-  Set the following: -  ${SECRET}to the secret string
-  ${ENCODED_SECRET}to the JWT string
-  ${CPI_ID}to the ID of the CPI
 
-  
-  Validate the identity and certification of the CPI: curl -X POST -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN " \ "https://sasportal.googleapis.com/v1alpha1/installer:validate" \ -d "{ \"installer_id\": \" ${CPI_ID}\ ", \"secret\": \" ${SECRET}\ ", \"encoded_secret\": \" ${ENCODED_SECRET}\ " }" 
Now the CPI can install a Citizens Broadband Radio Service Device (CBSD) that has all the required parameters.
Multistep CBSD registration
You can perform multistep CBSD registration with device parameters previously signed by a CPI or with a CPI account.
Device parameters previously signed by a CPI
This sample shows how to create an inactive device configuration with CBSD installation parameters previously encoded by a CPI. As a result, the non-CPI users can also create the configuration.
- Use the CPI's private key to encode the CBSD parameters. We recommend that you use the JSON Web Token format .
- Set ${ENCODED_DEVICE}to the JWT string and${CPI_ID}to the ID of the CPI.
-  Create the inactive device configuration: curl -X POST -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${TOKEN} " \ "https://sasportal.googleapis.com/v1alpha1/ ${CUSTOMER_NAME} /devices:createSigned" \ -d "{ \"installer_id\": \" ${CPI_ID} \", \"encoded_device\": \" ${ENCODED_DEVICE} \", \"parent\": \" ${CUSTOMER_NAME} \" }" 
The CBSD must then send a registration request to SAS to complete its registration.
CPI account
The CPI's identity must be validated before you validate a device configuration. When that is done, use the following command to create an inactive device configuration:
curl -X POST -H "X-Goog-User-Project: ${CLIENT_PROJECT} " \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ "https://sasportal.googleapis.com/v1alpha1/ ${DEVICE_NAME} :signDevice" \ -d " ${DEVICE} "
Replace  ${DEVICE} 
 
with the JSON representation of the
CBSD registration parameters. For more information about the
format, see REST Resource: customers.devices 
.
The CBSD must then send a registration request to SAS to complete its registration.
What's next
- To get an overview of the SAS Portal API, see Google SAS Portal API overview .
- For information about each API, see Customers API and Device Manager API .
- For reference documentation, see APIs and reference .

