[SalesForce] How to reset an API user’s password

We have set up a API user in Salesforce and just today got this error message:

INVALID_OPERATION_WITH_EXPIRED_PASSWORD: The users password has expired you must call the SetPassword before attempting any other API operations

Can someone clarify? I understand that apparently the API users password has expired, and that I should send a SetPassword request before further action. What is the best practice for this:

Should I reset the password once a month? once a day? only when the error is thrown? What are the password format requirements (special chars, numbers and letters, etc)?

Is there a way to lock the password for this user in the Salesforce admin setup section to deactivate the required password refresh?

Best Answer

To some degree it will depend on the security requirements for your organization. If you absolutely must change the password, then you can use the current session to call SetPassword(). Of course, this creates all sorts of other problems. You now need to automate the storage of the new password and potentially pickup the new security token as well.

Personally, I'd create a dedicated profile for API users.

Then on the profile under Administrative Permissions you can set "Password Never Expires".

With this you don't need to figure out password complexity options or security tokens.

You can also lock down what this profile has access to so it only makes sense to use it for an API user. Maybe restrict it to a particular IP address range.