Authentication Flow
GetCallerIdentity request to AWS. MoEngage is the only party that calls AWS STS to verify the signature.
Each MoEngage API request carries five headers:
Prerequisites
- Your application runs under an AWS IAM role, such as an Amazon EC2 instance profile, an Amazon ECS task role, an AWS Lambda execution role, or a role assumed through AWS STS. Permanent IAM user credentials are not supported.
- Your application uses an AWS SDK that exposes Signature Version 4 signing. The example in this article uses the Python
botocorelibrary. - You have access to Settings > Account > API keys with permission to create API keys.
- You have identified the data center that hosts your workspace. Refer to Data Centers.
Regional AWS STS Hosts
Sign against the AWS STS host for your MoEngage data center. The region in which your own infrastructure runs is not relevant. MoEngage verifies against the same host, so a signature produced against any other host fails, including one produced against the globalsts.amazonaws.com endpoint.
ap-southeast-3, which serves DC-06, is an AWS opt-in region. Enable it in your AWS account under Account > AWS Regions before signing against that host. This is an AWS account setting that MoEngage does not control.Step 1: Create an AWS STS Auth API Key
Open the API Keys Page
Open the Create New Key Dialog
Enter a Key Name
orders-integration.Select the Authentication Type
Set the Expiry Time
Add the Role ARNs
Select the API Access
Save the Key
MOE-APPSECRET value for the key.Retrieve the MOE-APPSECRET Value
MOE-APPSECRET value, which remains available after creation.Credential Handling
MOE-APPKEYholds your Workspace ID. The value is not secret, and every request must carry it.MOE-APPSECRETis specific to one key. Treat it as a password, store it in a secrets manager, and keep it out of source control.MOE-APPSECRETbinds a request to one MoEngage key and its API access. An AWS role is often shared across teams and environments, so the AWS signature alone does not identify the intended key.MOE-APPSECRETdoes not expire and does not rotate on its own, unlike the AWS credentials that sign the request.MOE-APPSECRETstays retrievable after creation. Select View key details from the key’s menu to display the value again.- To rotate the secret, use Regenerate key on the API key dashboard. Regeneration does not affect the key’s role ARNs or API access, and the previous secret stops working immediately.
Step 2: Sign a GetCallerIdentity Request
Build the following AWS STS request and sign it. Do not send it. MoEngage replays the same request to AWS STS to verify your signature, so every part must match exactly.botocore. Substitute the AWS SDK for your own language.
Authorization, X-Amz-Date, and X-Amz-Security-Token to prepared.headers.
Step 3: Call the MoEngage Public APIs
Send the signed headers on your MoEngage Public API request. AWS STS Auth has no separate MoEngage authentication endpoint.- Replace
{dc}with your data center number, and replace each placeholder with the value produced in Step 2. Content-Typeis required on the MoEngage call and prohibited on the signedGetCallerIdentityrequest.- For callable endpoints, refer to API Documentation. For request limits and payload caps, refer to Rate Limits.
Authentication Errors
An authenticated request returns the response that the endpoint normally returns. A request that MoEngage cannot authenticate returns401 Unauthorized, with a generic message rather than the specific cause, so that a failed request does not reveal which part of your configuration is incorrect. Refer to Troubleshooting.
Troubleshooting
Check the following in order when a request returns401 Unauthorized:
Find the ARN That MoEngage Resolves
When MoEngage verifies a request, AWS STS returns the ARN of the role that signed it, including the role session name. MoEngage compares that ARN with the ARNs on your key. Your application does not receive this AWS response. To see the same ARN, run the following AWS CLI command in the environment where your application runs, such as the Amazon EC2 instance or Amazon ECS task. In AWS Lambda, callget_caller_identity() on a boto3 STS client instead.
Arn value to your key. If the session name changes per instance or invocation, replace it with *, as described in Wildcards in Role ARNs.
Wildcards in Role ARNs
The ARN that AWS resolves includes a role session name, such as an Amazon EC2 instance ID, an Amazon ECS task ID, or an AWS Lambda request ID. That value changes per instance or invocation, and MoEngage matches ARNs exactly. The session name is also mandatory, so an entry that stops at the role name is rejected as Invalid format. Place* at the end of the segment you want to broaden:
- An entry accepts one
*, and only as the final character.assumed-role/My*Roleand any entry with two wildcards are invalid. - The role name must contain at least one character before the wildcard, so
assumed-role/*is invalid.
Recommended Practices
- Validate against a staging-only key with a staging role ARN before routing production traffic.
- Keep Basic Auth or OAuth 2.0 credentials active during the transition. No cutover is required.
- Sign and send in the same operation. Do not cache signatures.
- Store
MOE-APPSECRETin a secrets manager, and keep it out of client-side code. - Create separate keys when roles require different levels of API access.
Integration Checklist
- Your application signs with temporary assumed-role credentials.
- The STS host matches your MoEngage data center.
MOE-APPKEYandMOE-APPSECRETare added before signing.- The signed request carries no
Content-Typeheader. - The runtime-resolved ARN appears on the key, with an exact session name or a
*wildcard. - The key carries the API access your integration requires.
MOE-APPSECRETis stored in a secrets manager.- A MoEngage Public API call succeeds with the signed headers.
- No additional authentication header is present.
Frequently Asked Questions
Why is my request rejected when the correct role is allowlisted?
Why is my request rejected when the correct role is allowlisted?
Where do I find MOE-APPSECRET after creating the key?
Where do I find MOE-APPSECRET after creating the key?
Can MOE-APPSECRET be rotated without downtime?
Can MOE-APPSECRET be rotated without downtime?
Does AWS STS Auth replace Basic Auth or OAuth 2.0?
Does AWS STS Auth replace Basic Auth or OAuth 2.0?
When do key changes take effect?
When do key changes take effect?