Create API key
POST
https://example.com
/
api
/
api-keys
Create API key
curl --request POST \
--url https://example.com/api/api-keys \
--header 'Content-Type: application/json' \
--cookie better-auth.session_token= \
--data '
{
"indexId": "<string>",
"name": "<string>"
}
'const options = {
method: 'POST',
headers: {cookie: 'better-auth.session_token=', 'Content-Type': 'application/json'},
body: JSON.stringify({indexId: '<string>', name: '<string>'})
};
fetch('https://example.com/api/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://example.com/api/api-keys"
payload = {
"indexId": "<string>",
"name": "<string>"
}
headers = {
"cookie": "better-auth.session_token=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://example.com/api/api-keys"
payload := strings.NewReader("{\n \"indexId\": \"<string>\",\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "better-auth.session_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))
}{
"summary": {
"createdAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"id": 123,
"indexId": "<string>",
"lastUsedAt": "2023-11-07T05:31:56Z",
"name": "<string>",
"tokenPrefix": "<string>"
},
"token": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}⌘I
Create API key
curl --request POST \
--url https://example.com/api/api-keys \
--header 'Content-Type: application/json' \
--cookie better-auth.session_token= \
--data '
{
"indexId": "<string>",
"name": "<string>"
}
'const options = {
method: 'POST',
headers: {cookie: 'better-auth.session_token=', 'Content-Type': 'application/json'},
body: JSON.stringify({indexId: '<string>', name: '<string>'})
};
fetch('https://example.com/api/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://example.com/api/api-keys"
payload = {
"indexId": "<string>",
"name": "<string>"
}
headers = {
"cookie": "better-auth.session_token=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://example.com/api/api-keys"
payload := strings.NewReader("{\n \"indexId\": \"<string>\",\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "better-auth.session_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))
}{
"summary": {
"createdAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"id": 123,
"indexId": "<string>",
"lastUsedAt": "2023-11-07T05:31:56Z",
"name": "<string>",
"tokenPrefix": "<string>"
},
"token": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"requestId": "<string>",
"statusCode": 123,
"details": [
{
"message": "<string>",
"path": "<string>"
}
]
}
}
