Select programming language for code examples

linkThe key object

Below you will find the various attributes for the key resource, as well as the key resource's relationships. Keys cannot be validated, are not actual "licenses", and are only used for pooled policies.

When creating a pooled policy, you create a limited set of "keys" to fill the pool. Each time a license is created that implements the pooled policy, a "key" is taken from the pool and used for the new license, until the pool is depleted. After a pool has been depleted, new licenses cannot be created from the pooled policy until new keys are added. Pooled policies are usually used for limited betas or promotion deals for the first x users.

These are unused keys within a policy's pool – they are not valid licenses. These are used when creating new licenses for a pooled policy or when using a pool's pop action.

linkAttributes

  • linkdata.attributes.key

    string

    The unique key string for the key.

  • linkdata.attributes.created

    timestamp (iso8601)read only

    When the key was created.

  • linkdata.attributes.updated

    timestamp (iso8601)read only

    When the key was last updated.

linkRelationships

  • linkdata.relationships.account

    individual

    The account that the key belongs to.

  • linkdata.relationships.product

    individual

    The product that the key is associated with.

  • linkdata.relationships.policy

    individual

    The pooled policy that the key belongs to.

Example object

{
"data": {
"id": "6e936a61-94ad-44d1-88ac-88da9f10eca7",
"type": "keys",
"links": {
"self": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7"
},
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3",
"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>"
}
},
"product": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/product"
},
"data": {
"type": "products",
"id": "1f286fb6-c9bb-498b-a4e7-6c67748b1f4f"
}
},
"policy": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/policy"
},
"data": {
"type": "policies",
"id": "95981290-518b-4109-a611-c0001214b3c5"
}
}
}
}
}

linkCreate a key

Creates a new key resource.

linkAuthentication

  • linkBearer

    required

    An authentication token with privileges to create the resource: either an admin, an environment, or the product it belongs to.

linkURL Parameters

  • link<account>

    stringrequired

    The identifier (UUID) or slug of your Keygen account.

linkAttributes

  • linkdata.attributes.key

    stringrequired

    The unique key string for the key. The key cannot collide with license keys that already exist.

linkRelationships

linkReturns

A 201 Created response will be returned along with the new key object.

Upon error, an errors object will be returned along with an HTTP status code indicating the type of error. When an error occurs, the data property will not be included.

Definition

https://api.keygen.sh/v1/accounts/<account>/keys

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/keys", {
method: "POST",
headers: {
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
body: JSON.stringify({
"data": {
"type": "keys",
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3"
},
"relationships": {
"policy": {
"data": {
"type": "policies",
"id": "4ba02145-d1e7-4443-8104-dd1e4236d869"
}
}
}
}
})
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.post(
"https://api.keygen.sh/v1/accounts/<account>/keys",
headers={
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
data=json.dumps({
"data": {
"type": "keys",
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3"
},
"relationships": {
"policy": {
"data": {
"type": "policies",
"id": "4ba02145-d1e7-4443-8104-dd1e4236d869"
}
}
}
}
})
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/keys",
method: .post,
headers: [
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
],
parameters: [
"data": [
"type": "keys",
"attributes": [
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3"
],
"relationships": [
"policy": [
"data": [
"type": "policies",
"id": "4ba02145-d1e7-4443-8104-dd1e4236d869"
]
]
]
]
],
encoding: JSONEncoding.default
).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("keys", Method.POST);
 
request.AddHeader("Content-Type", "application/vnd.api+json");
request.AddHeader("Accept", "application/vnd.api+json");
request.AddHeader("Authorization", "Bearer <token>");
 
request.AddJsonBody(new {
data = new {
type = "keys",
attributes = new {
key = "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3"
},
relationships = new {
policy = new {
data = new {
type = "policies",
id = "4ba02145-d1e7-4443-8104-dd1e4236d869"
}
}
}
}
});
 
var response = client.Execute(request);
import com.mashape.unirest.http.exceptions.*
import com.mashape.unirest.http.*
import org.json.*
 
val body = JSONObject(mapOf(
"data" to mapOf(
"type" to "keys",
"attributes" to mapOf(
"key" to "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3"
),
"relationships" to mapOf(
"policy" to mapOf(
"data" to mapOf(
"type" to "policies",
"id" to "4ba02145-d1e7-4443-8104-dd1e4236d869"
)
)
)
)
))
 
val res = Unirest.post("https://api.keygen.sh/v1/accounts/<account>/keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/vnd.api+json")
.header("Accept", "application/vnd.api+json")
.body(body)
.asJson()
import com.mashape.unirest.http.exceptions.*;
import com.mashape.unirest.http.*;
import org.json.*;
 
import static java.util.Map.ofEntries;
import static java.util.Map.entry;
 
JSONObject body = new JSONObject(ofEntries(
entry("data", ofEntries(
entry("type", "keys"),
entry("attributes", ofEntries(
entry("key", "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3")
)),
entry("relationships", ofEntries(
entry("policy", ofEntries(
entry("data", ofEntries(
entry("type", "policies"),
entry("id", "4ba02145-d1e7-4443-8104-dd1e4236d869")
))
))
))
))
));
 
HttpResponse<JsonNode> res = Unirest.post("https://api.keygen.sh/v1/accounts/<account>/keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/vnd.api+json")
.header("Accept", "application/vnd.api+json")
.body(body)
.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 web::json;
using namespace utility;
 
http_client client("https://api.keygen.sh/v1/accounts/<account>");
http_request req;
 
value attrs;
attrs["key"] = value::string("C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3");
 
value policy_;
policy_["type"] = value::string("policies");
policy_["id"] = value::string("4ba02145-d1e7-4443-8104-dd1e4236d869");
 
value policy;
policy["data"] = policy_;
 
value rels;
rels["policy"] = policy;
 
value data;
data["type"] = value::string("keys");
data["attributes"] = attrs;
data["relationships"] = rels;
 
value body;
body["data"] = data;
 
req.headers().add("Authorization", "Bearer <token>");
req.headers().add("Content-Type", "application/vnd.api+json");
req.headers().add("Accept", "application/json");
 
req.set_request_uri("/keys");
req.set_method(methods::POST);
req.set_body(body.serialize());
 
client.request(req)
.then([](http_response res)
{
auto data = res.extract_json().get();
})
.wait();
curl -X POST https://api.keygen.sh/v1/accounts/<account>/keys \
-H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>' \
-d '{
"data": {
"type": "keys",
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3"
},
"relationships": {
"policy": {
"data": {
"type": "policies",
"id": "4ba02145-d1e7-4443-8104-dd1e4236d869"
}
}
}
}
}'

Example response / 201 Created

{
"data": {
"id": "6e936a61-94ad-44d1-88ac-88da9f10eca7",
"type": "keys",
"links": {
"self": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7"
},
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3",
"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>"
}
},
"product": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/product"
},
"data": {
"type": "products",
"id": "1f286fb6-c9bb-498b-a4e7-6c67748b1f4f"
}
},
"policy": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/policy"
},
"data": {
"type": "policies",
"id": "4ba02145-d1e7-4443-8104-dd1e4236d869"
}
}
}
}
}

linkRetrieve a key

Retrieves the details of an existing key.

linkAuthentication

  • linkBearer

    required

    An authentication token with privileges to view the resource: either an admin, an environment, or the product it belongs to.

linkURL Parameters

  • link<account>

    stringrequired

    The identifier (UUID) or slug of your Keygen account.

  • link<id>

    stringrequired

    The identifier (UUID) of the key to be retrieved.

linkReturns

A 200 OK response will be returned along with a key object.

Upon error, an errors object will be returned along with an HTTP status code indicating the type of error. When an error occurs, the data property will not be included.

Definition

https://api.keygen.sh/v1/accounts/<account>/keys/<id>

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7", {
method: "GET",
headers: {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.get(
"https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7",
headers: [
"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(
"keys/6e936a61-94ad-44d1-88ac-88da9f10eca7",
Method.GET
);
 
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>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7")
.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>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7")
.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("Authorization", "Bearer <token>");
req.headers().add("Accept", "application/json");
 
req.set_request_uri("/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7");
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>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7 \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 200 OK

{
"data": {
"id": "6e936a61-94ad-44d1-88ac-88da9f10eca7",
"type": "keys",
"links": {
"self": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7"
},
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3",
"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>"
}
},
"product": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/product"
},
"data": {
"type": "products",
"id": "1f286fb6-c9bb-498b-a4e7-6c67748b1f4f"
}
},
"policy": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/policy"
},
"data": {
"type": "policies",
"id": "95981290-518b-4109-a611-c0001214b3c5"
}
}
}
}
}

linkUpdate a key

Updates the specified key resource by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

linkAuthentication

  • linkBearer

    required

    An authentication token with privileges to manage the resource: either an admin, an environment, or the product it belongs to.

linkURL Parameters

  • link<account>

    stringrequired

    The identifier (UUID) or slug of your Keygen account.

  • link<id>

    stringrequired

    The identifier (UUID) of the key to be updated.

linkAttributes

  • linkdata.attributes.key

    stringoptional

    The unique key string for the key.

linkReturns

A 200 OK response will be returned along with the updated key object.

Upon error, an errors object will be returned along with an HTTP status code indicating the type of error. When an error occurs, the data property will not be included.

Definition

https://api.keygen.sh/v1/accounts/<account>/keys/<id>

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827", {
method: "PATCH",
headers: {
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
body: JSON.stringify({
"data": {
"type": "keys",
"attributes": {
"key": "9adce-26df1-9c487-nb293-d0279"
}
}
})
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.patch(
"https://api.keygen.sh/v1/accounts/<account>/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827",
headers={
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
data=json.dumps({
"data": {
"type": "keys",
"attributes": {
"key": "9adce-26df1-9c487-nb293-d0279"
}
}
})
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827",
method: .patch,
headers: [
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
],
parameters: [
"data": [
"type": "keys",
"attributes": [
"key": "9adce-26df1-9c487-nb293-d0279"
]
]
],
encoding: JSONEncoding.default
).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(
"keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827",
Method.PATCH
);
 
request.AddHeader("Content-Type", "application/vnd.api+json");
request.AddHeader("Accept", "application/vnd.api+json");
request.AddHeader("Authorization", "Bearer <token>");
 
request.AddJsonBody(new {
data = new {
type = "keys",
attributes = new {
key = "9adce-26df1-9c487-nb293-d0279"
}
}
});
 
var response = client.Execute(request);
import com.mashape.unirest.http.exceptions.*
import com.mashape.unirest.http.*
import org.json.*
 
val body = JSONObject(mapOf(
"data" to mapOf(
"type" to "keys",
"attributes" to mapOf(
"key" to "9adce-26df1-9c487-nb293-d0279"
)
)
))
 
val res = Unirest.patch("https://api.keygen.sh/v1/accounts/<account>/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/vnd.api+json")
.header("Accept", "application/vnd.api+json")
.body(body)
.asJson()
import com.mashape.unirest.http.exceptions.*;
import com.mashape.unirest.http.*;
import org.json.*;
 
import static java.util.Map.ofEntries;
import static java.util.Map.entry;
 
JSONObject body = new JSONObject(ofEntries(
entry("data", ofEntries(
entry("type", "keys"),
entry("attributes", ofEntries(
entry("key", "9adce-26df1-9c487-nb293-d0279")
))
))
));
 
HttpResponse<JsonNode> res = Unirest.patch("https://api.keygen.sh/v1/accounts/<account>/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/vnd.api+json")
.header("Accept", "application/vnd.api+json")
.body(body)
.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 web::json;
using namespace utility;
 
http_client client("https://api.keygen.sh/v1/accounts/<account>");
http_request req;
 
value attrs;
attrs["key"] = value::string("9adce-26df1-9c487-nb293-d0279");
 
value data;
data["type"] = value::string("keys");
data["attributes"] = attrs;
 
value body;
body["data"] = data;
 
req.headers().add("Authorization", "Bearer <token>");
req.headers().add("Content-Type", "application/vnd.api+json");
req.headers().add("Accept", "application/json");
 
req.set_request_uri("/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827");
req.set_method(methods::PATCH);
req.set_body(body.serialize());
 
client.request(req)
.then([](http_response res)
{
auto data = res.extract_json().get();
})
.wait();
curl -X PATCH https://api.keygen.sh/v1/accounts/<account>/keys/b18e3f3a-330c-4d8d-ae2e-014db21fa827 \
-H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>' \
-d '{
"data": {
"type": "keys",
"attributes": {
"key": "9adce-26df1-9c487-nb293-d0279"
}
}
}'

Example response / 200 OK

{
"data": {
"id": "6e936a61-94ad-44d1-88ac-88da9f10eca7",
"type": "keys",
"links": {
"self": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7"
},
"attributes": {
"key": "9adce-26df1-9c487-nb293-d0279",
"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>"
}
},
"product": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/product"
},
"data": {
"type": "products",
"id": "1f286fb6-c9bb-498b-a4e7-6c67748b1f4f"
}
},
"policy": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/policy"
},
"data": {
"type": "policies",
"id": "95981290-518b-4109-a611-c0001214b3c5"
}
}
}
}
}

linkDelete a key

Permanently deletes a key. It cannot be undone.

linkAuthentication

  • linkBearer

    required

    An authentication token with privileges to manage the resource: either an admin, an environment, or the product it belongs to.

linkURL Parameters

  • link<account>

    stringrequired

    The identifier (UUID) or slug of your Keygen account.

  • link<id>

    stringrequired

    The identifier (UUID) of the key to be deleted.

linkReturns

A 204 No Content response will be returned.

Upon error, an errors object will be returned along with an HTTP status code indicating the type of error. When an error occurs, the data property will not be included.

Definition

https://api.keygen.sh/v1/accounts/<account>/keys/<id>

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7", {
method: "DELETE",
headers: {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
})
import requests
 
res = requests.delete(
"https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
)
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7",
method: .delete,
headers: [
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
]
).responseJSON { response in
let status = response.response?.statusCode
}
using RestSharp;
 
var client = new RestClient("https://api.keygen.sh/v1/accounts/<account>");
var request = new RestRequest(
"keys/6e936a61-94ad-44d1-88ac-88da9f10eca7",
Method.DELETE
);
 
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.delete("https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7")
.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.delete("https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7")
.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("Authorization", "Bearer <token>");
req.headers().add("Accept", "application/json");
 
req.set_request_uri("/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7");
req.set_method(methods::DELETE);
 
client.request(req)
.then([](http_response res) {
auto status = res.status_code();
})
.wait();
curl -X DELETE https://api.keygen.sh/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7 \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 204 No Content

No content

linkList all keys

Returns a list of keys. The keys are returned sorted by creation date, with the most recent keys appearing first. Resources are automatically scoped to the authenticated bearer e.g. when authenticated as a product, only keys of that specific product will be listed.

linkAuthentication

  • linkBearer

    required

    An authentication token with privileges to view the resources: either an admin, an environment, or the product it belongs to.

linkURL Parameters

  • link<account>

    stringrequired

    The identifier (UUID) or slug of your Keygen account.

linkQuery Parameters

  • linklimit

    integerdefault=10

    A limit on the number of keys to be returned. Limit must be a number between 1 and 100.

    /v1/accounts/<account>/keys?limit=25
  • linkpage

    object<string, integer>

    Object containing page size and page number. Page size must be a number between 1 and 100.

    /v1/accounts/<account>/keys?page[size]=15&page[number]=2
  • linkproduct

    string

    The identifier (UUID) of the product to filter by.

    /v1/accounts/<account>/keys?product=3ab38aae-bbf7-4846-9c32-af9d94bf5ad4
  • linkpolicy

    string

    The identifier (UUID) of the policy to filter by.

    /v1/accounts/<account>/keys?policy=92ec8aa5-8f93-4e46-b356-4e54c16647be

linkReturns

A 200 OK response will be returned along with a list of key objects.

Upon error, an errors object will be returned along with an HTTP status code indicating the type of error. When an error occurs, the data property will not be included.

Definition

https://api.keygen.sh/v1/accounts/<account>/keys

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/keys?limit=15", {
method: "GET",
headers: {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.get(
"https://api.keygen.sh/v1/accounts/<account>/keys?limit=15",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/keys?limit=15",
headers: [
"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("keys", Method.GET);
 
request.AddHeader("Accept", "application/vnd.api+json");
request.AddHeader("Authorization", "Bearer <token>");
 
request.AddParameter("limit", 15);
 
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>/keys")
.header("Authorization", "Bearer <token>")
.header("Accept", "application/vnd.api+json")
.queryString("limit", 15)
.asJson()
import com.mashape.unirest.http.exceptions.*;
import com.mashape.unirest.http.*;
 
HttpResponse<JsonNode> res = Unirest.get("https://api.keygen.sh/v1/accounts/<account>/keys")
.header("Authorization", "Bearer <token>")
.header("Accept", "application/vnd.api+json")
.queryString("limit", 15)
.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("Authorization", "Bearer <token>");
req.headers().add("Accept", "application/json");
 
uri_builder uri("/keys");
uri.append_query("limit", 15);
 
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>/keys?limit=15 -g \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 200 OK

{
"data": [
{
"id": "6e936a61-94ad-44d1-88ac-88da9f10eca7",
"type": "keys",
"links": {
"self": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7"
},
"attributes": {
"key": "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3",
"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>"
}
},
"product": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/product"
},
"data": {
"type": "products",
"id": "1f286fb6-c9bb-498b-a4e7-6c67748b1f4f"
}
},
"policy": {
"links": {
"related": "/v1/accounts/<account>/keys/6e936a61-94ad-44d1-88ac-88da9f10eca7/policy"
},
"data": {
"type": "policies",
"id": "95981290-518b-4109-a611-c0001214b3c5"
}
}
}
},
]
}