Skip to content
Last updated

Every request to the eCommunicate API requires a Developer API key in the Authorization header.


How it works

The API uses a custom apiKey scheme. Pass your key directly in the Authorization header — no Bearer prefix, no Basic auth.

curl -X GET "https://api.payless4messaging.com/your-endpoint" \
  -H "Authorization: a1b2c3d4-e5f6-7890-abcd-ef1234567890"

API key format

Your API key is a standard UUID:

a1b2c3d4-e5f6-7890-abcd-ef1234567890

Retrieve your API key

Use this endpoint to obtain your API key using your account credentials. No existing API key is required — this is the recommended starting point for new integrations.

POST /payless4messaging-service/WhatsApp/authenticate/retrieveApiKey

Request body:

{
  "email": "user@example.com",
  "password": "your-password",
  "clientRef": "CLIENT001"
}

Response:

{
  "apiKey": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
curl -X POST "https://api.payless4messaging.com/payless4messaging-service/WhatsApp/authenticate/retrieveApiKey" \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "your-password", "clientRef": "CLIENT001"}'
Error response

If the credentials are invalid, the endpoint returns 401 with {"error": "Invalid credentials"}. Double-check your email, password, and client reference.


Generate a new key

POST /payless4messaging-service/WhatsApp/SystemUsers/generateAPIKey

Response:

{
  "token": "f6e5d4c3-b2a1-0987-6543-210fedcba987"
}
Immediate invalidation

Generating a new key immediately invalidates the previous one. All integrations using the old key will return 401 Unauthorized. Update all your services before or immediately after regeneration.


Error responses

StatusMessageCauseResolution
401Unauthorized userMissing or invalid API keyVerify your key — see Troubleshooting a 401
403ForbiddenValid key but insufficient permissionsContact support to verify your account permissions

Troubleshooting a 401

A 401 Unauthorized means the key the server received is not one it recognises. Before changing any code, confirm which key your account actually has — there are two ways to check, and they should agree.

1. Check the key in the web UI

Sign in to the eCommunicate web UI and open your API key settings. This shows the key currently active on your account, which is the value your integration must send.

2. Check the key via the API

Call the retrieve endpoint with your account credentials. It requires no existing API key, so it still works when every other call is returning 401:

curl -X POST "https://api.payless4messaging.com/payless4messaging-service/WhatsApp/authenticate/retrieveApiKey" \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "your-password", "clientRef": "CLIENT001"}'

If this call itself returns 401 with {"error": "Invalid credentials"}, the problem is your email, password or clientRef — not your API key.

3. Compare against what you're sending

Once you know the correct key, check the value your integration puts in the header. A valid key is a 36-character UUID; any other length means it was truncated or padded between your secret store and the request.

String apiKey = System.getenv("ECOMM_API_KEY");

if (apiKey == null || apiKey.isBlank()) {
    throw new IllegalStateException("ECOMM_API_KEY is not set");
}
apiKey = apiKey.trim();   // strip trailing newlines from files and shell exports

// Safe to log — never log the full key
logger.info("API key length={} suffix=...{}",
    apiKey.length(), apiKey.substring(apiKey.length() - 4));

Common causes

CauseFix
Authorization header missingAdd it to every request — there is no session or cookie fallback
Bearer prefix addedPass the key on its own; this API uses a custom apiKey scheme
Key was regenerated elsewhereRetrieve the current key — regeneration permanently invalidates the old one
Key belongs to a different clientRetrieve the key for the clientRef you're integrating against
Whitespace or newline in the valueTrim it before sending
Key copied from a truncated logCompare against the UI — a valid key is 36 characters
401 vs 403

401 means the key wasn't recognised — verify and fix the key. 403 means the key was recognised but your account isn't permitted to perform that operation — retrieving the key again won't help.

Still stuck after both checks agree? Contact support@ecommunicate.co.za with the requestId from the error response. See Error Handling for the full response format.


Security best practices

Protect your API key

Your API key grants full access to your eCommunicate account. Treat it like a password.

Store keys securely

Never hardcode your API key. Use environment variables or a secrets manager:

# .env (never commit this file)
ECOMM_API_KEY=a1b2c3d4-e5f6-7890-abcd-ef1234567890

# Access in your code
# Node.js: process.env.ECOMM_API_KEY
# Python:  os.environ["ECOMM_API_KEY"]
# Java:    System.getenv("ECOMM_API_KEY")

Key rules

RuleDetail
Server-side onlyMake API calls from your backend, never from browsers or mobile apps
HTTPS alwaysAll eCommunicate endpoints require HTTPS — never downgrade to HTTP
Rotate periodicallyUse the generate endpoint to rotate keys on a regular schedule
Separate environmentsUse different keys for staging and production where possible
Monitor usageCheck your Analytics dashboard for unexpected activity
Restrict accessUse the User Management endpoints to control who can access your account
Never log keysEnsure your logging framework redacts the Authorization header