curl --request POST \
--url https://app.gtm-api.com/id/v4/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Team-SID: <api-key>' \
--data '
{
"name": "<string>",
"permissions": [
"<string>"
],
"expires_at": "<string>"
}
'import requests
url = "https://app.gtm-api.com/id/v4/api/api-keys"
payload = {
"name": "<string>",
"permissions": ["<string>"],
"expires_at": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Team-SID": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Team-SID': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', permissions: ['<string>'], expires_at: '<string>'})
};
fetch('https://app.gtm-api.com/id/v4/api/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.gtm-api.com/id/v4/api/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([
'name' => '<string>',
'permissions' => [
'<string>'
],
'expires_at' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Team-SID: <api-key>"
],
]);
$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://app.gtm-api.com/id/v4/api/api-keys"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"permissions\": [\n \"<string>\"\n ],\n \"expires_at\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Team-SID", "<api-key>")
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://app.gtm-api.com/id/v4/api/api-keys")
.header("Authorization", "Bearer <token>")
.header("Team-SID", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"permissions\": [\n \"<string>\"\n ],\n \"expires_at\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.gtm-api.com/id/v4/api/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["Team-SID"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"permissions\": [\n \"<string>\"\n ],\n \"expires_at\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"operation": "create",
"item": {
"sid": "<string>",
"team_sid": "<string>",
"name": "<string>",
"token_prefix": "<string>",
"token_last4": "<string>",
"permissions": [
"<string>"
],
"status": "active",
"expires_at": "<string>",
"last_used_at": "<string>",
"created_by": {
"actor_type": "user",
"actor_sid": "<string>",
"team_sid": "<string>",
"permissions": {},
"request_sid": "<string>",
"reason": "<string>"
},
"created_at": "<string>",
"updated_at": "<string>",
"deleted_at": "<string>",
"plaintext_token": "<string>"
},
"already_exists": true,
"meta": {
"trace_id": "<string>",
"span_id": "<string>",
"timestamp": "<string>",
"duration_ms": 1,
"debug_url": "<string>"
}
}{
"success": false,
"error": {
"code": "validation_failed",
"message": "<string>",
"recoverable": true,
"suggestion": "<string>",
"field_errors": {},
"blockers": [
{
"type": "<string>",
"severity": "hard",
"description": "<string>",
"entity_sid": "<string>",
"resolution": "<string>",
"resolution_hint": "<string>",
"count": 123
}
],
"context": {}
},
"meta": {
"trace_id": "<string>",
"span_id": "<string>",
"timestamp": "<string>",
"duration_ms": 1,
"debug_url": "<string>"
}
}{
"success": false,
"error": {
"code": "validation_failed",
"message": "<string>",
"recoverable": true,
"suggestion": "<string>",
"field_errors": {},
"blockers": [
{
"type": "<string>",
"severity": "hard",
"description": "<string>",
"entity_sid": "<string>",
"resolution": "<string>",
"resolution_hint": "<string>",
"count": 123
}
],
"context": {}
},
"meta": {
"trace_id": "<string>",
"span_id": "<string>",
"timestamp": "<string>",
"duration_ms": 1,
"debug_url": "<string>"
}
}Create API key
Issue a new API key and return the full secret in the create envelope’s plaintext_token EXACTLY ONCE. It is unrecoverable, so hand it to the user immediately and never log or echo it; if lost, rotate. Callable by a human (api_keys.manage) or by a parent api_key, in which case the issued permissions MUST be a subset of the parent’s (downscoping only; escalation → 403). Default expires_at = now + 3 years; pass null for a perpetual key. Natural key (team_sid, name) among non-revoked keys → a duplicate returns already_exists with the existing key (and NO secret).
Contract:
- MCP tool
create_api_key, registry packagemcp.id/api_keys, mountid.access. - Operation
create, response envelopecreate. - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
curl --request POST \
--url https://app.gtm-api.com/id/v4/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Team-SID: <api-key>' \
--data '
{
"name": "<string>",
"permissions": [
"<string>"
],
"expires_at": "<string>"
}
'import requests
url = "https://app.gtm-api.com/id/v4/api/api-keys"
payload = {
"name": "<string>",
"permissions": ["<string>"],
"expires_at": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Team-SID": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Team-SID': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', permissions: ['<string>'], expires_at: '<string>'})
};
fetch('https://app.gtm-api.com/id/v4/api/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.gtm-api.com/id/v4/api/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([
'name' => '<string>',
'permissions' => [
'<string>'
],
'expires_at' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Team-SID: <api-key>"
],
]);
$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://app.gtm-api.com/id/v4/api/api-keys"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"permissions\": [\n \"<string>\"\n ],\n \"expires_at\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Team-SID", "<api-key>")
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://app.gtm-api.com/id/v4/api/api-keys")
.header("Authorization", "Bearer <token>")
.header("Team-SID", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"permissions\": [\n \"<string>\"\n ],\n \"expires_at\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.gtm-api.com/id/v4/api/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["Team-SID"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"permissions\": [\n \"<string>\"\n ],\n \"expires_at\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"operation": "create",
"item": {
"sid": "<string>",
"team_sid": "<string>",
"name": "<string>",
"token_prefix": "<string>",
"token_last4": "<string>",
"permissions": [
"<string>"
],
"status": "active",
"expires_at": "<string>",
"last_used_at": "<string>",
"created_by": {
"actor_type": "user",
"actor_sid": "<string>",
"team_sid": "<string>",
"permissions": {},
"request_sid": "<string>",
"reason": "<string>"
},
"created_at": "<string>",
"updated_at": "<string>",
"deleted_at": "<string>",
"plaintext_token": "<string>"
},
"already_exists": true,
"meta": {
"trace_id": "<string>",
"span_id": "<string>",
"timestamp": "<string>",
"duration_ms": 1,
"debug_url": "<string>"
}
}{
"success": false,
"error": {
"code": "validation_failed",
"message": "<string>",
"recoverable": true,
"suggestion": "<string>",
"field_errors": {},
"blockers": [
{
"type": "<string>",
"severity": "hard",
"description": "<string>",
"entity_sid": "<string>",
"resolution": "<string>",
"resolution_hint": "<string>",
"count": 123
}
],
"context": {}
},
"meta": {
"trace_id": "<string>",
"span_id": "<string>",
"timestamp": "<string>",
"duration_ms": 1,
"debug_url": "<string>"
}
}{
"success": false,
"error": {
"code": "validation_failed",
"message": "<string>",
"recoverable": true,
"suggestion": "<string>",
"field_errors": {},
"blockers": [
{
"type": "<string>",
"severity": "hard",
"description": "<string>",
"entity_sid": "<string>",
"resolution": "<string>",
"resolution_hint": "<string>",
"count": 123
}
],
"context": {}
},
"meta": {
"trace_id": "<string>",
"span_id": "<string>",
"timestamp": "<string>",
"duration_ms": 1,
"debug_url": "<string>"
}
}Authorizations
Access token issued by gtm.service.id. Its access_identity claim carries team_sid, actor_sid and actor_type, and that team scope is authoritative.
Team scope for tokens that do not carry one. Ignored when the token already names a team.
Body
Request body of create_api_key.
Human-readable key name; unique among the team's non-revoked keys.
1 - 255Unified permission list; must be ⊆ the parent key on delegation.
128ISO 8601 UTC; omit = now + 3 years; null = perpetual.