In the context of AWS, here are the points given for your provided scenario:-
Retrieving AWS account Identity with “aws get caller Identity”
“aws sts get-caller-identity”
This above Command would help you in retrieving the information about the AWS accounts that are making the API call, including the AWS accounts ID, IAM user or role ARN, and the IAM user or even name of the role.
Example of the output:-
{
  “UserId”: “XXXXXXXXXXXXXXXXXXXX”,
  “Account”: “123456789012”,
  “Arn”: “arn:aws:iam::123456789012:user/exampleuser”,
  “ResponseMetadata”: {
    “RequestId”: “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”,
    “HTTPStatusCode”: 200,
    “HTTPHeaders”: {
      “x-amzn-requestid”: “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”,
      “content-type”: “text/xml”,
      “content-length”: “396”,
      “date”: “Sun, 07 Feb 2024 00:00:00 GMT”
    },
    “RetryAttempts”: 0
  }
}
By using the “aws sts get-caller-identity” Command you can obtain valuable information about the AWS accounts which are making API calls. It will further enable you to audit, and manage your AWS resources and other activities.