API Key
Operations related to API key management
List API keys for a user
GET
/users/{userName}/api-keysReturns all API keys owned by the specified user. Secrets are never included.
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Code Examples
curl -X GET "/api/v1/users/{userName}/api-keys" \
-H "Authorization: Bearer YOUR_API_KEY"const response = await fetch('/api/v1/users/{userName}/api-keys', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();fetch('/api/v1/users/{userName}/api-keys', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => console.log(data));import requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
response = requests.get('/api/v1/users/{userName}/api-keys', headers=headers)
data = response.json()package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "/api/v1/users/{userName}/api-keys", nil)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}Responses
[
{
"key_id": "aBcDeFgHiJkLmNoPqRsT",
"name": "CI pipeline key",
"username": "johndoe",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
],
"created_at": "2024-01-01T00:00:00Z",
"expires_at": "2024-01-01T00:00:00Z"
}
]{
"error": "An error message"
}{
"error": "An error message"
}{
"error": "An error message"
}Create a new API key
POST
/users/{userName}/api-keysCreates a new API key for the specified user. The cleartext secret is returned only in this response.
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Request Body
Example:
{
"name": "CI pipeline key",
"expires_in": "720h",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
]
}Code Examples
curl -X POST "/api/v1/users/{userName}/api-keys" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "CI pipeline key",
"expires_in": "720h",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
]
}'const response = await fetch('/api/v1/users/{userName}/api-keys', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"name": "CI pipeline key",
"expires_in": "720h",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
]
})
});
const data = await response.json();fetch('/api/v1/users/{userName}/api-keys', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"name": "CI pipeline key",
"expires_in": "720h",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
]
})
})
.then(response => response.json())
.then(data => console.log(data));import requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
response = requests.post(
'/api/v1/users/{userName}/api-keys',
headers=headers,
json={
"name": "CI pipeline key",
"expires_in": "720h",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
]
}
)
data = response.json()package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
body := []byte(`{
"name": "CI pipeline key",
"expires_in": "720h",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
]
}`)
req, _ := http.NewRequest("POST", "/api/v1/users/{userName}/api-keys", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}Responses
{
"key_id": "aBcDeFgHiJkLmNoPqRsT",
"name": "CI pipeline key",
"username": "johndoe",
"permissions": [
{
"resource": "orders_table",
"resource_type": "table",
"type": "read"
}
],
"created_at": "2024-01-01T00:00:00Z",
"expires_at": "2024-01-01T00:00:00Z"
}{
"error": "An error message"
}{
"error": "An error message"
}{
"error": "An error message"
}{
"error": "An error message"
}Delete an API key
DELETE
/users/{userName}/api-keys/{keyId}Permanently deletes the specified API key. Subsequent requests using this key will be rejected.
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Code Examples
curl -X DELETE "/api/v1/users/{userName}/api-keys/{keyId}" \
-H "Authorization: Bearer YOUR_API_KEY"const response = await fetch('/api/v1/users/{userName}/api-keys/{keyId}', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();fetch('/api/v1/users/{userName}/api-keys/{keyId}', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => console.log(data));import requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
response = requests.delete('/api/v1/users/{userName}/api-keys/{keyId}', headers=headers)
data = response.json()package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
req, _ := http.NewRequest("DELETE", "/api/v1/users/{userName}/api-keys/{keyId}", nil)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}Responses
No response body
{
"error": "An error message"
}{
"error": "An error message"
}