curl --request POST \
--url https://api.example.com/credentials/api-token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"label": "<string>",
"upstream_base_url": "<string>",
"api_token": "<string>"
}
'import requests
url = "https://api.example.com/credentials/api-token"
payload = {
"label": "<string>",
"upstream_base_url": "<string>",
"api_token": "<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({label: '<string>', upstream_base_url: '<string>', api_token: '<string>'})
};
fetch('https://api.example.com/credentials/api-token', 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://api.example.com/credentials/api-token",
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([
'label' => '<string>',
'upstream_base_url' => '<string>',
'api_token' => '<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://api.example.com/credentials/api-token"
payload := strings.NewReader("{\n \"label\": \"<string>\",\n \"upstream_base_url\": \"<string>\",\n \"api_token\": \"<string>\"\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://api.example.com/credentials/api-token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"<string>\",\n \"upstream_base_url\": \"<string>\",\n \"api_token\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/credentials/api-token")
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 \"label\": \"<string>\",\n \"upstream_base_url\": \"<string>\",\n \"api_token\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"credential_id": "<string>"
}{
"error": {
"code": "validation_error",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "unauthorized",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "forbidden",
"message": "<string>",
"details": {}
}
}Create a static API-token credential
Creates a system.credential of kind: api_token carrying an upstream service’s API base URL + the user-supplied bearer token (encrypted at rest). The resulting credential id is passed as credential_ref on subsequent POST /connections/install calls.
For integrations whose upstream uses a static bearer (Todoist, Readwise, Raindrop, etc) rather than the OAuth dance. The connection proxy stamps the bearer transparently on every call; there is no refresh primitive — when the upstream rejects the token (401), the proxy surfaces 401 and emits a system.activity of severity action_required asking the operator to reinstall with a fresh token.
The bearer is encrypted server-side under the connectionOauthToken HKDF domain (AES-256-GCM) — same encryption domain that protects OAuth client secrets and access/refresh tokens. The plaintext is never returned by any read path.
Tenant-scoped: the credential is created in the calling key’s tenant.
curl --request POST \
--url https://api.example.com/credentials/api-token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"label": "<string>",
"upstream_base_url": "<string>",
"api_token": "<string>"
}
'import requests
url = "https://api.example.com/credentials/api-token"
payload = {
"label": "<string>",
"upstream_base_url": "<string>",
"api_token": "<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({label: '<string>', upstream_base_url: '<string>', api_token: '<string>'})
};
fetch('https://api.example.com/credentials/api-token', 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://api.example.com/credentials/api-token",
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([
'label' => '<string>',
'upstream_base_url' => '<string>',
'api_token' => '<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://api.example.com/credentials/api-token"
payload := strings.NewReader("{\n \"label\": \"<string>\",\n \"upstream_base_url\": \"<string>\",\n \"api_token\": \"<string>\"\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://api.example.com/credentials/api-token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"<string>\",\n \"upstream_base_url\": \"<string>\",\n \"api_token\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/credentials/api-token")
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 \"label\": \"<string>\",\n \"upstream_base_url\": \"<string>\",\n \"api_token\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"credential_id": "<string>"
}{
"error": {
"code": "validation_error",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "unauthorized",
"message": "<string>",
"details": {}
}
}{
"error": {
"code": "forbidden",
"message": "<string>",
"details": {}
}
}Authorizations
Pass an API key (marfa_k1_...) or OAuth access token (marfa_at_...)
Body
Response
Credential created. Returns the new credential's id for use as credential_ref on install.