Getting Started
Getting an API Key and Secret
Please contact us to have an API key and secret issued for your needs.
Once you have your API key and secret, you will need to use both of them to authenticate with the API. We utilize HMAC signature verification to validate the requests.
Making signed requests
The API Key must be sent using the x-api-key header.
The API Secret is used to generate an HMAC signature, with a timestamp included, and the signature must be sent using the x-signature header.
All requests must also include the x-req-timestamp header.
Signature Generation Process
The signature generation follows these steps:
Hash the secret using SHA256:
hashed_secret = SHA256(your_secret)Construct the payload to sign in the format:
payload = METHOD:URL_PATH:TIMESTAMP:BODYMETHOD: HTTP method (GET, POST, etc.)URL_PATH: Request path including query parameters, with the parameters sorted alphabetically by name (e.g.,/rest/v1/charging-events/site/{id}?from=2024-01-01T00:00:00Z&take=100&to=2024-01-02T00:00:00Z). See Query parameters.TIMESTAMP: Unix timestamp in secondsBODY: Request body as JSON string (empty string if no body)
Generate the HMAC-SHA256 signature using the hashed secret:
signature = HMAC-SHA256(payload, hashed_secret)Send in request headers as hex-encoded string
Query parameters
The query string you sign, and send, must list its parameters in alphabetical order by name. A request whose query string is signed in any other order is rejected with HTTP 401, even if the signature is otherwise correct.
| Query string | Result |
|---|---|
?from=2024-01-01T00:00:00Z&to=2024-01-02T00:00:00Z&take=100 | HTTP 401 |
?from=2024-01-01T00:00:00Z&take=100&to=2024-01-02T00:00:00Z | HTTP 200 |
Send colons (:) and commas (,) in values as they are rather than percent-encoded (%3A, %2C). Build the query string once, and use that same string both in the payload you sign and in the request URL.
const query = new URLSearchParams({
to: '2026-10-20T13:35:05Z',
from: '2026-10-20T13:07:32Z',
take: '1000',
});
query.sort(); // alphabetical order by parameter name
const path = `/ocpp-logs/site/${siteId}?${query.toString().replaceAll('%3A', ':').replaceAll('%2C', ',')}`;
// path is now /ocpp-logs/site/{siteId}?from=2026-10-20T13:07:32Z&take=1000&to=2026-10-20T13:35:05ZExample Implementation
WARNING
Notice we send the key, the timestamp, and the signature. The secret should never be transmitted over the wire.
const crypto = require('crypto');
function makeSignedRequest(method, path, body, apiKey, apiSecret) {
const timestamp = Math.floor(Date.now() / 1000);
// 1. Hash the secret using SHA256
const hashedSecret = crypto
.createHash('sha256')
.update(apiSecret)
.digest('hex');
// 2. Construct the payload to sign
let payloadToSign = `${method}:/rest/v1${path}:${timestamp}:`;
if (body) {
payloadToSign += JSON.stringify(body);
}
// 3. Create the signature using the hashed secret
const signature = crypto
.createHmac('sha256', hashedSecret)
.update(payloadToSign)
.digest('hex');
// 4. Send headers
return fetch(`https://chargepilot-api.tmhusa.energy/rest/v1${path}`, {
method: method,
...(body ? { body: JSON.stringify(body) } : {}),
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
'x-req-timestamp': timestamp.toString(),
'x-signature': signature,
}
});
}Timestamp validity
The x-req-timestamp you sign with must be within 300 seconds (5 minutes) of the server's clock. Requests carrying a timestamp outside that window are rejected as expired.
An expired timestamp returns the same generic HTTP 401 as any other authentication failure, so the response alone will not distinguish it from an invalid signature. If requests that used to work start failing with HTTP 401, check that the clock on the machine sending them is synchronised (for example via NTP), and generate a fresh timestamp for every request rather than reusing one.
Setting a User-Agent
The API is served through Cloudflare API Shield, which rejects requests sent with the default Python-urllib/3.x User-Agent of Python's built-in urllib module. These requests are blocked before they reach the API.
A blocked request returns HTTP 403 with a plain-text body instead of the usual JSON error response:
error code: 1010Setting any identifiable User-Agent avoids this — we recommend the name and version of your integration:
import urllib.request
request = urllib.request.Request(
'https://chargepilot-api.tmhusa.energy/rest/v1/ping',
headers={'User-Agent': 'my-integration/1.0'},
)Rate limiting
We currently limit usage to 40 requests per minute per endpoint for each API key.
Liveness checks
An unauthenticated endpoint is available at the path /rest/v1/ping for automated liveness checks. When the Rest API is healthy and available, this endpoint will return a HTTP 200 response.
Example request:
curl -X GET https://chargepilot-api.tmhusa.energy/rest/v1/pingSample response:
{ "result": "ChargePilot Rest API is available" }