curl --request POST \
--url https://your-site.com/{basePath}/handshake \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'X-Castro-Signature: <api-key>' \
--header 'X-Castro-Timestamp: <api-key>' \
--data '
{
"challenge": "3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543"
}
'import requests
url = "https://your-site.com/{basePath}/handshake"
payload = { "challenge": "3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543" }
headers = {
"X-API-Key": "<api-key>",
"X-Castro-Timestamp": "<api-key>",
"X-Castro-Signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-Key': '<api-key>',
'X-Castro-Timestamp': '<api-key>',
'X-Castro-Signature': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({challenge: '3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543'})
};
fetch('https://your-site.com/{basePath}/handshake', 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://your-site.com/{basePath}/handshake",
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([
'challenge' => '3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"X-Castro-Signature: <api-key>",
"X-Castro-Timestamp: <api-key>"
],
]);
$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://your-site.com/{basePath}/handshake"
payload := strings.NewReader("{\n \"challenge\": \"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("X-Castro-Timestamp", "<api-key>")
req.Header.Add("X-Castro-Signature", "<api-key>")
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://your-site.com/{basePath}/handshake")
.header("X-API-Key", "<api-key>")
.header("X-Castro-Timestamp", "<api-key>")
.header("X-Castro-Signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"challenge\": \"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-site.com/{basePath}/handshake")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["X-Castro-Timestamp"] = '<api-key>'
request["X-Castro-Signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"challenge\": \"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543\"\n}"
response = http.request(request)
puts response.read_body{
"capabilities": [
"posts.create"
],
"challenge_response": "<string>",
"name": "Acme Store Backend",
"version": "1.0"
}Verify the connection
Called once when the user connects (or re-verifies) their website in
Castro. Prove you hold the API key by returning
challenge_response = HMAC-SHA256(challenge, api_key) as lowercase
hex, and declare which optional endpoints you implemented.
The connection is rejected unless capabilities includes both
posts.create and posts.update.
curl --request POST \
--url https://your-site.com/{basePath}/handshake \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'X-Castro-Signature: <api-key>' \
--header 'X-Castro-Timestamp: <api-key>' \
--data '
{
"challenge": "3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543"
}
'import requests
url = "https://your-site.com/{basePath}/handshake"
payload = { "challenge": "3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543" }
headers = {
"X-API-Key": "<api-key>",
"X-Castro-Timestamp": "<api-key>",
"X-Castro-Signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-Key': '<api-key>',
'X-Castro-Timestamp': '<api-key>',
'X-Castro-Signature': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({challenge: '3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543'})
};
fetch('https://your-site.com/{basePath}/handshake', 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://your-site.com/{basePath}/handshake",
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([
'challenge' => '3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"X-Castro-Signature: <api-key>",
"X-Castro-Timestamp: <api-key>"
],
]);
$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://your-site.com/{basePath}/handshake"
payload := strings.NewReader("{\n \"challenge\": \"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("X-Castro-Timestamp", "<api-key>")
req.Header.Add("X-Castro-Signature", "<api-key>")
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://your-site.com/{basePath}/handshake")
.header("X-API-Key", "<api-key>")
.header("X-Castro-Timestamp", "<api-key>")
.header("X-Castro-Signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"challenge\": \"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-site.com/{basePath}/handshake")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["X-Castro-Timestamp"] = '<api-key>'
request["X-Castro-Signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"challenge\": \"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543\"\n}"
response = http.request(request)
puts response.read_body{
"capabilities": [
"posts.create"
],
"challenge_response": "<string>",
"name": "Acme Store Backend",
"version": "1.0"
}Authorizations
The connection key the user generated in Jorge Castro (Settings → Integration → Custom Website). Reject any request whose key doesn't match yours.
Unix time in milliseconds when the request was signed — Castro uses
Date.now(). Reject anything more than a few minutes old.
A seconds-based comparison makes every request look ~55,000 years in the future, and the freshness check then silently passes everything.
HMAC-SHA256("{timestamp}.{rawBody}", api_key), lowercase hex.
rawBody is the exact bytes of the request body — empty for GET
and DELETE, which therefore sign over "{timestamp}.". Hash the raw
bytes, never a re-serialized copy of the parsed JSON: whitespace and key
order differences will break the comparison for some payloads and not
others, which reads as an intermittent bug.
Compare in constant time (crypto.timingSafeEqual, hash_equals,
hmac.compare_digest).
Body
Random hex string to sign with your API key.
"3f9a1c62b6d94f0e8a17c54b9d2e6f38a1b0c9d8e7f6a5b4c3d2e1f009876543"
Response
Connection accepted
Which endpoints you implemented. MUST include posts.create and
posts.update.
posts.create, posts.update, posts.delete, blog_categories, authors, products, product_categories, seo, pages.list HMAC-SHA256 of the challenge, keyed with your API key, lowercase hex.
Your integration's display name.
"Acme Store Backend"
"1.0"

