Getting Started
API Base URL: https://api.sas.com/mysas
Introduction
The SAS Viya Orders API provides programmatic access to the deployment assets, certificates, and license files that are served at the My Viya Orders tab in My SAS. You can use the API to script the downloading of the files that are needed for the SAS Viya deployment and update process.
For a command-line interface to this API, see SAS Viya Orders CLI.
Configuring Your SAS Environment for API Use
Obtain Client Credentials
The Orders APIs use OAuth 2.0 with the Client Credentials flow
for authentication. You will start by visiting the SAS API Portal to get client
credentials for your application. NOTE In examples below, client_id
comes from the
Key
value obtained from the SAS API Portal, while client_secret
comes from the
Secret
value obtained from the SAS API Portal.
Obtain a Temporary Access Token
The client credentials obtained above are to be exchanged for a temporary Bearer token that expires after 30 minutes.
The token is used on API endpoint calls to authenticate your application to the API. In order to obtain a
Bearer token, you will use the /token
API endpoint. When passing your client credentials on an API call,
it is recommended by the OAuth 2.0 specification that you do so as an HTTP-Basic Authentication header
(described in IETF RFC 2617). This involves base64 encoding a string
formed with {client_id}:{client_secret}. The curl utility can do the encoding for you if you use the -u option.
NOTE See the lib/authn package in SAS Viya Orders CLI for a
Golang example of exchanging base64-encoded client credentials for a Bearer token.
For example, using curl:
client_id = "abcdef"
client_secret = "ghi"
curl -i -H 'Content-Type: application/x-www-form-urlencoded' -u 'abcdef:ghi' \ -X POST 'https://api.sas.com/mysas/token' -d 'grant_type=client_credentials'
HTTP/1.1 200 OK Date: Wed, 29 Jul 2020 21:15:03 GMT Content-Type: application/json Content-Length: 531 Connection: keep-alive Strict-Transport-Security: max-age=31536000; includeSubDomains X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Security-Policy: default-src 'self' { "token_type" : "Bearer", "access_token" : "jklmnop", "issued_at" : "1596057303202", "expires_in" : "1799", "scope" : "" }
You now have access token jklmnop
(see access_token property in the sample output above) to use for
authenticating to the Orders APIs for the next 30 minutes.
Making API Requests with an Access Token
Select Your Cadence
NOTE See the Terminology section for formal definitions of cadence name and cadence version. To use the API endpoints that download license files and deployment assets, you will need to know the name and possibly the version of the cadence you wish to use.
If you are patching an existing deployment, then use the cadence name and version that corresponds to what you already have deployed - when you download deployment assets at that cadence, the latest patches to it will be included.
If you are unsure of what cadences are available to your order:
Click the Get Started link in your Software Order Email to go to the My Viya Orders tab in My SAS.
Expand your order.
Click the "Select a Version" box on the right side to see the cadence names and versions that are available for your order. Note that in the image below, the only cadence name available is Stable. The versions of the Stable cadence that are available are 2020.0.4 and 2020.0.5.
See the SAS Viya Operations Guide Concepts FAQ for a more detailed explanation of cadences.
Examples of API Endpoint Usage
These examples use either curl, wget, or Postman to show a variety of options.
Get certificates
Get deployment assets at a specific version of a cadence
Get deployment assets at the latest version of a cadence
Get a license
Get certificates using curl
curl -o {path-and-name-of-output-certificates-file} \ -H "Authorization: Bearer {access-token}" \ https://api.sas.com/mysas/orders/{orderNumber}/certificates
Get deployment assets at a specific version of a cadence using Postman
Get deployment assets at the latest version of a cadence using curl
curl -o {path-and-name-of-output-deployment-assets-file} \ -H "Authorization: Bearer {access-token}" \ https://api.sas.com/mysas/orders/{orderNumber}/cadenceNames/{cadenceName}/deploymentAssets
Get JWT software license at a specific version of a cadence using wget:
wget -O {path-and-name-of-output-license-file} --header \ -H "Authorization: Bearer {access-token}" \ https://api.sas.com/mysas/orders/{orderNumber}/cadenceNames/{cadenceName}/cadenceVersions/{cadenceVersion}/license