
sec.createCredential( name as String, description as String, username as String?, password as String?, certificate as String?, private-key as String?, signing as Boolean, targets as element(sec.credentialTarget)[], permissions as element(sec.permission)[] ) as (Number|String)
This function creates a new security credential with the specified values.
http://marklogic.com/xdmp/privileges/create-credential
  This function must be executed against the security database.
    declareUpdate();
    const sec = require('/MarkLogic/security.xqy');
      
    sec.createCredential("my-secure-credential",
                         "a secure credential", 
                         "secure-user",
                         "secure-password",
                         null,
                         null,
                         fn.false(),
                         null, 
                         [xdmp.permission("secure-role", "execute", "element")]
                        );
      
  
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.