tokens
Create an API token
Creates a new API token with the given permission, scope and expiration. The raw ek_live_ value is returned once. Store it immediately.
POST
/
v1
/
workspace
/
{ws}
/
tokens
/
cURL
curl -X POST 'http://localhost:8080/v1/workspace/ws_example/tokens/' \
-H 'Authorization: Bearer ek_live_xxxxx' \
-H 'Content-Type: application/json' \
-d '{ // request body fields, see schema }'const response = await fetch('http://localhost:8080/v1/workspace/ws_example/tokens/', {
method: 'POST',
headers: {
Authorization: 'Bearer ek_live_xxxxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
// request body fields, see schema
}),
});
const data = await response.json();import requests
response = requests.post(
'http://localhost:8080/v1/workspace/ws_example/tokens/',
headers={
'Authorization': 'Bearer ek_live_xxxxx',
'Content-Type': 'application/json',
},
json={
# request body fields, see schema
},
)
data = response.json()<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/v1/workspace/{ws}/tokens/",
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>',
'scope' => [
'all' => true,
'teams' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'projects' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'environments' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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 := "http://localhost:8080/v1/workspace/{ws}/tokens/"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"scope\": {\n \"all\": true,\n \"teams\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"environments\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <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))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/v1/workspace/{ws}/tokens/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scope\": {\n \"all\": true,\n \"teams\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"environments\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/v1/workspace/{ws}/tokens/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"scope\": {\n \"all\": true,\n \"teams\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"environments\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"name": "<string>",
"prefix": "<string>",
"scope": {
"all": true,
"teams": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"projects": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"environments": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"expiresAt": "<string>"
}Authorizations
API key authentication. Pass Authorization: Bearer ek_live_xxxxx on every request.
Path Parameters
Required string length:
2 - 48Pattern:
^[a-z0-9-]+$Body
application/json
Response
201 - application/json
Default Response
Pattern:
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Available options:
read, read-write Show child attributes
Show child attributes
Previous
Revoke an API tokenRevokes an API token immediately. Any caller using the token loses access within 15 minutes (when the current JWT expires). Cannot be undone.
Next
⌘I
cURL
curl -X POST 'http://localhost:8080/v1/workspace/ws_example/tokens/' \
-H 'Authorization: Bearer ek_live_xxxxx' \
-H 'Content-Type: application/json' \
-d '{ // request body fields, see schema }'const response = await fetch('http://localhost:8080/v1/workspace/ws_example/tokens/', {
method: 'POST',
headers: {
Authorization: 'Bearer ek_live_xxxxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
// request body fields, see schema
}),
});
const data = await response.json();import requests
response = requests.post(
'http://localhost:8080/v1/workspace/ws_example/tokens/',
headers={
'Authorization': 'Bearer ek_live_xxxxx',
'Content-Type': 'application/json',
},
json={
# request body fields, see schema
},
)
data = response.json()<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/v1/workspace/{ws}/tokens/",
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>',
'scope' => [
'all' => true,
'teams' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'projects' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'environments' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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 := "http://localhost:8080/v1/workspace/{ws}/tokens/"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"scope\": {\n \"all\": true,\n \"teams\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"environments\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <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))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/v1/workspace/{ws}/tokens/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scope\": {\n \"all\": true,\n \"teams\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"environments\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/v1/workspace/{ws}/tokens/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"scope\": {\n \"all\": true,\n \"teams\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"environments\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"name": "<string>",
"prefix": "<string>",
"scope": {
"all": true,
"teams": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"projects": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"environments": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"expiresAt": "<string>"
}