Tiago Soromenho
posted this on May 28, 2011 02:04 pm
QUESTIONS:
1. When I do create a client account I provide the unique identification of user as "account_id". But while making a login call we use the field "user_id" so why you are referring them with different name in case of "create" request and "login" request?
2. When I got successful response of login request, I got an XML which shows that user_id and account_id does have the same value, but when I do make a request for "account_info" with my details, I got an error. Pleaseeeeeeeeee explain why????
3. Please explain the role of "user_id" and "account_id".
ANSWER:
The "account_id" refers to the actual business account, and its settings. The "user_id" refers to authorized users of that account. Their settings are separate (such as permissions, etc.)
Now, originally, when this program was first developed, there were no users. There was just an account, and this account had an account_id and an associated password. This was how someone who created (and thus "owned" the account) would log in.
Later, we added "users" that "belong" to a particular account, so that there would be permissions and campaign usage differentiation. But for existing clients and some custom integrations, we could not get rid of the original, and since renamed "owner" login.
So today, these two terms refer to two very different things, and that is why when you mix them, as you do in the examples you give, some of the API calls don't work. I'll explain further below:
When you create a new account, you provide an "account_id" which identifies this "loyalty account". Due to the backwards compatibility mentioned about, as well as the need to be able to make validated API calls once the account is created, you also provide a password, and this pair of credentials becomes also known as the "owner id" in the documentation. You can use the "account_id" as a "user_id" in API calls because some clients never establish any other users for their account (though we severely do not recommend this, as changing the password ALSO changes the API token/key).
So in regards to the calls you mention:
- The API call "user_login" can thus take both the "account_id" owner credentials, or "user_id" credentials. Note: The resulting information in the XML record will not differentiate between what is a "owner" and what is a "user" when returning the user info, such as "user_id" etc. So if you use the account's "owner" credentials to make the API calls, they are returned as if they are regular "user" for consistency's sake in integrations. In this call, the only different information is that the business name will be returned as the "user_name" if using the owner credentials.
- The API call "user_info" on the other hand, will return quite different information if called by "owner" credentials instead of "user" ones. To help differentiate, the meta tag "user_is_owner" is returned with a boolean value. For all other calls, this differentiation should not matter.
- The API call "account_info" can be called by either "account_id" or "user_id" credentials, BUT the "account_id" must be a valid Client Account. If an agency_id or user_id is given instead of an account_id, an error will be returned.
So basically, you have to be aware that there are the following "IDs":
1) agency_id: Not used for now in any API calls other than as a field in the "account_new" call.
2) account_id: SHOULD be used ONLY to refer to a specific client loyalty account, and should NOT be used as a user_id, though it is possible and allowed to do so, mainly to create new users or campaigns right after the account is newly created. To use the "account_id" as a "user_id" beyond these initial uses increases the risk of the confusion you are experiencing. When used as a user_id, the account_id is often referred to as an "owner id".
3) user_id: What should be used on a normal basis for making and validating API calls. This refers to individual users added to a Client Loyalty Account.
I hope this clarified the matter. If not, please let me know.