Select programming language for code examples

linkSandbox

For a sandbox environment, please create an isolated environment with a sandbox code.

The environment can then be provided via a request header:

Keygen-Environment: sandbox

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/licenses", {
method: "GET",
headers: {
"Keygen-Environment": "sandbox",
Accept: "application/vnd.api+json",
Authorization: "Bearer <token>",
}
})
 
const { data, links, errors } = await response.json()
import requests
import json
 
res = requests.get(
"https://api.keygen.sh/v1/accounts/<account>/licenses",
headers={
"Keygen-Environment": "sandbox",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/licenses",
headers: [
"Keygen-Environment": "sandbox",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
]
).responseJSON { response in
let json = JSON(data: response.data!)
}
using RestSharp;
 
var client = new RestClient("https://api.keygen.sh/v1/accounts/<account>");
var request = new RestRequest("licenses", Method.GET);
 
request.AddHeader("Keygen-Environment", "sandbox");
request.AddHeader("Accept", "application/vnd.api+json");
request.AddHeader("Authorization", "Bearer <token>");
 
var response = client.Execute(request);
import com.mashape.unirest.http.exceptions.*
import com.mashape.unirest.http.*
 
val res = Unirest.get("https://api.keygen.sh/v1/accounts/<account>/licenses")
.header("Keygen-Environment", "sandbox")
.header("Authorization", "Bearer <token>")
.header("Accept", "application/vnd.api+json")
.asJson()
import com.mashape.unirest.http.exceptions.*;
import com.mashape.unirest.http.*;
 
HttpResponse<JsonNode> res = Unirest.get("https://api.keygen.sh/v1/accounts/<account>/licenses")
.header("Keygen-Environment", "sandbox")
.header("Authorization", "Bearer <token>")
.header("Accept", "application/vnd.api+json")
.asJson();
#include <iostream>
#include <string>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
 
using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;
using namespace utility;
 
http_client client("https://api.keygen.sh/v1/accounts/<account>");
http_request req;
 
req.headers().add("Keygen-Environment", "sandbox");
req.headers().add("Authorization", "Bearer <token>");
req.headers().add("Accept", "application/json");
 
uri_builder uri("/licenses");
 
req.set_request_uri(uri.to_uri());
req.set_method(methods::GET);
 
client.request(req)
.then([](http_response res) {
auto data = res.extract_json().get();
})
.wait();
curl 'https://api.keygen.sh/v1/accounts/<account>/licenses' -g \
-H 'Keygen-Environment: sandbox' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response

{
"data": [
{
"id": "b18e3f3a-330c-4d8d-ae2e-014db21fa827",
"type": "licenses",
"links": {
"self": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827"
},
"attributes": {
"name": null,
"key": "6DFB15-6597FC-B7DBB6-E34DAB-9D77C0-V3",
"expiry": "2022-03-15T19:27:50.440Z",
"status": "ACTIVE",
"uses": 0,
"protected": false,
"version": "1.0.0",
"suspended": false,
"scheme": null,
"encrypted": false,
"floating": false,
"strict": false,
"maxMachines": 1,
"maxProcesses": null,
"maxUsers": null,
"maxCores": 64,
"maxUses": null,
"requireHeartbeat": false,
"requireCheckIn": false,
"lastValidated": "2021-03-15T19:27:50.440Z",
"lastCheckOut": null,
"lastCheckIn": null,
"nextCheckIn": null,
"metadata": {},
"created": "2017-01-02T20:26:53.464Z",
"updated": "2017-01-02T20:26:53.464Z"
},
"relationships": {
"account": {
"links": {
"related": "/v1/accounts/<account>"
},
"data": {
"type": "accounts",
"id": "<account>"
}
},
"environment": {
"links": {
"related": "/v1/accounts/<account>/environments/b3ee7987-5309-4c61-9df1-c156a216db7a"
},
"data": {
"type": "environments",
"id": "b3ee7987-5309-4c61-9df1-c156a216db7a"
}
},
"product": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/product"
},
"data": {
"type": "products",
"id": "eb4e14a7-ea41-4ede-b3fe-5e835c17156b"
}
},
"policy": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/policy"
},
"data": {
"type": "policies",
"id": "37b632f4-8e1e-4af9-8717-634765364628"
}
},
"group": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/group"
},
"data": null
},
"owner": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/owner"
},
"data": {
"type": "users",
"id": "015a33dd-3aca-43a9-8786-328042cce30a"
}
},
"users": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/users"
}
},
"machines": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/machines"
},
"meta": {
"count": 1
}
},
"tokens": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/tokens"
}
},
"entitlements": {
"links": {
"related": "/v1/accounts/<account>/licenses/b18e3f3a-330c-4d8d-ae2e-014db21fa827/entitlements"
}
}
}
},
]
}