import Whop from '@whop/sdk';
const client = new Whop({
apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});
const response = await client.companies.createAPIKey('parent_company_id', {
child_company_id: 'child_company_id',
});
console.log(response.id);curl --request POST \
--url https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"child_company_id": "<string>",
"name": "<string>",
"permissions": [
{
"actions": [
"<string>"
],
"grant": true,
"resources": [
"<string>"
]
}
]
}
'import requests
url = "https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys"
payload = {
"child_company_id": "<string>",
"name": "<string>",
"permissions": [
{
"actions": ["<string>"],
"grant": True,
"resources": ["<string>"]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'child_company_id' => '<string>',
'name' => '<string>',
'permissions' => [
[
'actions' => [
'<string>'
],
'grant' => true,
'resources' => [
'<string>'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys"
payload := strings.NewReader("{\n \"child_company_id\": \"<string>\",\n \"name\": \"<string>\",\n \"permissions\": [\n {\n \"actions\": [\n \"<string>\"\n ],\n \"grant\": true,\n \"resources\": [\n \"<string>\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"child_company_id\": \"<string>\",\n \"name\": \"<string>\",\n \"permissions\": [\n {\n \"actions\": [\n \"<string>\"\n ],\n \"grant\": true,\n \"resources\": [\n \"<string>\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"child_company_id\": \"<string>\",\n \"name\": \"<string>\",\n \"permissions\": [\n {\n \"actions\": [\n \"<string>\"\n ],\n \"grant\": true,\n \"resources\": [\n \"<string>\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"secret_key": "<string>"
}{
"error": {
"code": "parameter_missing",
"message": "Missing required parameter: amount.",
"param": "amount",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Invalid or missing API key",
"type": "unauthorized"
}
}{
"error": {
"message": "You do not have permission to access this resource",
"type": "forbidden"
}
}{
"error": {
"message": "Resource not found",
"type": "not_found"
}
}{
"error": null
}{
"error": null
}{
"error": {
"message": "An unexpected error occurred",
"type": "internal_server_error"
}
}Create child company API key
Create an API key for a connected account (child company) owned by a parent company.
import Whop from '@whop/sdk';
const client = new Whop({
apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});
const response = await client.companies.createAPIKey('parent_company_id', {
child_company_id: 'child_company_id',
});
console.log(response.id);curl --request POST \
--url https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"child_company_id": "<string>",
"name": "<string>",
"permissions": [
{
"actions": [
"<string>"
],
"grant": true,
"resources": [
"<string>"
]
}
]
}
'import requests
url = "https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys"
payload = {
"child_company_id": "<string>",
"name": "<string>",
"permissions": [
{
"actions": ["<string>"],
"grant": True,
"resources": ["<string>"]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'child_company_id' => '<string>',
'name' => '<string>',
'permissions' => [
[
'actions' => [
'<string>'
],
'grant' => true,
'resources' => [
'<string>'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys"
payload := strings.NewReader("{\n \"child_company_id\": \"<string>\",\n \"name\": \"<string>\",\n \"permissions\": [\n {\n \"actions\": [\n \"<string>\"\n ],\n \"grant\": true,\n \"resources\": [\n \"<string>\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"child_company_id\": \"<string>\",\n \"name\": \"<string>\",\n \"permissions\": [\n {\n \"actions\": [\n \"<string>\"\n ],\n \"grant\": true,\n \"resources\": [\n \"<string>\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.whop.com/api/v1/companies/{parent_company_id}/api_keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"child_company_id\": \"<string>\",\n \"name\": \"<string>\",\n \"permissions\": [\n {\n \"actions\": [\n \"<string>\"\n ],\n \"grant\": true,\n \"resources\": [\n \"<string>\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"secret_key": "<string>"
}{
"error": {
"code": "parameter_missing",
"message": "Missing required parameter: amount.",
"param": "amount",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Invalid or missing API key",
"type": "unauthorized"
}
}{
"error": {
"message": "You do not have permission to access this resource",
"type": "forbidden"
}
}{
"error": {
"message": "Resource not found",
"type": "not_found"
}
}{
"error": null
}{
"error": null
}{
"error": {
"message": "An unexpected error occurred",
"type": "internal_server_error"
}
}Authorizations
A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************
Path Parameters
The unique identifier of the parent platform company (e.g. 'biz_xxx').
Body
Parameters for CreateChildCompanyApiKey
The unique identifier of the connected account to create the API key for (e.g. 'biz_xxx').
A human-readable name for the API key, such as 'Production API Key'.
Granular permission statements defining which actions this API key can perform. Either permissions or role must be provided.
Show child attributes
Show child attributes
A system role to inherit permissions from (e.g. owner, admin, moderator). Either role or permissions must be provided.
owner, admin, moderator, sales_manager, advertiser Response
A successful response
An API key created for a child company, including the one-time secret key.

