Every API request needs an API key. Keys are sent with HTTP Basic authentication over HTTPS.
Create an API key
- Sign in to MessagePort.
- Open Settings in the sidebar, then API Keys.
- Click Create API Key and enter a name for the key.
Each key has two parts:
| Part | Used as |
|---|---|
| Access Token | Basic auth username |
| Token ID | Basic auth password |
The API Keys page labels them the same way. Create a separate key for each integration so you can disable one without affecting the others.
Send the credentials
Most HTTP clients take a username and password and build the header for you:
curl -u "ACCESS_TOKEN:TOKEN_ID" https://app.messageport.com.au/api/v2/accountIf yours doesn’t, send the header yourself. <credentials> is the Base64 encoding of the Access Token and Token ID joined by a single colon:
Authorization: Basic <credentials>For example, in PHP:
$header = 'Authorization: Basic ' . base64_encode($accessToken . ':' . $tokenId);Or in Node.js:
const header = 'Basic ' + Buffer.from(`${accessToken}:${tokenId}`).toString('base64');All requests must use HTTPS.
Authentication errors
A missing, malformed, invalid or disabled key returns 401 Unauthorized:
{
"message": "Unauthenticated."
}Send Accept: application/json with every request so errors always come back as JSON.
Test with the OpenAPI spec
The OpenAPI spec for this API is at /api/openapi.json. Import it into Postman, Insomnia or another API client, set Basic auth with your Access Token as the username and Token ID as the password, and every endpoint is ready to try.
Keep keys safe
Anyone with a key can send messages on your account. Keep keys on your server, never in browser or mobile app code, and disable a key from the API Keys page if it leaks. See Security.