Hi Chris, Thanks I was able to get this sorted by running the below command.

curl --user "<private>:<public>" --digest \
  --header "Content-Type: application/json" \
  --include \
  --request POST "https://cloud.mongodb.com/api/atlas/v1.0/groups/<group-id>/databaseUsers" \
  --data '{
    "databaseName": "$external",
    "roles": [
      {
        "databaseName": "test",
        "roleName": "readWrite"
        
      }
    ],
    "username": "CN=test_user",
    "x509Type": "CUSTOMER"
  }'  

Also, is there a mechanism to specify the collection name as well? I couldn’t find it here in this document.
https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Database-Users/operation/updateDatabaseUser