Basic API Requests

This guide assumes you have obtained an access token from an authorized user. You can obtain an access token either by completing the OAuth flow (see the User Authentication guide) or by using the Access Token Generator to generate a token using your own Bluescape login information.

The Base URL

All API endpoints share the same base URL:

https://api.apps.us.bluescape.com

Assembling a Request

URL

A request URL is assembled from the base URL and the path information for an operation as found in the reference. For example, Add a User to an Organization is an operation with path /organizations/<organization_id>/users. Combining this path with the base URL gives us a request URL of:

https://api.apps.us.bluescape.com/organizations/<organization_id>/users

Parameters

The path for the operation above, like many in the Bluescape API, contains a parameter. Adding a user to an organization requires we identify the organization to which the new user should be invited. To finish preparing this request URL, we must replace <organization_id> with a valid organization ID, such as one obtained from the List a User's Organizations operation. Replacing the parameter placeholder with a sample organization ID yields a request URL of:

https://api.apps.us.bluescape.com/organizations/18223/users

In addition to path parameters, some requests will have query, body and form data parameters. Reviewing the documentation for Add a User to an Organization, we see that this operation has a JSON-format body parameter with a required email field. When an operation requires a body parameter, be sure to send your request with a Content-Type header of application/json. When a form data parameter is expected, be sure to send your request with a Content-Type header of multipart/form-data. A valid body for this request looks like:

{
  "email": "michael.scott@bluescape.com"
}

Authorization Header

Lastly, all operations require an Authorization header based on the access tokens received from the OAuth flow. The value of this header should match the format of Bearer <access-token>.

Assembled Request

Putting this all together, a request to Add a User to an Organization looks like:

Bourne shell example:
curl -X POST https://api.apps.us.bluescape.com/organizations/18223/users \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3d...' \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "michael.scott@bluescape.com"
  }'

Python example:
import requests
...
...
portal = 'https://api.apps.us.bluescape.com'
API_endpoint = '/v1/workspaces/' + workspace_id + '/images'

the_request = requests.get(
    portal + API_endpoint,
    headers={"Authorization": "Bearer " + token,
                "Content-Type": "application/json"
                }
)

json_response = the_request.json()
... 
...

If you have any questions or comments, please contact us at Bluescape support.