Interacting with the Evernote Business API
Evernote Business empowers businesses with new tools and possibilities for their employees. From a user's perspective, all the contents and notebooks are accessed in the same software environment when working on personal or business notes. Therefore, integrating with the business accounts is only an extension of the general API and simply requires to download the latest version of our libraries.
This document is intended for developers that are familiar with the Cloud API and that have already integrated authentication and at least some basic use of the Evernote API. To better understand this chapter, it is important to have basic knowledge of sharing since access to Business accounts is built on it (general knowledge of our service architecture can also be helpful).
How to determine if a user is part of a business
All the information about the user's affiliation to a business (a user can only be part of one business) is included in the User object (accessible using UserStore.getUser). if the value user.accounting.businessId is set, then the user is part of a business named user.accounting.businessName.
Authenticating, locating and connecting to a business shard
A business account is similar to another user's account in the sense that it is probably stored on another shard, requiring another authentication token and NoteStore connection. Once you are assured that the user is part of a business, you can get a token (valid for an hour) to access the business account using UserStore.authenticateToBusiness. Using that new token, you can access all the business notebooks associated to the user.
Pseudo code - Authenticating to a business
AuthenticationResult auth = UserStore.authenticateToBusiness(userAuthToken)
businessNoteStore = new NoteStore (auth.NoteStoreURL)
// Using auth.authenticationToken and BusinessNoteStore you can access the Business notebooksCreating a notebook in a business account
Evernote Business is built on Evernote's sharing functions and requires to use sharedNotebooks and linkedNotebooks. All the business notebooks that are shown in a user's account are references to notebooks (linkedNotebook) in the business account. On the other hand, every notebook in the business account has references to users that can access it (sharedNotebook).
When a new Notebook is created in a business account, a corresponding SharedNotebook is automatically created and returned in the sharedNotebooks field of the new Notebook object (to specify that the creator of the notebook can access it). After creating the Notebook object in the business account, you must create the corresponding LinkedNotebook object in the user’s account to keep a reference to it. Otherwise, the notebook will not be visible to the user.
Pseudo code - Creating a new notebook in a business account
Notebook notebook = businessNoteStore.createNotebook(...)
SharedNotebook snb = notebook.sharedNotebooks[0]
LinkedNotebook lnb = new LinkedNotebook
lnb.shareKey = snb.shareKey
lnb.shareName = notebook.name
lnb.username = businessUserName
lnb.shardId = businessUser.shardId
userNoteStore.createLinkedNotebook(lnb)Listing all the notebooks accessible by the user in a business
To list all the business notebooks that you should shown in your app, use userNoteStore.listLinkedNotebooks(userAuthToken) and check whether the LinkedNotebook is a business notebook(if linkedNotebook.businessId is set). This is the method we use for our client apps to list all the notebooks that the user is actually accessing. To know if the user can write in a business notebook (or in any LinkedNotebook) check the privilege property of the SharedNotebook.
Creating / updating / reading content in a business notebook
Using the business authentication token and NoteStore, all operations can be done the same way as in the regular user's account. Based on the rights that were granted for each notebook, you may read and potential write content in them.
Note note = new note
note.title = "My new note"
businessNoteStore.createNote(businessAuthenticationToken, note)
...
businessNoteStore.updateNote(businessAuthenticationToken, ...)
...
businessNoteStore.findNotes(businessAuthenticationToken, ...)Creating and activating a business on sandbox
To be able to use and test business notebooks on sandbox, you need to go through the following steps
1) Visit the business account creation page on sandbox
2) Create your business account by selecting Annual invoice as a payment method
3) Open a ticket to request the business activation