Create API Key
Try it
POST
/v0/api_keysCreate a new API key with the specified name. The generated API key will be returned in the response and cannot be retrieved again later.
Authentication
JSON web token (JWT) or API keyBearer token
Request body
Content type: application/json
- objectRequest to create a new API key.
namestringrequiredKey name.
Response
201API key created successfully
application/json- objectResponse to a successful API key creation.
api_keystringrequiredGenerated secret API key. There is no way to retrieve this key again through the API, so store it securely.idstring (uuid)requiredAPI key identifier.namestringrequiredAPI key name provided by the user.
409API key with that name already exists
application/json- objectInformation returned by REST API endpoints on error.
detailsobjectrequiredDetailed error metadata. The contents of this field is determined by `error_code`.error_codestringrequiredError code is a string that specifies this error type.messagestringrequiredHuman-readable error message.
curl -X POST 'https://api.example.com/v0/api_keys' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'const response = await fetch('https://api.example.com/v0/api_keys', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
body: JSON.stringify({})
});
const data = await response.json();
console.log(data);interface ApiResponse {
// shape your response here
}
const response: Response = await fetch('https://api.example.com/v0/api_keys', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
body: JSON.stringify({})
});
const data = (await response.json()) as ApiResponse;
console.log(data);import requests
url = "https://api.example.com/v0/api_keys"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
payload = {}
response = requests.request("post", url, headers=headers, json=payload)
print(response.json())package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{}`)
req, err := http.NewRequest("POST", "https://api.example.com/v0/api_keys", body)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}{
"message": "An entity with this name already exists",
"error_code": "DuplicateName",
"details": null
}