Update an organization API key
curl --request PATCH \
--url https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId} \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme Growth Workspace",
"allowed_origins": [
"https://app.acme.co/signup"
],
"scopes": [
"*"
]
}
'import requests
url = "https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}"
payload = {
"name": "Acme Growth Workspace",
"allowed_origins": ["https://app.acme.co/signup"],
"scopes": ["*"]
}
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Acme Growth Workspace',
allowed_origins: ['https://app.acme.co/signup'],
scopes: ['*']
})
};
fetch('https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}"
payload := strings.NewReader("{\n \"name\": \"Acme Growth Workspace\",\n \"allowed_origins\": [\n \"https://app.acme.co/signup\"\n ],\n \"scopes\": [\n \"*\"\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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))
}require 'uri'
require 'net/http'
url = URI("https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Acme Growth Workspace\",\n \"allowed_origins\": [\n \"https://app.acme.co/signup\"\n ],\n \"scopes\": [\n \"*\"\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Acme Growth Workspace',
'allowed_origins' => [
'https://app.acme.co/signup'
],
'scopes' => [
'*'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"object": "api_key",
"id": "key_6cw04zdmetw8t5rsdppadhper0",
"type": "publishable",
"environment": "live",
"name": "Acme Growth Workspace",
"status": "active",
"allowed_origins": [
"https://app.acme.co/signup"
],
"scopes": [
"*"
],
"rate_limit": 1,
"key_preview": "FOIL_SAMPLE_KEY",
"display_key": "FOIL_SAMPLE_KEY",
"revealed_key": "FOIL_SAMPLE_KEY",
"last_used_at": "2026-03-24T20:00:05.000Z",
"created_at": "2026-03-24T20:00:00.000Z",
"rotated_at": "2026-03-24T20:00:05.000Z",
"revoked_at": "2026-03-24T20:00:05.000Z",
"grace_expires_at": "2026-03-24T20:00:05.000Z"
},
"meta": {
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1"
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}API keys
Update an organization API key
Requires the api_keys:manage secret-key scope.
PATCH
/
v1
/
organizations
/
{organizationId}
/
api-keys
/
{keyId}
Update an organization API key
curl --request PATCH \
--url https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId} \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme Growth Workspace",
"allowed_origins": [
"https://app.acme.co/signup"
],
"scopes": [
"*"
]
}
'import requests
url = "https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}"
payload = {
"name": "Acme Growth Workspace",
"allowed_origins": ["https://app.acme.co/signup"],
"scopes": ["*"]
}
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Acme Growth Workspace',
allowed_origins: ['https://app.acme.co/signup'],
scopes: ['*']
})
};
fetch('https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}"
payload := strings.NewReader("{\n \"name\": \"Acme Growth Workspace\",\n \"allowed_origins\": [\n \"https://app.acme.co/signup\"\n ],\n \"scopes\": [\n \"*\"\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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))
}require 'uri'
require 'net/http'
url = URI("https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Acme Growth Workspace\",\n \"allowed_origins\": [\n \"https://app.acme.co/signup\"\n ],\n \"scopes\": [\n \"*\"\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usefoil.com/v1/organizations/{organizationId}/api-keys/{keyId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Acme Growth Workspace',
'allowed_origins' => [
'https://app.acme.co/signup'
],
'scopes' => [
'*'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"object": "api_key",
"id": "key_6cw04zdmetw8t5rsdppadhper0",
"type": "publishable",
"environment": "live",
"name": "Acme Growth Workspace",
"status": "active",
"allowed_origins": [
"https://app.acme.co/signup"
],
"scopes": [
"*"
],
"rate_limit": 1,
"key_preview": "FOIL_SAMPLE_KEY",
"display_key": "FOIL_SAMPLE_KEY",
"revealed_key": "FOIL_SAMPLE_KEY",
"last_used_at": "2026-03-24T20:00:05.000Z",
"created_at": "2026-03-24T20:00:00.000Z",
"rotated_at": "2026-03-24T20:00:05.000Z",
"revoked_at": "2026-03-24T20:00:05.000Z",
"grace_expires_at": "2026-03-24T20:00:05.000Z"
},
"meta": {
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1"
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}{
"error": {
"code": "request.validation_failed",
"message": "Observation payload failed validation.",
"status": 1,
"retryable": true,
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1",
"docs_url": "https://app.acme.co/signup",
"details": {
"fields": [
{
"name": "Acme Growth Workspace",
"issue": "required",
"expected": "string",
"received": "any_of"
}
],
"allowed_values": [
"verified"
],
"header_name": "x-forwarded-for",
"parameter_set": "browser_fingerprint",
"next_action": "retry"
}
}
}Path Parameters
Pattern:
^org_[0123456789abcdefghjkmnpqrstvwxyz]{26}$Example:
"org_f6m39y94nh6fs513q03skj929c"
Pattern:
^key_[0123456789abcdefghjkmnpqrstvwxyz]{26}$Example:
"key_6cw04zdmetw8t5rsdppadhper0"
Body
application/json
Example:
"Acme Growth Workspace"
Example:
["https://app.acme.co/signup"]
When updating a secret key, provide at least one supported secret-key scope, or ["*"] for all current and future scopes.
Minimum array length:
1Available options:
*, sessions:list, sessions:read, sessions:update, fingerprints:list, fingerprints:read, organizations:create, organizations:read, organizations:update, api_keys:read, api_keys:manage, gate:agent_tokens:verify, gate:agent_tokens:revoke, gate:login_sessions:consume, gate:services:read, gate:services:manage, webhooks:read, webhooks:manage Example:
["*"]
Response
Revoked API key response.
Show child attributes
Show child attributes
Example:
{
"object": "api_key",
"id": "key_6cw04zdmetw8t5rsdppadhper0",
"type": "publishable",
"environment": "live",
"name": "Acme Growth Workspace",
"status": "active",
"allowed_origins": ["https://app.acme.co/signup"],
"scopes": ["*"],
"rate_limit": 1,
"key_preview": "FOIL_SAMPLE_KEY",
"display_key": "FOIL_SAMPLE_KEY",
"revealed_key": "FOIL_SAMPLE_KEY",
"last_used_at": "2026-03-24T20:00:05.000Z",
"created_at": "2026-03-24T20:00:00.000Z",
"rotated_at": "2026-03-24T20:00:05.000Z",
"revoked_at": "2026-03-24T20:00:05.000Z",
"grace_expires_at": "2026-03-24T20:00:05.000Z"
}
Show child attributes
Show child attributes
Example:
{
"request_id": "req_cf147349a4134208aebb8c70e25fb7e1"
}
⌘I