Skip to main content

Get an access token

POST/oauth2/token

Returns a bearer token for your OAuth 2.0 client. Send it in the Authorization header of every other request, in place of the apiKey header. It lasts an hour.

Create the client under Settings › Developers › API Keys in the app. A Test client's tokens work only at the sandbox base URL, and a Live client's only at the live one. Get the token from the base URL you'll call. See Use OAuth 2.0 instead.

Headers​

  • #AuthorizationstringRequired
    Basic, then your client ID and client secret joined by a colon and Base64-encoded. curl and most HTTP libraries build it for you from the two values.
    Example: Basic <Base64 of clientId:clientSecret>
  • #Content-TypestringRequired
    The body is a form, not JSON.
    Example: application/x-www-form-urlencoded

Body parameters​

  • #grant_typestringRequired
    Always client_credentials.
    Example: client_credentials

Use the token​

curl $PONITOR_BASE_URL/messaging/v1/sms/e2c38865-dc0a-4299-baef-c07a9bfa9c33 \
-H "Authorization: Bearer $PONITOR_ACCESS_TOKEN"

Keep the token and reuse it until expires_in runs out, or until a call answers 401. Then get a new one. Getting a token for every call only slows your calls down.

Example request​

curl -X POST "https://api.ponitor.com/oauth2/token" \
-u "$PONITOR_CLIENT_ID:$PONITOR_CLIENT_SECRET" \
-d grant_type=client_credentials

Responses​

OK. The token, and how many seconds it lasts.

{
"access_token": "<your access token>",
"scope": "default",
"token_type": "Bearer",
"expires_in": 3600
}