Using API keys
API keys allow you to send authenticated API requests to products in Console that have exposed their APIs.
Check available APIs
You can find the list of products and the APIs they offer here:
For more information on using CloudSCAPE/CodeSCAPE APIs, please refer to the xSCAPE API User Guide.
Send an API request
1. Generate a bearer token
Before sending an API request, generate a short-term bearer token for authentication.
URL: https://login.microsoftonline.com/<Directory ID>/oauth2/v2.0/token
METHOD: Post
CONTENT-TYPE: application/x-www-form-urlencoded
PARAMS:
- client_id=<Client ID>
- client_secret=<API Key>
- grant_type=client_credentials
- scope=<Bearer token scope>The Directory ID, Client ID, and Bearer token scope can be found in the API key details page in Console.
Use the API key value you generated in your subscription account as the client_secret.
You will receive a response in the following format:
{
"token_type": "Bearer",
"expires_in": xxx,
"ext_expires_in": xxx,
"access_token": "<Bearer Token>"
}Sending the request
To send the API request, identify the API endpoint and method that the target product is offering. The format is as follows:
Staging environment: https://commonapi.console.stg.developer.tech.gov.sg/<product_id>/<product_endpoint>
Example: https://commonapi.console.stg.developer.tech.gov.sg/stackops/deployments
Production environment: https://commonapi.console.developer.tech.gov.sg/<product_id>/<product_endpoint>
Example: https://commonapi.console.developer.tech.gov.sg/shiphats/projectsAdd the bearer token to the header of the API request:
Authorization: Bearer <Bearer Token>The request can then be sent, together with any required query parameters or request body as specified by the endpoint.