Spheron API

What is Spheron API?
Spheron API is an API that gives users access over Spheron platform, providing all the available resources, exposed as HTTPS endpoints.
REST API
REST API is called “Representational State Transfer” and it makes the APIs relatively easy to use and discover. Spheron API is a REST-styled API that makes all data available. REST makes data and functionality available as resources, using unique URLs. To request a data or resources, we just need to provide its URL.
API Basics
Spheron API is exposed as an HTTP/1 and HTTP/2 service over SSL. All endpoints live under the URL https://api-v2.spheron.network and follow the REST architecture.
HTTP and TLS
The API supports HTTP versions 1, 1.1, and 2, although HTTP/2 is preferred. TLS versions 1.2 and 1.3 are supported, with resumption.
Content-Type
All requests made to the API must be encoded as JSON with the Content-Type: application/json header. If not otherwise specified, responses from the Spheron API, including errors, are encoded exclusively as JSON as well.
For new users
Before creating an access token for authentication, we need to sync our GitHub or GitLab account to give Spheron access. Click here for more instructions about granting access to your repository.
Creating an Access Token
Access Tokens can be created and managed from inside your account settings.
Go to your profile icon in your Spheron dashboard app and click on it.
Click on settings from the image above to go to your settings page and navigate to the Tokens in your Account Settings.
Click Create to open a new Access Token.
Enter a descriptive name and choose the scope from the list of Organizations in the drop-down menu and select an expiration date for the token and click create a token.
The scope ensures that only your specified Organization can use an Access Token. Once you've created an Access Token securely store the value as it will not be shown again.
Authentication
Spheron Access Tokens are required to authenticate and use the Spheron API.
Authorization: Bearer <TOKEN>
API Keys
For Project
GET/v1/project/{projectId}/deployments
GET/v1/project/{projectId}/deployments/count
PATCH/v1/project/{projectId}/state
PUT/v1/project/{projectId}/configuration
For Environment Variables
POST/v1/project/{projectId}/environment-variables
PUT/v1/project/{projectId}/environment-variables/{environmentVariableId}
DELETE/v1/project/{projectId}/environment-variables/{environmentVariableId}
For Deployment Environment
GET/v1/project/{projectId}/deployment-environments
POST/v1/project/{projectId}/deployment-environments
PUT/v1/project/{projectId}/deployment-environments/{deploymentEnvironmentId}
DELETE/v1/project/{projectId}/deployment-environments/{deploymentEnvironmentId}
PATCH/v1/project/{projectId}/deployment-environments/{deploymentEnvironmentId}/deactivate
PATCH/v1/project/{projectId}/deployment-environments/{deploymentEnvironmentId}/activate
To Compute machine images
GET/v1/compute-machine-images/regions
API response codes
REST APIs use the Status-Line part of an HTTP response message to inform clients of their request’s overarching result. Spheron API uses standardized status codes from 100 to 511.
| Code | Description |
| 200 | **Successfully fetch Organization information |
Successfully fetch an Array of coupons
Successfully fetch Array of invite users
Successfully fetch Project information
Successfully Added environment variables
Successfully Create a deployment |
| 401 | This means that the request was unauthorized** |
Failed Authentication
If authentication is unsuccessful for a request, the error status code 403 is returned.
References:
Documentation https://docs.spheron.network/rest-api/
API Endpoints https://api-v2.spheron.network/docs/rest-api/