Select programming language for code examples

linkThe product object

Below you will find the various attributes for the product resource, as well as the product resource's relationships.

linkAttributes

  • linkdata.attributes.name

    string

    The name of the product.

  • linkdata.attributes.code

    string

    The unique code, or 'slug', for the product. The code cannot collide with any products that already exist.

  • linkdata.attributes.url

    string

    A related URL for the product e.g. the marketing website, company website, etc.

  • linkdata.attributes.distributionStrategy

    stringdefault=LICENSED

    The strategy for distributing releases.

    Options
    • LICENSED: Only licensed users, with a valid license, can access releases and release artifacts. API authentication is required.
    • OPEN: Anybody can access releases. No API authentication required, so this is a great option for rendering releases on a public downloads page, open source projects, or freemium products.
    • CLOSED: Only admins can access releases. Download links will need to be generated server-side. API authentication is required.
  • linkdata.attributes.platforms

    array<string>

    An array of platforms the product supports.

  • linkdata.attributes.permissions

    array<string>ent onlyThese attributes are only available for accounts on an Ent tier.

    The permissions for the product. Default and available permissions are covered here.

  • linkdata.attributes.metadata

    object<string, any>

    Object containing product metadata.

  • linkdata.attributes.created

    timestamp (iso8601)read only

    When the product was created.

  • linkdata.attributes.updated

    timestamp (iso8601)read only

    When the product was last updated.

linkRelationships

  • linkdata.relationships.account

    individual

    The account that the product belongs to.

  • linkdata.relationships.environment

    individualent onlyThese relationships are only available for accounts on an Ent tier.

    The environment that the product belongs to.

  • linkdata.relationships.policies

    collection

    The policies that are associated with the product.

  • linkdata.relationships.licenses

    collection

    The licenses that are associated with the product.

  • linkdata.relationships.machines

    collection

    The machines that are associated with the product.

  • linkdata.relationships.users

    collection

    The users that own a license for the product.

  • linkdata.relationships.tokens

    collection

    The authentication tokens of the product.

Example object

{
"data": {
"id": "31339351-f7f5-4bdd-8346-5d8399a1ac07",
"type": "products",
"links": {
"self": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07"
},
"attributes": {
"name": "Example App",
"code": "example",
"distributionStrategy": "OPEN",
"url": "https://example.com",
"platforms": [],
"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>"
}
},
"policies": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/policies"
}
},
"licenses": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/licenses"
}
},
"machines": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/machines"
}
},
"users": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/users"
}
},
"tokens": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens"
}
}
}
}
}

linkCreate a product

Creates a new product resource.

linkAuthentication

  • linkBearer

    required

    An authentication token with admin privileges.

linkURL Parameters

  • link<account>

    stringrequired

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

linkAttributes

  • linkdata.attributes.name

    stringrequired

    The name of the product.

  • linkdata.attributes.code

    stringrequired

    The unique code, or 'slug', for the product. The code cannot collide with any products that already exist.

  • linkdata.attributes.url

    stringoptional

    A related URL for the product e.g. the marketing website, company website, etc. Must be a valid URL.

  • linkdata.attributes.distributionStrategy

    stringoptionaldefault=LICENSED

    The strategy for distributing releases.

    Options
    • LICENSED: Only licensed users, with a valid license, can access releases and release artifacts. API authentication is required.
    • OPEN: Anybody can access releases. No API authentication required, so this is a great option for rendering releases on a public downloads page, open source projects, or freemium products.
    • CLOSED: Only admins can access releases. Download links will need to be generated server-side. API authentication is required.
  • linkdata.attributes.platforms

    array<string>optional

    An array of platforms the product supports.

  • linkdata.attributes.permissions

    array<string>ent onlyThese attributes are only available for accounts on an Ent tier.

    The permissions for the product. Default and available permissions are covered here.

  • linkdata.attributes.metadata

    object<string, any>optional

    Object containing product metadata.

linkReturns

A 201 Created response will be returned along with the new product 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>/products

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/products", {
method: "POST",
headers: {
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
body: JSON.stringify({
"data": {
"type": "products",
"attributes": {
"name": "Example On-Premise",
"url": "https://example.com",
"platforms": ["iOS", "Android"]
}
}
})
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.post(
"https://api.keygen.sh/v1/accounts/<account>/products",
headers={
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
data=json.dumps({
"data": {
"type": "products",
"attributes": {
"name": "Example On-Premise",
"url": "https://example.com",
"platforms": ["iOS", "Android"]
}
}
})
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/products",
method: .post,
headers: [
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
],
parameters: [
"data": [
"type": "products",
"attributes": [
"name": "Example On-Premise",
"url": "https://example.com",
"platforms": ["iOS", "Android"]
]
]
],
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("products", 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 = "products",
attributes = new {
name = "Example On-Premise",
url = "https://example.com",
platforms = new[] { "iOS", "Android" }
}
}
});
 
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 "products",
"attributes" to mapOf(
"name" to "Example On-Premise",
"url" to "https://example.com",
"platforms" to listOf("iOS", "Android")
)
)
))
 
val res = Unirest.post("https://api.keygen.sh/v1/accounts/<account>/products")
.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;
import static java.util.List.of;
 
JSONObject body = new JSONObject(ofEntries(
entry("data", ofEntries(
entry("type", "products"),
entry("attributes", ofEntries(
entry("name", "Example On-Premise"),
entry("url", "https://example.com"),
entry("platforms", of("iOS", "Android"))
))
))
));
 
HttpResponse<JsonNode> res = Unirest.post("https://api.keygen.sh/v1/accounts/<account>/products")
.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 platforms;
platforms[0] = value::string("iOS");
platforms[1] = value::string("Android");
 
value attrs;
attrs["name"] = value::string("Example On-Premise");
attrs["url"] = value::string("https://example.com");
attrs["platforms"] = platforms;
 
value data;
data["type"] = value::string("products");
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("/products");
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>/products \
-H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>' \
-d '{
"data": {
"type": "products",
"attributes": {
"name": "Example On-Premise",
"url": "https://example.com",
"platforms": ["iOS", "Android"]
}
}
}'

Example response / 201 Created

{
"data": {
"id": "31339351-f7f5-4bdd-8346-5d8399a1ac07",
"type": "products",
"links": {
"self": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07"
},
"attributes": {
"name": "Example On-Premise",
"code": "on-prem",
"distributionStrategy": "LICENSED",
"url": "https://example.com",
"platforms": ["linux"],
"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>"
}
},
"policies": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/policies"
}
},
"licenses": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/licenses"
}
},
"machines": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/machines"
}
},
"users": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/users"
}
},
"tokens": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens"
}
}
}
}
}

linkRetrieve a product

Retrieves the details of an existing product.

linkAuthentication

  • linkBearer

    required

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

linkURL Parameters

  • link<account>

    stringrequired

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

  • link<id>

    stringrequired

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

linkReturns

A 200 OK response will be returned along with a product 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>/products/<id>

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07", {
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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
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(
"products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07")
.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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07")
.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("/products/31339351-f7f5-4bdd-8346-5d8399a1ac07");
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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07 \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 200 OK

{
"data": {
"id": "31339351-f7f5-4bdd-8346-5d8399a1ac07",
"type": "products",
"links": {
"self": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07"
},
"attributes": {
"name": "Example App",
"code": "example",
"distributionStrategy": "OPEN",
"url": "https://example.com",
"platforms": [],
"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>"
}
},
"policies": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/policies"
}
},
"licenses": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/licenses"
}
},
"machines": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/machines"
}
},
"users": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/users"
}
},
"tokens": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens"
}
}
}
}
}

linkUpdate a product

Updates the specified product 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.

linkURL Parameters

  • link<account>

    stringrequired

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

  • link<id>

    stringrequired

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

linkAttributes

  • linkdata.attributes.name

    stringoptional

    The name of the product.

  • linkdata.attributes.code

    stringoptional

    The unique code, or 'slug', for the product. The code cannot collide with any products that already exist.

  • linkdata.attributes.url

    stringoptional

    A related URL for the product e.g. the marketing website, company website, etc. Must be a valid URL.

  • linkdata.attributes.distributionStrategy

    stringoptional

    The strategy for distributing releases.

    Options
    • LICENSED: Only licensed users, with a valid license, can access releases and release artifacts. API authentication is required.
    • OPEN: Anybody can access releases. No API authentication required, so this is a great option for rendering releases on a public downloads page, open source projects, or freemium products.
    • CLOSED: Only admins can access releases. Download links will need to be generated server-side. API authentication is required.
  • linkdata.attributes.platforms

    array<string>optional

    An array of platforms the product supports.

  • linkdata.attributes.permissions

    array<string>ent onlyThese attributes are only available for accounts on an Ent tier.

    The permissions for the product. Default and available permissions are covered here.

  • linkdata.attributes.metadata

    object<string, any>optional

    Object containing product metadata.

linkReturns

A 200 OK response will be returned along with the updated product 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>/products/<id>

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07", {
method: "PATCH",
headers: {
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
body: JSON.stringify({
"data": {
"type": "products",
"attributes": {
"platforms": [
"iOS",
"Android",
"Windows"
]
}
}
})
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.patch(
"https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
headers={
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
},
data=json.dumps({
"data": {
"type": "products",
"attributes": {
"platforms": [
"iOS",
"Android",
"Windows"
]
}
}
})
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
method: .patch,
headers: [
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
],
parameters: [
"data": [
"type": "products",
"attributes": [
"platforms": [
"iOS",
"Android",
"Windows"
]
]
]
],
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(
"products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
Method.PATCH
);
 
request.AddHeader("Accept", "application/vnd.api+json");
request.AddHeader("Authorization", "Bearer <token>");
 
request.AddJsonBody(new {
data = new {
type = "products",
attributes = new {
platforms = new[] { "iOS", "Android", "Windows" }
}
}
});
 
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 "products",
"attributes" to mapOf(
"platforms" to listOf("iOS", "Android", "Windows")
)
)
))
 
val res = Unirest.patch("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07")
.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;
import static java.util.List.of;
 
JSONObject body = new JSONObject(ofEntries(
entry("data", ofEntries(
entry("type", "products"),
entry("attributes", ofEntries(
entry("platforms", of("iOS", "Android", "Windows"))
))
))
));
 
HttpResponse<JsonNode> res = Unirest.patch("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07")
.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 platforms;
platforms[0] = value::string("iOS");
platforms[1] = value::string("Android");
platforms[2] = value::string("Windows");
 
value attrs;
attrs["platforms"] = platforms;
 
value data;
data["type"] = value::string("products");
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("/products/31339351-f7f5-4bdd-8346-5d8399a1ac07");
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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07 \
-H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>' \
-d '{
"data": {
"type": "products",
"attributes": {
"platforms": [
"iOS",
"Android",
"Windows"
]
}
}
}'

Example response / 200 OK

{
"data": {
"id": "31339351-f7f5-4bdd-8346-5d8399a1ac07",
"type": "products",
"links": {
"self": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07"
},
"attributes": {
"name": "Example App",
"code": "example",
"distributionStrategy": "OPEN",
"url": "https://example.com",
"platforms": [],
"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>"
}
},
"policies": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/policies"
}
},
"licenses": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/licenses"
}
},
"machines": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/machines"
}
},
"users": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/users"
}
},
"tokens": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens"
}
}
}
}
}

linkDelete a product

Permanently deletes a product. It cannot be undone. This action also immediately deletes any policies, licenses and machines that the product is associated with.

linkAuthentication

  • linkBearer

    required

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

linkURL Parameters

  • link<account>

    stringrequired

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

  • link<id>

    stringrequired

    The identifier (UUID) of the product 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>/products/<id>

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07", {
method: "DELETE",
headers: {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
})
import requests
 
res = requests.delete(
"https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
)
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
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(
"products/31339351-f7f5-4bdd-8346-5d8399a1ac07",
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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07")
.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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07")
.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("/products/31339351-f7f5-4bdd-8346-5d8399a1ac07");
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>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07 \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 204 No Content

No content

linkList all products

Returns a list of products. The products are returned sorted by creation date, with the most recent products appearing first.

linkAuthentication

  • linkBearer

    required

    An authentication token with admin privileges.

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 products to be returned. Limit must be a number between 1 and 100.

    /v1/accounts/<account>/products?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>/products?page[size]=15&page[number]=2

linkReturns

A 200 OK response will be returned along with a list of product 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>/products

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/products?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>/products?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>/products?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("products", 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>/products")
.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>/products")
.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("/products");
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>/products?limit=15 -g \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 200 OK

{
"data": [
{
"id": "31339351-f7f5-4bdd-8346-5d8399a1ac07",
"type": "products",
"links": {
"self": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07"
},
"attributes": {
"name": "Example App",
"code": "example",
"distributionStrategy": "OPEN",
"url": "https://example.com",
"platforms": [],
"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>"
}
},
"policies": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/policies"
}
},
"licenses": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/licenses"
}
},
"machines": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/machines"
}
},
"users": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/users"
}
},
"tokens": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens"
}
}
}
},
]
}

linkGenerate a product token

Generates a new product token resource. Product tokens do not expire.

Product tokens should not be included in any client-facing code, as they offer full access to all of the product's resources. Only use these tokens server-side e.g. to integrate Keygen into a backend system, consume webhooks, or to manage resources in response to events from your payment provider.

linkAuthentication

  • linkBearer

    required

    An authentication token with admin privileges.

linkURL Parameters

  • link<account>

    stringrequired

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

  • link<id>

    stringrequired

    The identifier (UUID) of the product to generate a token for.

linkAttributes

  • linkdata.attributes.name

    stringoptional

    An optional name for the token. This can be used to easily identify tokens at a glance.

  • linkdata.attributes.expiry

    timestamp (iso8601)optional

    The timestamp for when the token expires. Requests using an expired token will be rejected.

  • linkdata.attributes.permissions

    array<string>default=["*"]ent onlyThese attributes are only available for accounts on an Ent tier.

    The permissions for the token. Available permissions, dependent on the bearer, are covered here. By default, it is set to a wildcard `*`, which inherits all permissions from the token bearer.

linkReturns

A 200 OK response will be returned along with the new token object. The token attribute of the token object, which is used for authentication, is ONLY readable directly after creation. Please securely store this value for later use, otherwise the token may need to be regenerated.

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>/products/<id>/tokens

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens", {
method: "POST",
headers: {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
})
 
const { data, errors } = await response.json()
import requests
import json
 
res = requests.post(
"https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer <token>"
}
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens",
method: .post,
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(
"products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens",
Method.POST
);
 
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.post("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens")
.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.post("https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens")
.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("/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens");
req.set_method(methods::POST);
 
client.request(req)
.then([](http_response res) {
auto data = res.extract_json().get();
})
.wait();
curl -X POST https://api.keygen.sh/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07/tokens \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <token>'

Example response / 200 OK

{
"data": {
"id": "07d52aa8-b96c-4b55-b05d-f5f570e1775a",
"type": "tokens",
"attributes": {
"kind": "product-token",
"token": "prod-2ddd064509b6bcaa356958dcce6da3a538919e13ddbc26b359fb374ff89dfacav3",
"expiry": "2022-03-15T19:27:50.440Z",
"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>"
}
},
"bearer": {
"links": {
"related": "/v1/accounts/<account>/products/31339351-f7f5-4bdd-8346-5d8399a1ac07"
},
"data": {
"type": "products",
"id": "31339351-f7f5-4bdd-8346-5d8399a1ac07"
}
}
}
}
}