Steven Hearn wrote:
Hello, I have used the API guide however I cannot get the authentication to work with my instance of SB M. My code appears below…can you advise what I am doing wrong and what has to be changed ?
We’re trying to call the JSON-RPC method getBookings on https://user-api.simplybook.me with parameters [{ booking_code }], but we’re getting ‘Method not found’. What is the correct method name to retrieve a booking by booking code?"
Here’s the exact raw code being used in my Zapier step:
const LOGIN_URL = “https://user-api.simplybook.me/login”;
const API_URL = “https://user-api.simplybook.me”;
const COMPANY_LOGIN = “my company name”;
const API_KEY = “the api key”;
const booking_code = inputData.booking_code || “TEST_BOOKING”;
const new_date = inputData.new_date || “15/03/26”;
const new_time = inputData.new_time || “14:00”;
function convertDateFormat(dateStr) {
if (!dateStr) return “2026-03-15”;
if (dateStr.includes(“-”) && dateStr.length === 10) return dateStr;
const parts = dateStr.split(“/”);
if (parts.length === 3) {
const [day, month, yearShort] = parts;
const fullYear = parseInt(yearShort) < 50 ? “20” + yearShort : “19” + yearShort;
return ${fullYear}-${month.padStart(2,"0")}-${day.padStart(2,"0")};
}
return “2026-03-15”;
}
const apiDate = convertDateFormat(new_date);
async function getToken() {
const response = await fetch(LOGIN_URL, {
method: ‘POST’,
headers: { “Content-Type”: “application/json” },
body: JSON.stringify({
jsonrpc: “2.0”,
method: “getToken”,
params: [COMPANY_LOGIN, API_KEY],
id: 1
})
});
const data = await response.json();
if (data.error) throw new Error(Token error: ${data.error.message});
return data.result;
}
async function getBookings(token) {
const response = await fetch(API_URL, {
method: ‘POST’,
headers: {
“Content-Type”: “application/json”,
“X-Company-Login”: COMPANY_LOGIN,
“X-Token”: token
},
body: JSON.stringify({
jsonrpc: “2.0”,
method: “getBookings”,
params: [{ booking_code }],
id: Date.now()
})
});
const data = await response.json();
if (data.error) throw new Error(Booking error: ${data.error.message});
return data.result;
}
const token = await getToken();
const bookingList = await getBookings(token);
if (!bookingList || !bookingList[0]) throw new Error(Booking not found);
const booking = bookingList[0];
return {
timestamp: new Date().toISOString(),
booking_id: booking.id,
booking_code: booking.booking_code,
client_name: booking.client_name,
client_email: booking.client_email,
client_phone: booking.client_phone,
service_name: booking.service_name,
service_id: booking.service_id,
location_id: booking.location_id,
artist_name: booking.unit_name || “Unknown”,
artist_mobile: booking.unit_phone || “”,
original_date: booking.start_date,
requested_date_input: new_date,
requested_time_input: new_time,
api_date: apiDate,
api_time: new_time,
availability_status: “Pending”,
sms_status: “Pending”,
client_email_status: “Pending”,
artist_response_status: “Awaiting Response”,
escalation_status: “Not Triggered”,
full_booking_json: JSON.stringify(booking)
};
Key Details
Credentials being used:
Company Login: Carinda
API Key: 8d9b4bbcd47ddc85c568f357d8fb033f10e0bb32e0d9228bb161d13d57182ea2
API Endpoints:
Login: https://user-api.simplybook.me/login
API: https://user-api.simplybook.me
JSON-RPC Methods being called:
getToken with params: [COMPANY_LOGIN, API_KEY]
getBookings with params: [{ booking_code }]
Error we’re getting:
“Method not found” on the getBookings call
Error: API Error: Method not found at jsonRpcCall (line 42, column 21)
Are these the correct method names?
Are the parameters in the correct format?
Should I be using different headers or authentication approach?
steve