API keys
Create a scoped API key
Create an API key limited to some actions, sandboxes or environments, with an expiry. Same as boat api-key create.
POST
/
api-keys
/
scoped
Create a scoped API key
curl --request POST \
--url https://boat.dev/api/v1/api-keys/scoped \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"ttl": "90d",
"actions": [
"<string>"
],
"sandboxIds": [
"<string>"
],
"environmentIds": [
"<string>"
]
}
'import requests
url = "https://boat.dev/api/v1/api-keys/scoped"
payload = {
"name": "<string>",
"ttl": "90d",
"actions": ["<string>"],
"sandboxIds": ["<string>"],
"environmentIds": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
ttl: '90d',
actions: ['<string>'],
sandboxIds: ['<string>'],
environmentIds: ['<string>']
})
};
fetch('https://boat.dev/api/v1/api-keys/scoped', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://boat.dev/api/v1/api-keys/scoped",
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>',
'ttl' => '90d',
'actions' => [
'<string>'
],
'sandboxIds' => [
'<string>'
],
'environmentIds' => [
'<string>'
]
]),
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 := "https://boat.dev/api/v1/api-keys/scoped"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"ttl\": \"90d\",\n \"actions\": [\n \"<string>\"\n ],\n \"sandboxIds\": [\n \"<string>\"\n ],\n \"environmentIds\": [\n \"<string>\"\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("https://boat.dev/api/v1/api-keys/scoped")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"ttl\": \"90d\",\n \"actions\": [\n \"<string>\"\n ],\n \"sandboxIds\": [\n \"<string>\"\n ],\n \"environmentIds\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://boat.dev/api/v1/api-keys/scoped")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"ttl\": \"90d\",\n \"actions\": [\n \"<string>\"\n ],\n \"sandboxIds\": [\n \"<string>\"\n ],\n \"environmentIds\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"type": "<string>",
"apiKey": {
"id": "sak_123",
"name": "Production worker",
"credentialLane": "legacy",
"keyPrefix": "boat_live",
"keyLastFour": "9abc",
"sandboxId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z",
"usage": {
"requests": 1842,
"windowDays": 30
},
"resources": {
"total": 1,
"sandboxes": 1,
"agents": 1
},
"expiresAt": "2023-11-07T05:31:56Z",
"expired": true,
"expiringSoon": true,
"scope": {
"expiresAt": "2023-11-07T05:31:56Z",
"actions": [
"<string>"
],
"sandboxes": "*",
"environments": "*",
"grandfathered": true
}
},
"secret": "<string>",
"apiKeys": [
{
"id": "sak_123",
"name": "Production worker",
"credentialLane": "legacy",
"keyPrefix": "boat_live",
"keyLastFour": "9abc",
"sandboxId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z",
"usage": {
"requests": 1842,
"windowDays": 30
},
"resources": {
"total": 1,
"sandboxes": 1,
"agents": 1
},
"expiresAt": "2023-11-07T05:31:56Z",
"expired": true,
"expiringSoon": true,
"scope": {
"expiresAt": "2023-11-07T05:31:56Z",
"actions": [
"<string>"
],
"sandboxes": "*",
"environments": "*",
"grandfathered": true
}
}
]
}{
"ok": false,
"type": "sandbox.error",
"status": 400,
"code": "invalid_json",
"message": "Request body must be valid JSON.",
"error": {
"code": "invalid_json",
"message": "Request body must be valid JSON.",
"status": 400
},
"requestId": "req_01HX..."
}{
"ok": false,
"type": "sandbox.error",
"status": 401,
"code": "unauthorized",
"message": "Unauthorized",
"error": {
"code": "unauthorized",
"message": "Unauthorized",
"status": 401
},
"requestId": "req_01HX..."
}{
"ok": false,
"type": "sandbox.error",
"status": 403,
"code": "forbidden",
"message": "Forbidden",
"error": {
"code": "forbidden",
"message": "Forbidden",
"status": 403
},
"requestId": "req_01HX..."
}{
"error": "scoped_api_key_creation_disabled",
"message": "<string>",
"scopedCreationEnabled": false
}Authorizations
Boat bearer token in the form boat_.... Service API keys authenticate sandbox operations.
Body
application/json
Response
Created key metadata plus the one-time secret.
⌘I
Create a scoped API key
curl --request POST \
--url https://boat.dev/api/v1/api-keys/scoped \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"ttl": "90d",
"actions": [
"<string>"
],
"sandboxIds": [
"<string>"
],
"environmentIds": [
"<string>"
]
}
'import requests
url = "https://boat.dev/api/v1/api-keys/scoped"
payload = {
"name": "<string>",
"ttl": "90d",
"actions": ["<string>"],
"sandboxIds": ["<string>"],
"environmentIds": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
ttl: '90d',
actions: ['<string>'],
sandboxIds: ['<string>'],
environmentIds: ['<string>']
})
};
fetch('https://boat.dev/api/v1/api-keys/scoped', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://boat.dev/api/v1/api-keys/scoped",
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>',
'ttl' => '90d',
'actions' => [
'<string>'
],
'sandboxIds' => [
'<string>'
],
'environmentIds' => [
'<string>'
]
]),
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 := "https://boat.dev/api/v1/api-keys/scoped"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"ttl\": \"90d\",\n \"actions\": [\n \"<string>\"\n ],\n \"sandboxIds\": [\n \"<string>\"\n ],\n \"environmentIds\": [\n \"<string>\"\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("https://boat.dev/api/v1/api-keys/scoped")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"ttl\": \"90d\",\n \"actions\": [\n \"<string>\"\n ],\n \"sandboxIds\": [\n \"<string>\"\n ],\n \"environmentIds\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://boat.dev/api/v1/api-keys/scoped")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"ttl\": \"90d\",\n \"actions\": [\n \"<string>\"\n ],\n \"sandboxIds\": [\n \"<string>\"\n ],\n \"environmentIds\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"type": "<string>",
"apiKey": {
"id": "sak_123",
"name": "Production worker",
"credentialLane": "legacy",
"keyPrefix": "boat_live",
"keyLastFour": "9abc",
"sandboxId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z",
"usage": {
"requests": 1842,
"windowDays": 30
},
"resources": {
"total": 1,
"sandboxes": 1,
"agents": 1
},
"expiresAt": "2023-11-07T05:31:56Z",
"expired": true,
"expiringSoon": true,
"scope": {
"expiresAt": "2023-11-07T05:31:56Z",
"actions": [
"<string>"
],
"sandboxes": "*",
"environments": "*",
"grandfathered": true
}
},
"secret": "<string>",
"apiKeys": [
{
"id": "sak_123",
"name": "Production worker",
"credentialLane": "legacy",
"keyPrefix": "boat_live",
"keyLastFour": "9abc",
"sandboxId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z",
"usage": {
"requests": 1842,
"windowDays": 30
},
"resources": {
"total": 1,
"sandboxes": 1,
"agents": 1
},
"expiresAt": "2023-11-07T05:31:56Z",
"expired": true,
"expiringSoon": true,
"scope": {
"expiresAt": "2023-11-07T05:31:56Z",
"actions": [
"<string>"
],
"sandboxes": "*",
"environments": "*",
"grandfathered": true
}
}
]
}{
"ok": false,
"type": "sandbox.error",
"status": 400,
"code": "invalid_json",
"message": "Request body must be valid JSON.",
"error": {
"code": "invalid_json",
"message": "Request body must be valid JSON.",
"status": 400
},
"requestId": "req_01HX..."
}{
"ok": false,
"type": "sandbox.error",
"status": 401,
"code": "unauthorized",
"message": "Unauthorized",
"error": {
"code": "unauthorized",
"message": "Unauthorized",
"status": 401
},
"requestId": "req_01HX..."
}{
"ok": false,
"type": "sandbox.error",
"status": 403,
"code": "forbidden",
"message": "Forbidden",
"error": {
"code": "forbidden",
"message": "Forbidden",
"status": 403
},
"requestId": "req_01HX..."
}{
"error": "scoped_api_key_creation_disabled",
"message": "<string>",
"scopedCreationEnabled": false
}