curl --request POST \
--url https://oauth2-{dc}.moengage.com/v1/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id=YOUR_WORKSPACE_ID \
--data client_secret=YOUR_API_KEY{
"status": "SUCCESS",
"data": {
"access_token": "eyJhbGciOiJSUzI1NiJ9.eyJkYXRhIjoiUlN3Q2t6...",
"refresh_token": "550e8400-e29b-41d4-a716-446655440000",
"token_type": "Bearer",
"expires_in": 900
}
}{
"status": "FAILURE",
"error_type": "ER019",
"reason": "client_id is required."
}{
"status": "FAILURE",
"error_type": "ER011",
"reason": "Auth validation failed."
}{
"status": "FAILURE",
"error_type": "<string>",
"reason": "<string>"
}{
"status": "FAILURE",
"error_type": "RATE_LIMIT_EXCEEDED",
"reason": "Too many requests."
}Generate Access Token
Exchange the client_id and client_secret of an OAuth 2.0 API key for an access token and a refresh token.
The client_id is your Workspace ID, and the client_secret is the API key value that the dashboard displays once, when you create the key. The key must have Authentication Type set to OAuth 2.0 on the API key dashboard, or the request fails with ER012.
To create the key, refer to API Key Dashboard. For the end-to-end integration, refer to OAuth 2.0 Overview. To renew an access token without resending your API key, refer to Refresh Access Token.
curl --request POST \
--url https://oauth2-{dc}.moengage.com/v1/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id=YOUR_WORKSPACE_ID \
--data client_secret=YOUR_API_KEY{
"status": "SUCCESS",
"data": {
"access_token": "eyJhbGciOiJSUzI1NiJ9.eyJkYXRhIjoiUlN3Q2t6...",
"refresh_token": "550e8400-e29b-41d4-a716-446655440000",
"token_type": "Bearer",
"expires_in": 900
}
}{
"status": "FAILURE",
"error_type": "ER019",
"reason": "client_id is required."
}{
"status": "FAILURE",
"error_type": "ER011",
"reason": "Auth validation failed."
}{
"status": "FAILURE",
"error_type": "<string>",
"reason": "<string>"
}{
"status": "FAILURE",
"error_type": "RATE_LIMIT_EXCEEDED",
"reason": "Too many requests."
}Body
The form-encoded credentials for the client credentials grant.
The OAuth 2.0 grant type. The supported value is client_credentials.
client_credentials Your Workspace ID. The API key dashboard displays the Workspace ID at Settings > Account > API keys.
The API key value. The dashboard displays the API key only once, when you create the key.