openapi: 3.0.0 info: title: Nylas API Template version: '2.1' description: This demonstrates how to document Nylas REST APIs. contact: url: 'http://support.nylas.com/' license: name: MIT url: 'https://opensource.org/licenses/MIT' x-logo: url: '' servers: - url: 'https://api.nylas.com' paths: /folders: get: tags: - Folders parameters: - name: in description: 'Use the `in` filter with`folder_id`, `name`, `display_name`.' schema: type: string in: query - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': content: application/json: schema: type: array items: $ref: '#/components/schemas/Folder-Object' examples: ReturnAllFoldersResponse: value: - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Archive id: ajs4ef7xu74vns6o5ufsu69m7 name: archive object: folder - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Conversation History id: etmvbqwqo64vlm73qvyfj2tet name: string object: folder - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Deleted Items id: blrfzbz4r066ip8x1bh8k8g1y name: trash object: folder - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Drafts id: a6vnuwv9gjj1xidxkhyzxeke1 name: drafts object: folder - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Inbox id: b8un1ec0syrv94153fg3p61ci name: inbox object: folder - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Junk Email id: 8tqebvw8t0aky7f2or1oagwt8 name: spam object: folder - account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Sent Items id: clzqp0nsim0138aohwzha34vk name: sent object: folder description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type description: Bad Request security: - ACCESS_TOKEN: [] operationId: get-folders summary: Return All Folders description: Returns all folders. x-code-samples: - lang: HTTP label: HTTP source: | GET /folders HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Basic WVVUWjZ2**** cache-control: no-cache - lang: bash label: cURL source: |- # Return all folders found in the user's inbox curl -X GET 'https://api.nylas.com/folders' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use offset, and limit to paginate the results curl -X GET 'https://api.nylas.com/folders?limit=2&offset=4' \ -H 'Authorization: Bearer ACCESS_TOKEN - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all folders found in the user's inbox nylas.folders.all() # Use offset, and limit to paginate the results nylas.folders.where(limit=2, offset=4) # Return the first folder folder = nylas.folders.first() # The following attributes are available for the folder object folder.display_name folder.name folder.object folder.account_id folder.id' - lang: ruby label: Ruby SDK source: |- # Return all folders found in the user's inbox nylas.folders # Use offset, and limit to paginate the results nylas.folders.limit(2).offset(4) # Return the last folder nylas.folders.last # Return the first folder folder = nylas.folders.first # The following attributes are available for the folder object folder.display_name folder.name folder.object folder.account_id folder.id - lang: js label: Node.js SDK source: >- // Return all folders found in the user's inbox nylas.folders.list().then(folders => console.log(folders)); // Use offset, and limit to paginate the results nylas.folders.list({limit: 2, offset: 4}).then(folders => console.log(folders)) // Return the first folder nylas.folders.first().then(folder => console.log(folder)); // The following attributes are available for the folder object folder.id folder.object folder.accountId folder.name folder.displayName - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Folder; import com.nylas.FolderQuery; import com.nylas.Folders; public class NylasExamples { public static void getFoldersExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Folders folders = account.folders(); // Return all folders found in the user's inbox folders.list(); // Use offset, and limit to control pagination folders.list(new FolderQuery().limit(2).offset(4)); // Return the first folder Folder folder = folders.list(new FolderQuery().limit(1)).get(0); // The following attributes are available for the folder object folder.getDisplayName(); folder.getName(); folder.getObject(); folder.getId(); folder.getAccountId(); } } post: requestBody: content: application/json: schema: $ref: '#/components/schemas/Folder-Create' examples: CreateAFolderRequest: value: display_name: My Renamed Folder tags: - Folders parameters: - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': content: application/json: schema: $ref: '#/components/schemas/Folder-Object' examples: CreateAFolderResponse: value: account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Archive id: ajs4ef7xu74vns6o5ufsu69m7 name: archive object: folder description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type description: Bad Request security: - ACCESS_TOKEN: [] operationId: post-folders summary: Create a folder description: Creates a new folder. x-code-samples: - lang: HTTP label: HTTP source: | POST /folders HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Basic WVVUW**** cache-control: no-cache { "display_name": "My New Folder" } - lang: bash label: cURL source: |- # Create a new folder curl -X POST 'https://api.nylas.com/folders' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "display_name": "My New Folder" }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Create a new folder folder = nylas.folders.create() # The following attributes can be set for a new folder object folder.display_name = "My Custom Folder" # Save the folder to Nylas and the 3rd party provider # Note: folder.display_name must be assigned a value before you can save the folder folder.save() - lang: ruby label: Ruby SDK source: >- # Create a new folder folder = nylas.folders.create(display_name: 'My Custom Folder') # The following attributes can be set for a new folder object folder.display_name = "My Custom Folder" # Save the folder to Nylas and the 3rd party provider # Note: folder.display_name must be assigned a value before you can save the folder folder.save - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Folder; import com.nylas.Folders; public class NylasExamples { public static void postFolderExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Folders folders = account.folders(); // Create a new folder with the provided display name Folder folder = folders.create("My Custom Folder"); } } '/folders/{id}': get: tags: - Folders parameters: - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': content: application/json: schema: $ref: '#/components/schemas/Folder-Object' examples: example-1: value: account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Archive id: ajs4ef7xu74vns6o5ufsu69m7 name: archive object: folder description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' description: Bad Request security: - ACCESS_TOKEN: [] operationId: get-folders-id summary: Return a folder description: Returns a folder by ID. x-code-samples: - lang: HTTP label: HTTP source: | GET /folders/4zv7p**** HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Basic WVVUWjZ2**** cache-control: no-cache - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/folders/{folder_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate folder id folder = nylas.folders.get('{id}') # The following attributes are available for the folder object folder.display_name folder.name folder.object folder.account_id folder.id - lang: ruby label: Ruby SDK source: |- # Replace {id} with the appropriate folder id folder = nylas.folders.find('{id}') # The following attributes are available for the folder object folder.display_name folder.name folder.object folder.account_id folder.id - lang: js label: Node.js SDK source: |- # Replace {id} with the appropriate folder id nylas.folders.find('{id}').then(folder => console.log(folder)); # The following attributes are available for the folder object folder.id folder.object folder.accountId folder.name folder.displayName - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Folder; import com.nylas.Folders; public class NylasExamples { public static void getFolderExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Folders folders = account.folders(); // Replace {id} with the appropriate folder id Folder folder = folders.get("{id}"); // The following attributes are available for the folder object folder.getDisplayName(); folder.getName(); folder.getId(); folder.getAccountId(); folder.getObject(); } } put: requestBody: content: application/json: schema: $ref: '#/components/schemas/Folder-Update' examples: UpdateAFolderRequest: value: display_name: My Renamed Folder name: renamed-folder tags: - Folders parameters: - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': content: application/json: schema: $ref: '#/components/schemas/Folder-Object' examples: UpdateAFolderResponse: value: account_id: 79xcak1h10r1tmm5ogavx28lb display_name: Archive id: ajs4ef7xu74vns6o5ufsu69m7 name: archive object: folder description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type description: Bad Request security: - ACCESS_TOKEN: [] operationId: put-folders-id summary: Update a folder description: Updates a folder by ID. x-code-samples: - lang: HTTP label: HTTP source: | PUT /folders/51si**** HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Basic WVVU**** Accept: */* Cache-Control: no-cache Host: api.nylas.com accept-encoding: gzip, deflate content-length: 43 Connection: keep-alive cache-control: no-cache { "display_name": "My Renamed Folder" } - lang: bash label: cURL source: |- # Replace {id} to get a specific folder curl -X PUT 'https://api.nylas.com/folders/{folder_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "display_name": "My New Folder Renamed" }' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} to get a specific folder folder = nylas.folders.get('{id}') # The following attributes can be set for a new folder object folder.display_name = "My Custom Folder" # Save folder changes to Nylas and the 3rd party provider # display_name must be set before calling this function folder.save() - lang: ruby label: Ruby SDK source: |- # Replace {id} to get a specific folder folder = nylas.folders.find('{id}') # The following attributes can be set for a new folder object folder.display_name = "My Custom Folder" # Save folder changes to Nylas and the 3rd party provider folder.save - lang: js label: Node.js SDK source: |- // Replace {id} to get a specific folder let folder; nylas.folders.find('{id}').then(res => folder = res); // The following attributes can be set for a new folder object folder.displayName = 'My Custom Folder'; // Save folder changes to Nylas and the 3rd party provider folder.save(); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Folders; public class NylasExamples { public static void putFolderExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Folders folders = account.folders(); // Update a folder's display name by passing the folder ID and the new name. folders.setDisplayName("{folder_id}", "My Custom Label"); } } delete: tags: - Folders parameters: - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type description: Bad Request security: - ACCESS_TOKEN: [] operationId: delete-folders-id summary: Delete a folder description: Deletes a folder. x-code-samples: - lang: HTTP label: HTTP source: | DELETE /folders/51si**** HTTP/1.1 Host: api.nylas.com Content-Type: application/json cache-control: no-cache - lang: bash label: cURL source: |- curl -X DELETE 'https://api.nylas.com/folders/{folder_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Delete folders by specifying the appropriate id nylas.folders.delete('{id}') - lang: ruby label: Ruby SDK source: |- # Replace {id} to get a specific folder folder = nylas.folders.find('{id}') # Delete folder folder.destroy - lang: js label: Node.js SDK source: |- // Delete folders by specifying the appropriate id nylas.folders.delete('{id}'); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Folders; public class NylasExamples { public static void deleteFolderExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Folders folders = account.folders(); // Delete folders by specifying the appropriate id folders.delete("{folder_id}"); } } parameters: - name: id description: The ID of the folder. schema: type: string in: path required: true /oauth/authorize: get: tags: - Hosted Authentication parameters: - name: client_id description: Your Nylas application's client ID. schema: type: string in: query required: true - name: redirect_uri description: >- The URI to which the user will be redirected once authentication completes. This must match a URI registered in the developer dashboard. schema: type: string in: query required: true - name: response_type description: '`code` for server side, `token` for client side.' schema: type: string in: query required: true - name: scopes description: Any combination of supported authentication scopes. schema: type: string in: query required: true - name: login_hint description: >- The user’s email address, if known. If you don't supply a `login_hint`, the Nylas OAuth flow will prompt the user for an email address to authenticate. schema: type: string in: query - name: state description: >- An optional arbitrary string that is returned as a URL parameter in your redirect URI. You can pass a value here to keep track of a specific user’s authentication flow. This may also be used to protect against [CSRF attacks](https://en.wikipedia.org/wiki/Cross-site_request_forgery). The maximum length of this string is 255 characters. schema: type: string in: query - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': content: application/json: schema: type: object properties: code: type: string examples: AuthenticateUserResponse: value: code: string description: OK '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' security: - BASIC_AUTH: [] operationId: get-oauth-authorize summary: Authenticate User description: Authenticate user. x-code-samples: - lang: bash label: cURL source: >- curl -G \ --url 'https://api.nylas.com/oauth/authorize' \ -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \ -d 'client_id=nylas_client_id' \ -d 'redirect_uri=http://example.com/nylas_callback' \ -d 'response_type=code' \ -d 'scopes=email.read_only,calendar.read_only,contacts.read_only' \ -d 'login_hint=my_email@example.com' \ -d 'state=MyCustomStateString' # After your user authenticates, Nylas will return a unique, one-time-use code. # This code can be used to create an access token that grants access to the user account. # See: https://docs.nylas.com/reference#oauthtoken - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) auth_url = nylas.authentication_url( "http://example.com/login_callback", # Required login_hint="your_email@example.com", # Optional state="unique_identifier", # Optional scopes='email, calendar, contacts' # Optional - Default is all scopes # A full list of available scopes can be found here: # https://docs.nylas.com/docs/authentication-scopes ) # This is the URL you need to send the user to to authenticate their account. print(auth_url) # After your user authenticates, Nylas will return a unique, one-time-use code. # This code can be used to create an access token that grants access to the user account. # See: https://docs.nylas.com/reference#oauthtoken - lang: ruby label: Ruby SDK source: |- use OmniAuth::Builder do provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], { name: 'google', access_type: :offline, approval_prompt: "force", prompt: 'consent', scope: ['email', 'profile', 'https://mail.google.com/', 'https://www.google.com/m8/feeds/', 'calendar'].join(', ') } end get "/" do 'Authenticate a Google Account' end get "/auth/failure" do params[:message] end - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); options = { loginHint: 'you_email@example.com', redirectURI: 'https://localhost/callback', scopes: ['email.read_only', 'email.send'], }; // Redirect your user to the auth_url auth_url = Nylas.urlForAuthentication(options); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.HostedAuthentication; import com.nylas.Scope; public class NylasExamples { public static void hostedAuthExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); HostedAuthentication authentication = application.hostedAuthentication(); String hostedAuthUrl = authentication.urlBuilder() .redirectUri("https://example.com/redirect") .responseType("code") // Use token for client-side apps .scopes(Scope.EMAIL, Scope.CALENDAR, Scope.CONTACTS) .loginHint("nyla@nylas.com") .state("example_csrf_token") .buildUrl(); // This is the URL you need to send the user to to authenticate their account. System.out.println(hostedAuthUrl); // After your user authenticates, Nylas will return a unique, one-time-use code. // This code can be used to create an access token that grants access to the user account. // See: https://docs.nylas.com/reference#oauthtoken } } /oauth/token: post: requestBody: description: '' content: application/json: schema: required: - client_id - client_secret - grant_type - code type: object properties: client_id: description: Your Nylas application's client ID. type: string client_secret: description: Your Nylas Developer App client secret. type: string grant_type: description: Set to `authorization_code`. type: string code: description: The authorization code returned from `/oauth/authorize`. type: string examples: SendAccessTokenRequest: value: client_id: string client_secret: string grant_type: string code: string tags: - Hosted Authentication parameters: - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' description: Bad Request security: - BASIC_AUTH: [] operationId: post-oauth-token summary: Send Access Token description: Send access token. x-code-samples: - lang: HTTP label: HTTP source: | POST /oauth/token HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Basic WVVUW**** cache-control: no-cache { "client_id": "CLIENT_ID", "client_secret": "CLIENT_SECRET", "grant_type": "authorization_code", "code": "AUTHORIZATION_CODE" }------WebKitFormBoundary7MA4YWxkTrZu0gW-- - lang: bash label: cURL source: |- curl -X POST \ https://api.nylas.com/oauth/token \ -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \ -d '{ "client_id": "CLIENT_ID", "client_secret": "CLIENT_SECRET", "grant_type": "authorization_code", "code": "AUTHORIZATION_CODE" }' - lang: py label: Python SDK source: >- from nylas import APIClient # Create a client that has access to your Nylas app. nylas_app = APIClient( CLIENT_ID, CLIENT_SECRET ) # Get an access token that grants access to user data and functionality. # You need to generate a one-time-use code via Nylas to pass to this function. # See: https://docs.nylas.com/reference#oauthauthorize ACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}') nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Now you have a Nylas client object that has access to user data and functionality print(nylas.account) - lang: ruby label: Ruby SDK source: |- nylas_token = api.authenticate( name: auth_hash[:info][:name], email_address: auth_hash[:info][:email], provider: :gmail, settings: { google_client_id: ENV['GOOGLE_CLIENT_ID'], google_client_secret: ENV['GOOGLE_CLIENT_SECRET'], google_refresh_token: auth_hash[:credentials][:refresh_token] } ) - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); // Pass credentials to the Nylas client to manage authentication Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); // Get an access token that grants access to user data and functionality. // You need to generate a one-time-use code via Nylas to pass to this function. // See: https://docs.nylas.com/reference#oauthauthorize let access_token; Nylas.exchangeCodeForToken(NYLAS_CODE).then(resp => access_token = resp.access_token); // Pass access_token to the Nylas client const nylas = Nylas.with(access_token); // Now your Nylas client object has access to user data and functionality nylas.calendars.list(); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.NylasAccount; import com.nylas.HostedAuthentication; public class NylasExamples { public static void hostedTokenExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); // Create a client that has access to your Nylas app. NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); HostedAuthentication authentication = application.hostedAuthentication(); // Get an access token that grants access to user data and functionality. // You need to generate a one-time-use code via Nylas to pass to this function. // See: https://docs.nylas.com/reference#oauthauthorize String accessToken = authentication.fetchToken("{code}").getAccessToken(); // Now you have a Nylas client object that has access to user data and functionality NylasAccount account = nylas.account(accessToken); } } /oauth/revoke: post: tags: - Hosted Authentication parameters: - name: Accept schema: default: application/json type: string in: header - name: Content-Type schema: default: application/json type: string in: header responses: '200': description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' description: Bad Request security: - BASIC_AUTH: [] operationId: post-oauth-revoke summary: Revoke Access Tokens description: >- Revoke access tokens. Include the to-be-revoked access token as the HTTP Basic Auth username. ``` curl -X POST https://api.nylas.com/oauth/revoke --user ACCESS_TOKEN_TO_REVOKE ``` A 200 status code response with a body of `{ "success": True }` signifies that the token has been successfully revoked and can no longer be used. If needed, you can also revoke all active access tokens by using the Account Management endpoints. x-code-samples: - lang: HTTP label: HTTP source: | POST /oauth/revoke HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Basic WVVUW**** cache-control: no-cache - lang: bash label: cURL source: >- curl -X POST https://api.nylas.com/oauth/revoke --user ACCESS_TOKEN_TO_REVOKE: - lang: py label: Python SDK source: >- from nylas import APIClient # Pass the access token to the Nylas client to manage the account's tokens nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Revoke the access token that was passed to the Nylas client. nylas.revoke_token() # Revoke all access tokens for the user account. nylas.revoke_all_tokens() # You can also revoke all tokens except for one. nylas.revoke_all_tokens(keep_access_token='{ACCESS_TOKEN}') - lang: ruby label: Ruby SDK source: >- # Revoke the nylas access token so it cannot be used in the future (you probably don't want to do this # unless people deactivate their account with your software) api.revoke(nylas_token) - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); // Pass credentials to the Nylas client to manage authentication Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); // Get the user account let account; Nylas.accounts.find(ACCOUNT_ID).then(resp => account = resp); // Revoke all access tokens for the user account. account.revokeAll(); // You can also revoke all tokens except for one. nylas.revokeAll(ACCESS_TOKEN); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Accounts; public class NylasExamples { public static void revokeTokensExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Accounts accounts = application.accounts(); // Revoke all tokens for an account by providing its ID accounts.revokeAllTokensForAccount("{accountId}", null); // Pass an optional access token to revoke all tokens except for one. accounts.revokeAllTokensForAccount("{accountId}", "{ACCESS_TOKEN}"); } } /connect/authorize: post: requestBody: content: application/json: schema: $ref: '#/components/schemas/Native-Auth-Post' examples: {} tags: - Native Authentication parameters: - name: Accept schema: default: application/json type: string in: header required: true - name: Content-Type schema: default: application/json type: string in: header required: true responses: '200': content: application/json: schema: type: object properties: code: type: string examples: example-1: value: code: one-time-use-code description: OK '400': content: application/json: schema: type: object examples: example-1: value: message: Please include the missing fields type: auth_error missing_fields: - provider error: Missing fields. description: Bad Request '403': content: application/json: schema: type: object examples: example-1: value: message: Please include the missing fields type: auth_error missing_fields: - provider error: Missing fields. description: Forbidden operationId: post-connect-authorize summary: Send Authorization description: > This endpoint is where your application sends mailbox credentials to verify they are correct. This begins the connection process. A successful authentication will return your application a JSON encoded body with a single code parameter. In the next step, your server backend should exchange this code for an access token, which can then be used to make API requests. **Notice about POSTing to /connect/authorize** We recommend that you POST these values directly to api.nylas.com using AJAX from your web application. By sending these directly, your app will never be required to manipulate or store passwords for a user's mailbox. (You don't even want to take the chance of logging these by accident!) x-code-samples: - lang: bash label: cURL source: >- # The following examples will return a one-time-use code. # This code can be exchanged for an account access token that grants full access to user account functionality. # Authenticate Google Accounts curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@nylas.com", "provider": "gmail", "settings": { "google_client_id": "{google_api_client_id}", "google_client_secret": "{geoogle_api_client_secret}", "google_refresh_token": "{google_api_refresh_token}" }, "scopes": "email.read_only,calendar.read_only,contacts.read_only" }' # Authenticate Google Account using a Service Account curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@gmail.com", # Account to be authenticated "provider": "gmail", "settings": { "service_account_json": { # Service account credentials "type": "service_account", "project_id": "my-google-app-123456", "private_key_id": "68915b4e55baac9191dd32e0be784687c6873b14", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIE....fZ1F8=\n-----END PRIVATE KEY-----\n", "client_email": "test-service-account@my-google-app-123456.iam.gserviceaccount.com", "client_id": "10569134234239528168761", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40my-google-app-123456.iam.gserviceaccount.com" } "scopes": "calendar" }' # Authenticate Office365 Accounts curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@nylas.com", "provider": "office365", "settings":{ "microsoft_client_id": "{microsoft_client_id}", "microsoft_client_secret": "{microsoft_client_secret}", "microsoft_refresh_token": "{microsoft_refresh_token}", "redirect_uri": "https://example.com/redirect", # Redirect URI that the was originally used to get the refresh token }, "scopes": "email.read_only,calendar.read_only,contacts.read_only" }' # Authenticate Exchange Accounts curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@nylas.com", "provider": "exchange", "settings": { "username": "nyla@nylas.com", "password": "MakeEmailSuckLess", "exchange_server_host": "exchange.nylas.com" }, "scopes": "email.read_only,calendar.read_only,contacts.read_only" }' # Authenticate Exchange Account using a Service Account via Password curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@nylas.com", # Account to authenticate "provider": "exchange", "settings": { "username": "username", # Service account username "password": "password", # Service account password "service_account": true } "scopes": "calendar.read_only" }' # Authenticate Exchange Account using a Service Account via OAuth curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@nylas.com", # Account to authenticate "provider": "exchange", "settings": { "microsoft_client_id": "{microsoft_client_id}", "microsoft_client_secret": "{microsoft_client_secret}", "microsoft_refresh_token": "{microsoft_refresh_token}", # Service account refresh token! "redirect_uri": "https://example.com/redirect", "service_account": true }, "scopes": "calendar" }' # Authenticate Outlook Accounts curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@outlook.com", "provider": "outlook", "settings": { "username": "nyla@outlook.com", "password": "MakeEmailSuckLess", "exchange_server_host": "eas.outlook.com" }, "scopes": "email.read_only,calendar.read_only,contacts.read_only" }' # Authenticate known IMAP providers curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@aol.com", "provider": "aol", "settings": { "password": "MakeEmailSuckLess" }, "scopes": "email.read_only,calendar.read_only,contacts.read_only" }' # Authenticate a generic IMAP provider curl -X POST https://api.nylas.com/connect/authorize -d '{ "client_id": "nylas_client_id", "name": "Nyla the Cheetah", "email_address": "nyla@nylas.com", "provider": "imap", "settings": { "imap_host": "imap.nylas.com", "imap_port": 993, "imap_username": "nyla", "imap_password": "MakeEmailSuckLess", "smtp_host": "smtp.nylas.net", "smtp_port": 587, "smtp_username": "nyla", "smtp_password": "MakeEmailSuckLess", "ssl_required": true }, "scopes": "email.read_only,calendar.read_only,contacts.read_only" }' - lang: py label: Python SDK source: >- from nylas import APIClient import requests # Create a client that has access to your Nylas app. nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) # Authenticate Gmail Accounts gmail_authentication = { # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-gmail "client_id": CLIENT_ID, "name": "Nyla The Cheetah", "email_address": "nyla@nylas.com", "provider": "gmail", "settings": { # See the Example above to learn more about these values "google_client_id": "{google_api_client_id}", "google_client_secret": "{google_api_client_secret}", "google_refresh_token": "{google_api_refresh_token}" }, "scopes": "email,calendar,contacts" } # Post the authentication payload to Nylas. nylas_authorization = requests.post( "https://api.nylas.com/connect/authorize", json=gmail_authentication ) # This code can be exchanged for an account access token nylas_code = nylas_authorization.json()["code"] # ------------------------------------------- # The remainder contains examples of how to authenticate other types of accounts # Authenticate Exchange Accounts exchange_authentication = { # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-exchange "client_id": CLIENT_ID, "name": "Nyla The Cheetah", "email_address": "nyla@nylas.com", "provider": "exchange", "settings": { "username": "nyla@exchange_server.com", "password": "MakeEmailSuckLess", "eas_server_host": "exchange.your_server.com" }, "scopes": "email,calendar,contacts" } # Authenticate an Outlook Account outlook_authentication = { "client_id": CLIENT_ID, "name": "Nyla The Cheetah", "email_address": "nyla@outlook.com", "provider": "outlook", "settings": { # Uses the same format as Exchange Servers "username": "nyla@outlook.com", "password": "MakeEmailSuckLess", "eas_server_host": "outlook.com" }, "scopes": "email,calendar,contacts" } # Authenticate an account from a known IMAP provider known_imap_authentication = { "client_id": CLIENT_ID, "name": "Nyla The Cheetah", "email_address": "nyla@yahoo.com", "provider": "yahoo", # can also be aol, icloud, or hotmail "settings": { "password": "MakeEmailSuckLess" }, "scopes": "email,calendar,contacts" } # Authenticate any other IMAP account generic_imap_authentication = { "client_id": CLIENT_ID, "name": "Nyla The Cheetah", "email_address": "nyla@nylas.com", "provider": "imap", "settings": { "imap_host": "imap.nylas.com", "imap_port": 12345, "imap_username": "nyla", "imap_password": "MakeEmailSuckLess", "smtp_host": "smtp.nylas.net", "smtp_port": 12346, "smtp_username": "nyla", "smtp_password": "MakeEmailSuckLess", "ssl_required": 'true' }, "scopes": "email,calendar,contacts" } - lang: ruby label: Ruby SDK source: |- nylas_token = api.authenticate( name: auth_hash[:info][:name], email_address: auth_hash[:info][:email], provider: :gmail, settings: { google_client_id: ENV['GOOGLE_CLIENT_ID'], google_client_secret: ENV['GOOGLE_CLIENT_SECRET'], google_refresh_token: auth_hash[:credentials][:refresh_token] } ) - lang: js label: Node.js SDK source: "// The following examples will return a Promise, which resolves to a one-time-use code.\n// This code can be exchanged for an account access token that grants full access to user account functionality.\n\nconst Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// Authenticate Google Accounts\nNylas.connect.authorize({\n name: 'Nyla The Cheetah',\n email_address: 'nyla@gmail.com',\n provider: 'gmail',\n settings: {\n google_client_id: '{google_api_client_id}',\n google_client_secret: '{google_api_client_secret}',\n google_refresh_token: '{google_api_refresh_token}',\n },\n scopes: 'email.read_only,calendar.read_only,contacts.read_only'\n});\n\n// Authenticate Office365 Accounts\nNylas.connect.authorize({\n name: 'Nyla The Cheetah',\n email_address: 'nyla@nylas.com',\n provider: 'office365',\n settings: {\n microsoft_client_id: '{microsoft_client_id}',\n microsoft_client_secret: '{microsoft_client_secret}',\n microsoft_refresh_token: '{microsoft_refresh_token}',\n redirect_uri: 'https://example.com/redirect', // Redirect URI that the was originally used to get the refresh token\n },\n scopes: 'email.read_only,calendar.read_only,contacts.read_only'\n});\n\n// Authenticate Exchange Accounts\nNylas.connect.authorize({\n name: 'Nyla The Cheetah',\n email_address: 'nyla@nylas.com',\n provider: 'exchange',\n settings: {\n username: 'nyla@nylas.com',\n password: 'MakeEmailSuckLess'\n },\n scopes: 'email.read_only,calendar.read_only,contacts.read_only'\n});\n\n// Authenticate Outlook Accounts\nNylas.connect.authorize({\n name: 'Nyla The Cheetah',\n email_address: 'nyla@outlook.com',\n provider: 'outlook',\n settings: {\n username: 'nyla@outlook.com',\n password: 'MakeEmailSuckLess',\n eas_server_host: \"outlook.com\"\n },\n scopes: 'email.read_only,calendar.read_only,contacts.read_only'\n});\n\n// Authenticate known IMAP providers\nNylas.connect.authorize({\n name: 'Nyla The Cheetah',\n email_address: 'nyla@aol.com',\n provider: 'aol',\n settings: {\n \tpassword: 'MakeEmailSuckLess',\n },\n scopes: 'email.read_only,calendar.read_only,contacts.read_only'\n});\n\n// Authenticate a generic IMAP provider\nNylas.connect.authorize({\n name: 'Nyla The Cheetah',\n email_address: 'nyla@nylas.com',\n provider: 'imap',\n settings: {\n imap_host: 'imap.nylas.com',\n imap_port: 993,\n imap_username: 'nyla',\n imap_password: 'MakeEmailSuckLess',\n smtp_host: 'smtp.nylas.com',\n smtp_port: 465,\n smtp_username: 'nyla',\n smtp_password: 'MakeEmailSuckLess',\n ssl_required: true\n },\n scopes: 'email.read_only,calendar.read_only,contacts.read_only'\n});" - lang: java label: Java SDK source: "import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Scope;\nimport com.nylas.NativeAuthentication;\nimport com.nylas.NativeAuthentication.AuthRequestBuilder;\n\nimport com.nylas.GoogleProviderSettings;\nimport com.nylas.ImapProviderSettings;\n\n\npublic class NylasExamples {\n public static void nativeAuthExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n NativeAuthentication authentication = application.nativeAuthentication();\n\n ImapProviderSettings settings = new ImapProviderSettings()\n .imapHost(\"imap.nylas.com\")\n .imapPort(1234)\n .imapUsername(\"nyla\")\n .imapPassword(\"MakeEmailSuckLess\")\n .smtpHost(\"smtp.nylas.com\")\n .smtpPort(2345)\n .smtpUsername(\"nyla\")\n .smtpPassword(\"MakeEmailSuckLess\")\n .sslRequired(true)\n ;\n\n AuthRequestBuilder authRequest = authentication.authRequest()\n .name(\"Nyla The Cheetah\")\n .emailAddress(\"nyla@nylas.com\")\n .providerSettings(settings)\n .scopes(Scope.EMAIL, Scope.CALENDAR, Scope.CONTACTS);\n \n System.out.println(\"Making a native authentication request.\");\n String authorizationCode = authRequest.execute();\n System.out.println(\"Success! Authorization code: \" + authorizationCode);\n\n\t\t\t\t// --------------------------------------------------------\n // The remainder contains examples of how to authenticate other types of accounts\n \n // Authenticate Google Accounts\n GoogleProviderSettings googleSettings = new GoogleProviderSettings()\n .googleClientId(\"google.api.client.id\")\n .googleClientSecret(\"google.api.client.secret\")\n .googleRefreshToken(\"google.refresh.token\")\n ;\n\n ProviderSettings office365Auth = new MicrosoftOffice365ProviderSettings()\n .microsoftClientId(\"{MS_CLIENT_ID}\")\n .microsoftClientSecret(\"{MS_CLIENT_SECRET}\")\n .microsoftRefreshToken(\"{MS_REFRESH_TOKEN}\")\n .redirectUri(\"example.com/nylas-redirect\")\n ;\n \n ProviderSettings exchangeAuth = new MicrosoftExchangeProviderSettings()\n .username(\"nyla@exchange_server.com\")\n .password(\"MakeEmailSuckLess\")\n .easServerHost(\"exchange.your_server.com\")\n ;\n \n ProviderSettings knownImapAuth = new KnownImapProviderSettings(\n \"yahoo\")\n .password(\"MakeEmailSuckLess\")\n ;\n }\n}" security: - BASIC_AUTH: [] /account: get: tags: - Accounts parameters: - name: Accept schema: default: application/json type: string in: header required: true - name: Content-Type schema: default: application/json type: string in: header required: true responses: '200': content: application/json: schema: $ref: '#/components/schemas/Account-Get' examples: ReturnAccountDetails: value: id: awa6ltos76vz5hvphkp8k17nt object: account account_id: awa6ltos76vz5hvphkp8k17nt name: Dorothy Vaughan provider: gmail organization_unit: label sync_state: running linked_at: 1470231381 email_address: dorothy@spacetech.com description: OK '400': content: application/json: schema: $ref: '#/components/schemas/Error-400' description: Bad Request security: - BASIC_AUTH: [] operationId: get-account summary: Return Account Details description: Returns account details. x-code-samples: - lang: HTTP label: HTTP source: | GET /account HTTP/1.1 Host: api.nylas.com Content-Type: application/json Authorization: Bearer ACCESS_TOKEN cache-control: no-cache - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/account \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: |- nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) account = nylas.account # The following attributes are available for the Account object account.id account.account_id account.object account.name account.email_address account.provider account.organization_unit account.sync_state account.linked_at - lang: ruby label: Ruby SDK source: |- nylas = Nylas::API.new( app_id: APP_ID, app_secret: APP_SECRET, access_token: ACCESS_TOKEN ) account = nylas.current_account # The following attributes are available for the Account object account.id account.account_id account.object account.name account.email_address account.provider account.organization_unit account.sync_state account.linked_at - lang: js label: Node.js SDK source: |- nylas.account.get().then(account => console.log(account)); // The following attributes are available for the Account object account.id account.accountId account.object account.name account.emailAddress account.provider account.organizationUnit account.syncState account.linkedAt - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.AccountDetail; import com.nylas.NylasClient; public class DocExamples { public static void getAccountExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); AccountDetail account = nylas.account("{ACCESS_TOKEN}").fetchAccountByAccessToken(); // The following attributes are available for the account object account.getId(); account.getName(); account.getEmailAddress(); account.getProvider(); account.getOrganizationUnit(); account.getSyncState(); account.getLinkedAt(); } } /connect/token: post: summary: Exchange the Token tags: - Native Authentication responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Native-Auth-Token' examples: ExchangeTokenResponse: value: access_token: token account_id: account-id billing_state: paid email_address: nyla@nylas.com id: id linked_at: 1563496685 name: Nyla The Cheeta object: account organization_unit: label provider: google sync_state: running '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-connect-token description: >- This endpoint is where your application exchanges the code received from `/connect/authorize` and receives an access token. This associates the mailbox with your Nylas Cloud app. A successful response from this will be an account object with an access_token attribute. Once you’ve obtained a token, you include it with Nylas API requests as the HTTP Basic Auth Username. You can remove this account from your Nylas Cloud app in the Nylas API console. > **Never send your client secret to a browser!** This request should be made from your server. It's important that you never send your client secret to a browser. In order to do this, your browser JavaScript code should securely send the received code in the previous step to your web app, which in turn makes the request to `/connect/token`. x-code-samples: - lang: HTTP label: HTTP source: |- POST /connect/token HTTP/1.1 Host: api.nylas.com Content-Type: application/json cache-control: no-cache { "client_id": "95fm****", "client_secret": "5s827****", "code": "fZztR****" } - lang: bash label: cURL source: |- curl -X POST "https://api.nylas.com/connect/token" -d '{ "client_id": "{client-id}", "client_secret": "{client-secret}", "code": "{nylas_code}" }' - lang: py label: Python SDK source: >- from nylas import APIClient # Create a client that has access to your Nylas app. nylas_app = APIClient( CLIENT_ID, CLIENT_SECRET ) # Get an access token that grants access to user data and functionality. # You need to generate a one-time-use code via Nylas to pass to this function. # See: https://docs.nylas.com/reference#connectauthorize ACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}') nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Now you have a Nylas client object that has access to user data and functionality print(nylas.account) - lang: ruby label: Ruby SDK source: "auth_hash = env['omniauth.auth']\n\nnylas_token = api.authenticate(name: auth_hash[:info][:name], \n \temail_address: auth_hash[:info][:email], \n provider: :gmail, settings:\n { \n google_client_id: ENV['GOOGLE_CLIENT_ID'],\n google_client_secret: ENV['GOOGLE_CLIENT_SECRET'],\n google_refresh_token: auth_hash[:credentials][:refresh_token] })\n\napi_as_user = api.as(nylas_token)" - lang: js label: Node.js SDK source: >- // The following examples will return a Promise, which resolves to a Nylas account, complete with account id and access token. // This access token grants full access to user account functionality. const Nylas = require('nylas'); Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); // First, you need to generate a one-time-use code via Nylas // See: https://docs.nylas.com/reference#connectauthorize let access_code; Nylas.connect.authorize({ name: 'Nyla The Cheetah', email_address: 'nyla@gmail.com', provider: 'gmail', settings: { google_client_id: '{google_api_client_id}', google_client_secret: '{google_api_client_secret}', google_refresh_token: '{google_api_refresh_token}', }, scopes: 'email.read_only,calendar.read_only,contacts.read_only' }).then(resp => access_code = resp.code); // Use this code to connect the account to your Nylas Application let account; Nylas.connect.token(access_code).then(resp => account = resp); // Use the account's access token to get a Nylas client with access to the account's data and functionality const nylas = Nylas.with(account.access_token); nylas.calendars.list().then(resp => console.log(resp)); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.NylasAccount; import com.nylas.NativeAuthentication; public class NylasExamples { public static void nativeTokenExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); // Create a client that has access to your Nylas app. NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); NativeAuthentication authentication = application.nativeAuthentication(); // Get an access token that grants access to user data and functionality. // You need to generate a one-time-use code via Nylas to pass to this function. // See: https://docs.nylas.com/reference#connectauthorize String accessToken = authentication.fetchToken("{code}").getAccessToken(); // Now you have a Nylas client object that has access to user data and functionality NylasAccount account = nylas.account(accessToken); } } parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true requestBody: content: application/json: schema: type: object properties: client_id: type: string description: Your client ID from the Nylas Developer console. client_secret: type: string description: Your client secret from the Nylas Developer console. code: type: string description: The value returned from calling `/connect/authorize`. required: - client_id - client_secret - code examples: ExchangeTokenRequest: value: client_id: string client_secret: string code: string '/a/{client_id}/accounts': get: summary: Return All Accounts tags: - Account Management responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Account-Return-All' examples: ReturnAllAccounts: value: - account_id: 622x1k5v1ujh55t6ucel7av4 billing_state: free email: example@example.com id: 622x1k5v1ujh55t6ucel7av4 provider: yahoo sync_state: running trial: false - account_id: 123rvgm1iccsgnjj7nn6jwu1 billing_state: paid email: example@example.com id: 123rvgm1iccsgnjj7nn6jwu1 provider: gmail sync_state: running trial: false '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-a-client_id-accounts description: Returns a list of all accounts. x-code-samples: - lang: bash label: cURL source: "curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/ \\\n\t-H 'Authorization: Basic ENCODED_SECRET'" - lang: py label: Python SDK source: >- nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) # Return a list of dictionary objects that represent all accounts connected to an app accounts = nylas.accounts.all() # Return an account specified by a specific id account = nylas.accounts.get('{id}') # Return the first account account = nylas.accounts.first() # The following attributes are available for the account object account.email account.id account.sync_state account.billing_state account.trial - lang: ruby label: Ruby SDK source: >- nylas = Nylas::API.new( app_id: CLIENT_ID, app_secret: CLIENT_SECRET ) # Return a list of dictionary objects that represent all accounts connected to an app accounts = nylas.accounts # Return an account specified by a specific id account = nylas.accounts.find('{id}') # Return the first account account = nylas.accounts.first # The following attributes are available for the account object account.email account.id account.sync_state account.billing_state account.trial - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); Nylas.accounts.list().then(accounts => console.log(accounts)); // Get an account specified by a specific id Nylas.accounts.find('accountId').then(account => console.log(account)); // Get the first account Nylas.accounts.first().then(account => console.log(account)); // The following attributes are available for the Account object account.id account.accountId account.billingState account.emailAddress account.provider account.syncState account.trial account.clientId - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Account; import com.nylas.Accounts; public class NylasExamples { public static void getAccountsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Accounts accounts = application.accounts(); // Return all accounts connected to your Nylas app accounts.list(); // Return an account by specifying its ID Account account = accounts.get("{accountId}"); // The following attributes are available for the account object account.getBillingState(); account.getEmail(); account.getProvider(); account.getSyncState(); account.getTrial(); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true parameters: - schema: type: string name: client_id in: path required: true description: The client ID of your Nylas developer application. '/a/{client_id}/accounts/{id}': parameters: - schema: type: string name: client_id in: path required: true description: The ID of your Nylas developer application. - schema: type: string name: id in: path required: true description: The ID of the account. get: summary: Return a Account tags: - Account Management responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Account-Return-All' examples: ReturnAnAccount: value: account_id: 123rvgm1iccsgnjj7nn6jwu1 billing_state: paid email: example@example.com id: 123rvgm1iccsgnjj7nn6jwu1 provider: gmail sync_state: running trial: false '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-a-client_id-accounts-id description: Returns details from a single account. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/a/{client_id}/accounts/{id} \ -H 'Authorization: Basic ENCODED_SECRET' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) # Return an account specified by a specific id account = nylas.accounts.get('{id}') # Return the first account account = nylas.accounts.first() # The following attributes are available for the account object account.email account.id account.sync_state account.billing_state account.trial - lang: ruby label: Ruby SDK source: |- nylas = Nylas::API.new( app_id: APP_ID, app_secret: APP_SECRET ) - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}) // Get an account specified by a specific id Nylas.accounts.find('accountId').then(account => console.log(account)); // Get the first account Nylas.accounts.first().then(account => console.log(account)); // The following attributes are available for the Account object account.id account.accountId account.billingState account.emailAddress account.provider account.syncState account.trial account.clientId - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Account; import com.nylas.Accounts; public class NylasExamples { public static void getAccountExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Accounts accounts = application.accounts(); // Return an account by specifying its ID Account account = accounts.get("{accountId}"); // The following attributes are available for the account object account.getBillingState(); account.getEmail(); account.getProvider(); account.getSyncState(); account.getTrial(); } } parameters: - schema: type: string default: application/json in: header name: Accept required: true - schema: type: string default: application/json in: header name: Content-Type required: true security: - BASIC_AUTH: [] '/a/{client_id}/accounts/{id}/downgrade': post: summary: Cancel an Account tags: - Account Management responses: '200': description: OK content: application/json: schema: description: '' type: object properties: success: type: string minLength: 1 required: - success examples: CancelAnAccount: value: success: 'true' '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-a-client_id-accounts-id-downgrade description: Cancels a paid Nylas account. x-code-samples: - lang: bash label: cURL source: |- curl -X POST \ https://api.nylas.com/a/{client_id}/accounts/{id}/downgrade \ -H 'Authorization: Basic ENCODED_SECRET' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) # Cancel an account, replace {id} with the appropriate account id account = nylas.accounts.get('{id}') account.downgrade() - lang: ruby label: Ruby SDK source: |- nylas = Nylas::API.new( app_id: APP_ID, app_secret: APP_SECRET ) # Cancel an account, replace {id} with the appropriate account id account = nylas.accounts.find('{id}') account.downgrade - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); // Cancel an account, replace {id} with the appropriate account id Nylas.accounts .find('{id}') .then(account => account.downgrade()) .then(response => console.log(response)); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Accounts; public class NylasExamples { public static void cancelAccountExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Accounts accounts = application.accounts(); // Cancel an account by providing its ID accounts.downgrade("{accountId}"); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept required: true - schema: type: string default: application/json in: header name: Content-Type required: true parameters: - schema: type: string name: client_id in: path required: true description: The ID of your Nylas developer application. - schema: type: string name: id in: path required: true description: The ID of the account to cancel. '/a/{client_id}/accounts/{id}/upgrade': parameters: - schema: type: string name: client_id in: path required: true description: The ID of your Nylas developer application. - schema: type: string name: id in: path required: true description: The ID of the account to reactivate. post: summary: Reactivate an Account tags: - Account Management responses: '200': description: OK content: application/json: schema: description: '' type: object properties: success: type: string minLength: 1 required: - success examples: ReactivateAnAccount: value: success: 'true' '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-a-client_id-accounts-id-upgrade description: Reactivate a cancelled account. x-code-samples: - lang: bash label: cURL source: |- curl -X POST \ https://api.nylas.com/a/{client_id}/accounts/{id}/upgrade \ -H 'Authorization: Basic ENCODED_SECRET' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) account = nylas.accounts.get('{id}') account.upgrade() - lang: ruby label: Ruby SDK source: |- nylas = Nylas::API.new( app_id: APP_ID, app_secret: APP_SECRET ) account = nylas.accounts.find('{id}') account.upgrade - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); Nylas.accounts .find('{id}') .then(account => account.upgrade()); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Accounts; public class NylasExamples { public static void upgradeAccountExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Accounts accounts = application.accounts(); // Reactivate an account by providing its ID accounts.upgrade("{accountId}"); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true '/a/{client_id}/accounts/{id}/revoke-all': parameters: - schema: type: string name: client_id in: path required: true description: The ID of your Nylas developer application. - schema: type: string name: id in: path required: true description: The ID of an account for which to revoke all tokens. post: summary: Revoke All Tokens tags: - Account Management responses: '200': description: OK content: application/json: schema: description: '' type: object properties: success: type: string minLength: 1 required: - success examples: RevokeAllTokensResponse: value: success: 'true' '404': description: Not Found content: application/json: schema: description: '' type: object properties: message: type: string minLength: 1 type: type: string minLength: 1 required: - message - type examples: example-1: value: message: No tokens found for that account id type: api_error operationId: post-a-client_id-accounts-id-revoke-all description: >- Revoke all access tokens for an account. There are two ways to use this endpoint, you can revoke all access tokens, or pass in a access token you want to keep. To revoke all access tokens, pass an empty body. To keep access tokens, pass in a access token. ``` { "keep_access_token": "ACCESS_TOKEN" } ``` x-code-samples: - lang: bash label: cURL source: >- curl -X POST \ https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \ -H 'Authorization: Basic ENCODED_SECRET' # Alternatively, pass an access token to revoke all except the provided token curl -X POST \ https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \ -H 'Authorization: Basic ENCODED_SECRET' \ -d '{ "keep_access_token": "ACCESS_TOKEN" }' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Revoke all tokens nylas.revoke_all_tokens() # Revoke all tokens except for one nylas.revoke_all_tokens(keep_access_token=ACCESS_TOKEN) - lang: ruby label: Ruby SDK source: |- nylas = Nylas::API.new( app_id: APP_ID, app_secret: APP_SECRET, access_token: ACCESS_TOKEN ) account = nylas.accounts.find('{id}') # Revoke all tokens account.revoke_all # Revoke all tokens except for one account.revoke_all(keep_access_token: ACCESS_TOKEN) - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); // Revoke all tokens Nylas.accounts .find('accountId') .then(account => account.revokeAll()); // Revoke all tokens except for one Nylas.accounts .find('accountId') .then(account => account.revokeAll('kept_access_token')); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Accounts; public class NylasExamples { public static void revokeTokensExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Accounts accounts = application.accounts(); // Revoke all tokens for an account by providing its ID accounts.revokeAllTokensForAccount("{accountId}", null); // Pass an optional access token to revoke all tokens except for one. accounts.revokeAllTokensForAccount("{accountId}", "{ACCESS_TOKEN}"); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept required: true - schema: type: string default: application/json in: header name: Content-Type required: true requestBody: content: application/json: schema: description: '' type: object properties: keep_access_token: type: string minLength: 1 description: >- Use this to keep an existing access token instead of deleting them all examples: RevokeAllTokensRequest: value: keep_access_token: string '/a/{client_id}/ip_addresses': parameters: - schema: type: string name: client_id in: path required: true description: The client ID of your Nylas developer application. get: summary: Return Application IP Addresses tags: - Account Management responses: '200': description: OK content: application/json: schema: description: '' type: object properties: ip_addresses: type: array items: {} updated_at: type: number required: - ip_addresses - updated_at examples: ReturnApplicationIPAddressesResponse: value: ip_addresses: - 52.25.153.17 - 52.26.120.161 - 52.39.252.208 - 54.71.62.98 - 34.208.138.149 - 52.88.199.110 - 54.69.11.122 - 54.149.110.158 updated_at: 1544658529 operationId: get-a-client_id-ip_addresses description: |- Return application IP addresses. > Paid Applications > > This endpoint can only be accessed by paid applications. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/a/{client_id}/ip_addresses \ -H 'Authorization: Basic ENCODED_SECRET' - lang: py label: Python SDK source: print(client.ip_addresses()) - lang: ruby label: Ruby SDK source: puts api.ip_addresses - lang: js label: Node.js SDK source: |- Nylas.accounts.first() .then(account => account.ipAddresses()) .then(response => console.log(response)); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.IPAddressWhitelist; public class NylasExamples { public static void ipAddressesExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); IPAddressWhitelist ipAddresses = application.fetchIpAddressWhitelist(); // The following attributes are available for the IPAddressWhitelist object ipAddresses.getIpAddresses(); ipAddresses.getUpdatedAt(); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type description: '' required: true - schema: type: string default: application/json in: header name: Accept required: true '/a/{client_id}/accounts/{id}/token-info': parameters: - schema: type: string name: client_id in: path required: true description: The client_id of your Nylas developer application. - schema: type: string name: id in: path required: true description: The id of the account for which to return information. post: summary: Return Token Information tags: - Account Management responses: '200': description: OK content: application/json: schema: description: '' type: object properties: created_at: type: number description: Timestamp indicating when the access_token was created. example: 1563496685 scopes: type: string minLength: 1 description: >- Which authentications scopes are allowed with this token. See authentication scopes for a list of possible scopes values. example: 'calendar,email,contacts' state: type: string minLength: 1 description: >- Can be valid or inactive. Using an inactive token will return an authorization error. enum: - invalid - valid example: valid updated_at: type: number description: >- Timestamp indicating when the token object was updated, typically reflecting a change in the token's state. example: 1563496685 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: No access_token passed. type: api_error '404': description: Not Found content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: No such token found for that account type: api_error operationId: post-a-client_id-accounts-id-token-info description: Return information about an accounts access token. x-code-samples: - lang: bash label: cURL source: "curl -X POST https://api.nylas.com/a/{client_id}/accounts/{id}/token-info \\\n -H 'Authorization: Basic ENCODED_SECRET' \\\n -d '{\n\t\"access_token\": \"{access_token}\"\n}'" - lang: js label: Node.js SDK source: |- Nylas.accounts .first() .then(account => account.tokenInfo()) .then(response => console.log(response)); - lang: java label: Java SDK source: "curl -X POST https://api.nylas.com/a/{client_id}/accounts/{id}/token-info \\\n -H 'Authorization: Basic ENCODED_SECRET' \\\n -d '{\n\t\"access_token\": \"{access_token}\"\n}'" security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept required: true - schema: type: string default: application/json in: header name: Content-Type required: true requestBody: content: application/json: schema: description: '' type: object properties: access_token: type: string minLength: 1 description: >- The account's access_token value that is returned during authentication. required: - access_token examples: ReturnTokenInformationResponse: value: access_token: string '/a/{client_id}': parameters: - schema: type: string name: client_id in: path required: true description: The client_id of your Nylas developer application. get: summary: Return Application Details tags: - Application Management responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Application-Details-Get' examples: ReturnApplicationDetailsResponse: value: application_name: Moon Indigo ✨ icon_url: >- https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6 redirect_uris: - 'http://localhost:5555/login_callback' - localhost operationId: get-a-client_id description: Return information about a Nylas application. security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true post: summary: Update Application Details operationId: post-a-client_id responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Application-Details-Get' examples: UpdateApplicationDetailsResponse: value: application_name: string icon_url: >- https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6 redirect_uris: - string description: Update application details. security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true requestBody: content: application/json: schema: description: '' type: object properties: application_name: type: string minLength: 1 redirect_uris: type: array items: type: string required: - application_name - redirect_uris examples: UpdateApplicationDetailsRequest: value: application_name: My New App Name redirect_uris: - 'http://localhost:5555/login_callback' - localhost - 'https://customerA.myapplication.com/login_callback' tags: - Application Management /threads: get: summary: Returns All Threads tags: - Threads responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Thread-Object' examples: ReturnAllThreadsResponse: value: - account_id: 1234*** draft_ids: [] first_message_timestamp: 1557950729 folders: - display_name: Inbox id: 4567**** name: inbox has_attachments: false id: 4312**** last_message_received_timestamp: 1557950729 last_message_sent_timestamp: 1557950729 last_message_timestamp: 1557950729 message_ids: - 5634*** object: thread participants: - email: no-reply@cc.yahoo-inc.com name: Yahoo - email: james****@yahoo.com name: James snippet: 'Hi James, welcome.' starred: false subject: Security settings changed on your Yahoo account unread: false version: 1 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-threads description: >- Returns one or more threads that match the filter specified by the query parameters. x-code-samples: - lang: bash label: cURL source: >- # Get all threads found in the user's inbox curl -X GET 'https://api.nylas.com/threads' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Get threads that are filtered by specified arguments # Available filters: subject, to, from, cc, bcc, in, unread, # starred, filename, last_message_before, last_message_after, started_before, started_after curl -X GET 'https://api.nylas.com/threads?to=swag@nylas.com' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use offset, and limit to control pagination curl -X GET 'https://api.nylas.com/threads?limit=5&offset=10' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Get all threads that meet a specified search criteria curl -X GET 'https://api.nylas.com/threads/search?q=agenda' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all threads found in the user's inbox nylas.threads.all() # Return threads that are filtered by specified arguments nylas.threads.where(to='swag@nylas.com') # Available filters: subject, to, from_, cc, bcc, in_, unread, # starred, filename, last_message_before, last_message_after, started_before, started_after # Use offset, and limit to control pagination nylas.threads.where(limit=10, offset=5) # Return all threads that meet a specified search criteria nylas.threads.search('swag@nylas.com') # Return the most recent thread thread = nylas.threads.first() # The following attributes are available for the thread object thread.subject thread.message_ids thread.unread thread.labels # Gmail accounts only thread.folders # All providers other than Gmail thread.last_message_timestamp thread.last_message_received_timestamp thread.account_id thread.object thread.first_message_at thread.id thread.snippet thread.participants thread.draft_ids thread.last_message_received_at thread.version thread.last_message_at thread.first_message_timestamp thread.starred thread.has_attachments - lang: ruby label: Ruby SDK source: >- # Return all threads found in the user's inbox nylas.threads # Return threads that are filtered by specified arguments nylas.threads.where(to: 'swag@nylas.com') # Available filters: subject, to, from, cc, bcc, in, unread, # starred, filename, last_message_before, last_message_after, started_before, started_after # Use offset, and limit to control pagination nylas.threads.limit(10).offset(5) # Return all threads that meet a specified search criteria nylas.threads.search('swag@nylas.com') # Return the most recent thread thread = nylas.threads.first # The following attributes are available for the thread object thread.subject thread.message_ids thread.unread thread.labels # Gmail accounts only thread.folders # All providers other than Gmail thread.last_message_timestamp thread.last_message_received_timestamp thread.account_id thread.object thread.first_message_timestamp thread.id thread.snippet thread.participants thread.draft_ids thread.last_message_received_timestamp thread.version thread.last_message_timestamp thread.starred - lang: js label: Node.js SDK source: >- // Get all threads found in the user's inbox nylas.threads.list().then(threads => console.log(threads)) // Get threads that are filtered by specified arguments nylas.threads.list({to: 'swag@nylas.com'}).then(resp => console.log(resp)); // Available filters: subject, to, from_, cc, bcc, in_, unread, // starred, filename, last_message_before, last_message_after, started_before, started_after // Use offset, and limit to control pagination nylas.threads.list({limit: 5}).then(threads => console.log(threads)) // Get all threads that meet a specified search criteria nylas.threads.search('Debrief').then(threads => console.log(threads)); // Get the most recent thread nylas.threads.first().then(thread => console.log(thread)); // The following attributes are available for the thread object thread.id thread.object thread.accountId thread.subject thread.participants thread.lastMessageTimestamp thread.lastMessageReceivedTimestamp thread.lastMessageSentTimestamp thread.firstMessageTimestamp thread.snippet thread.unread thread.starred thread.hasAttachments thread.version thread.labels thread.messageIds thread.draftIds - lang: java label: Java SDK source: "import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Thread;\nimport com.nylas.ThreadQuery;\nimport com.nylas.Threads;\n\npublic class NylasExamples {\n public static void getThreadsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Threads threads = account.threads();\n \n // Return all threads found in the user's inbox \n threads.list();\n \n // Return threads that are filtered by specified arguments\n // Available filters: subject, to, from, cc, bcc, in, unread,\n // starred, filename, lastMessageBefore, lastMessageAfter, startedBefore, startedAfter\n threads.list(new ThreadQuery().to(\"swag@nylas.com\"));\n \n // Use offset, and limit to control pagination\n threads.list(new ThreadQuery().limit(10).offset(10));\n \n // Return all threads that meet a specified search criteria\n threads.search(\"swag@nylas.com\");\n \n // Return the most recent thread\n Thread thread = threads.list(new ThreadQuery().limit(1)).get(0);\n \n // The following attributes are available for the thread object\n thread.getSubject();\n thread.getMessageIds();\n thread.isUnread();\n thread.getLabels(); // Gmail accounts only\n thread.getFolders(); // All providers other than Gmail\n thread.getFirstMessageTimestamp();\n thread.getLastMessageTimestamp();\n thread.getLastMessageReceivedTimestamp();\n thread.getLastMessageSentTimestamp();\n thread.getAccountId();\n thread.getObjectType();\n \tthread.hasAttachments();\n thread.getId();\n thread.getSnippet();\n thread.getParticipants();\n thread.getDraftIds();\n thread.getVersion();\n thread.isStarred();\n }\n}" parameters: - schema: type: string enum: - ids - count - expanded in: query name: view description: >- Can be one of ids, count, or expanded. See Views for more information. - schema: type: integer format: int32 default: 100 in: query name: limit description: >- The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies. - schema: type: integer format: int32 in: query name: offset description: >- Zero-based offset from default object sorting. See pagination for more information - schema: type: string in: query name: subject description: Return threads with a matching literal subject. - schema: type: string in: query name: any_email description: >- Return threads that have been sent or received from this comma-separated list of email addresses. For example: mail1@mail.com,mail2@mail.com. A maximum of 25 emails may be specified. - schema: type: string in: query name: to description: Return threads containing messages sent to this email address. - schema: type: string in: query name: from description: Return threads containing messages sent from this email address. - schema: type: string in: query name: cc description: >- Return threads containing messages that were CC'd to this email address. - schema: type: string in: query name: bcc description: >- Return threads containing messages that were BCC'd to this email address, likely sent from the parent account. (Most SMTP gateways remove BCC information.) - schema: type: string in: query name: in description: >- Return threads in a given folder, or with a given label. This parameter supports the name, display_name, or id of a folder or label. To get all drafts, use the /drafts endpoint. - schema: type: boolean in: query name: unread description: Return threads with one or more unread messages. - schema: type: string in: query name: starred description: Return threads with one or more starred messages. - schema: type: string in: query name: filename description: Return threads that contain attachments with the given filename. - schema: type: integer format: int32 in: query name: last_message_before description: >- Return threads whose most recent message was received before this Unix-based timestamp. - schema: type: integer format: int32 in: query name: last_message_after description: >- Return threads whose most recent message was received after this Unix-based timestamp. - schema: type: integer format: int32 in: query description: >- Return threads whose first message was received before this Unix-based timestamp. name: started_before - schema: type: integer format: int32 in: query description: >- Return threads whose first message was received after this Unix-based timestamp. name: started_after security: - ACCESS_TOKEN: [] '/threads/{id}': parameters: - schema: type: string name: id in: path required: true description: The ID of the thread to return. get: summary: Returns a Thread tags: - Threads responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Thread-Object' examples: ReturnAThreadResponse: value: account_id: 1234*** draft_ids: [] first_message_timestamp: 1557950729 folders: - display_name: Inbox id: 4567**** name: inbox has_attachments: false id: 4312**** last_message_received_timestamp: 1557950729 last_message_sent_timestamp: 1557950729 last_message_timestamp: 1557950729 message_ids: - 5634*** object: thread participants: - email: no-reply@cc.yahoo-inc.com name: Yahoo - email: james****@yahoo.com name: James snippet: 'Hi James, welcome.' starred: false subject: Security settings changed on your Yahoo account unread: false version: 1 operationId: get-threads-id description: Returns the thread by the specified thread ID. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/threads/{thread_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return a single thread, replace {id} with the appropriate value nylas.threads.get('{id}') # The following attributes are available for the thread object thread.subject thread.message_ids thread.unread thread.labels # Gmail accounts only thread.folders # All providers other than Gmail thread.last_message_timestamp thread.last_message_received_timestamp thread.account_id thread.object thread.first_message_at thread.id thread.snippet thread.participants thread.draft_ids thread.last_message_received_at thread.version thread.last_message_at thread.first_message_timestamp thread.starred thread.has_attachments - lang: ruby label: Ruby SDK source: |- # Return a single thread, replace {id} with the appropriate value nylas.threads.find('{id}') # The following attributes are available for the thread object thread.subject thread.message_ids thread.unread thread.labels # Gmail accounts only thread.folders # All providers other than Gmail thread.last_message_timestamp thread.last_message_received_timestamp thread.account_id thread.object thread.first_message_timestamp thread.id thread.snippet thread.participants thread.draft_ids thread.last_message_received_timestamp thread.version thread.last_message_timestamp thread.starred - lang: js label: Node.js SDK source: |- // Get a single thread, by its id nylas.threads.find('{id}').then(thread => console.log(thread)); // The following attributes are available for the thread object thread.id thread.object thread.accountId thread.subject thread.participants thread.lastMessageTimestamp thread.lastMessageReceivedTimestamp thread.lastMessageSentTimestamp thread.firstMessageTimestamp thread.snippet thread.unread thread.starred thread.hasAttachments thread.version thread.labels thread.messageIds thread.draftIds - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Thread; import com.nylas.Threads; public class NylasExamples { public static void getThreadExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Threads threads = account.threads(); // Replace '{id}' with the appropriate value Thread thread = threads.get("{id}"); // The following attributes are available for the thread object thread.getSubject(); thread.getMessageIds(); thread.isUnread(); thread.getLabels(); // Gmail accounts only thread.getFolders(); // All providers other than Gmail thread.getFirstMessageTimestamp(); thread.getLastMessageTimestamp(); thread.getLastMessageReceivedTimestamp(); thread.getLastMessageSentTimestamp(); thread.getAccountId(); thread.getObjectType(); thread.getId(); thread.getSnippet(); thread.getParticipants(); thread.getDraftIds(); thread.getVersion(); thread.isStarred(); } } parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept security: - ACCESS_TOKEN: [] put: summary: Update a Thread operationId: put-threads-id responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Thread-Object' examples: UpdateAThreadResponse: value: account_id: 6534**** draft_ids: [] first_message_timestamp: 1557950729 folders: - display_name: Inbox id: 3245**** name: inbox has_attachments: false id: 4312**** last_message_received_timestamp: 1557950729 last_message_sent_timestamp: 1557950729 last_message_timestamp: 1557950729 message_ids: - 87567**** object: thread participants: - email: no-reply@cc.yahoo-inc.com name: Yahoo - email: james****@yahoo.com name: James snippet: 'Hi James, welcome.' starred: false subject: Security settings changed on your Yahoo account unread: true version: 2 description: |- Update a thread by ID. When you update a thread, all message in a thread are updated. x-code-samples: - lang: bash label: cURL source: "# Change the unread or starred status of an email thread\ncurl -X PUT 'https://api.nylas.com/threads/{thread_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"unread\": true,\n \"starred\": false\n}'\n\n# Gmail uses labels to organize threads\ncurl -X PUT 'https://api.nylas.com/threads/{thread_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \t\"label_ids\": [\"{label_id}\", \"{label_id}\"] \n}'\n\n# All other providers use folders to organize threads\ncurl -X PUT 'https://api.nylas.com/threads/{thread_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"folder_id\": \"{folder_id}\" \n}'" - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace '{id}' with the appropriate value thread = client.threads.get('{id}') # Mark thread read thread.mark_as_read() # Mark thread unread thread.mark_as_unread() # Star a thread thread.star() # Unstar a thread thread.unstar() # Add a new label to a thread (Gmail) thread.add_label('{label_id}') # Remove a label from a thread (Gmail) thread.remove_label('{label_id}') # Batch update labels on a thread (Gmail) thread.update_labels(['{label_id}', '{another_label_id}']) # Move a thread to a different folder (Non-Gmail) thread.update_folder('{folder_id}') - lang: ruby label: Ruby SDK source: |- # Replace '{id}' with the appropriate value thread = client.threads.find('{id}') # Mark thread read thread.update(unread: false) # Mark thread unread thread.update(unread: true) # Star a thread thread.update(starred: true) # Unstar a thread thread.update(starred: false) # Batch update labels on a thread (Gmail) thread.update(label_ids: ['first-label-id']) - lang: js label: Node.js SDK source: |- // Get a single thread, by its id nylas.threads.find('{id}').then(thread => { // mark as unread (false for read) thread.unread = true; // mark as starred (false for unstarred) thread.starred = true; // add label const existingLabel = nylas.labels.build({displayName: 'Reminders', id: ''}); thread.labels.push(existingLabel); // remove label thread.labels = thread.labels.filter(function(value, index, arr){ return value.displayName != 'Important'; }); // save updates thread.save(); }) - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.util.Arrays; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Threads; public class NylasExamples { public static void putThreadExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Threads threads = account.threads(); // Mark thread read threads.setUnread("{thread_id}", false); // Mark thread unread threads.setUnread("{thread_id}", true); // Star a thread threads.setStarred("{thread_id}", true); // Unstar a thread threads.setStarred("{thread_id}", false); // Update labels on a thread (Gmail) threads.setLabelIds("{thread_id}", Arrays.asList("{label_id}", "{another_label_id}")); // Move a thread to a different folder (Non-Gmail) threads.setFolderId("{thread_id}", "{folder_id}"); } } parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true requestBody: content: application/json: schema: $ref: '#/components/schemas/Thread-PUT' examples: UpdateAThreadRequest: value: unread: true starred: true folder_id: string label_ids: - string tags: - Threads security: - ACCESS_TOKEN: [] /messages: get: summary: Return All Messages tags: - Messages responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Message-Object' examples: ReturnAllMessageResponse: value: - account_id: 43jf**** bcc: [] body: |- Welcome ... </html> cc: [] date: 1557950729 events: [] files: [] folder: display_name: Inbox id: 7hcg**** name: inbox from: - email: no-reply@cc.yahoo-inc.com name: Yahoo id: 7a8939**** object: message reply_to: - email: no-reply@cc.yahoo-inc.com name: Yahoo snippet: 'Hi James, james****@yahoo.com. Welcome.' starred: false subject: Welcome thread_id: cvsp**** to: - email: james****@yahoo.com name: '' unread: true '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-messages description: Returns all messages. Use the query parameters to filter the data. x-code-samples: - lang: bash label: cURL source: >- # Get all threads found in the user's inbox curl -X GET 'https://api.nylas.com/messages' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Get threads that are filtered by specified arguments # Available filters: subject, to, from_, cc, bcc, in_, unread, # starred, filename, last_message_before, last_message_after, started_before, started_after curl -X GET 'https://api.nylas.com/messages?to=swag@nylas.com' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use offset, and limit to control pagination curl -X GET 'https://api.nylas.com/messages?limit=5&offset=10' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use view to expand curl -X GET 'https://api.nylas.com/messages?view=expanded' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Get all threads that meet a specified search criteria curl -X GET 'https://api.nylas.com/messages/search?q=agenda' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all messages found in the user's inbox nylas.messages.all() # Return messages that are filtered by specified arguments nylas.messages.where(to='swag@nylas.com') # Available filters: subject, to, from_, cc, bcc, in_, unread, # starred, filename, thread_id, received_before, received_after # Use offset, and limit to paginate the results nylas.messages.where(limit=10, offset=5) # Expanded view returns additional header information (see below) nylas.messages.where(view='expanded') # Return all messages that meet a specified search criteria nylas.messages.search('swag@nylas.com') # Return the most recent message message = nylas.messages.first() # The following attributes are available for the message object message.id message.object message.account_id message.thread_id message.subject message.from_ message.to message.cc message.bcc message.date message.unread message.starred message.snippet message.body message.files message.events message.folder message.labels message.received_at # These are available in expanded view only. message.headers['Message-Id'] message.headers['References'] message.headers['In-Reply-To'] - lang: ruby label: Ruby SDK source: |- # Return all messages found in the user's inbox nylas.messages # Return messages that are filtered by specified arguments nylas.messages.where(to: 'swag@nylas.com') # Available filters: subject, to, from, cc, bcc, in, unread, # starred, filename, thread_id, received_before, received_after # Use offset, and limit to paginate the results nylas.messages.limit(10).offset(5) # Expanded view returns additional header information (see below) nylas.messages.where(view: 'expanded') # Return all messages that meet a specified search criteria nylas.messages.search('swag@nylas.com') # Return the most recent message message = nylas.messages.first # The following attributes are available for the message object message.id message.object message.account_id message.thread_id message.subject message.from message.to message.cc message.bcc message.date message.unread message.starred message.snippet message.body message.files message.events message.folder message.labels message.received_date # These are available in expanded view only. message.headers.message_id message.headers.references message.headers.in_reply_to - lang: js label: Node.js SDK source: >- // Get all messages found in the user's inbox nylas.messages.list().then(messages => console.log(messages)); // Get messages that are filtered by specified arguments nylas.messages.list({to: 'swag@nylas.com'}).then(resp => console.log(resp)); // Available filters: subject, to, from, cc, bcc, in, unread, // starred, filename, last_message_before, last_message_after, started_before, started_after // Use offset and limit to control pagination nylas.messages.list({limit: 5}).then(messages => console.log(messages)); // Expanded view returns additional header information (see below) nylas.messages.list({view: 'expanded'}).then(resp => console.log(resp)); // Get all messages that meet a specified search criteria nylas.messages.search('Debrief').then(messages => console.log(messages)); // The following attributes are available for the message object message.id message.object message.accountId message.threadId message.subject message.from message.to message.replyTo message.cc message.bcc message.date message.unread message.starred message.snippet message.body message.files message.events message.folder message.labels // These are available in expanded view only. message.headers['Message-Id'] message.headers['References'] message.headers['In-Reply-To'] - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Message; import com.nylas.MessageQuery; import com.nylas.Messages; public class NylasExamples { public static void getMessagesExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Messages messages = account.messages(); // Return all messages found in the user's inbox messages.list(); // Return messages that are filtered by specified arguments // Available Filters: anyEmail, bcc, cc, filename, // from, hasAttachment, in, receivedAfter, receivedBefore, // starred, subject, threadId, to, unread messages.list(new MessageQuery().to("swag@nylas.com")); // Use offset, and limit to control pagination messages.list(new MessageQuery().limit(10).offset(10)); // Return all messages that meet a specified search criteria messages.search("swag@nylas.com"); // Return the most recent message Message message = messages.list(new MessageQuery().limit(1)).get(0); // The following attributes are available for the message object message.getSubject(); message.getSnippet(); message.getBody(); message.getFiles(); message.getFrom(); message.getTo(); message.getCc(); message.getBcc(); message.getUnread(); message.getDate(); message.getLabels(); // Gmail accounts only message.getFolder(); // All providers other than Gmail message.getReplyTo(); message.getAccountId(); message.getObjectType(); message.getId(); message.getSnippet(); message.getStarred(); message.getThreadId(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept - schema: type: string enum: - ids - count - expanded in: query name: view description: >- Can be one of ids, count, or expanded. See Views for more information. - schema: type: integer format: int32 in: query name: limit description: >- The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies. - schema: type: integer format: int32 in: query name: offset description: >- The zero-based offset for the default object sorting. See pagination for more information. - schema: type: string in: query name: subject description: Return messages with a matching literal subject. - schema: type: string in: query name: any_email description: >- Return threads that have been sent or received from this comma-separated list of email addresses. For example: mail1@mail.com,mail2@mail.com. A maximum of 25 emails may be specified. - schema: type: string in: query name: to description: Return messages sent to this email address. - schema: type: string in: query name: from description: Return messages sent from this email address. - schema: type: string in: query name: cc description: Return messages that were CC'd to this email address. - schema: type: string in: query name: bcc description: >- Return messages that were BCC'd to this email address, likely sent from the parent account. (Most SMTP gateways remove BCC information.) - schema: type: string enum: - name - display_name - id in: query name: in description: >- Return messages in a given folder, or with a given label. This parameter supports the name, display_name, or id of a folder or label. Note: If you'd like to get all drafts, use the /drafts endpoint. - schema: type: boolean in: query name: unread description: Return unread messages - schema: type: string in: query name: starred description: Return starred messages. - schema: type: string in: query name: filename description: Return messages that contain attachments with the given filename. - schema: type: string in: query name: thread_id description: Return messages belonging to a specific thread. - schema: type: string in: query name: recieved_before description: Return messages received before this unix timestamp. - schema: type: string in: query name: recieved_after description: Return messages received after this unix timestamp. - schema: type: boolean default: true in: query name: has_attachment description: Return only messages that have attachments (only true is supported). '/messages/{id}': parameters: - schema: type: string name: id in: path required: true description: ID of the message get: summary: Return a Message tags: - Messages responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Message-Object' examples: ReturnAMessageResponse: value: account_id: string bcc: - {} body: string cc: - {} date: 0 events: - {} files: - {} folder: display_name: string id: string name: string from: - email: string name: string id: string object: message reply_to: - email: string name: string snippet: string starred: true subject: string thread_id: string to: - email: string name: string unread: true labels: - string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-messages-id security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json enum: - message/rfc822 - application/json in: header name: Accept description: >- Set the accept header to `message/rfc822`to return the raw message contents. - schema: type: string default: application/json in: header name: Content-Type description: "Returns a message by ID.\n\n**Raw Message Contents**\n\nYou can also return the raw message content by setting the Accept header to `message/rfc822`. This will return the message in [RFC 2822 format](https://www.ietf.org/rfc/rfc2822.txt), including all MIME body subtypes and attachments.\n\n```\ncurl -X GET 'https://api.nylas.com/messages/{message_id}' \\\n-H 'Accept: message/rfc822' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n```\n\n```\nX-Apparently-To: james****@yahoo.com; Wed, 15 May 2019 20:05:29 +0000\nReturn-Path: <accounts@returns.bulk.yahoo.com>\nReceived-SPF: pass (domain of returns.bulk.yahoo.com designates **.***.**.** as permitted sender)\nX-YMailISG: _O6mSNY****\nX-Originating-IP: [**.**.**.**]\nAuthentication-Results: ***.mail.ne1.yahoo.com \n header.i=@cc.yahoo-inc.com; header.s=fz2048; dkim=pass (ok)\nReceived: from 127.0.0.1 (EHLO ***.****.mail.gq1.yahoo.com) (**.***.**.**)\n by ***.mail.ne1.yahoo.com with SMTPS; Wed, 15 May 2019 20:05:28 +0000\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cc.yahoo-inc.com; s=***; t=155****; bh=hXsR****; h=Date:From:Reply-To:To:Subject:From:Subject; b=LI39rKBTkhJNCz9Gl****A==\nReceived: from ****.***.mail.ne1.yahoo.com by ****.***.mail.gq1.yahoo.com with HTTP; Wed, 15 May 2019 20:05:27 +0000\nDate: Wed, 15 May 2019 20:05:23 +0000 (UTC)\nFrom: Yahoo <no-reply@cc.yahoo-inc.com>\nReply-To: Yahoo <no-reply@cc.yahoo-inc.com>\nTo: james****@yahoo.com\nMessage-ID: <1939****.****.15579****@****.member.gq1.yahoo.com>\nSubject: Welcome\nMIME-Version: 1.0\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\nContent-Length: 7282\n\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <style type=\"text/css\">\n html {\n -webkit-text-size-adjust:none;\n }\n body {\n width:100%;\n margin:0 auto;\n padding:0;\n }\n p {\n width:280px;\n line-height: 16px;\n letter-spacing: 0.5px;\n }\n </style>\n <title>Welcome\n \n\n\n\t...\n\n\n\n```" x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/messages/{message_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate message id message = nylas.messages.get('{id}') # The following attributes are available for the message object message.id message.object message.account_id message.thread_id message.subject message.from_ message.to message.cc message.bcc message.date message.unread message.starred message.snippet message.body message.files message.events message.folder message.labels message.received_at # These are available in expanded view only. message.headers['Message-Id'] message.headers['References'] message.headers['In-Reply-To'] - lang: ruby label: Ruby SDK source: |- # Replace {id} with the appropriate message id message = nylas.messages.find('{id}') # The following attributes are available for the message object message.id message.object message.account_id message.thread_id message.subject message.from message.to message.cc message.bcc message.date message.unread message.starred message.snippet message.body message.files message.events message.folder message.labels message.received_date # These are available in expanded view only. message.headers.message_id message.headers.references message.headers.in_reply_to - lang: js label: Node.js SDK source: |- // Replace {id} with the appropriate message id nylas.messages.find('{id}').then(message =>{ // The following attributes are available for the message object message.id message.object message.accountId message.threadId message.subject message.from message.to message.replyTo message.cc message.bcc message.date message.unread message.starred message.snippet message.body message.files message.events message.folder message.labels // These are available in expanded view only. message.headers['Message-Id'] message.headers['References'] message.headers['In-Reply-To'] }); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Message; import com.nylas.Messages; public class NylasExamples { public static void getMessageExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Messages messages = account.messages(); // Replace '{id}' with the appropriate value Message message = messages.get("{id}"); // The following attributes are available for the message object message.getSubject(); message.getSnippet(); message.getBody(); message.getFiles(); message.getFrom(); message.getTo(); message.getCc(); message.getBcc(); message.getUnread(); message.getDate(); message.getLabels(); // Gmail accounts only message.getFolder(); // All providers other than Gmail message.getReplyTo(); message.getAccountId(); message.getObjectType(); message.getId(); message.getSnippet(); message.getStarred(); message.getThreadId(); } } put: summary: Update a Message tags: - Messages responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Message-Object' examples: UpdateAMessageResponse: value: account_id: 43jf3**** bcc: [] body: |- Welcome ... cc: [] date: 1557950729 events: [] files: [] folder: display_name: Inbox id: 7hcg**** name: inbox from: - email: no-reply@cc.yahoo-inc.com name: Yahoo id: 7a8939**** object: message reply_to: - email: no-reply@cc.yahoo-inc.com name: Yahoo snippet: 'Hi James, james****@yahoo.com Welcome.' starred: false subject: Welcome to... thread_id: cvsppk**** to: - email: james****@yahoo.com name: '' unread: true '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: put-messages-id description: Update a message by ID. x-code-samples: - lang: bash label: cURL source: "# Change the unread or starred status of an email message\ncurl -X PUT 'https://api.nylas.com/messages/{message_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"unread\": true,\n \"starred\": false\n}'\n\n# Gmail uses labels to organize messages\ncurl -X PUT 'https://api.nylas.com/messages/{message_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \t\"label_ids\": [\"{label_id}\", \"{label_id}\"] \n}'\n\n# All other providers use folders to organize messages\ncurl -X PUT 'https://api.nylas.com/messages/{message_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"folder_id\": \"{folder_id}\" \n}'" - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace '{id}' with the appropriate value message = client.messages.get('{id}') # Mark message read message.mark_as_read() # Mark message unread message.mark_as_unread() # Star a message message.star() # Unstar a message message.unstar() # Add a new label to a message (Gmail) message.add_label('{label_id}') # Remove a label from a message (Gmail) message.remove_label('{label_id}') # Batch update labels on a message (Gmail) message.update_labels(['{label_id}', '{another_label_id}']) # Move a message to a different folder (Non-Gmail) message.update_folder('{folder_id}') # All message changes must be saved to be synced to the third party provider message.save() - lang: ruby label: Ruby SDK source: >- # Replace '{id}' with the appropriate value message = client.messages.find('{id}') # Mark message read message.update(unread: false) # Mark message unread message.update(unread: true) # Star a message message.update(starred: true) # Unstar a message message.update(starred: false) # Batch update labels on a message (Gmail) message.update(label_ids: ['label-id']) # All message changes must be saved to be synced to the third party provider message.save - lang: js label: Node.js SDK source: |- // Get a single message, by its id nylas.messages.find('{id}').then(message => { // mark as unread (false for read) message.unread = true; // mark as starred (false for unstarred) message.starred = true; // add a label to a message const existingLabel = nylas.labels.find('{labelId}'); message.labels.push(existingLabel); // remove label message.labels = message.labels.filter(function(value, index, arr){ return value.displayName != 'Important'; }); // save your updates to the email provider message.save(); }) - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.util.Arrays; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Messages; public class NylasExamples { public static void putMessageExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Messages messages = account.messages(); // Mark message read messages.setUnread("{message_id}", false); // Mark message unread messages.setUnread("{message_id}", true); // Star a message messages.setStarred("{message_id}", true); // Unstar a message messages.setStarred("{message_id}", false); // Update labels on a message (Gmail) messages.setLabelIds("{message_id}", Arrays.asList("{label_id}", "{another_label_id}")); // Move a message to a different folder (Non-Gmail) messages.setFolderId("{message_id}", "{folder_id}"); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true requestBody: content: application/json: schema: $ref: '#/components/schemas/Message-PUT' examples: UpdateAMessageRequest: value: unread: true starred: true folder_id: string label_ids: - string /labels: get: summary: Return All Labels tags: - Labels responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Labels-Object' examples: ReturnAllLabelsResponse: value: - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: All Mail id: 12r72ur7rojisrmjp5xzau8xs name: all object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: Drafts id: cqb6hnxsx4ihy864he04r5t38 name: drafts object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: Spam id: 93c69s6ekyqsnfq9ujiq9f63b name: spam object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: Important id: 7x5r0j00n2ihffpdrg6kuh06h name: important object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: Inbox id: 9jg5lbc2u95jeguxr0gxw1mp5 name: inbox object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: Trash id: 6p7mt7zoygqbgv0p6hnr3876o name: trash object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent object: label - account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: keep id: eluc9ishugbda9egbmtkkc934 name: 'null' object: label '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-labels description: Returns all labels. x-code-samples: - lang: bash label: cURL source: >- # Return all labels found in the user's inbox curl -X GET 'https://api.nylas.com/labels' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use offset, and limit to paginate the results curl --location --request GET 'https://api.nylas.com/labels?limit=2&offset=4' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all labels found in the user's inbox nylas.labels.all() # Use offset, and limit to paginate the results nylas.labels.where(limit=2, offset=4) # Return the first label label = nylas.labels.first() # The following attributes are available for the label object label.display_name label.name label.object label.account_id label.id - lang: ruby label: Ruby SDK source: |- label = api.labels.last # Return all labels found in the user's inbox nylas.labels # Use offset, and limit to paginate the results nylas.labels.limit(2).offset(4) # Return the last label nylas.labels.last # Return the first label label = nylas.labels.first # The following attributes are available for the label object label.display_name label.name label.object label.account_id label.id - lang: js label: Node.js SDK source: >- // Return all labels found in the user's inbox nylas.labels.list().then(labels => console.log(labels)); // Use offset, and limit to paginate the results nylas.labels.list({limit: 2, offset: 4}).then(labels => console.log(labels)); // Return the first label nylas.labels.first().then(label => console.log(label); // The following attributes are available for the label object label.displayName label.name label.object label.accountId label.id - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Label; import com.nylas.LabelQuery; import com.nylas.Labels; public class NylasExamples { public static void getLabelsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Labels labels = account.labels(); // Return all labels found in the user's inbox labels.list(); // Use offset, and limit to control pagination labels.list(new LabelQuery().limit(2).offset(4)); // Return the first label Label label = labels.list(new LabelQuery().limit(1)).get(0); // The following attributes are available for the label object label.getDisplayName(); label.getName(); label.getId(); label.getAccountId(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type required: true - schema: type: string default: application/json in: header name: Accept required: true - schema: type: string in: query name: limit description: >- The number of objects to return. This value often defaults to 100. If set too high, requests may fail to prevent excessively large response bodies. - schema: type: string in: query name: offset description: A zero-based offset from the default object sorting. post: summary: Create a Label tags: - Labels responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Labels-Object' examples: CreateALabelResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: keep id: eluc9ishugbda9egbmtkkc934 name: 'null' object: label '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-labels description: Creates a new label. x-code-samples: - lang: bash label: cURL source: |- curl -X POST 'https://api.nylas.com/labels' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "display_name": "My New Label" }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Create a new label label = nylas.labels.create() # The following attributes can be set for a new label object label.display_name = "My Custom label" # Save the label to Nylas and the 3rd party provider # Note: label.display_name must be assigned a value before you can save the label label.save() - lang: ruby label: Ruby SDK source: >- # Create a new label label = nylas.labels.create(display_name: "My Custom label") # The following attributes can be set for a new label object label.display_name = "My Custom label" # Save the label to Nylas and the 3rd party provider # Note: label.display_name must be assigned a value before you can save the label label.save - lang: js label: Node.js SDK source: >- // Create a new label label = nylas.labels.build(); // The following attributes can be set for a new label object label.displayName = 'My Custom label'; // Save the label to Nylas and the 3rd party provider // Note: label.displayName must be assigned a value before you can save the label label.save(); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Label; import com.nylas.LabelQuery; import com.nylas.Labels; public class NylasExamples { public static void postLabelExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Labels labels = account.labels(); // Create a new label by specifying a display name Label label = labels.create("My Custom Label"); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: description: '' type: object properties: display_name: type: string minLength: 1 required: - display_name examples: CreateALabelRequest: value: display_name: string '/labels/{id}': parameters: - schema: type: string name: id in: path required: true description: Label ID get: summary: Return a Label tags: - Labels responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Labels-Object' examples: ReturnALabelResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: keep id: eluc9ishugbda9egbmtkkc934 name: 'null' object: label operationId: get-labels-id description: Return a label by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/labels/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate message id label = nylas.labels.get('{id}') # The following attributes are available for the label object label.display_name label.name label.object label.account_id label.id - lang: ruby label: Ruby SDK source: |- # Replace {id} with the appropriate message id label = nylas.labels.find('{id}') # The following attributes are available for the label object label.display_name label.name label.object label.account_id label.id - lang: js label: Node.js SDK source: |- // Replace {id} with the appropriate message id nylas.labels.find('{id}').then(label => console.log(label); // The following attributes are available for the label object label.displayName label.name label.object label.accountId label.id - lang: java label: Java SDK source: |- // Replace {id} with the appropriate message id nylas.labels.find('{id}').then(label => console.log(label); // The following attributes are available for the label object label.displayName label.name label.object label.accountId label.id security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept put: summary: Update a Label tags: - Labels responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Labels-Object' examples: UpdateALabelResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah display_name: keep id: eluc9ishugbda9egbmtkkc934 name: 'null' object: label operationId: put-labels-id description: Updates an existing label. x-code-samples: - lang: bash label: cURL source: |- curl -X PUT 'https://api.nylas.com/labels/{label_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "display_name": "My New Label Renamed" }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate message id label = nylas.labels.get('{id}') # The following attributes can be set for a new label object label.display_name = "My Custom label" # Save the label to Nylas and the 3rd party provider # Note: label.display_name must be assigned a value before you can save the label label.save() - lang: ruby label: Ruby SDK source: >- # Replace {id} with the appropriate message id label = nylas.labels.find('{id}') # The following attributes can be set for a new label object label.display_name = "My Custom label" # Save the label to Nylas and the 3rd party provider # Note: label.display_name must be assigned a value before you can save the label label.save - lang: js label: Node.js SDK source: >- // Replace {id} with the appropriate message id let label; nylas.labels.find('{id}').then(res => label = res); // The following attributes can be set for a new label object label.displayName = "My Custom label" // Save the label to Nylas and the 3rd party provider // Note: label.displayName must be assigned a value before you can save the label label.save() - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Labels; public class NylasExamples { public static void putLabelExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Labels labels = account.labels(); // Update a label's display name by passing the label ID and the new display name. labels.setDisplayName("{label_id}", "My Custom Label"); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: description: '' type: object properties: display_name: type: string minLength: 1 description: The human-readable name for the new label. required: - display_name examples: UpdateALabelRequest: value: display_name: string description: '' delete: summary: Delete a Label tags: - Labels responses: '200': description: OK content: application/json: schema: description: '' type: object properties: job_status_id: type: string minLength: 1 description: >- Use the ID to query the status of deleting the label. See Job Status. examples: DeleteALabelResponse: value: job_status_id: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: delete-labels-id description: Deletes a label. x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE 'https://api.nylas.com/labels/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Delete labels by specifying the appropriate id nylas.labels.delete('{id}') - lang: ruby label: Ruby SDK source: |- # Replace {id} with the appropriate message id label = nylas.labels.find('{id}') # Delete label label.destroy - lang: js label: Node.js SDK source: |- // Delete labels by specifying the appropriate id nylas.labels.delete('{id}') - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Labels; public class NylasExamples { public static void deleteLabelsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Labels labels = account.labels(); // Delete labels by specifying the appropriate id labels.delete("{label_id}"); } } /drafts: get: summary: Return All Drafts tags: - Drafts responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Drafts' examples: ReturnAllDraftsResponse: value: - account_id: 43jf3n4*** bcc: [] body: 'Hello, how are you?' cc: [] date: 1559763005 events: [] files: [] folder: {} from: - email: nylastest***@yahoo.com name: John Doe id: 43vfrmdu1*** object: draft reply_to: [] reply_to_message_id: 43jf3n4*** snippet: 'Hello, how are you?' starred: false subject: ugh? thread_id: 46wnzkxa*** to: - email: '{{email}}' name: '{{name}}' unread: false version: 0 - account_id: 43jf3n4*** bcc: [] body: 'Hello, how are you?' cc: [] date: 1559762902 events: [] files: [] folder: display_name: Draft id: eeangfw9vm*** name: drafts from: - email: nylastest***@yahoo.com name: John Doe id: 92c7gucghzh*** object: draft reply_to: [] reply_to_message_id: 43jf3n4*** snippet: 'Hello, how are you?' starred: false subject: Hello thread_id: e48pmw615r2**** to: - email: '{{email}}' name: '{{name}}' unread: false version: 0 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-drafts description: Returns all drafts. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/drafts/' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all drafts found for a user account nylas.drafts.all() # Use queries to filter results nylas.drafts.where(any_email="swag@nylas.com") # Available filters include to, cc, bcc, unread, starred, subject # Use offset, and limit to paginate the results nylas.drafts.where(limit=1, offset=2) draft = nylas.drafts.first() # The following attributes are available for the draft object draft.subject draft.to draft.cc draft.bcc draft.reply_to_message_id draft.files draft.body draft.date draft.reply_to draft.starred draft.thread_id draft.id draft.last_modified_at draft.snippet draft.version draft.from_ draft.account_id draft.object draft.unread - lang: ruby label: Ruby SDK source: draft = api.drafts.last - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // Get all drafts found in the user's account nylas.drafts.list().then(drafts => console.log(drafts)); // Use queries to filter results // Available filters include to, cc, bcc, unread, starred, subject nylas.drafts.list({to: 'support@nylas.com'}).then(resp => console.log(resp)); // Use offset and limit to paginate the results nylas.drafts.list({limit: 10, offset: 100}).then(resp => console.log(resp)); // Get the first draft nylas.drafts.first().then(draft => console.log(draft)); // The following attributes are available for the draft object draft.id draft.object draft.accountId draft.subject draft.from draft.replyTo draft.to draft.cc draft.bcc draft.date draft.threadId draft.snippet draft.body draft.unread draft.starred draft.files draft.events draft.labels draft.version draft.replyToMessageId - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Draft; import com.nylas.DraftQuery; import com.nylas.Drafts; public class NylasExamples { public static void getDraftsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Drafts drafts = account.drafts(); // Return all drafts found in the user's inbox drafts.list(); // Return drafts that are filtered by specified arguments drafts.list(new DraftQuery().to("swag@nylas.com")); // Available Filters: to, cc, bcc, unread, starred, subject // Use offset, and limit to control pagination drafts.list(new DraftQuery().limit(10).offset(10)); // Return all drafts that meet a specified search criteria drafts.search("swag@nylas.com"); // Return the most recent draft Draft draft = drafts.list(new DraftQuery().limit(1)).get(0); // The following attributes are available for the draft object draft.getSubject(); draft.getSnippet(); draft.getBody(); draft.getFiles(); draft.getFrom(); draft.getTo(); draft.getCc(); draft.getBcc(); draft.getUnread(); draft.getDate(); draft.getReplyToMessageId(); draft.getVersion(); draft.getLabels(); // Gmail accounts only draft.getFolder(); // All providers other than Gmail draft.getAccountId(); draft.getObjectType(); draft.getId(); draft.getSnippet(); draft.getStarred(); draft.getThreadId(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept - schema: type: string in: query name: any_email description: >- Return drafts that have been sent or received from this comma-separated list of email addresses. For example: mail1@mail.com,mail2@mail.com. A maximum of 25 emails may be specified. post: summary: Create a New Draft tags: - Drafts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Drafts' examples: CreateNewDraftResponse: value: account_id: string bcc: - name: string email: string body: string cc: - name: string email: string date: 0 events: - {} files: - {} from: - email: string name: string id: string labels: - display_name: string id: string name: string object: draft reply_to: - {} reply_to_message_id: string snippet: string starred: true subject: string thread_id: string to: - email: string name: string unread: true version: 0 folder: display_name: string id: string name: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type operationId: post-drafts description: Creates a new draft x-code-samples: - lang: bash label: cURL source: |- curl -X POST 'https://api.nylas.com/drafts/' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "body":"This email was sent using the Nylas email API. Visit https://nylas.com for details.", "reply_to": [{ 'email': 'you@example.com', 'name': 'Your Name' }], "from": [{ 'email': 'you@example.com', 'name': 'Your Name' }], "to": [ { {'email': 'swag@nylas.com', 'name': 'My Nylas Friend'} } ], "subject": "With Love, From Nylas", "file_ids": ["{file_id}"] }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Create a new draft object draft = nylas.drafts.create() draft.subject = "With Love, From Nylas" draft.to = [{'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}] # You can also assign draft.cc, draft.bcc, and draft.from_ in the same manner draft.body = "This email was sent using the Nylas email API. Visit https://nylas.com for details." draft.reply_to = [{'email': 'you@example.com', 'name': 'Your Name'}] # Note: changing from_ to a different email address may cause deliverability issues draft.from_ = [{'email': 'you@example.com', 'name': 'Your Name'}] # Replace {id} with the appropriate id for a file that you want to attach to a draft file = nylas.files.get('{id}') # Attach a file to a draft draft.attach(file) # Remove a file attachment from a draft draft.detach(file) # You must save the draft for changes to take effect draft.save() # Note: Nylas saves all drafts, but not all providers # display the drafts on their user interface - lang: ruby label: Ruby SDK source: 'api.drafts.create(display_name: "My New Draft")' - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // Create a new draft object const draft = nylas.drafts.build({ to: [{ name: 'Nylas Swag', email: 'swag@nylas.com' }], subject: 'With Love, From Nylas', body: 'This email was sent using the Nylas email API. Visit https://nylas.com for details.', fileIds: ['{existingFileId}'] }); // Save the draft to send it to Nylas draft.save() - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.util.Arrays; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Draft; import com.nylas.NameEmail; import com.nylas.File; public class NylasExamples { public static void postDraftExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Create a new draft object Draft draft = new Draft(); draft.setSubject("With Love, From Nylas"); draft.setTo(Arrays.asList(new NameEmail("My Nylas Friend", "swag@nylas.com"))); // setCc(), setBcc(), work in the same manner as setTo(). draft.setBody("This email was sent using the Nylas email API. Visit https://nylas.com for details."); draft.setReplyTo(new NameEmail("Your Name", "you@example.com")); // Note: changing the from email address to somthing different may cause deliverability issues draft.setFrom(new NameEmail("Your Name", "you@example.com")); // Replace {id} with the appropriate id for a file that you want to attach to a draft File file = account.files().get("{id}"); // Attach a file to a draft draft.attach(file); // Remove a file attachment from a draft draft.detach(file); // You must save the draft for changes to take effect draft = account.drafts().save(draft); // Note: Nylas saves all drafts, but not all providers // display the drafts on their user interface } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: $ref: '#/components/schemas/Draft-Create' examples: CreateNewDraftRequest: value: subject: From Nylas to: - email: swag@nylas.com name: Nylas cc: - name: string email: string bcc: - name: string email: string from: - name: you@example.com email: Your Name reply_to: - name: Nylas email: swag@nylas.com reply_to_message_id: string body: >- This email was sent using the Nylas email API. Visit https://nylas.com for details. file_ids: - string '/drafts/{id}': parameters: - schema: type: string name: id in: path required: true description: ID of the draft. get: summary: Return a Draft tags: - Drafts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Drafts' examples: ReturnADraftResponse: value: account_id: string bcc: - name: string email: string body: string cc: - name: string email: string date: 0 events: - {} files: - {} from: - email: string name: string id: string labels: - display_name: string id: string name: string object: draft reply_to: - {} reply_to_message_id: string snippet: string starred: true subject: string thread_id: string to: - email: string name: string unread: true version: 0 folder: display_name: string id: string name: string operationId: get-drafts-id description: Returns a draft by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/drafts/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate draft id draft = nylas.drafts.get('{id}') # The following attributes are available for the draft object draft.subject draft.to draft.cc draft.bcc draft.reply_to_message_id draft.files draft.body draft.date draft.reply_to draft.starred draft.thread_id draft.id draft.last_modified_at draft.snippet draft.version draft.from_ draft.account_id draft.object draft.unread - lang: ruby label: Ruby SDK source: draft = api.drafts.find(draft.id) - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // Replace {id} with the appropriate draft id nylas.drafts.find('{id}').then(draft => console.log(draft)); // The following attributes are available for the draft object draft.id draft.object draft.accountId draft.subject draft.from draft.replyTo draft.to draft.cc draft.bcc draft.date draft.threadId draft.snippet draft.body draft.unread draft.starred draft.files draft.events draft.labels draft.version draft.replyToMessageId - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Draft; public class NylasExamples { public static void getDraftExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Replace '{id}' with the appropriate value Draft draft = drafts.get("{id}"); // The following attributes are available for the draft object draft.getSubject(); draft.getSnippet(); draft.getBody(); draft.getFiles(); draft.getFrom(); draft.getTo(); draft.getCc(); draft.getBcc(); draft.getUnread(); draft.getDate(); draft.getLabels(); // Gmail accounts only draft.getFolder(); // All providers other than Gmail draft.getReplyTo(); draft.getAccountId(); draft.getObjectType(); draft.getId(); draft.getSnippet(); draft.getVersion(); draft.getStarred(); draft.getThreadId(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept put: summary: Update a Draft tags: - Drafts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Drafts' examples: UpdateADraftResponse: value: account_id: string bcc: - name: string email: string body: string cc: - name: string email: string date: 0 events: - {} files: - {} from: - email: string name: string id: string labels: - display_name: string id: string name: string object: draft reply_to: - email: nylastest***@yahoo.com name: John Doe reply_to_message_id: string snippet: string starred: true subject: string thread_id: string to: - email: string name: string unread: true version: 0 folder: display_name: string id: string name: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: put-drafts-id description: Updates an existing draft by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X PUT 'https://api.nylas.com/drafts/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "body":"This revised email was sent using the Nylas email API. Visit https://nylas.com for details.", "reply_to": [{ 'email': 'you@example.com', 'name': 'Your Name' }], "from": [{ 'email': 'you@example.com', 'name': 'Your Name' }], "to": [ { {'email': 'swag@nylas.com', 'name': 'My Nylas Friend'} } ], "subject": "With Love, From Nylas", "file_ids": ["{file_id}"], "version": 0 }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate draft id draft = nylas.drafts.get('{id}') draft.subject = "With Love, From Nylas" draft.to = [{'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}] # You can also assign draft.cc, draft.bcc, and draft.from_ in the same manner draft.body = "This email was sent using the Nylas email API. Visit https://nylas.com for details." draft.reply_to = [{'email': 'you@example.com', 'name': 'Your Name'}] # Note: changing from_ to a different email address may cause deliverability issues draft.from_ = [{'email': 'you@example.com', 'name': 'Your Name'}] # Replace {id} with the appropriate id for a file that you want to attach to a draft file = nylas.files.get('{id}') # Attach a file to a draft draft.attach(file) # Remove a file attachment from a draft draft.detach(file) # You must save the draft for changes to take effect draft.save() # Note: Nylas saves all drafts, but not all providers display the drafts on their user interface - lang: ruby label: Ruby SDK source: |- draft_to_change = api.drafts.find("51si***") draft_to_change.update(display_name: "My Renamed Draft") - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // You need a draft's id and its version to update it. // All other fields are optional const draft = nylas.drafts.build({ id: '{id}', version: 0 }); // Update any fields you want to change draft.subject = 'Updated subject: Hello World!'; // Save the draft to persist your updates draft.save() - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.util.Arrays; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Draft; import com.nylas.NameEmail; import com.nylas.File; public class NylasExamples { public static void putDraftExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Replace '{id}' with the appropriate value Draft draft = account.drafts().get("{id}"); draft.setSubject("With Love, From Nylas"); draft.setTo(Arrays.asList(new NameEmail("My Nylas Friend", "swag@nylas.com"))); /// setCc(), setBcc(), work in the same manner as setTo(). draft.setBody("This email was sent using the Nylas email API. Visit https://nylas.com for details."); draft.setReplyTo(new NameEmail("Your Name", "you@example.com")); // Note: changing the from email address to somthing different may cause deliverability issues draft.setFrom(new NameEmail("Your Name", "you@example.com")); // Replace {id} with the appropriate id for a file that you want to attach to a draft File file = account.files().get("{id}"); // Attach a file to a draft draft.attach(file); // Remove a file attachment from a draft draft.detach(file); // You must save the draft for changes to take effect draft = account.drafts().save(draft); // Note: Nylas saves all drafts, but not all providers // display the drafts on their user interface } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: $ref: '#/components/schemas/Draft-Update' examples: UpdateADraftRequest: value: subject: From Nylas to: - email: swag@nylas.com name: Nylas cc: - name: string email: string bcc: - name: string email: string from: - name: you@example.com email: Your Name reply_to: - name: Nylas email: swag@nylas.com reply_to_message_id: string body: >- This email was sent using the Nylas email API. Visit https://nylas.com for details. file_ids: - string delete: summary: Delete a Draft tags: - Drafts responses: '200': description: OK '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: delete-drafts-id description: >- Deletes a draft by ID. The draft version must be specified otherwise it will return an error. x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE 'https://api.nylas.com/drafts/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "version": 0 }' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) draft = nylas.drafts.get("{id}") draft.delete() - lang: ruby label: Ruby SDK source: |- draft = api.drafts.find(draft.id) draft.destroy - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // Delete a draft (draft.version must be valid) const options = { item: draft, callback: optionalCallback } nylas.drafts.deleteItem(options); // Delete a draft by its id and version nylas.drafts.delete('{id}', { version: 0 }, optionalCallback); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Drafts; public class NylasExamples { public static void deleteDraftExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Drafts drafts = account.drafts(); // Delete drafts by specifying the appropriate id drafts.delete("{draft_id}"); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: description: '' type: object properties: version: type: number description: Version of the draft that you are modifying. required: - version examples: DeleteADraftRequest: value: version: 0 /send#drafts: post: summary: Send a Draft tags: - Sending responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Message-Object' examples: SendADraftResponse: value: account_id: string bcc: - {} body: string cc: - {} date: 0 events: - {} files: - {} folder: display_name: string id: string name: string from: - email: string name: string id: string object: message reply_to: - email: string name: string snippet: string starred: true subject: string thread_id: string to: - email: string name: string unread: true labels: - string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-send#drafts description: Send an existing draft. x-code-samples: - lang: bash label: cURL source: |- curl -X POST 'https://api.nylas.com/send' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "draft_id": "{draft_id}", "version": 0 }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate draft id draft = nylas.drafts.get("{id}") draft.send() # The following attributes can be assigned to a draft object draft.subject = "With Love, From Nylas" draft.to = [{'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}] # You can also assign draft.cc, draft.bcc, and draft.from_ in the same manner draft.body = "This email was sent using the Nylas email API. Visit https://nylas.com for details." draft.reply_to = [{'email': 'you@example.com', 'name': 'Your Name'}] # Note: changing from_ to a different email address may cause deliverability issues draft.from_ = [{'email': 'you@example.com', 'name': 'Your Name'}] - lang: ruby label: Ruby SDK source: |- # Replace {id} with the appropriate draft id draft = api.drafts.find("{id}") draft.send! - lang: js label: Node.js SDK source: "// Replace {id} with the appropriate draft id\nnylas.drafts.find('{id}').then(draft => {\n\tdraft.send().then(resp => console.log(resp));\n});\n\n// The following attributes can be assigned to a draft object\ndraft.subject = \"With Love, From Nylas\"\ndraft.to = [{'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}]\n// You can also assign draft.cc, draft.bcc, and draft.from_ in the same manner\ndraft.body = \"This email was sent using the Nylas email API. Visit https://nylas.com for details.\"\ndraft.replyTo = [{'email': 'you@example.com', 'name': 'Your Name'}]\n// Note: changing from to a different email address may cause deliverability issues\ndraft.from = [{'email': 'you@example.com', 'name': 'Your Name'}]" - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.util.Arrays; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Draft; import com.nylas.File; import com.nylas.NameEmail; public class NylasExamples { public static void sendDraftExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Create a new draft object Draft newDraft = new Draft(); // Or, you can get an existing Draft by specifying its ID Draft draft = account.drafts().get("{id}"); draft.setSubject("With Love, From Nylas"); draft.setTo(Arrays.asList(new NameEmail("My Nylas Friend", "swag@nylas.com"))); // You can also assign cc, draft.bcc, and draft.from_ in the same manner draft.setBody("This email was sent using the Nylas email API. Visit https://nylas.com for details."); draft.setReplyTo(new NameEmail("Your Name", "you@example.com")); // Note: changing the from email address to somthing different may cause deliverability issues draft.setFrom(new NameEmail("Your Name", "you@example.com")); // Replace {id} with the appropriate id for a file that you want to attach to a draft File file = account.files().get("{id}"); // Attach a file to a draft draft.attach(file); // Remove a file attachment from a draft draft.detach(file); // You must save the draft for changes to take effect draft = account.drafts().save(draft); // Note: Nylas saves all drafts, but not all providers // display the drafts on their user interface // Finally, send the draft account.drafts().send(draft); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: description: '' type: object properties: draft_id: type: string minLength: 1 description: ID of the existing draft. example: 8p8vg2elbbo98kkqyd4zwoi7p version: type: number description: >- The version of the draft. This must be the most recent version or the request will fail. example: 0 tracking: type: object properties: links: type: boolean description: True enables link tracking. opens: type: boolean description: True enables message open tracking. thread_replies: type: boolean description: True enables thread reply tracking. payload: type: string minLength: 1 description: >- An optional string that allows you to keep track of additional information. This string will be included in the webhook notification. example: Any string required: - draft_id - version examples: SendADraftRequest: value: draft_id: 8p8vg2elbbo98kkqyd4zwoi7p version: 0 tracking: links: true opens: true thread_replies: true payload: Any string /send#directly: post: summary: Send Directly tags: - Sending responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Message-Object' examples: SendDirectlyResponse: value: account_id: 43jf3n4*** bcc: [] body: Sounds great! See you then. cc: [] date: 1559772028 events: [] files: [] folder: {} from: - email: nylastest***@yahoo.com name: John Doe id: 2poq0fz6*** object: message reply_to: - email: nylastest***@yahoo.com name: John Doe snippet: Sounds great! See you then. starred: false subject: 'Re: Meeting' thread_id: cvsppkteox*** to: - email: no-reply@cc.yahoo-inc.com name: '{{name}}' unread: false '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-send#directly description: Send a message without saving it as a draft. x-code-samples: - lang: bash label: cURL source: "curl -X POST 'https://api.nylas.com/send' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n\t\"from\": [{\n\t\t\"email\": \"you@example.com\",\n\t\t\"name\": \"Your Name\"\n\t}],\n\t\"to\": [{\n\t\t\"email\": \"swag@nylas.com\",\n\t\t\"name\": \"My Nylas Friend\"\n\t}],\n\t\"reply_to_message_id\": \"{message_id}\",\n\t\"subject\": \"With Love, From Nylas\",\n\t\"body\": \"This email was sent directly using the Nylas email API. Visit https://nylas.com for details.\",\n\t\"reply_to\": [{\n\t\t\"email\": \"you@example.com\",\n\t\t\"name\": \"Your Name\"\n\t}],\n\t\"file_ids\": [\"{file_id}\"]\n}'" - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Send replies by setting reply_to_message_id for a draft message = nylas.messages.get('{id}') draft = nylas.drafts.create() draft.reply_to_message_id = message.id draft.body = "This is my response" draft.to = message.from_ draft.send() # Replace {id} with the appropriate id for a file that you want to attach to a draft file = nylas.files.get('{id}') # Attach / Remove a file attachment draft.attach(file) draft.detach(file) # The following attributes can be assigned to a draft object draft.subject = "With Love, From Nylas" draft.to = [{'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}] # You can also assign draft.cc, draft.bcc, and draft.from_ in the same manner draft.body = "This email was sent using the Nylas email API. Visit https://nylas.com for details." draft.reply_to = [{'email': 'you@example.com', 'name': 'Your Name'}] # Note: changing from_ to a different email address may cause deliverability issues draft.from_ = [{'email': 'you@example.com', 'name': 'Your Name'}] - lang: ruby label: Ruby SDK source: |- nylas.send!( to: [{ email: 'swag@nylas.com', name: "Nylas" }], subject: "With Love, from Nylas", body: "This email was sent using the Nylas Email API. Visit https://nylas.com for details." ).to_h - lang: js label: Node.js SDK source: |- const replyCallback = function (err, message) { if (err) { console.log(err); } else { const draft = nylas.drafts.build(); // Send replies by setting replyToMessageId for a draft draft.replyToMessageId = message.id; draft.to = message.from; draft.body = 'This is my response'; draft.send(); } } nylas.messages.find('{id}', replyCallback); // Replace {id} with the appropriate id for a file that you want to attach to a draft nylas.files.find('{id}').then(file => { draft.files = [file]; // Attach file(s) draft.files = []; // Detach files draft.save(); }) // The following attributes can be assigned to a draft object draft.subject = "With Love, From Nylas" draft.to = [{'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}] // You can also assign draft.cc, draft.bcc, and draft.from_ in the same manner draft.body = "This email was sent using the Nylas email API. Visit https://nylas.com for details." draft.replyTo = [{'email': 'you@example.com', 'name': 'Your Name'}] // Note: changing from to a different email address may cause deliverability issues draft.from = [{'email': 'you@example.com', 'name': 'Your Name'}] - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.util.Arrays; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Draft; import com.nylas.File; import com.nylas.NameEmail; public class NylasExamples { public static void sendDirectExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Create a new draft object Draft newDraft = new Draft(); // Or, you can get an existing Draft by specifying its ID Draft draft = account.drafts().get("{id}"); draft.setSubject("With Love, From Nylas"); draft.setTo(Arrays.asList(new NameEmail("My Nylas Friend", "swag@nylas.com"))); // You can also assign cc, bcc, and from in the same manner draft.setBody("This email was sent using the Nylas email API. Visit https://nylas.com for details."); draft.setReplyTo(new NameEmail("Your Name", "you@example.com")); // Note: changing the from email address to somthing different may cause deliverability issues draft.setFrom(new NameEmail("Your Name", "you@example.com")); // Replace {id} with the appropriate id for a file that you want to attach to a draft File file = account.files().get("{id}"); // Attach a file to a draft draft.attach(file); // Remove a file attachment from a draft draft.detach(file); // Send the draft without saving it to the third party provider account.drafts().send(draft); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/jso in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: $ref: '#/components/schemas/Draft-Create' examples: SendDirectlyRequest: value: subject: From Nylas to: - email: swag@nylas.com name: Nylas cc: - name: string email: string bcc: - name: string email: string from: - name: you@example.com email: Your Name reply_to: - name: Nylas email: swag@nylas.com reply_to_message_id: string body: >- This email was sent using the Nylas email API. Visit https://nylas.com for details. file_ids: - string description: '' /send: post: summary: Send Raw MIME tags: - Sending responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Message-Object' examples: SendRawMimeResponse: value: account_id: 43jf3n4*** bcc: [] body: Sounds great! See you then. cc: [] date: 1559772028 events: [] files: [] folder: {} from: - email: nylastest***@yahoo.com name: John Doe id: 2poq0fz6*** object: message reply_to: - email: nylastest***@yahoo.com name: John Doe snippet: Sounds great! See you then. starred: false subject: 'Re: Meeting' thread_id: cvsppkteox*** to: - email: no-reply@cc.yahoo-inc.com name: '{{name}}' unread: false operationId: post-send#raw description: | Sends a raw MIME message. x-code-samples: - lang: bash label: cURL source: >- curl -X POST 'https://api.nylas.com/send' \ -H 'Content-Type: message/rfc822' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d 'MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com> References: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com> Subject: With Love, From Nylas From: You To: My Nylas Friend This email was sent via raw MIME using the Nylas email API. Visit https://nylas.com for details.' - lang: py label: Python SDK source: '# This is not implemented in the Python SDK' - lang: ruby label: Ruby SDK source: api.messages.raw.send(message.id) - lang: js label: Node.js SDK source: >- // Send a message with raw MIME const draft = nylas.drafts.build({ rawMime }); // rawMIME should be a MIME-format string with headers and multipart message draft.send().then(message => console.log(message)); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Message; public class NylasExamples { public static void sendRawMimeExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // rawMIME should be a MIME-format string with headers and multipart message String rawMime = ""; Message message = account.drafts().sendRawMime(rawMime); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: message/rfc822 in: header name: Content-Type - schema: type: string default: '1.0' in: header name: MIME-Version requestBody: content: text/plain: schema: type: string examples: SendRawMimRequest: value: >- curl -X POST 'https://api.nylas.com/send' \ -H 'Content-Type: message/rfc822' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d 'MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com> References: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com> Subject: With Love, From Nylas From: You To: My Nylas Friend This email was sent via raw MIME using the Nylas email API. Visit https://nylas.com for details.' description: >- ``` curl -X POST 'https://api.nylas.com/send' \ -H 'Content-Type: message/rfc822' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d 'MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com> References: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com> Subject: With Love, From Nylas From: You To: My Nylas Friend This email was sent via raw MIME using the Nylas email API. Visit https://nylas.com for details.' ``` parameters: [] /files: get: summary: Return All Files tags: - Files responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/File-Object' examples: ReturnAllFilesResponse: value: - account_id: 43jf3n4es3*** content_type: image/jpeg filename: image.jpg id: 9etjh6talp*** object: file size: 72379 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-files description: Returns information about each files metadata. x-code-samples: - lang: bash label: cURL source: |- # Return all file attachments found in the user's account curl -X GET 'https://api.nylas.com/files/' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use limit and offset to control pagination curl -X GET 'https://api.nylas.com/files/?limit=5&offset=10' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Available filters: content_type, message_id, filename curl -X GET 'https://api.nylas.com/files?content_type=image/jpeg' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all file attachments found in the user's account nylas.files.all() # Use limit and offset to control pagination nylas.files.where(limit=5, offset=10) # .where() returns files that are filtered by specified arguments # Available filters: content_type, message_id, filename file = nylas.files.where(content_type='application/pdf').first() # .first() returns the oldest file from the results of a query # The following attributes are available for the file object file.size file.account_id file.object file.filename file.content_type file.message_ids file.content_id file.id - lang: ruby label: Ruby SDK source: |- example_file = api.files.first # Listing files api.files.limit(2).map(&:to_h) - lang: js label: Node.js SDK source: >- // Return all file attachments found in the user's account nylas.files.list().then(files => console.log(files)); // Use limit and offset to control pagination nylas.files.list({limit: 5, offset: 10}).then(files => console.log(files)); // .list() and .first() return files that are filtered by specified arguments // Available filters: contentType, messageId, filename nylas.files.first({content_type: 'application/pdf'}).then(file => console.log(file)); // .first() returns the oldest file from the results of a query // The following attributes are available for the file object file.id file.object file.accountId file.contentType file.size file.filename file.messageIds file.contentId file.contentDisposition - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.File; import com.nylas.FileQuery; import com.nylas.Files; public class NylasExamples { public static void getFilesExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Files files = account.files(); // Return all files found in the user's inbox files.list(); // Return files that are filtered by specified arguments // Available Filters: contentType, messageId, filename files.list(new FileQuery().filename("My File")); // Use offset, and limit to control pagination files.list(new FileQuery().limit(5).offset(10)); // Return the most recent file File file = files.list(new FileQuery().limit(1)).get(0); // The following attributes are available for the file object file.getId(); file.getContentId(); file.getContentType(); file.getFilename(); file.getMessageIds(); file.getSize(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept - schema: type: string in: query name: filename description: Return files that match the specified file name. - schema: type: string in: query name: message_id description: Return files matching the specified message ID. - schema: type: string in: query description: Return files matching the specified content type. name: content_type - schema: type: string enum: - count - ids in: query name: view description: >- Return files matching the specified count or ids. See Views for more info. post: summary: Upload a New File tags: - Files responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/File-Object' examples: UploadAFileResponse: value: - account_id: 43jf3n4es3*** content_type: image/jpeg filename: image.jpg id: 9etjh6talp*** object: file size: 72379 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-files description: Uploads a new file. x-code-samples: - lang: bash label: cURL source: |- curl -X POST 'https://api.nylas.com/files/' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ --form 'file=@{path_to_file}' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Create a new file with the stream interface for binary objects attachment = open('attachment.pdf', 'r') file = nylas.files.create() file.filename = 'attachment.pdf' file.stream = attachment # .save() saves the file to Nylas, file.id can then be used to attach the file to an email file.save() attachment.close() # Create a new file with the data interface for text objects file = nylas.files.create() file.filename = 'test.txt' file.data = "Hello World." file.save() - lang: ruby label: Ruby SDK source: >- # Uploading a file api.files.create(file: File.open(File.expand_path(__FILE__), 'r')).to_h - lang: js label: Node.js SDK source: |- fs.readFile(filePath, (err, data) => { f = nylas.files.build({ filename: filePath, data: data, contentType: 'text/plain', }); f.upload((err, file) => { // Create a draft and attach the file to it. const draft = nylas.drafts.build({ subject: 'Ice Cream', to: [{ email: 'helena@nylas.com' }], body: 'Hey, find the file attached.', }); draft.files = [file]; draft.send().then(message => { console.log(`${message.id} was sent`); }); }); }); // Stream files from AWS const AWS = require('aws-sdk'); const Nylas = require('nylas'); Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); const nylas = Nylas.with(ACCESS_TOKEN); var s3 = new AWS.S3(); var s3Stream = s3.getObject({Bucket: s3bucket, Key: s3key}).createReadStream(); var newFile = nylas.files.build({filename: 'newfileyay.jpg', data: s3Stream, contentType: 'image/jpeg', size: s3size}); newFile.upload(); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.nio.file.Paths; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Files; import com.nylas.File; public class NylasExamples { public static void postFileExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Files files = account.files(); byte[] myFile = java.nio.file.Files.readAllBytes(Paths.get("/path/to/myFile.pdf")); File upload = files.upload("My Upload", "application/pdf", myFile); System.out.println(upload); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: multipart/form-data: schema: type: object properties: file: type: string description: The file to upload. Upload size limit is ~25 MB. format: binary examples: UploadAFileRequest: value: file: string '/files/{id}': parameters: - schema: type: string name: id in: path required: true description: The file ID. get: summary: Returns a File tags: - Files responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/File-Object' examples: ReturnsAFileResponse: value: account_id: 43jf3n4es3*** content_type: image/jpeg filename: image.jpg id: 9etjh6talp*** object: file size: 72379 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-files-id description: Returns file metadata by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/files/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate file id file = nylas.files.get('{id}') # The following attributes are available for the file object file.size file.account_id file.object file.filename file.content_type file.message_ids file.content_id file.id - lang: ruby label: Ruby SDK source: |- # Retrieving file metadata example_file = api.files.first api.files.find(example_file.id).to_h - lang: js label: Node.js SDK source: |- // Replace {id} with the appropriate file id nylas.files.find('{id}').then(file => console.log(file)); // The following attributes are available for the file object file.id file.object file.accountId file.contentType file.size file.filename file.messageIds file.contentId file.contentDisposition - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.File; import com.nylas.Files; public class NylasExamples { public static void getFileExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Files files = account.files(); // Get a file by specifying the file ID File file = files.get("FILE_ID"); // The following attributes are available for the file object file.getId(); file.getContentId(); file.getContentType(); file.getFilename(); file.getMessageIds(); file.getSize(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept delete: summary: Delete a File tags: - Files responses: '200': description: OK '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: delete-files-id description: Deletes a file by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE 'https://api.nylas.com/files/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate file id nylas.files.delete('{id}') # Note: Only files that have been uploaded via Nylas can be deleted. - lang: ruby label: Ruby SDK source: '# Not supported' - lang: js label: Node.js SDK source: >- // Replace {id} with the appropriate file id nylas.files.delete('{id}') // Note: Only files that have been uploaded via Nylas can be deleted. - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Files; public class NylasExamples { public static void deleteFileExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Files files = account.files(); files.delete("{fileId}"); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type '/files/{id}/download': parameters: - schema: type: string name: id in: path required: true description: The file ID get: summary: Download a File tags: - Files responses: '200': description: OK. Response will return file data for download. '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-files-id-download description: Download a file. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/files/{id}/download' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Replace {id} with the appropriate file id file = nylas.files.get('{id}') # .download() returns the file itself. # Most files will be returned as a binary object file.download() - lang: ruby label: Ruby SDK source: >- # Downloading a particular file example_file = api.files.first example_file.download # Downloading a particular file is cached. Notice the path didn't change example_file = api.files.first example_file.download # Re-downloading a file, notice the path does change. example_file = api.files.first example_file.download! - lang: js label: Node.js SDK source: |- // Replace {id} with the appropriate file id let file; nylas.files.find('{id}').then(res => file = res); // .download() returns the file itself. // Most files will be returned as a binary object file.download().then(res => console.log(res)); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import java.nio.file.Paths; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.File; import com.nylas.Files; public class NylasExamples { public static void downloadFileExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Files files = account.files(); File file = files.get("{fileId}"); byte[] fileBytes = files.downloadBytes(file.getId()); java.nio.file.Files.write(Paths.get("/tmp/" + file.getFilename()), fileBytes); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type /calendar: get: summary: Return All Calendars tags: - Calendar responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Calendar' examples: ReturnAllCalendarsResponse: value: - description: Events id: 67qmz3fuk9wf*** name: Calendar account_id: bh1vu31mw9ap*** object: calendar read_only: false - description: Emailed events id: b4xm1jjibrxky*** name: Emailed events account_id: bh1vu31mw9a*** object: calendar read_only: true operationId: get-calendar description: Returns all calendars. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/calendars' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all calendars found in the user's account nylas.calendars.all() # Returns a count of the calendars the user account has nylas.calendars.where(view='count') # You can also provide view='id' to provide the calendar ids only. # Return the first calendar calendar = nylas.calendars.first() # The following attributes are available for the calendar object calendar.id calendar.object calendar.account_id calendar.name calendar.description calendar.read_only - lang: ruby label: Ruby SDK source: |- # Return all calendars found in the user's account nylas.calendars # Return the ids of all calendars for a user account nylas.calendars.ids # Return the count of the calendars a user account has api.calendars.count # Return the first two calendars for the user account calendars.calendars.limit(2) # Return the first calendar calendar = nylas.calendars.first # The following attributes are available for the calendar object calendar.id calendar.object calendar.account_id calendar.name calendar.description calendar.read_only - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // Get all calendars found in the user's account nylas.calendars.list().then(calendars => console.log(calendars)); // Get a count of all the users' calendars nylas.calendars.count().then(calendarCount => console.log(calendarCount)); // Get the first calendar nylas.calendars.first().then(calendar => console.log(calendar)); // The following attributes are available for the Calendar object calendar.id calendar.object calendar.accountId calendar.name calendar.description calendar.readOnly - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Calendar; import com.nylas.CalendarQuery; import com.nylas.Calendars; public class NylasExamples { public static void getCalendarsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Calendars calendars = account.calendars(); // Return all calendars found for the user calendars.list(); // Use offset, and limit to control pagination calendars.list(new CalendarQuery().limit(2).offset(4)); // Return the first calendar Calendar calendar = calendars.list(new CalendarQuery().limit(1)).get(0); // The following attributes are available for the calendar object calendar.getId(); calendar.getAccountId(); calendar.getDescription(); calendar.getName(); calendar.isReadOnly(); } } parameters: - schema: type: string enum: - count - ids in: query name: view description: >- Return calendars matching the specified view. Value can be count or ids. Reference Views for more info. - schema: type: string nullable: true in: query name: limt description: >- Return calendars with a specified result limit. Reference Pagination for additional details. - schema: type: string in: query name: offset description: >- Return calendars matching the specified result pagination offset. See Pagination for additional details. - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type security: - ACCESS_TOKEN: [] post: summary: Create a Calendar tags: - Calendar responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Calendar-Create-Update-Response' examples: CreateACalendarResponse: value: account_id: eof2wrhqkl7kdwhy9hylpv9o9 description: Description of my new calendar id: 8e570s302fdazx9zqwiuk9jqn is_primary: true job_status_id: 48pp6ijzrxpw9jors9ylnsxnf location: Location description name: My New Calendar object: calendar read_only: true timezone: America/Los_Angeles operationId: post-calendar description: > Create a calendar. When making modifications to calendar objects, Nylas exposes a Job Status that represents whether the action has synced back to the provider or not. > Support > > Creating calendars is currently only supported for Gmail and GSuite account types. x-code-samples: - lang: bash label: cURL source: '' - lang: py label: Python SDK source: | # Not yet supported - lang: ruby label: Ruby SDK source: '# Not yet supported' - lang: js label: Node.js SDK source: // Not yet supported - lang: java label: Java SDK source: // Not yet supported security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: $ref: '#/components/schemas/Calendar-Create' examples: CreateCalendarRequest: value: name: My New Calendar description: Description of my new calendar location: Location description timezone: America/Los_Angeles '/calendar/{id}': parameters: - schema: type: string name: id in: path required: true description: The ID of the calendar. get: summary: Return A Calendar tags: - Calendar responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Calendar' examples: ReturnACalendarResponse: value: description: Emailed events id: 67qmz3fuk9wf*** name: Calendar account_id: bh1vu31mw9ap*** object: calendar read_only: true '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-calendar-id description: Returns a calendar by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/calendars/{calendar_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return a single calendar by specifying its id calendar = nylas.calendars.get('{id}') # The following attributes are available for the calendar object calendar.id calendar.object calendar.account_id calendar.name calendar.description calendar.read_only - lang: ruby label: Ruby SDK source: |- # Return a single calendar by specifying its id calendar = nylas.calendars.find('{id}') # The following attributes are available for the calendar object calendar.id calendar.object calendar.account_id calendar.name calendar.description calendar.read_only - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({clientId: 'clientId', clientSecret: 'clientSecret'}); const nylas = Nylas.with('access_token'); // Get a calendar by its id nylas.calendars.find('calendarId').then(calendar => console.log(calendar)); // The following attributes are available for the Calendar object calendar.id calendar.object calendar.accountId calendar.name calendar.description calendar.readOnly - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Calendar; import com.nylas.Calendars; public class NylasExamples { public static void getCalendarExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Calendars calendars = account.calendars(); // Get a calendar by specifying the calendar ID Calendar calendar = calendars.get("FILE_ID"); // The following attributes are available for the calendar object calendar.getId(); calendar.getAccountId(); calendar.getDescription(); calendar.getName(); calendar.isReadOnly(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type put: summary: Update A Calendar tags: - Calendar responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Calendar-Create-Update-Response' examples: UpdateACalendarResponse: value: account_id: eof2wrhqkl7kdwhy9hylpv9o9 description: Description of my new calendar id: 8e570s302fdazx9zqwiuk9jqn is_primary: true job_status_id: 48pp6ijzrxpw9jors9ylnsxnf location: Location description name: My New Calendar object: calendar read_only: true timezone: America/Los_Angeles '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: put-calendar-id description: Updates a calendar. x-code-samples: - lang: bash label: cURL source: "curl -X PUT \\\n\"https://api.nylas.com/calendars\" \\\n-d '{\n\t\"description\":\"Updating the description my new calendar.\"\n}'" - lang: py label: Python SDK source: '# Not yet supported' - lang: ruby label: Ruby SDK source: '# Not yet supported' - lang: js label: Node.js SDK source: // Not yet supported - lang: java label: Java SDK source: // Not yet supported security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: $ref: '#/components/schemas/Calendar-Create' examples: UpdateACalendarRequest: value: name: My New Calendar description: Description of my new calendar location: Location description timezone: America/Los_Angeles delete: summary: Delete a Calendar tags: - Calendar responses: '200': description: OK content: application/json: schema: description: '' type: object properties: job_status_id: type: string minLength: 1 required: - job_status_id examples: DeleteACalenderResponse: value: job_status_id: d38mgop88je0agkqrf03sw0sw '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: delete-calendar-id description: Deletes a calendar security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE \ "https://api.nylas.com/calendars/38mgop88je038mgop88je0/ - lang: py label: Python SDK source: '# Not yet supported' - lang: ruby label: Ruby SDK source: '# Not yet supported' - lang: js label: Node.js SDK source: | // Not yet supported - lang: java label: Java SDK source: // Not yet supported /calendars/free-busy: post: summary: Calendar Free or Busy tags: - Calendar responses: '200': description: OK content: application/json: schema: type: array description: '' minItems: 1 uniqueItems: true items: type: object description: '' properties: object: type: string minLength: 1 example: free_busy email: type: string minLength: 1 example: swag@nylas.com time_slots: type: array uniqueItems: true minItems: 1 items: type: object properties: object: type: string minLength: 1 example: time_slot status: type: string minLength: 1 example: busy start_time: type: number example: 1409594400 end_time: type: number example: 1409599000 examples: CalendarFreeBusyResponse: value: - object: free_busy email: swag@nylas.com time_slots: - object: time_slot status: busy start_time: 1409594400 end_time: 0 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-calendars-free-busy description: >- Check calendar free or busy status. The `/calendars/free-busy` endpoint lets you look for availability without accessing sensitive information such as titles, descriptions, or locations. ## Scopes * calendar * calendar.read_only You need to pass in the account access token of the calender you want to check. x-code-samples: - lang: bash label: cURL source: "curl -X POST \"https://api.nylas.com/calendars/free-busy\" \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d \"{\n\t\\\"start_time\\\":\\\"1409594400\\\",\n\t\\\"end_time\\\":\\\"1409598000\\\",\n\t\\\"emails\\\": [\\\"nyla@nylas.com\\\"]\n} \"" - lang: py label: Python SDK source: >- from nylas import APIClient from datetime import datetime, timedelta # Create a client that has access an end user account nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Search for free-busy time slots over the next 24 hours. start_time = datetime.now() end_time = datetime.now() + timedelta(hours = 24) # Provide the email address to check, a start time, and an end time free_busy = nylas.free_busy("your_email@example.com", start_time, end_time) - lang: ruby label: Ruby SDK source: '# Not yet supported in the Nylas Ruby SDK' - lang: js label: Node.js SDK source: >- const Nylas = require('nylas'); Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); // Create a client that has access an end user account const nylas = Nylas.with(ACCESS_TOKEN); // Search for free-busy time slots over the next 24 hours. const startTime = Math.floor(Date.now() / 1000) // current unix timestamp in seconds const endTime = startTime + (60 * 60 * 24) // add 24 hours in seconds // Provide the email address to check, a start time, and an end time nylas.calendars.freeBusy( { startTime: startTime, end_time: endTime, emails: ['your_email@example.com'] }).then(freeBusy => console.log(freeBusy)); - lang: java label: Java SDK source: "import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.time.temporal.ChronoUnit;\nimport java.util.List;\nimport java.time.ZonedDateTime;\nimport com.nylas.Calendar;\nimport com.nylas.Calendars;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.FreeBusy;\nimport java.time.Instant;\n\n\npublic class NylasExamples {\n public static void freeBusyExample() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasAccount account = client.account(\"{ACCESS_TOKEN}\");\n Calendars calendars = account.calendars();\n \n \t// Provide the ID for an email address calendar\n Calendar calendar = account.calendars().get(\"{calendarId}\");\n\t\t\t\t\n \t// Check for free-busy information for the next 24 hours.\n Instant start = ZonedDateTime.now().toInstant();\n Instant end = start.plus(1, ChronoUnit.DAYS);\n List freeBusyList = calendars.checkFreeBusy(\n start.getEpochSecond(), \n end.getEpochSecond(),\n calendar.getName());\n freeBusyList.stream().forEach((FreeBusy freeBusy) -> {\n System.out.println(freeBusy);\n });\n }\n}" security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: type: object properties: start_time: type: string description: Unix timestamp for the beginning of the freebusy window. example: '1409594400' end_time: type: string description: Unix timestamp for the end of the freebusy window. example: '1409598000' emails: type: array description: >- The email to check freebusy times for. You can only check one email at a time. items: type: string format: email example: nyla@nylas.com required: - start_time - end_time - emails examples: CalendarFreeBusyRequest: value: start_time: '1409594400' end_time: '1409598000' emails: - nyla@nylas.com description: '' /events: get: summary: Return All Events tags: - Events responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Events' examples: ReturnAllEventsResponse: value: - account_id: aaz875kwuvxik6ku7pwkqp3ah busy: true calendar_id: 947kpa7ih22bfkeujpkfqn5bf description: coffee meeting ical_uid: 5i2voruhvks4pbt5ktngk28bc9@google.com id: 4t0kwb4qb6xr0pfzzook70nd8 location: null message_id: null object: event owner: participants: - comment: null email: email@email.com name: null status: noreply read_only: true title: 'Remote Event: Group Yoga Class' when: object: time time: 1408875644 status: confirmed '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-events description: |- Returns all events. > Sorting > > Events are always sorted by their start date. x-code-samples: - lang: bash label: cURL source: >- # Return all events found for the user's account. Limited to 100 results curl -X GET \ https://api.nylas.com/events \ -H 'Authorization: Bearer ACCESS_TOKEN' \ # Return events that are filtered by specified arguments curl -X GET \ 'https://api.nylas.com/events?title=Birthday%20Party%21' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Available filters: show_cancelled, event_id, description, title, location, # busy, starts_before, starts_after, ends_before, ends_after # Use offset, and limit to paginate the results curl -X GET \ 'https://api.nylas.com/events?limit=10&offset=5' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Expand recurring events into multiple event objects. curl -X GET \ 'https://api.nylas.com/events?expand_recurring=true' \ -H 'Authorization: Bearer ACCESS_TOKEN' # Use special views like ids and count curl -X GET \ 'https://api.nylas.com/events/?view=ids' \ -H 'Authorization: Bearer ACCESS_TOKEN' curl -X GET \ 'https://api.nylas.com/events/?view=count' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all events found for the user's account nylas.events.all() # Return events that are filtered by specified arguments nylas.events.where(title='Birthday Party!') # Available filters: show_cancelled, event_id, description, title, location, # busy, starts_before, starts_after, ends_before, ends_after # Use offset, and limit to paginate the results nylas.events.where(limit=10, offset=5) # Expand recurring events into multiple event objects. nylas.events.where(expand_recurring=True) # Return the first event event = nylas.events.first() # The following attributes are available for the event object event.title event.description event.read_only event.id event.when event.status event.busy event.object event.message_id event.participants event.location event.owner event.calendar_id event.account_id - lang: ruby label: Ruby SDK source: |- # Counting the events api.events.count # Retrieving a few events api.events.limit(2).map(&:to_h) # Expand recurring events into independent event objects api.events.expand_recurring.map(&:to_h) # Include cancelled events api.events.show_cancelled.map(&:to_h) - lang: js label: Node.js SDK source: >- // Return all events found for the user's account nylas.events.list().then(events => console.log(events)); // Return events that are filtered by specified arguments nylas.events.list({title: 'Birthday Party!'}).then(events => console.log(events)); // Available filters: show_cancelled, event_id, calendar_id, description, title, // location, starts_before, starts_after, ends_before, ends_after // Use offset, and limit to paginate the results nylas.events.list({limit: 10, offset: 5}).then(events => console.log(events)); // Expand recurring events into multiple event objects. nylas.events.list({expand_recurring: true}).then(events => console.log(events)); // Return the first event nylas.events.first().then(event => console.log(event)); // The following attributes are available for the event object event.id event.object event.accountId event.calendarId event.messageId event.title event.description event.owner event.participants event.readOnly event.location event.when event.start event.end event.busy event.status event.iCalUID - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Event; import com.nylas.EventQuery; import com.nylas.Events; public class NylasExamples { public static void getEventsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Events events = account.events(); // Return all events found in the user's inbox events.list(); // Return events that are filtered by specified arguments events.list(new EventQuery().title("Birthday Party")); // Available Filters: description, endsAfter, endsBefore, // eventId, location, startsAfter, startsBefore, title // Use offset, and limit to control pagination events.list(new EventQuery().limit(10).offset(10)); // Return the first event from a calendar Event event = events.list(new EventQuery().limit(1)).get(0); // The following attributes are available for the event object event.getId(); event.getBusy(); event.getCalendarId(); event.getDescription(); event.getLocation(); event.getMasterEventId(); event.getOriginalStartTime(); event.getOwner(); event.getParticipants(); event.getReadOnly(); event.getRecurrence(); event.getStatus(); event.getTitle(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Access - schema: type: string default: application/json in: header name: Content-Type - schema: type: boolean in: query name: expand_recurring description: >- Return events matching the specified recurrence. If the recurrence is true, the results will expand single recurring events into individual event instances that fall within the requested time range. - schema: type: boolean in: query name: show_cancelled description: >- Return events matching the specified cancellation. If the cancellation is true, the results will include cancelled events. This is set to false by default. - schema: type: integer format: int32 in: query name: limt description: >- Return events matching the specified limit. This value often defaults to 100. If the value is set too high, the request may fail to prevent excessively large response bodies. See Pagination for additional info. - schema: type: integer format: int32 in: query name: offset description: >- Return events matching the specified offset. This is zero-based offset from default object sorting. See Pagination for additional info. - schema: type: string in: query name: event_id description: Return the event matching the specified event ID. - schema: type: string in: query name: calendar_id description: Return events belonging to the specified calendar ID. - schema: type: string in: query name: title description: Return events matching the specified title. - schema: type: string in: query name: description description: Return events matching the specified description. - schema: type: string in: query name: location description: Return events matching the specified location. - schema: type: integer format: int32 in: query name: starts_before description: Return events starting before the specified unix timestamp. - schema: type: integer format: int32 in: query description: Return events starting after the specified unix timestamp. name: starts_after - schema: type: integer format: int32 in: query name: ends_before description: Return events ending before the specified unix timestamp. - schema: type: integer format: int32 in: query name: ends_after description: Return events ending after the specified unix timestamp. post: summary: Create an Event tags: - Events responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Events' examples: CreateAnEventResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah busy: true calendar_id: 947kpa7ih22bfkeujpkfqn5bf description: Coffee meeting ical_uid: 5i2voruhvks4pbt5ktngk28bc9@google.com id: 4t0kwb4qb6xr0pfzzook70nd8 location: null message_id: null object: event owner: participants: - comment: null email: email@email.com name: null status: noreply read_only: true title: 'Remote Event: Group Yoga Class' when: object: time time: 1408875644 status: confirmed '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-events description: >- Creates an event. > `notify_participants ` > > For certain Microsoft/Exchange/O365 accounts that are syncing via ActiveSync 16.0+, setting `notify_participants` to `false` will have no effect. By default, notifications will get sent no matter the value of `notify_participants`. >Setting `notify_participants` to `true` will always make the event show up as a meeting. If you'd like the event to show up as an appointment, set `notify_participants` to false and make sure the event does not have other participants than the appointment owner. x-code-samples: - lang: bash label: cURL source: "\ncurl -X POST 'https://api.nylas.com/events' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' \\\n -d '{\n \"title\":\"Birthday Party\",\n \"location\": \"Roller Rink\",\n \"calendar_id\": \"{calendar_id}\",\n \"status\": \"confirmed\",\n \"busy\": true,\n \"read_only\": false,\n \"participants\": [\n {\n \"name\": \"Aristotle\",\n \"email\": \"aristotle@nylas.com\"\n },\n {\n \"name\": \"Plato\",\n \"email\": \"plato@nylas.com\"\n }\n ], \n \"description\": \"another year for ole aristotle\",\n \"when\": { \"date\": \"2019-12-20\" }\n }'\n\n// Recurring events\n\ncurl -X POST \\\n https://api.nylas.com/events \\\n -H 'Authorization: Basic WVVUWjZ****' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"title\":\"Example Recurring Event\",\n \"when\" : {\n \"start_time\": 1576628762,\n \"end_time\": 1576630562\n },\n \"location\": \"Coffee Shop\",\n \"calendar_id\": \"92qhjiceuv6k4nx6v76024uia\",\n \"participants\": [\n {\n \"email\": \"nylatest2@nylatest.onmicrosoft.com\",\n \"name\": \"Sarah Nylanaut\"\n }\n ],\n \"recurrence\": {\n \"rrule\": [ \n \"RRULE:FREQ=WEEKLY;BYDAY=WE;INTERVAL=2\"\n ],\n \"timezone\": \"America/New_York\"\n }\t\n }'" - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) #Create a new event event = nylas.events.create() # .save()must be called to save the event to the third party provider # The event object must have values assigned to calendar_id and when before you can save it. event.save(notify_participants='true') # notify_participants='true' will send a notification email to # all email addresses specified in the participant subobject event.title = "Party!" event.location = "My House!" event.description = "Let's celebrate our calendar integration!!" event.busy = True # Provide the appropriate id for a calendar to add the event to a specific calendar event.calendar_id='{id}' # Participants are added as a list of dictionary objects # email is required, name is optional event.participants = [{"name": "My Nylas Friend", 'email': 'swag@nylas.com'}] # The event date/time can be set in one of 3 ways. # For details: https://docs.nylas.com/reference#event-subobjects event.when = {"start_time": 1577829600, "end_time": 1577840400} event.when = {"time": 1577829600} event.when = {"date": "2020-01-01"} event.when = {"start_date": "2019-08-29", "end_date": "2019-09-01"} - lang: ruby label: Ruby SDK source: >- # Creating an event example_event = api.events.last api.events.create(title: "A fun event!", location: "The Party Zone", calendar_id: calendar.id, when: { start_time: Time.now + 60, end_time: Time.now + 120 }).to_h - lang: js label: Node.js SDK source: >- //Create a new event let event = nylas.events.build(); // .save()must be called to save the event to the third party provider // The event object must have values assigned to calendarId and when before you can save it. event.save({notify_participants: true}); // {notify_participants: true} will send a notification email to // all email addresses specified in the participant subobject event.title = 'Party!'; event.location = 'My House!'; event.description = 'Let\'s celebrate our calendar integration!!'; event.busy = true; // Provide the appropriate id for a calendar to add the event to a specific calendar event.calendarId='{id}'; // Participants are added as a list of dictionary objects // email is required, name is optional event.participants = [{name: 'My Nylas Friend', email: 'swag@nylas.com'}]; // The event date/time can be set in one of 4 ways. // For details: https://docs.nylas.com/reference#event-subobjects event.when = {time: 1408875644}; event.when = {start_time: 1577829600, end_time: 1577840400}; event.when = {date: '2020-01-01'}; event.when = {start_date: '2019-08-29', end_date: '2019-09-01'}; // You may also set the date/time with the NodeSDK's start and end attributes. // start and end can be assigned to either a number or string // if start = end, the when parameter will be either suboject type date or time event.start = 1577829600; event.end = 1577840400; or event.start = '2019-08-29'; event.end = '2019-09-01'; - lang: java label: Java SDK source: "import java.io.IOException;\nimport java.util.Arrays;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Event;\nimport com.nylas.Participant;\n\npublic class NylasExamples {\n public static void postEventExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n \t// Create a new event object\n // Provide the ID for a calendar that is readOnly = false\n Event event = new Event(\"{CALENDAR_ID}\", when);\n \n // The event \"when\" (date/time) can be set as one of 4 types.\n // For details: https://docs.nylas.com/reference#event-subobjects\n Event.When when = null;\n LocalDate today = LocalDate.now();\n when = new Event.Date(today);\n when = new Event.Datespan(today, today.plusDays(1));\n Instant sixPmUtc = today.atTime(18, 0).toInstant(ZoneOffset.UTC);\n when = new Event.Time(sixPmUtc);\n when = new Event.Timespan(sixPmUtc, sixPmUtc.plus(1, ChronoUnit.HOURS));\n \tevent.setWhen(when);\n \n event.setTitle(\"Party!\");\n event.setLocation(\"My House!\");\n event.setDescription(\"Let's celebrate our calendar integration!!\");\n event.setBusy(true);\n \n // Participants are added as a list of Participant objects, \n // email is required\n // name, status, and comment are optional\n event.setParticipants(\n Arrays.asList(new Participant(\"swag@nylas.com\").name(\"My Nylas Friend\"))\n );\n\n // Use events().create() to save the event to the third party provider\n // 2nd argument is a boolean to determine if a notification\n // will be sent to all participants.\n account.events().create(event, true);\n \n }\n}" security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept - schema: type: boolean in: query name: notify_participants description: >- If set to true, email notifications containing the calendar event will be sent to all event participants. requestBody: content: application/json: schema: $ref: '#/components/schemas/Event-Create-Update' examples: example-1: value: title: Birthday Party calendar_id: 947kpa7ih22bfkeujpkfqn5bu status: confirmed busy: true read_only: true participants: - name: Aristotle email: aristotle@nylas.com status: 'yes' comment: string description: Come ready to skate when: object: time time: 1408875644 location: Roller Rink recurrence: rrule: - 'RRULE:FREQ=WEEKLY;BYDAY=MO' timezone: America/New_York '/events/{id}': parameters: - schema: type: string name: id in: path required: true description: The ID of the event. get: summary: Return An Event tags: - Events responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Events' examples: ReturnAnEventResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah busy: true calendar_id: 947kpa7ih22bfkeujpkfqn5bf description: Coffee meeting ical_uid: 5i2voruhvks4pbt5ktngk28bc9@google.com id: 4t0kwb4qb6xr0pfzzook70nd8 location: string message_id: null object: event owner: participants: - comment: string email: email@email.com name: string status: noreply read_only: true title: 'Remote Event: Group Yoga Class' when: object: time time: 1408875644 status: confirmed '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-events-id description: Returns an event by ID. x-code-samples: - lang: bash label: cURL source: |- # Return an event by specifying its id curl -X GET \ 'https://api.nylas.com/events/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return an event by specifying its id event = nylas.events.get('{id}') # The following attributes are available for the event object event.title event.description event.read_only event.id event.when event.status event.busy event.object event.message_id event.participants event.location event.owner event.calendar_id event.account_id - lang: ruby label: Ruby SDK source: |- # Retrieving a particular event example_event = api.events.last api.events.find(example_event.id).to_h - lang: js label: Node.js SDK source: |- // Return an event by specifying its id let event; nylas.events.find('{id}').then(resp => event = resp); // The following attributes are available for the event object event.id event.object event.accountId event.calendarId event.messageId event.title event.description event.owner event.participants event.readOnly event.location event.when event.start event.end event.busy event.status event.iCalUID - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Event; import com.nylas.Events; public class NylasExamples { public static void getEventExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Events events = account.events(); // Return an event by specifying the ID Event event = events.get("{eventId}"); // The following attributes are available for the event object event.getId(); event.getBusy(); event.getCalendarId(); event.getDescription(); event.getLocation(); event.getMasterEventId(); event.getOriginalStartTime(); event.getOwner(); event.getParticipants(); event.getReadOnly(); event.getRecurrence(); event.getStatus(); event.getTitle(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type put: summary: Update An Event tags: - Events responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Events' examples: UpdateAnEventResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah busy: true calendar_id: 947kpa7ih22bfkeujpkfqn5bf description: Coffee meeting ical_uid: 5i2voruhvks4pbt5ktngk28bc9@google.com id: 4t0kwb4qb6xr0pfzzook70nd8 location: string message_id: null object: event owner: participants: - comment: string email: email@email.com name: string status: noreply read_only: true title: 'Remote Event: Group Yoga Class' when: object: time time: 1408875644 status: confirmed '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: put-events-id description: >- Updates an event. > Ready Only and Recurring Events > > Updating and deleting an event is managed in a similar fashion to other endpoints with the restriction that `read_only` events cannot be updated and events cannot be updated or deleted from a `read_only` calendar. x-code-samples: - lang: bash label: cURL source: |- curl -X PUT 'https://api.nylas.com/events/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "title":"Birthday Party II", "location": "Roller Rink", "calendar_id": "{calendar_id}", "status": "confirmed", "busy": true, "read_only": false, "participants": [ { "name": "Aristotle", "email": "aristotle@nylas.com" }, { "name": "Plato", "email": "plato@nylas.com" } ], "description": "aristotle'\''s birthday bash!", "when": { "date": "2019-12-31" } }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # You can only modify events that are not ready only for the user event = nylas.events.where(read_only=False).first() # .save()must be called to save the event to the third party provider event.save(notify_participants='true') # notify_participants='true' will send a notification email to # all emails specified in the participant subobject event.title = "Party!" event.location = "My House!" event.description = "Let's celebrate our calendar integration!!" event.busy = True # Provide the appropriate id for a calendar to add the event to a specific calendar event.calendar_id='{id}' # Participants are added as a list of dictionary objects # email is required, name is optional event.participants = [{"name": "My Nylas Friend", 'email': 'swag@nylas.com'}] # The event dat/time can be set in one of 3 ways. # For details: https://docs.nylas.com/reference#event-subobjects event.when = {"start_time": 1577829600, "end_time": 1577840400} event.when = {"time": 1577829600} event.when = {"date": "2020-01-01"} event.when = {"start_date": "2019-08-29", "end_date": "2019-09-01"} - lang: ruby label: Ruby SDK source: |- # Updating an event example_event = api.events.last example_event.update(location: "Somewhere else!") - lang: js label: Node.js SDK source: >- // You can only modify events that are not ready only for the user event = nylas.events.list({calendarId: 'non read only calendar id', limit: 1}); // .save()must be called to save the event to the third party provider event.save({notify_participants: true}); // {notify_participants: true} will send a notification email to // all emails specified in the participant subobject event.title = 'Party!'; event.location = 'My House!'; event.description = 'Let's celebrate our calendar integration!!'; event.busy = true; // Provide the appropriate id for a calendar to add the event to a specific calendar event.calendarId='{id}'; // Participants are added as a list of dictionary objects // email is required, name is optional event.participants = [{name: 'My Nylas Friend', email: 'swag@nylas.com'}]; // The event dat/time can be set in one of 3 ways. // For details: https://docs.nylas.com/reference#event-subobjects event.when = {time: 1408875644}; event.when = {start_time: 1577829600, end_time: 1577840400}; event.when = {date: '2020-01-01'}; event.when = {start_date: '2019-08-29', end_date: '2019-09-01'}; // You may also set the date/time with the NodeSDK's start and end attributes. // start and end can be assigned to either a number or string // if start = end, the when parameter will be either suboject type date or time event.start = 1577829600; event.end = 1577840400; or event.start = '2019-08-29'; event.end = '2019-09-01'; - lang: java label: Java SDK source: "import java.io.IOException;\nimport java.util.Arrays;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Event;\nimport com.nylas.Participant;\n\npublic class NylasExamples {\n public static void putEventExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n\n // Get an event by specifying its ID\n Event event = account.events().get(\"EVENT_ID\");\n\n event.setTitle(\"Party!\");\n event.setLocation(\"My House!\");\n event.setDescription(\"Let's celebrate our calendar integration!!\");\n event.setBusy(true);\n\n // The event \"when\" (date/time) can be set as one of 4 types.\n\t\t// For details: https://docs.nylas.com/reference#event-subobjects\n\t\tEvent.When when = null;\n\t\tLocalDate today = LocalDate.now();\n\t\twhen = new Event.Date(today);\n\t\twhen = new Event.Datespan(today, today.plusDays(1));\n\t\tInstant sixPmUtc = today.atTime(18, 0).toInstant(ZoneOffset.UTC);\n\t\twhen = new Event.Time(sixPmUtc);\n\t\twhen = new Event.Timespan(sixPmUtc, sixPmUtc.plus(1, ChronoUnit.HOURS));\n event.setWhen(when);\n\n // Participants are added as a list of Participant objects, \n // email is required\n // name, status, and comment are optional\n event.setParticipants(\n Arrays.asList(new Participant(\"swag@nylas.com\").name(\"My Nylas Friend\"))\n );\n\n // Update the event with the new values and notify all participants\n account.events().update(event, true);\n }\n}" security: - ACCESS_TOKEN: [] parameters: - schema: type: boolean in: query name: notify_participants description: >- Updates the event with the specified participant notification preference. If the value is set to true, email notifications containing the calendar event will be sent to all event participants. - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: $ref: '#/components/schemas/Event-Create-Update' examples: UpdateAnEventRequest: value: title: Birthday Party calendar_id: 947kpa7ih22bfkeujpkfqn5bu status: confirmed busy: true read_only: true participants: - name: Aristotle email: aristotle@nylas.com status: 'yes' comment: string description: Come ready to skate when: object: time time: 1408875644 location: Roller Rink recurrence: rrule: - 'RRULE:FREQ=WEEKLY;BYDAY=MO' timezone: America/New_York delete: summary: Delete An Event tags: - Events responses: '200': description: OK '400': description: Bad Request operationId: delete-events-id description: Deletes an event. parameters: - schema: type: boolean in: query description: >- Deletes an event with the specified notification preference. If the value is set to true, email notifications containing the calendar event will be sent to all event participants name: notify_participants - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE 'https://api.nylas.com/events/{id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Delete an Event and notify all participants via email nylas.events.delete('{id}', notify_participants='true') - lang: ruby label: Ruby SDK source: |- # Deleting an event example_event = api.events.last example_event.destroy - lang: js label: Node.js SDK source: |- // Delete an Event and notify all participants via email nylas.events.delete('{id}', {notify_participants: true}); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; public class NylasExamples { public static void deleteEventExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Delete an event by specifying its ID and notify participants account.events().delete("EVENT_ID", true); } } security: - ACCESS_TOKEN: [] /send-rsvp: post: summary: Send RSVP tags: - Events responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Events' examples: SendRSVPResponse: value: account_id: aaz875kwuvxik6ku7pwkqp3ah busy: true calendar_id: 947kpa7ih22bfkeujpkfqn5bf description: Coffee meeting ical_uid: 5i2voruhvks4pbt5ktngk28bc9@google.com id: 4t0kwb4qb6xr0pfzzook70nd8 location: string message_id: null object: event owner: participants: - comment: string email: email@email.com name: string status: noreply read_only: true title: 'Remote Event: Group Yoga Class' when: object: time time: 1408875644 status: confirmed operationId: post-send-rsvp description: >- The RSVP endpoint allows you to send attendance status updates to event organizers. This is only possible for events that appears on the “Emailed events”, which are calendar invitations. If the RSVP is successful, the event object is returned with your RSVP participant status updated. This endpoint is idempotent: this means that only one email will be sent when you issue the same request with the same body multiple times. Behind the scenes, RSVPs work by sending an email back to the event organizer in iMIP format. Errors when RSVPing to events follow the same status codes as sending errors. parameters: - schema: type: boolean in: query name: notify_participants description: >- If set to true, email notifications containing the calendar event will be sent to all event participants. - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type x-code-samples: - lang: bash label: cURL source: |- curl -X POST 'https://api.nylas.com/send-rsvp/' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "event_id": "{event_id}", "status": "yes", "comment": "Excited to come!", "account_id": "{account_id}" }' - lang: py label: Python SDK source: >- # RSVP to an invite. Note that you can only RSVP to invites found in the # "Emailed events" calendar. event = nylas.events.get("{id}") # .rsvp() accepts a status and an optional message. # The message will be sent via email to all participants event.rsvp("maybe", "I will try to make it") # rsvp status must be one of yes, no, or maybe - lang: ruby label: Ruby SDK source: >- # RSVPing to an Event calendar = api.calendars.select { |c| c.name == "Emailed events" }.first event = calendar.events.first event.rsvp(:yes, notify_participants: true) event.rsvp(:no, notify_participants: true) event.rsvp(:maybe, notify_participants: true) - lang: js label: Node.js SDK source: >- // RSVP to an invite. Note that you can only RSVP to invites found in the // "Emailed events" calendar. nylas.events .find("{id}") // .rsvp() accepts a status and an optional message. // The message will be sent via email to all participants .then(event => event.rsvp('maybe', 'I may attend this event')) // Possible rsvp statuses include yes, no, and maybe .then(event => console.log('RSVP sent!')); - lang: java label: Java SDK source: |- // The Java SDK is in beta and may experience breaking changes. // Nylas recommends it for testing purposes only. import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; public class NylasExamples { public static void sendRsvpExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // RSVP to an invite. You can only RSVP to invites found in the "Emailed events" calendar. // rsvp() accepts a status and an optional message // status must be one of yes, no, or maybe // If notifyParticipants is true, the message will be sent via email to all participants account.events().rsvp("{eventId}", "maybe", "{accountId}", "I may attend this event", true); System.out.println("RSVP sent!"); } } security: - ACCESS_TOKEN: [] requestBody: content: application/json: schema: description: '' type: object properties: event_id: type: string minLength: 1 description: >- Sends a RSVP status update for the specified event ID. This value must be a valid event ID from the “Emailed events” calendar. status: type: string minLength: 1 description: Sends a RSVP status update with the specified status enum: - 'yes' - 'no' - maybe comment: type: string minLength: 1 description: Sends a RSVP status update with the specified comment. account_id: type: string minLength: 1 description: Sends a RSVP status update for the specified account ID. required: - event_id - status - account_id examples: SendRSVPRequest: value: event_id: string status: 'yes' comment: string account_id: string /resources: get: summary: Return Resource Information tags: - Room Resources responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Room-Resources' examples: RoomResourcesResponse: value: - object: room_resource email: training-room-1A@office365.com name: Training Room 1A capacity: '8' building: West Building floor_name: '7' floor_number: '7' '400': description: Bad Request operationId: get-resources description: >- With the `/resources` endpoint, you can see which rooms a user can book within their GSuite or Office365 organization. To book an event in a room, including the room resource as a participant when creating the event with the `/events` endpoint. ## Authentication Depending on if you are using GSuite or Microsoft Office 365 you'll need to enable certain permissions. ### Microsoft For Microsoft Office 365 you need to enable `Place.Read.All` as an admin to use Room Resources. See Admin Approval for more. You also need to enable the `room_resources.read_only` scope. See the authentication scopes guide for more info. ### GSuite You need to enable the `room_resources.read_only` scope. See the authentication scopes guide for more info. security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type /contacts: get: summary: Return All Contacts tags: - Contacts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Contact' examples: ReturnAllContactsResponse: value: account_id: x2x2x2x2x2x2x2x2x2x2x2 birthday: '1960-12-31' company_name: Nylas emails: - email: john@doe.com type: work given_name: John id: z3z3z3z3z3z3z3z3z3z3z3 im_addresses: - type: aim im_address: myaimaddress job_title: Software Engineer manager_name: Bill the manager middle_name: Jacob nickname: JD notes: Loves ramen object: contact office_location: 123 Main Street phone_numbers: - number: 1 800 123 4567 type: business physical_addresses: - format: string type: work street_address: string city: string postal_code: string state: string country: string picture_url: 'https://api.nylas.com/contacts/427abc427abc427abc/picture' suffix: string surname: string web_pages: - type: profile url: string groups: - id: string object: contact_group account_id: string name: string path: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-contacts description: > Returns all contacts. ## Exact Matches We currently only support filtering on exact value matches in the database. That means the strings you filter on must be the exact strings stored on the contact in the database. ## Parameter Percent Encoding It is important to note that parameter values must use [percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding) (also known as URL encoding). x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/contacts' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Return all contacts found in the user's contact book contacts = nylas.contacts.all() # Return contacts that are filtered by specified arguments contacts = nylas.contacts.where(email='swag@nylas.com') # Available filters: email, phone_number, # street_address, postal_code, state, and country # Use offset, and limit to control pagination of the results contacts = nylas.contacts.where(limit=10, offset=5) # Return the first contact contact = nylas.contacts.first() # The following attributes are available for the contact object contact.id contact.given_name contact.middle_name contact.surname contact.suffix contact.nickname contact.emails contact.physical_addresses contact.office_location contact.picture_url contact.account_id contact.company_name contact.notes contact.object contact.manager_name contact.im_addresses contact.web_pages contact.phone_numbers contact.job_title contact.birthday - lang: ruby label: Ruby SDK source: |- # Return all contacts found in the user's contact book contacts = nylas.contacts # Return contacts that are filtered by specified arguments contacts = nylas.contacts.where(email: 'swag@nylas.com') # Available filters: email, phone_number, # street_address, postal_code, state, and country # Use offset, and limit to control pagination of the results contacts = nylas.contacts.limit(10).offset(5) # Return the first contact contact = nylas.contacts.first # The following attributes are available for the contact object contact.id contact.given_name contact.middle_name contact.surname contact.suffix contact.nickname contact.emails contact.physical_addresses contact.office_location contact.picture_url contact.account_id contact.company_name contact.notes contact.object contact.manager_name contact.im_addresses contact.web_pages contact.phone_numbers contact.job_title contact.birthday contact.groups - lang: js label: Node.js SDK source: >- // Return all contacts found in the user's contact book nylas.contacts.list().then(contacts => console.log(contacts)); // Return contacts that are filtered by specified arguments nylas.contacts.list({email: 'swag@nylas.com'}).then(resp => console.log(resp)); // Available filters: email, phone_number, // street_address, postal_code, state, country, source, group, recurse // Use offset, and limit to control pagination of the results nylas.contacts.list({limit: 10, offset: 5}).then(contacts => console.log(contacts)); // Return the first contact nylas.contacts.first().then(contact => console.log(contact)); // The following attributes are available for the contact object contact.id, contact.object, contact.accountId, contact.givenName, contact.middleName, contact.surname, contact.suffix, contact.nickname, contact.birthday, contact.companyName, contact.jobTitle, contact.managerName, contact.officeLocation, contact.notes, contact.pictureUrl, contact.emailAddresses, contact.imAddresses, contact.physicalAddresses, contact.phoneNumbers, contact.webPages, contact.groups, contact.source - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Contact; import com.nylas.ContactQuery; import com.nylas.Contacts; public class NylasExamples { public static void getContactsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Contacts contacts = account.contacts(); // Return all contacts found in the user's inbox contacts.list(); // Return contacts that are filtered by specified arguments contacts.list(new ContactQuery().email("swag@nylas.com")); // Available filters: email, phoneNumber, // streetAddress, postalCode, state, country, source, groupId, recurse // Use offset, and limit to control pagination contacts.list(new ContactQuery().limit(10).offset(10)); // Return the first contact Contact contact = contacts.list(new ContactQuery().limit(1)).get(0); // The following attributes are available for the contact object contact.getId(); contact.getBirthday(); contact.getCompanyName(); contact.getEmails(); contact.getGivenName(); contact.getGroups(); contact.getIMAddresses(); contact.getJobTitle(); contact.getManagerName(); contact.getMiddleName(); contact.getNickname(); contact.getNotes(); contact.getOfficeLocation(); contact.getPhoneNumbers(); contact.getPhysicalAddresses(); contact.getPictureUrl(); contact.getSource(); contact.getSuffix(); contact.getSurname(); contact.getWebPages(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Access - schema: type: string default: application/json in: header name: Content-Type - schema: type: integer in: query name: limit description: >- Returns the contacts with the specified number of objects. This value often defaults to 100. If set too high, requests may fail to prevent excessively large response bodies. - schema: type: integer in: query description: >- Returns the contacts with the specified offset. This value is a zero-based offset from default object sorting. name: offset - schema: type: string example: email=fred%40nylas.com in: query name: email description: 'Returns the contacts matching the exact contact''s email. ' - schema: type: string example: phone_number=4158889999 in: query name: phone_number description: Returns the contacts matching the contact's exact phone number. - schema: type: string example: street_address=1600%20Pennsylvania%20Ave in: query name: street_address description: >- Returns the contacts matching the one of the contact's exact street address. - schema: type: string example: postal_code=20500 in: query name: postal_code description: >- Returns the contacts matching the contact's exact postal code of one of the contact's addresses. - schema: type: string in: query name: state description: >- Returns the contacts matching the contact's exact state for one of the contact's physical addresses - schema: type: string in: query name: country description: Returns the contacts matching the contact's exact physical addresses - schema: type: string example: source=inbox in: query name: source description: >- Returns the contacts matching from the address book or auto-generated contacts from emails. For example of contacts only from the address book: `/`contacts?source=address_book` or for only autogenerated contacts: `/contacts?source=inbox`. - schema: type: string in: query name: group description: >- Returns the contacts belonging to the Contact Group matching this ID. - schema: type: boolean in: query name: recurse description: >- When set to true, returns the contacts also within the specified Contact Group subgroups, if the group parameter is set. post: summary: Create a Contact tags: - Contacts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Contact' examples: CreateAContactResponse: value: account_id: x2x2x2x2x2x2x2x2x2x2x2 birthday: '1960-12-31' company_name: Nylas emails: - email: john@doe.com type: work given_name: John id: z3z3z3z3z3z3z3z3z3z3z3 im_addresses: - type: aim im_address: myaimaddress job_title: Software Engineer manager_name: Bill the manager middle_name: Jacob nickname: JD notes: Loves ramen object: contact office_location: 123 Main Street phone_numbers: - number: 1 800 123 4567 type: business physical_addresses: - format: string type: work street_address: string city: string postal_code: string state: string country: string picture_url: 'https://api.nylas.com/contacts/427abc427abc427abc/picture' suffix: string surname: string web_pages: - type: profile url: string groups: - id: string object: contact_group account_id: string name: string path: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-contacts description: Creates a contact. x-code-samples: - lang: bash label: cURL source: |- curl -X POST 'https://api.nylas.com/contacts' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "given_name": "My", "middle_name": "Nylas", "surname": "Friend", "birthday": "2014-06-01", "suffix": "API", "nickname": "Nylas", "company_name": "Nylas", "job_title": "Communications Platform", "manager_name": "Communications", "office_location": "SF", "notes": "Check out the Nylas Email, Calendar, and Contacts APIs", "emails": [{ "type": "personal", "email": "swag@nylas.com" } ], "physical_addresses": [{ "format": "structured", "type": "work", "street_address": "944 Market St, 8th Floor", "city": "San Francisco", "postal_code": "94102", "state": "CA", "country": "USA" } ], "phone_numbers": [{ "type":"home", "number": "123-123-1234" }], "web_pages": [{ "type": "homepage", "url":"https://nylas.com" }], "im_addresses": [{ "type": "gtalk", "im_address": "Nylas" }], }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Create a new contact contact = nylas.contacts.create() # Save the contact to Nylas and the 3rd party provider # This must be executed whenever you want to save changes. contact.save() # The following attributes can be modified for the contact object contact.given_name = 'My' contact.middle_name = 'Nylas' contact.surname = 'Friend' contact.suffix = 'API' contact.nickname = 'Nylas' contact.office_location = 'San Francisco' contact.company_name = 'Nylas' contact.notes = 'Check out the Nylas Email, Calendar, and Contacts APIs' contact.manager_name = 'Communications' contact.job_title = 'Communications Platform' contact.birthday = '2014-06-01' # emails must be one of type personal, or work contact.emails['personal'] = ['swag@nylas.com'] # physical_addresses must be one of type work, home, or other contact.physical_addresses['work'] = [{ # physical addresses must be structured like the following 'format': 'structured', 'city': 'San Francisco', 'country': 'US', 'state': 'CA', 'postal_code': '94102', 'type': 'work', 'street_address': '944 Market St, 8th Floor'}] # phone_numbers must be one of type # business, organization_main, mobile, assistant, # business_fax, home_fax, radio, car, home, or pager contact.phone_numbers['business'] = ['555 555-5555'] # web_pages must be one of type homepage, profile, work, or blog contact.web_pages['homepage'] = ['https://nylas.com'] # im_addresses must be one of type gtalk, aim, # yahoo, lync, skype, qq, msn, icc, or jabber contact.im_addresses['gtalk'] = 'Nylas' - lang: ruby label: Ruby SDK source: >- # Create a new contact contact = nylas.contacts.create # Save the contact to Nylas and the 3rd party provider. # This must be executed whenever you want to save changes. contact.save # The following attributes can be modified for the contact object contact.given_name = 'My' contact.middle_name = 'Nylas' contact.surname = 'Friend' contact.suffix = 'API' contact.nickname = 'Nylas' contact.office_location = 'San Francisco' contact.company_name = 'Nylas' contact.notes = 'Check out the Nylas Email, Calendar, and Contacts APIs' contact.manager_name = 'Communications' contact.job_title = 'Communications Platform' contact.birthday = '2014-06-01' # emails must be one of type personal, or work contact.emails = [{type: 'personal', email: 'swag@nylas.com'}] # physical_addresses must be one of type work, home, or other contact.physical_addresses = [{ # physical addresses must be structured like the following format: 'structured', city: 'San Francisco', country: 'US', state: 'CA', postal_code: '94102', type: 'work', street_address: '944 Market St, 8th Floor'}] # phone_numbers must be one of type # business, organization_main, mobile, assistant, # business_fax, home_fax, radio, car, home, or pager contact.phone_numbers = [{type: 'business', number: '555 555-5555'}] # web_pages must be one of type homepage, profile, work, or blog contact.web_pages = [{type: 'homepage', url: 'https://nylas.com'}] # im_addresses must be one of type gtalk, aim, # yahoo, lync, skype, qq, msn, icc, or jabber contact.im_addresses = [{type: 'gtalk', im_address: 'nylas'}] - lang: js label: Node.js SDK source: >- // Create a new contact const contact = nylas.contacts.build(); // Save the contact to Nylas and the 3rd party provider // This must be executed whenever you want to save changes. contact.save(); // The following attributes can be modified for the contact object contact.givenName = 'My' contact.middleName = 'Nylas' contact.surname = 'Friend' contact.suffix = 'API' contact.nickname = 'Nylas' contact.birthday = '2014-06-01' contact.companyName = 'Nylas' contact.jobTitle = 'Communications Platform' contact.managerName = 'Communications' contact.officeLocation = 'San Francisco' contact.notes = 'Check out the Nylas Email, Calendar, and Contacts APIs' // emails must be one of type personal, or work contact.emailAddresses = [{type: 'personal', email: 'swag@nylas.com'}]}; // physical_addresses must be one of type work, home, or other contact.physicalAddresses = [ {'format': 'structured', 'city': 'San Francisco', 'country': 'US', 'state': 'CA', 'postalCode': '94102', 'type': 'work', 'streetAddress': '944 Market St, 8th Floor'} ]; // phone_numbers must be one of type // business, organization_main, mobile, assistant, // business_fax, home_fax, radio, car, home, or pager contact.phoneNumbers = [{type: 'business', number: '555 555-5555'}]; // web_pages must be one of type homepage, profile, work, or blog contact.webPages = [{type: 'homepage', url: 'https://nylas.com'}]; // im_addresses must be one of type gtalk, aim, // yahoo, lync, skype, qq, msn, icc, or jabber contact.imAddresses = [{type: 'gtalk', imAddress: 'Nylas'}]; - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Contact; import java.util.Arrays; public class NylasExamples { public static void postContactExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Create a new contact Contact contact = new Contact(); // The following attributes can be modified for the contact object contact.setGivenName("My"); contact.setMiddleName("Nylas"); contact.setSurname("Friend"); contact.setSuffix("API"); contact.setNickname("Nylas"); contact.setOfficeLocation("San Francisco"); contact.setCompanyName("Nylas"); contact.setNotes("Check out the Nylas Email, Calendar, and Contacts APIs"); contact.setManagerName("Communications"); contact.setJobTitle("Communications Platform"); contact.setBirthday("2014-06-01"); // Email must be one of type personal, or work contact.setEmails(Arrays.asList(new Contact.Email("personal", "swag@nylas.com"))); Contact.PhysicalAddress address = new Contact.PhysicalAddress(); address.setStreetAddress("944 Market St"); address.setType("work"); // PhysicalAddress must be one of type work, home, or other address.setCity("San Francisco"); address.setState("CA"); address.setCountry("US"); address.setPostalCode("94102"); address.setFormat("structured"); contact.setPhysicalAddresses(Arrays.asList(address)); // PhoneNumbers must be one of type // business, organization_main, mobile, assistant, // business_fax, home_fax, radio, car, home, or pager contact.setPhoneNumbers(Arrays.asList(new Contact.PhoneNumber("business", "555 555-5555"))); // WebPage must be one of type homepage, profile, work, or blog contact.setWebPages(Arrays.asList(new Contact.WebPage("homepage", "https://nylas.com"))); // imAddress must be one of type gtalk, aim, // yahoo, lync, skype, qq, msn, icc, or jabber contact.setIMAddresses(Arrays.asList(new Contact.IMAddress("gtalk", "Nylas"))); // Save the contact to Nylas and the 3rd party provider contact = account.contacts().create(contact); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: $ref: '#/components/schemas/CreateAContact' examples: CreateAContactRequest: value: birthday: '1960-12-31' company_name: Nylas emails: - email: john@doe.com type: work given_name: John im_addresses: - type: aim im_address: myaimaddress job_title: Software Engineer manager_name: Bill the manager middle_name: Jacob nickname: JD notes: Loves ramen office_location: 123 Main Street phone_numbers: - number: 1 800 123 4567 type: business physical_addresses: - format: string type: work street_address: string city: string postal_code: string state: string country: string suffix: string surname: string web_pages: - type: profile url: string group: string '/contacts/{id}': parameters: - schema: type: string name: id in: path required: true description: The ID of the contact. get: summary: Return a Contact tags: - Contacts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Contact' examples: ReturnAContactResponse: value: account_id: x2x2x2x2x2x2x2x2x2x2x2 birthday: '1960-12-31' company_name: Nylas emails: - email: john@doe.com type: work given_name: John id: z3z3z3z3z3z3z3z3z3z3z3 im_addresses: - type: aim im_address: myaimaddress job_title: Software Engineer manager_name: Bill the manager middle_name: Jacob nickname: JD notes: Loves ramen object: contact office_location: 123 Main Street phone_numbers: - number: 1 800 123 4567 type: business physical_addresses: - format: string type: work street_address: string city: string postal_code: string state: string country: string picture_url: 'https://api.nylas.com/contacts/427abc427abc427abc/picture' suffix: string surname: string web_pages: - type: profile url: string groups: - id: string object: contact_group account_id: string name: string path: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-contacts-id description: Returns a contact by ID. x-code-samples: - lang: bash label: cURL source: code_samples/contacts/get-contacts-id/get-contacts-id.txt - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) contact = nylas.contacts.get('{id}') # The following attributes are available with the contact object contact.id contact.given_name contact.middle_name contact.surname contact.suffix contact.nickname contact.emails contact.physical_addresses contact.office_location contact.picture_url contact.account_id contact.company_name contact.notes contact.object contact.manager_name contact.im_addresses contact.web_pages contact.phone_numbers contact.job_title contact.birthday - lang: ruby label: Ruby SDK source: |- contact = nylas.contacts.find('{id}') # The following attributes are available with the contact object contact.id contact.given_name contact.middle_name contact.surname contact.suffix contact.nickname contact.emails contact.physical_addresses contact.office_location contact.picture_url contact.account_id contact.company_name contact.notes contact.object contact.manager_name contact.im_addresses contact.web_pages contact.phone_numbers contact.job_title contact.birthday contact.groups - lang: js label: Node.js SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Contact; import com.nylas.Contacts; public class NylasExamples { public static void getContactExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Contacts contacts = account.contacts(); // Return a contact by specifying its ID Contact contact = contacts.get("{contactID}"); // The following attributes are available for the contact object contact.getId(); contact.getBirthday(); contact.getCompanyName(); contact.getEmails(); contact.getGivenName(); contact.getGroups(); contact.getIMAddresses(); contact.getJobTitle(); contact.getManagerName(); contact.getMiddleName(); contact.getNickname(); contact.getNotes(); contact.getOfficeLocation(); contact.getPhoneNumbers(); contact.getPhysicalAddresses(); contact.getPictureUrl(); contact.getSource(); contact.getSuffix(); contact.getSurname(); contact.getWebPages(); } } - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Contact; import com.nylas.Contacts; public class NylasExamples { public static void getContactExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Contacts contacts = account.contacts(); // Return a contact by specifying its ID Contact contact = contacts.get("{contactID}"); // The following attributes are available for the contact object contact.getId(); contact.getBirthday(); contact.getCompanyName(); contact.getEmails(); contact.getGivenName(); contact.getGroups(); contact.getIMAddresses(); contact.getJobTitle(); contact.getManagerName(); contact.getMiddleName(); contact.getNickname(); contact.getNotes(); contact.getOfficeLocation(); contact.getPhoneNumbers(); contact.getPhysicalAddresses(); contact.getPictureUrl(); contact.getSource(); contact.getSuffix(); contact.getSurname(); contact.getWebPages(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type put: summary: Update a Contact tags: - Contacts responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Contact' examples: UpdateAContactResponse: value: account_id: x2x2x2x2x2x2x2x2x2x2x2 birthday: '1960-12-31' company_name: Nylas emails: - email: john@doe.com type: work given_name: John id: z3z3z3z3z3z3z3z3z3z3z3 im_addresses: - type: aim im_address: myaimaddress job_title: Software Engineer manager_name: Bill the manager middle_name: Jacob nickname: JD notes: Loves ramen object: contact office_location: 123 Main Street phone_numbers: - number: 1 800 123 4567 type: business physical_addresses: - format: string type: work street_address: string city: string postal_code: string state: string country: string picture_url: 'https://api.nylas.com/contacts/427abc427abc427abc/picture' suffix: string surname: string web_pages: - type: profile url: string groups: - id: string object: contact_group account_id: string name: string path: string '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type operationId: put-contacts-id description: Updates a contact. x-code-samples: - lang: bash label: cURL source: |- curl -X PUT 'https://api.nylas.com/contacts/{contact_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -d '{ "given_name": "My Very Best", "middle_name": "Nylas", "surname": "Friend", "birthday": "2014-06-01", "suffix": "API", "nickname": "Nylas", "company_name": "Nylas", "job_title": "Communications Platform", "manager_name": "Communications", "office_location": "SF", "notes": "Check out the Nylas Email, Calendar, and Contacts APIs", "emails": [{ "type": "personal", "email": "swagg@nylas.com" } ], "physical_addresses": [{ "format": "structured", "type": "work", "street_address": "944 Market St, 8th Floor", "city": "San Francisco", "postal_code": "94102", "state": "CA", "country": "USA" } ], "phone_numbers": [{ "type":"home", "number": "123-123-1234" }], "web_pages": [{ "type": "homepage", "url":"https://nylas.com" }], "im_addresses": [{ "type": "gtalk", "im_address": "Nylas" }] }' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Get a contact with a specified id contact = api_client.contacts.get("{id}") # Save the contact to Nylas and the 3rd party provider contact.save() # The following attributes can be modified for the contact object contact.given_name = 'My' contact.middle_name = 'Nylas' contact.surname = 'Friend' contact.suffix = '' contact.nickname = 'Nylas' contact.office_location = 'San Francisco' contact.company_name = 'Nylas' contact.notes = 'Check out the Nylas Email, Calendar, and Contacts APIs' contact.manager_name = '' contact.job_title = 'Communications Platform' contact.birthday = '2014-06-01' # emails must be one of type personal, or work contact.emails['personal'] = ['swag@nylas.com'] # physical_addresses must be one of type work, home, or other contact.physical_addresses['work'] = [{ # physical addresses must be structured like the following 'format': 'structured', 'city': 'San Francisco', 'country': 'US', 'state': 'CA', 'postal_code': '94102', 'type': 'work', 'street_address': '944 Market St, 8th Floor'}] # phone_numbers must be one of type # business, organization_main, mobile, assistant, # business_fax, home_fax, radio, car, home, or pager contact.phone_numbers['business'] = ['555 555-5555'] # web_pages must be one of type homepage, profile, work, or blog contact.web_pages['homepage'] = ['https://nylas.com'] # im_addresses must be one of type gtalk, aim, # yahoo, lync, skype, qq, msn, icc, or jabber contact.im_addresses['gtalk'] = 'Nylas' - lang: ruby label: Ruby SDK source: >- # Create a new contact contact = nylas.contacts.find("{id}") # Save the contact to Nylas and the 3rd party provider contact.save # The following attributes can be modified for the contact object contact.given_name = 'My' contact.middle_name = 'Nylas' contact.surname = 'Friend' contact.suffix = 'API' contact.nickname = 'Nylas' contact.office_location = 'San Francisco' contact.company_name = 'Nylas' contact.notes = 'Check out the Nylas Email, Calendar, and Contacts APIs' contact.manager_name = 'Communications' contact.job_title = 'Communications Platform' contact.birthday = '2014-06-01' # emails must be one of type personal, or work contact.emails = [{type: 'personal', email: 'swag@nylas.com'}] # physical_addresses must be one of type work, home, or other contact.physical_addresses = [{ # physical addresses must be structured like the following format: 'structured', city: 'San Francisco', country: 'US', state: 'CA', postal_code: '94102', type: 'work', street_address: '944 Market St, 8th Floor'}] # phone_numbers must be one of type # business, organization_main, mobile, assistant, # business_fax, home_fax, radio, car, home, or pager contact.phone_numbers = [{type: 'business', number: '555 555-5555'}] # web_pages must be one of type homepage, profile, work, or blog contact.web_pages = [{type: 'homepage', url: 'https://nylas.com'}] # im_addresses must be one of type gtalk, aim, # yahoo, lync, skype, qq, msn, icc, or jabber contact.im_addresses = [{type: 'gtalk', im_address: 'nylas'}] - lang: js label: Node.js SDK source: >- // Get a contact with a specified id nylas.contacts.find('{id}').then(resp => contact = resp); // Save the contact to Nylas and the 3rd party provider contact.save() // The following attributes can be modified for the contact object contact.givenName = 'My' contact.middleName = 'Nylas' contact.surname = 'Friend' contact.suffix = 'API' contact.nickname = 'Nylas' contact.birthday = '2014-06-01' contact.companyName = 'Nylas' contact.jobTitle = 'Communications Platform' contact.managerName = 'Communications' contact.officeLocation = 'San Francisco' contact.notes = 'Check out the Nylas Email, Calendar, and Contacts APIs' // emails must be one of type personal, or work contact.emailAddresses = [{type: 'personal', email: 'swag@nylas.com'}]}; // physical_addresses must be one of type work, home, or other contact.physicalAddresses = [ {'format': 'structured', 'city': 'San Francisco', 'country': 'US', 'state': 'CA', 'postalCode': '94102', 'type': 'work', 'streetAddress': '944 Market St, 8th Floor'} ]; // phone_numbers must be one of type // business, organization_main, mobile, assistant, // business_fax, home_fax, radio, car, home, or pager contact.phoneNumbers = [{type: 'business', number: '555 555-5555'}]; // web_pages must be one of type homepage, profile, work, or blog contact.webPages = [{type: 'homepage', url: 'https://nylas.com'}]; // im_addresses must be one of type gtalk, aim, // yahoo, lync, skype, qq, msn, icc, or jabber contact.imAddresses = [{type: 'gtalk', imAddress: 'Nylas'}]; - lang: java label: Java SDK source: |- import java.util.Arrays; import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Contact; public class NylasExamples { public static void putContactExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Get a contact by specifying its ID Contact contact = account.contacts().get("{contactId}"); // The following attributes can be modified for the contact object contact.setGivenName("My"); contact.setMiddleName("Nylas"); contact.setSurname("Friend"); contact.setSuffix("API"); contact.setNickname("Nylas"); contact.setOfficeLocation("San Francisco"); contact.setCompanyName("Nylas"); contact.setNotes("Check out the Nylas Email, Calendar, and Contacts APIs"); contact.setManagerName("Communications"); contact.setJobTitle("Communications Platform"); contact.setBirthday("2014-06-01"); // Email must be one of type personal, or work contact.setEmails(Arrays.asList(new Contact.Email("personal", "swag@nylas.com"))); // PhysicalAddress must be one of type work, home, or other Contact.PhysicalAddress address = new Contact.PhysicalAddress(); address.setStreetAddress("695 Minna St"); address.setType("work"); address.setCity("San Francisco"); address.setState("CA"); address.setCountry("US"); address.setPostalCode("94103"); address.setFormat("structured"); contact.setPhysicalAddresses(Arrays.asList(address)); // PhoneNumbers must be one of type // business, organization_main, mobile, assistant, // business_fax, home_fax, radio, car, home, or pager contact.setPhoneNumbers(Arrays.asList(new Contact.PhoneNumber("business", "555 555-5555"))); // WebPages must be one of type homepage, profile, work, or blog contact.setWebPages(Arrays.asList(new Contact.WebPage("homepage", "https://nylas.com"))); // imAddresses must be one of type gtalk, aim, // yahoo, lync, skype, qq, msn, icc, or jabber contact.setIMAddresses(Arrays.asList(new Contact.IMAddress("gtalk", "Nylas"))); // Save the contact to Nylas and the 3rd party provider // This must be executed whenever you want to save changes. contact = account.contacts().update(contact); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: $ref: '#/components/schemas/CreateAContact' examples: UpdateAContactRequest: value: birthday: '1960-12-31' company_name: Nylas emails: - email: john@doe.com type: work given_name: John im_addresses: - type: aim im_address: myaimaddress job_title: Software Engineer manager_name: Bill the manager middle_name: Jacob nickname: JD notes: Loves ramen office_location: 123 Main Street phone_numbers: - number: 1 800 123 4567 type: business physical_addresses: - format: string type: work street_address: string city: string postal_code: string state: string country: string suffix: string surname: string web_pages: - type: profile url: string group: string delete: summary: Delete a Contact tags: - Contacts responses: '200': description: OK '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' examples: example-1: value: message: Error Message type: Error Type operationId: delete-contacts-id description: Deletes a contact. x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE 'https://api.nylas.com/contacts/{contact_id}' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Delete contacts by passing the contact id to .delete() nylas.contacts.delete('{id}') - lang: ruby label: Ruby SDK source: |- # Delete a contact by calling .destroy nylas.contacts.find('{id}').destroy - lang: js label: Node.js SDK source: |- // Delete contacts by passing the contact id to .delete() nylas.contacts.delete('{id}') - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; public class NylasExamples { public static void deleteContactExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Delete an contact by specifying its ID account.contacts().delete("{contactId}"); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type '/contacts/{id}/picture': parameters: - schema: type: string name: id in: path required: true get: summary: Returns a Contacts Picture tags: - Contacts responses: '200': description: OK content: text/html: schema: type: string examples: Binary Data: value: >- HTTP/1.1 200 OK Server: nginx Date: Mon, 05 Feb 2018 21:26:04 GMT Content-Type: image/jpeg Content-Length: 2388 Connection: close Access-Control-Allow-Headers: Authorization,Accept,Cache-Control,X-Requested-With,Content-Type Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS Access-Control-Allow-Credentials: true Nylas-API-Version: 2.0 Strict-Transport-Security: max-age=31536000; includeSubDomains X-XSS-Protection: 1 X-Content-Type-Options: nosniff Content-Security-Policy: default-src https: 'unsafe-eval' 'unsafe-inline'; object-src 'none' {BINARY DATA BLOB} '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-contacts-id-picture description: >- Some contacts have profile pictures. If a contact has a picture associated with it, when you make a normal GET request for the contact, the `picture_url` field will be filled out with the url to send the picture GET request. The result is the header information with binary data. If you pipe the result into a data file specified by Content-Type field in the header data, jpg for this example, you can open that file and view the picture. ``` curl --include --request GET \ --url 'https://api.nylas.com/contacts/{id}/picture' \ --header "authorization: " > picture.jpg ``` x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/contacts/{contact_id}/picture' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Get a contact object to access it's picture contact = nylas.contacts.get('{id}') # get_picture() returns the urllib request for the picture file picture = contact.get_picture() # Here's an example that shows how to save the picture to a file file = open('picture.jpg', 'w+b"') file.write(picture.read()) file.close() # You can also access the url where Nylas stores the picture with the picture_url attribute contact.picture_url - lang: ruby label: Ruby SDK source: >- # Get a contact object to access it's picture contact = nylas.contacts.find('{id}') # picture returns the picture file picture = contact.picture # You can also access the url where Nylas stores the picture with the picture_url attribute contact.picture_url - lang: js label: Node.js SDK source: >- // Get a contact object to access it's picture let contact; nylas.contacts.find('{id}').then(resp => contact = resp); // get_picture() returns the urllib request for the picture file let picture; contact.getPicture().then(resp => picture = resp); // Here's an example that shows how to save the picture to a file const fs = require('fs'); fs.writeFile('picture.jpg', picture, 'binary', (err) => { if (err) throw err; console.log('The picture was saved!'); }); // You can also access the url where Nylas stores the picture with the picture_url attribute contact.pictureUrl - lang: java label: Java SDK source: |- import java.io.IOException; import okhttp3.ResponseBody; import java.nio.file.Paths; import java.nio.file.Files; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Contact; public class NylasExamples { public static void downloadContactPictureExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("YOUR_ACCESS_TOKEN"); // Stream and save a contact's picture to a local file. // use try-with-resources to make sure the response is properly closed after saving try (ResponseBody picResponse = account.contacts().downloadProfilePicture("{contact_id}")) { Files.copy(picResponse.byteStream(), Paths.get("picture.jpg")); } // You can also access the url where Nylas stores the picture with the pictureUrl attribute Contact contact = account.contacts().get("{contact_id}"); contact.getPictureUrl(); } } parameters: - schema: type: string in: header name: authorization description: '`" > picture.jpg`' /contacts/groups: get: summary: Return Contact Groups tags: - Contacts responses: '200': description: OK content: application/json: schema: type: array description: '' minItems: 1 uniqueItems: true items: type: object properties: id: type: string minLength: 1 example: a0a0a0a0a0a0a0a0a0a0a0 object: type: string minLength: 1 example: contact_group default: contact_group account_id: type: string minLength: 1 example: x2x2x2x2x2x2x2x2x2x2x2 name: type: string minLength: 1 example: Work path: type: string minLength: 1 example: Contacts/Work examples: ReturnContactGroupsResponse: value: - id: a0a0a0a0a0a0a0a0a0a0a0 object: contact_group account_id: x2x2x2x2x2x2x2x2x2x2x2 name: Work path: Contacts/Work '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-contacts-groups description: >- Returns contact groups. Contact groups provide a way for users to organize their contacts. Contact groups have different meanings across different providers. This affects the way contact groups are presented through the Nylas API. ## Gmail Gmail contact groups translate to labels. Any number of contacts may have any number of labels. Gmail contacts can belong to any number of contact groups. At this time, labels cannot be nested. Gmail contact groups will have equivalent name and path fields. ## Exchange Exchange contact groups translate to contact folders. A specific contact must live inside of exactly one folder. Exchange contacts belong to exactly one contact group. Contact folders may be nested. To avoid ambiguity, the path field of Exchange contact groups represents the fully qualified path of the corresponding contact folder (e.g. Contacts/Personal) and the name field represents the name of the folder only (e.g. Personal). x-code-samples: - lang: bash label: cURL source: |- curl -X GET 'https://api.nylas.com/contacts/groups' \ -H 'Authorization: Bearer ACCESS_TOKEN' - lang: py label: Python SDK source: '# This is not yet implemented in the Python SDK' - lang: ruby label: Ruby SDK source: '# This feature is not yet implemented in the Ruby SDK' - lang: js label: Node.js SDK source: // This feature is not yet implemented in the Ruby SDK - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.ContactGroup; import com.nylas.ContactGroups; public class NylasExamples { public static void getContactGroupsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); // Return all contact groups for an account ContactGroups groups = account.contactGroups(); ContactGroup group = groups.list().get(0); // The following attributes are available for a contact group group.getName(); group.getPath(); group.getId(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type /messages/search: get: summary: Search Messages tags: - Search responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Search-Messages' examples: SearchMessagesResponse: value: - account_id: 43jf3n4es3*** bcc: [] body: 'Hello, how are you?' cc: [] date: 1559770299 events: [] files: [] folder: display_name: Draft id: eeangfw9vm5*** name: drafts from: - email: nylastest***@yahoo.com name: John Doe id: 27hvuc1w2v85*** object: draft reply_to: [] reply_to_message_id: null snippet: 'Hello, how are you?' starred: false subject: ugh? thread_id: 3sso5z8gb3*** to: - email: '{{email}}' name: '{{name}}' unread: false version: 0 - account_id: 43jf3n4es3i*** bcc: [] body: 'Hello, how are you?' cc: [] date: 1559762902 events: [] files: [] folder: display_name: Draft id: eeangfw9vm5j4f*** name: drafts from: - email: nylastest***@yahoo.com name: John Doe id: 92c7gucghzh16147dpluw1q2d object: draft reply_to: [] reply_to_message_id: null snippet: 'Hello, how are you?' starred: false subject: Hello thread_id: e48pmw615r*** to: - email: '{{email}}' name: '{{name}}' unread: false version: 0 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-messages-search parameters: - schema: type: string in: query name: q description: The query used to search messages. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/messages/search?q=hello \ -H 'Authorization: Basic WVVUWjZ****' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Find all messages with the word "hello" messages = nylas.messages.search("hello") - lang: ruby label: Ruby SDK source: 'nylas.messages.search("hello").map(&:to_h)' - lang: js label: Node.js SDK source: >- nylas.messages.search('hello').then(messages => console.log(messages)); - lang: java label: Java SDK source: |- import java.io.IOException; import java.util.List; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Message; import com.nylas.Messages; public class NylasExamples { public static void searchMessagesExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Messages messages = account.messages(); // Search for provided string with a limit and offset List results = messages.search("swag@nylas.com", 5, 0); } } required: true - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept description: >- Searches messages. For details on the query syntax for the most commmon providers, please see: * [Google](https://support.google.com/mail/answer/7190?hl=en) * [Exchange/Outlook](https://support.office.com/en-us/article/Learn-to-narrow-your-search-criteria-for-better-searches-in-Outlook-d824d1e9-a255-4c8a-8553-276fb895a8da) * [Yahoo](https://help.yahoo.com/kb/SLN4701.html) * [Generic IMAP](https://tools.ietf.org/html/rfc3501#section-6.4.4) security: - ACCESS_TOKEN: [] /threads/search: get: summary: Search Threads tags: - Search responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Search-Threads' examples: SearchThreadsResponse: value: - account_id: 43jf3n4es3i*** draft_ids: - 27hvuc1w2v85*** first_message_timestamp: 1559770299 folders: - display_name: Draft id: eeangfw9vm5j*** name: drafts has_attachments: false id: 3sso5z8gb3ts*** last_message_received_timestamp: null last_message_sent_timestamp: null last_message_timestamp: 1559770299 message_ids: [] object: thread participants: [] snippet: '' starred: false subject: ugh? unread: false version: 1 - account_id: 43jf3n4es3i*** draft_ids: - 92c7gucghzh*** first_message_timestamp: 1559762902 folders: - display_name: Draft id: eeangfw9vm5*** name: drafts has_attachments: false id: e48pmw615r2i*** last_message_received_timestamp: null last_message_sent_timestamp: null last_message_timestamp: 1559762902 message_ids: [] object: thread participants: [] snippet: '' starred: false subject: Hello unread: false version: 1 '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-threads-search description: >- Searches threads.For details on the query syntax for the most commmon providers, please see: * [Google](https://support.google.com/mail/answer/7190?hl=en) * [Exchange/Outlook](https://support.office.com/en-us/article/Learn-to-narrow-your-search-criteria-for-better-searches-in-Outlook-d824d1e9-a255-4c8a-8553-276fb895a8da) * [Yahoo](https://help.yahoo.com/kb/SLN4701.html) * [Generic IMAP](https://tools.ietf.org/html/rfc3501#section-6.4.4) x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/threads/search?q=hello \ -H 'Authorization: Basic WVVUWjZ****' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: |- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN ) # Find all threads with the word "hello" threads = nylas.threads.search("hello") - lang: ruby label: Ruby SDK source: 'nylas.threads.search("hello").map(&:to_h)' - lang: js label: Node.js SDK source: nylas.threads.search('hello').then(threads => console.log(threads)); - lang: java label: Java SDK source: |- import java.io.IOException; import java.util.List; import com.nylas.RequestFailedException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.Thread; import com.nylas.Threads; public class NylasExamples { public static void searchThreadsExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account("{ACCESS_TOKEN}"); Threads threads = account.threads(); // Search for provided string with a limit and offset List results = threads.search("swag@nylas.com", 5, 0); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type - schema: type: string in: query name: q description: The query used to search for threads. '/a/{client_id}/webhooks': parameters: - schema: type: string name: client_id in: path required: true description: The client ID of your Nylas developer application. get: summary: Return All Webhooks tags: - Webhooks responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Webhooks-Object' examples: ReturnAllWebhooksResponse: value: - application_id: 8eejdhpc5dv04w6ea8lzlxtkt callback_url: 'https://97a5db5e7c59.ngrok.io/webhook' id: 7b5y8f25p344jy8yem6v5jir state: active triggers: - message.created version: '2.0' operationId: get-a-client_id-webhooks description: Returns all webhooks. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/a/{client_id}/webhooks \ -H 'Authorization: Basic WVVUWjZ****' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: '# This feature is not yet supported in the Python SDK' - lang: ruby label: Ruby SDK source: |- # Retrieving a count of webhooks api.webhooks.count # Retrieving a subset of webhooks using limit api.webhooks.limit(5).map(&:to_h) - lang: js label: Node.js SDK source: Nylas.webhooks.list().then(webhooks => console.log(webhooks)); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Webhook; import com.nylas.Webhooks; public class NylasExamples { public static void getWebhooksExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Webhooks webhooks = application.webhooks(); // Return all webhooks found in the user's inbox webhooks.list(); // Return the first webhook Webhook webhook = webhooks.list().get(0); // The following attributes are available for the webhook object webhook.getId(); webhook.getApplicationId(); webhook.getCallbackUrl(); webhook.getState(); webhook.getTriggers(); webhook.getVersion(); } } security: - ACCESS_TOKEN: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept post: summary: Create a Webhook tags: - Webhooks responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Webhooks-Object' examples: CreateAWebhookResponse: value: application_id: 8eejdhpc5dv04w6ea8lzlxtkt callback_url: 'https://97a5db5e7c59.ngrok.io/webhook' id: 7b5y8f25p344jy8yem6v5jir state: active triggers: - message.created version: '2.0' operationId: post-a-client_id-webhooks description: Creates a webhook. x-code-samples: - lang: bash label: cURL source: "curl -X POST \\\n https://api.nylas.com/a/6yvh3ynadnwqtumyfper72svf/webhooks/ \\\n -H 'Authorization: Basic mYSuP3rSecR3tB4s1cAutHtOk3n=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n\t\"callback_url\": \"https://084eb929.ngrok.io/webook\",\n\t\"triggers\": [\"message.opened\"],\n\t\"state\": \"active\"\n}'" - lang: py label: Python SDK source: '# This feature is not yet supported in the Python SDK' - lang: ruby label: Ruby SDK source: '# This feature is not yet supported in the Ruby SDK' - lang: js label: Node.js SDK source: |- const newWebhook = Nylas.webhooks.build({ callbackUrl: 'https://wwww.myapp.com/webhook', state: 'active', triggers: ['event.created', 'event.updated'], }); newWebhook.save().then(webhook => console.log(webhook.id)); - lang: java label: Java SDK source: |- import java.io.IOException; import java.util.Arrays; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Webhook; public class NylasExamples { public static void postWebhookExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); Webhook webhook = new Webhook(); webhook.setCallbackUrl("https://wwww.myapp.com/webhook"); webhook.setState("active"); webhook.setTriggers(Arrays.asList("event.created", "event.updated")); webhook = application.webhooks().create(webhook); System.out.println(webhook); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept requestBody: content: application/json: schema: description: '' type: object properties: callback_url: type: string minLength: 1 description: >- Creates a URL where the Nylas servers can send notifications. It must be accessible from the public internet and must be an HTTPS endpoint. example: 'https://97a5db5e7c59.ngrok.io/webhook' triggers: type: array description: >- Creates a set of triggers, describing the notifications this webhook should receive. items: type: string example: message.created state: type: string minLength: 1 enum: - active - inactive description: >- Set the state of the webhook. Can be set to active or inactive. example: active required: - callback_url - triggers - state examples: CreateAWebhookRequest: value: callback_url: 'https://97a5db5e7c59.ngrok.io/webhook' triggers: - message.created state: active description: '' '/a/{client_id}/webhooks/{id}': parameters: - schema: type: string name: client_id in: path required: true description: The client ID of your Nylas developer application. - schema: type: string name: id in: path required: true description: The ID of the webhook. get: summary: Return a Webhook tags: - Webhooks responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Webhooks-Object' examples: ReturnAWebhookResponse: value: application_id: 8eejdhpc5dv04w6ea8lzlxtkt callback_url: 'https://97a5db5e7c59.ngrok.io/webhook' id: 7b5y8f25p344jy8yem6v5jir state: active triggers: - message.created version: '2.0' operationId: get-a-client_id-webhooks-id description: Returns a webhook by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/a/client_id****/webhooks/evh5uy0shh*** \ -H 'Authorization: Basic WVVUWjZ2****' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: '# This feature is not yet supported in the Python SDK' - lang: ruby label: Ruby SDK source: |- example_webhook = api.webhooks.first api.webhooks.find(example_webhook.id).to_h - lang: js label: Node.js SDK source: |- Nylas.webhooks.find('existingWebhookId').then(existingWebhook => { console.log(existingWebhook); }) - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Webhook; public class NylasExamples { public static void getWebhookExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); // Get a Webhook by specifying its ID Webhook webhook = application.webhooks().get("{webhookId}"); // The following attributes are available for the webhook object webhook.getId(); webhook.getApplicationId(); webhook.getCallbackUrl(); webhook.getState(); webhook.getTriggers(); webhook.getVersion(); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type put: summary: Update a Webhook tags: - Webhooks responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Webhooks-Object' examples: UpdateAWebhookResponse: value: application_id: 8eejdhpc5dv04w6ea8lzlxtkt callback_url: 'https://97a5db5e7c59.ngrok.io/webhook' id: 7b5y8f25p344jy8yem6v5jir state: active triggers: - message.created version: '2.0' operationId: put-a-client_id-webhooks-id description: Updates a webhook by ID. x-code-samples: - lang: bash label: cURL source: "curl -X PUT \\\n https://api.nylas.com/a/6yvh3ynadnwqtumyfper72svf/webhooks/6cclep8i8aqknqnjqxsgs3ycw \\\n\t-H 'Authorization: Basic mYSuP3rSecR3tB4s1cAutHtOk3n=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n\t\"state\": \"inactive\"\n}'" - lang: py label: Python SDK source: '# This feature is not yet supported in the Python SDK' - lang: ruby label: Ruby SDK source: '# This feature is not yet supported in the Ruby SDK' - lang: js label: Node.js SDK source: |- Nylas.webhooks.find('existingWebhookId').then(existingWebhook => { existingWebhook.state = 'active'; existingWebhook.save(); }) - lang: java label: Java SDK source: |- import java.io.IOException; import java.util.Arrays; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.Webhook; public class NylasExamples { public static void putWebhookExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); // Get a Webhook by specifying its ID Webhook webhook = application.webhooks().get("{webhookId}"); webhook.setCallbackUrl("https://wwww.myapp.com/webhook"); webhook.setState("active"); webhook.setTriggers(Arrays.asList("event.created", "event.updated")); webhook = application.webhooks().update(webhook); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type requestBody: content: application/json: schema: type: object properties: state: type: string description: Set the state to active or inactive enum: - active - inactive delete: summary: Delete a Webhook tags: - Webhooks responses: '200': description: OK. Returns `null`. operationId: delete-a-client_id-webhooks-id description: Deletes a webhook by ID. x-code-samples: - lang: bash label: cURL source: |- curl -X DELETE \ https://api.nylas.com/a/6yvh3ynadnwqtumyfper72svf/webhooks/ \ -H 'Authorization: Basic mYSuP3rSecR3tB4s1cAutHtOk3n=' \ -H 'Content-Type: application/json' \ - lang: py label: Python SDK source: '# This feature is not yet supported in the Python SDK' - lang: ruby label: Ruby SDK source: '# This feature is not yet supported in the Ruby SDK' - lang: js label: Node.js SDK source: Nylas.webhooks.delete(existingWebhook); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; public class NylasExamples { public static void deleteWebhookExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); // Delete a webhook by specifying its ID application.webhooks().delete("{webhookId}"); } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type /delta/latest_cursor: post: summary: Get A Delta Cursor tags: - Deltas responses: '200': description: OK content: application/json: schema: description: '' type: object properties: cursor: type: string minLength: 1 required: - cursor examples: GetADeltaCursorResponse: value: cursor: aqb0llc2ioo0*** '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: post-delta-latest_cursor description: >- Return a delta cursor. The delta cursor is used to return data using the other deltas endpoints. Review the [Deltas documentation](# link) for more. x-code-samples: - lang: bash label: cURL source: |- curl -X POST \ https://api.nylas.com/delta/latest_cursor \ -H 'Authorization: Basic WVVUWjZ2****' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: '# This feature is not supported' - lang: ruby label: Ruby SDK source: |- # Retrieves the latest colletion of deltas latest_deltas = api.deltas.latest.class # Retrieves the latest cursor api.deltas.latest_cursor - lang: js label: Node.js SDK source: >- const DELTA_EXCLUDE_TYPES = ['contact', 'calendar', 'event', 'file']; nylas.deltas.latestCursor((error, cursor) => { // Save inital cursor. persistCursor(cursor); // Start the stream and add event handlers. const stream = nylas.deltas.startStream(cursor, DELTA_EXCLUDE_TYPES); stream .on('delta', delta => { // Handle the new delta. console.log('Received delta:', delta); // Save new cursor so this delta doesn't need to be re-fetched for future streams. persistCursor(delta.cursor); }) .on('error', err => { // Handle errors here, such as by restarting the stream at the last cursor. console.error('Delta streaming error:', err); }); // Closing the stream explicitly, if needed stopButton.addEventListener('click', () => { stream.close(); }); }); - lang: java label: Java SDK source: // This feature is not supported by the Java SDK security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type /delta: get: summary: Request Delta Cursors tags: - Deltas responses: '200': description: OK content: application/json: schema: description: '' type: object properties: cursor_end: type: string minLength: 1 cursor_start: type: string minLength: 1 deltas: type: array uniqueItems: true minItems: 1 items: type: object properties: attributes: type: object properties: account_id: type: string minLength: 1 bcc: type: array items: type: object body: type: string minLength: 1 cc: type: array items: type: object date: type: number events: type: array items: type: object files: type: array items: type: object from: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 id: type: string minLength: 1 labels: type: array uniqueItems: true minItems: 1 items: type: object properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 object: type: string minLength: 1 reply_to: type: array items: type: object snippet: type: string minLength: 1 starred: type: boolean subject: type: string minLength: 1 thread_id: type: string minLength: 1 to: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 unread: type: boolean cursor: type: string minLength: 1 event: type: string minLength: 1 id: type: string minLength: 1 object: type: string minLength: 1 examples: RequestDeltaCursorsResponse: value: cursor_end: 4ekj8ktel67njbaw1c0nlvbdi cursor_start: 9fboxh6t9b3ar4fwocxpwrcss deltas: - attributes: account_id: aaz875kwuvxik6ku7pwkqp3ah bcc: [] body: >-
Hi

Katherine Perry

Lead Technical Writer, Nylas

email@nylas.com

cc: [] date: 1602001027 events: [] files: [] from: - email: email@nylas.com name: Katherine Perry id: 52m5un5v1m7rjigna5agc7y35 labels: - display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent object: message reply_to: [] snippet: >- Hi Katherine PerryLead Technical Writer, Nylasemail@nylas.com starred: false subject: New Message thread_id: chvd75bowkhg3gfpgeeygcxbb to: - email: swag@nylas.com name: Katherine Personal unread: false cursor: 8hhvivgus0fbo4qengko8c38x event: create id: 52m5un5v1m7rjigna5agc7y35 object: message - attributes: account_id: aaz875kwuvxik6ku7pwkqp3ah draft_ids: [] first_message_timestamp: 1602001027 has_attachments: false id: chvd75bowkhg3gfpgeeygcxbb labels: - display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent last_message_received_timestamp: null last_message_sent_timestamp: 1602001027 last_message_timestamp: 1602001027 message_ids: - 52m5un5v1m7rjigna5agc7y35 object: thread participants: - email: swag@nylas.com name: Katherine Personal - email: email@nylas.com name: Katherine Perry snippet: >- Hi Katherine PerryLead Technical Writer, Nylasemail@nylas.com starred: false subject: New Message unread: false version: 0 cursor: 4ekj8ktel67njbaw1c0nlvbdi event: create id: chvd75bowkhg3gfpgeeygcxbb object: thread '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-delta description: >- Returns a set of delta cursors. This endpoint returns the most recent set of deltas. Use the data cursor as a query parameter to return deltas. This endpoint does not stream or poll for data. If this is your first time getting data, this could return nothing. The response will vary based on the type of delta cursor. Review the [Deltas documentation](# link) for more. parameters: - schema: type: string in: query name: cursor required: true description: The data cursor from `/delta/latest_cursor`. - schema: type: string default: expanded in: query name: view description: >- This value indicates if the data expands thread and message objects in the response to include additional information, when the value is set to expanded. - schema: type: string enum: - contact - file - message - event - draft - thread - folder - label example: contact in: query name: excluded_types description: >- A comma-separated list of object types to exclude from the returned deltas. - schema: type: string enum: - contact - event - file - message - draft - thread - folder - label in: query name: include_types description: >- A comma-separated list of the object types that will only be included in the returned deltas. - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/delta?cursor=aqb0llc2ioo0*** \ -H 'Authorization: Basic WVVUWjZ2****' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: '# This feature is not supported in the Python SDK' - lang: ruby label: Ruby SDK source: |- # Retrieves a particular cursor deltas_from_cursor = api.deltas.since(ENV['NYLAS_PREVIOUS_CURSOR']) # Get the deltas metadata deltas_from_cursor.cursor_end deltas_from_cursor.cursor_start deltas_from_cursor.count # Retrieving multiple pages of deltas deltas_from_cursor.find_each.map(&:id).count # 5 delta's deltas_from_cursor.take(5).map(&:to_h) # Models are cast to Nylas::Model objects deltas_from_cursor.first&.model&.class # And can be viewed directly deltas_from_cursor.first&.to_h - lang: js label: Node.js SDK source: // This feature is not supported - lang: java label: Java SDK source: // This feature is not supported by the Java SDK security: - BASIC_AUTH: [] /delta/longpoll: get: summary: Return Long-Polling Deltas tags: - Deltas responses: '200': description: OK content: application/json: schema: description: '' type: object properties: cursor_end: type: string minLength: 1 cursor_start: type: string minLength: 1 deltas: type: array uniqueItems: true minItems: 1 items: type: object properties: attributes: type: object properties: account_id: type: string minLength: 1 bcc: type: array items: type: object body: type: string minLength: 1 cc: type: array items: type: object date: type: number events: type: array items: type: object files: type: array items: type: object from: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 id: type: string minLength: 1 labels: type: array uniqueItems: true minItems: 1 items: type: object properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 object: type: string minLength: 1 reply_to: type: array items: type: object snippet: type: string minLength: 1 starred: type: boolean subject: type: string minLength: 1 thread_id: type: string minLength: 1 to: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 unread: type: boolean cursor: type: string minLength: 1 event: type: string minLength: 1 id: type: string minLength: 1 object: type: string minLength: 1 examples: ReturnLongPollingDeltasResponse: value: cursor_end: 4ekj8ktel67njbaw1c0nlvbdi cursor_start: 9fboxh6t9b3ar4fwocxpwrcss deltas: - attributes: account_id: aaz875kwuvxik6ku7pwkqp3ah bcc: [] body: >-
Hi

Katherine Perry

Lead Technical Writer, Nylas

email@nylas.com

cc: [] date: 1602001027 events: [] files: [] from: - email: email@nylas.com name: Katherine Perry id: 52m5un5v1m7rjigna5agc7y35 labels: - display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent object: message reply_to: [] snippet: >- Hi Katherine PerryLead Technical Writer, Nylasemail@nylas.com starred: false subject: New Message thread_id: chvd75bowkhg3gfpgeeygcxbb to: - email: swag@nylas.com name: Katherine Personal unread: false cursor: 8hhvivgus0fbo4qengko8c38x event: create id: 52m5un5v1m7rjigna5agc7y35 object: message - attributes: account_id: aaz875kwuvxik6ku7pwkqp3ah draft_ids: [] first_message_timestamp: 1602001027 has_attachments: false id: chvd75bowkhg3gfpgeeygcxbb labels: - display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent last_message_received_timestamp: null last_message_sent_timestamp: 1602001027 last_message_timestamp: 1602001027 message_ids: - 52m5un5v1m7rjigna5agc7y35 object: thread participants: - email: swag@nylas.com name: Katherine Personal - email: email@nylas.com name: Katherine Perry snippet: >- Hi Katherine PerryLead Technical Writer, Nylasemail@nylas.com starred: false subject: New Message unread: false version: 0 cursor: 4ekj8ktel67njbaw1c0nlvbdi event: create id: chvd75bowkhg3gfpgeeygcxbb object: thread '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-delta-longpoll description: >- Long Polling deltas will instruct the server to keep the connection open until a change comes through or it times out. You can use this behavior on platforms that do not support partial response parsing, such as web browsers. Review the [Deltas documentation](# link) for more. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/delta?cursor=aqb0llc2ioo0*** \ -H 'Authorization: Basic WVVUWjZ2****' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: '# This feature is not supported in the Python SDK' - lang: ruby label: Ruby SDK source: |- # Retrieves a particular cursor deltas_from_cursor = api.deltas.since(ENV['NYLAS_PREVIOUS_CURSOR']) # Get the deltas metadata deltas_from_cursor.cursor_end deltas_from_cursor.cursor_start deltas_from_cursor.count # Retrieving multiple pages of deltas deltas_from_cursor.find_each.map(&:id).count # 5 delta's deltas_from_cursor.take(5).map(&:to_h) # Models are cast to Nylas::Model objects deltas_from_cursor.first&.model&.class # And can be viewed directly deltas_from_cursor.first&.to_h - lang: js label: Node.js SDK source: // This feature is not supported - lang: java label: Java SDK source: // This feature is not supported by the Java SDK security: - BASIC_AUTH: [] parameters: - schema: type: string in: query name: cursor required: true description: The data cursor from `/delta/latest_cursor`. - schema: type: string default: expanded in: query name: view description: >- This value indicates if the data expands thread and message objects in the response to include additional information, when the value is set to expanded. - schema: type: string enum: - contact - file - message - event - draft - thread - folder - label example: contact in: query name: excluded_types description: >- A comma-separated list of object types to exclude from the returned deltas. - schema: type: string enum: - contact - event - file - message - draft - thread - folder - label in: query name: include_types description: >- A comma-separated list of the object types that will only be included in the returned deltas. - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type /delta/streaming: get: summary: Streaming Deltas tags: - Deltas responses: '200': description: OK content: application/json: schema: description: '' type: object properties: cursor_end: type: string minLength: 1 cursor_start: type: string minLength: 1 deltas: type: array uniqueItems: true minItems: 1 items: type: object properties: attributes: type: object properties: account_id: type: string minLength: 1 bcc: type: array items: type: object body: type: string minLength: 1 cc: type: array items: type: object date: type: number events: type: array items: type: object files: type: array items: type: object from: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 id: type: string minLength: 1 labels: type: array uniqueItems: true minItems: 1 items: type: object properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 object: type: string minLength: 1 reply_to: type: array items: type: object snippet: type: string minLength: 1 starred: type: boolean subject: type: string minLength: 1 thread_id: type: string minLength: 1 to: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 unread: type: boolean cursor: type: string minLength: 1 event: type: string minLength: 1 id: type: string minLength: 1 object: type: string minLength: 1 examples: StreamingDeltasResponse: value: cursor_end: 4ekj8ktel67njbaw1c0nlvbdi cursor_start: 9fboxh6t9b3ar4fwocxpwrcss deltas: - attributes: account_id: aaz875kwuvxik6ku7pwkqp3ah bcc: [] body: >-
Hi

Katherine Perry

Lead Technical Writer, Nylas

email@nylas.com

cc: [] date: 1602001027 events: [] files: [] from: - email: email@nylas.com name: Katherine Perry id: 52m5un5v1m7rjigna5agc7y35 labels: - display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent object: message reply_to: [] snippet: >- Hi Katherine PerryLead Technical Writer, Nylasemail@nylas.com starred: false subject: New Message thread_id: chvd75bowkhg3gfpgeeygcxbb to: - email: swag@nylas.com name: Katherine Personal unread: false cursor: 8hhvivgus0fbo4qengko8c38x event: create id: 52m5un5v1m7rjigna5agc7y35 object: message - attributes: account_id: aaz875kwuvxik6ku7pwkqp3ah draft_ids: [] first_message_timestamp: 1602001027 has_attachments: false id: chvd75bowkhg3gfpgeeygcxbb labels: - display_name: Sent Mail id: ertg5obp5nvn43xtqe2e55en0 name: sent last_message_received_timestamp: null last_message_sent_timestamp: 1602001027 last_message_timestamp: 1602001027 message_ids: - 52m5un5v1m7rjigna5agc7y35 object: thread participants: - email: swag@nylas.com name: Katherine Personal - email: email@nylas.com name: Katherine Perry snippet: >- Hi Katherine PerryLead Technical Writer, Nylasemail@nylas.com starred: false subject: New Message unread: false version: 0 cursor: 4ekj8ktel67njbaw1c0nlvbdi event: create id: chvd75bowkhg3gfpgeeygcxbb object: thread operationId: get-delta-streaming parameters: - schema: type: string in: query name: cursor required: true description: The data cursor from `/delta/latest_cursor`. - schema: type: string default: expanded in: query name: view description: >- This value indicates if the data expands thread and message objects in the response to include additional information, when the value is set to expanded. - schema: type: string enum: - contact - file - message - event - draft - thread - folder - label example: contact in: query name: excluded_types description: >- A comma-separated list of object types to exclude from the returned deltas. - schema: type: string enum: - contact - event - file - message - draft - thread - folder - label in: query name: include_types description: >- A comma-separated list of the object types that will only be included in the returned deltas. - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type description: >- Streaming deltas process real-time updates. The server connection does not close. You can use this for server-side applications that can parse data in real-time. Review the [Deltas documentation](# link) for more. x-code-samples: - lang: bash label: cURL source: |- curl -X GET \ https://api.nylas.com/delta?cursor=aqb0llc2ioo0*** \ -H 'Authorization: Basic WVVUWjZ2****' \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache' - lang: py label: Python SDK source: '# This feature is not supported in the Python SDK' - lang: ruby label: Ruby SDK source: |- # Retrieves a particular cursor deltas_from_cursor = api.deltas.since(ENV['NYLAS_PREVIOUS_CURSOR']) # Get the deltas metadata deltas_from_cursor.cursor_end deltas_from_cursor.cursor_start deltas_from_cursor.count # Retrieving multiple pages of deltas deltas_from_cursor.find_each.map(&:id).count # 5 delta's deltas_from_cursor.take(5).map(&:to_h) # Models are cast to Nylas::Model objects deltas_from_cursor.first&.model&.class # And can be viewed directly deltas_from_cursor.first&.to_h - lang: js label: Node.js SDK source: // This feature is not supported - lang: java label: Java SDK source: // This feature is not supported by the Java SDK security: - BASIC_AUTH: [] /job-statuses: get: summary: Return All Job Statuses tags: - Job Statuses responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Job-Status' examples: ReturnAllJobStatusesResponse: value: - account_id: eof2wrhqkl7kdwhy9hylpv9o9 action: create_calendar created_at: 1592374298 id: 8e570s302fdazx9zqwiuk9jqn job_status_id: 48pp6ijzrxpw9jors9ylnsxnf object: calendar status: successful - account_id: eof2wrhqkl7kdwhy9hylpv9o9 action: update_calendar created_at: 1592375249 id: 8e570s302fdazx9zqwiuk9jqn job_status_id: aqghhhldmq8eyxnn14z0tlsun object: calendar status: successful - account_id: eof2wrhqkl7kdwhy9hylpv9o9 action: delete_calendar created_at: 1592375759 id: 8e570s302fdazx9zqwiuk9jqn job_status_id: d38mgop88je0agkqrf03sw0sw object: calendar status: successful '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-job-statuses description: Return all job statuses. x-code-samples: - lang: bash label: cURL source: >- curl --location --request GET 'https://api.nylas.com/job-statuses/' \ --header 'Authorization: Basic {ENCODED_SECRET}' \ - lang: py label: Python SDK source: '' - lang: ruby label: Ruby SDK source: '' - lang: js label: Node.js SDK source: '' - lang: java label: Java SDK source: '' security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Accept - schema: type: string default: application/json in: header name: Content-Type '/job-statuses/{id}': parameters: - schema: type: string name: id in: path required: true description: The ID of the job status. get: summary: Return A Job Status tags: - Job Statuses responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Job-Status' examples: ReturnAJobStatusResponse: value: account_id: eof2wrhqkl7kdwhy9hylpv9o9 action: update_message created_at: 1592374298 id: 8e570s302fdazx9zqwiuk9jqn job_status_id: 48pp6ijzrxpw9jors9ylnsxnf object: message status: successful '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Error-400' operationId: get-job-statuses-id description: Return a job status by ID. x-code-samples: - lang: bash label: cURL source: >- curl --location --request GET 'https://api.nylas.com/job-statuses/48pp6ijzrxpw9jors9ylnsxnf' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic mySupe3rSecretAcc3sST0k3N==' \ - lang: py label: Python SDK source: >- from nylas import APIClient nylas = APIClient( CLIENT_ID, CLIENT_SECRET ) auth_url = nylas.authentication_url( "http://example.com/login_callback", # Required login_hint="your_email@example.com", # Optional state="unique_identifier", # Optional scopes='email, calendar, contacts' # Optional - Default is all scopes # A full list of available scopes can be found here: # https://docs.nylas.com/docs/authentication-scopes ) # This is the URL you need to send the user to to authenticate their account. print(auth_url) # After your user authenticates, Nylas will return a unique, one-time-use code. # This code can be used to create an access token that grants access to the user account. # See: https://docs.nylas.com/reference#oauthtoken - lang: ruby label: Ruby SDK source: |- use OmniAuth::Builder do provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], { name: 'google', access_type: :offline, approval_prompt: "force", prompt: 'consent', scope: ['email', 'profile', 'https://mail.google.com/', 'https://www.google.com/m8/feeds/', 'calendar'].join(', ') } end get "/" do 'Authenticate a Google Account' end get "/auth/failure" do params[:message] end - lang: js label: Node.js SDK source: |- const Nylas = require('nylas'); Nylas.config({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, }); options = { loginHint: 'you_email@example.com', redirectURI: 'https://localhost/callback', scopes: ['email.read_only', 'email.send'], }; // Redirect your user to the auth_url auth_url = Nylas.urlForAuthentication(options); - lang: java label: Java SDK source: |- import java.io.IOException; import com.nylas.RequestFailedException; import com.nylas.NylasApplication; import com.nylas.NylasClient; import com.nylas.HostedAuthentication; import com.nylas.Scope; public class NylasExamples { public static void hostedAuthExample() throws IOException, RequestFailedException { NylasClient nylas = new NylasClient(); NylasApplication application = nylas.application("{CLIENT_ID}", "{CLIENT_SECRET}"); HostedAuthentication authentication = application.hostedAuthentication(); String hostedAuthUrl = authentication.urlBuilder() .redirectUri("https://example.com/redirect") .responseType("code") // Use token for client-side apps .scopes(Scope.EMAIL, Scope.CALENDAR, Scope.CONTACTS) .loginHint("nyla@nylas.com") .state("example_csrf_token") .buildUrl(); // This is the URL you need to send the user to to authenticate their account. System.out.println(hostedAuthUrl); // After your user authenticates, Nylas will return a unique, one-time-use code. // This code can be used to create an access token that grants access to the user account. // See: https://docs.nylas.com/reference#oauthtoken } } security: - BASIC_AUTH: [] parameters: - schema: type: string default: application/json in: header name: Content-Type - schema: type: string default: application/json in: header name: Accept components: schemas: Account-Return-All: title: Account-Return-All type: object description: '`/a/client_id/accounts`' properties: account_id: type: string description: >- A reference to the parent account object (self-referential in this case. example: 622x1k5v1ujh55t6ucel7av4 billing_state: type: string description: >- The billing state for the account. Values are `paid`, `cancelled`, or `deleted`. enum: - paid - cancelled - deleted - free email: type: string description: The email address of the account. example: al@particletech.com id: type: string description: A globally unique object identifier. example: 622x1k5v1ujh55t6ucel7av4 provider: type: string description: Specifies the provider that backs the account. example: yahoo sync_state: type: string description: The current sync state for the account. example: running enum: - running - invalid - stopped trial: type: boolean description: The trial state for the application. Folder-Object: title: Folder-Object description: '' type: object properties: id: description: Globally unique object identifier. type: string example: blrfzbz4r066ip8x1bh8k8g1y object: description: A string describing the type of object (value is "folder"). type: string example: folder account_id: description: Reference to parent account object. type: string example: 79xcak1h10r1tmm5ogavx28lb name: description: >- Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154). Can be one of the following: * inbox * all * trash * archive * drafts * sent * spam * important * null (regular user-created folder) type: string example: inbox display_name: description: >- Localized name of folder, matching what is presented in their other mail apps. If you are displaying folders, use this instead of `name`. type: string example: Inbox x-tags: - Folders x-examples: {} Folder-Create: title: Folder-Create type: object properties: display_name: description: The human-readable name for the new folder. type: string example: My Renamed Folder Folder-Update: title: Folder-Update type: object properties: display_name: description: The human-readable name for the new folder. type: string example: My Renamed Folder name: description: >- Specify `sent` to update this folder as the primary sent folder. This feature is supported for custom IMAP accounts only. type: string example: renamed-folder Error-400: title: Error-400 type: object properties: message: description: Error Message type: string example: Error Message type: description: Error Type type: string example: Error Type x-examples: {} Native-Auth-Post: title: Native-Auth-Post required: - client_id - name - email_address - provider type: object properties: client_id: description: Your client ID from the Nylas Developer console. type: string name: description: The full name of the user (e.g. “John Snow”). type: string email_address: description: The user’s email address. type: string provider: description: >- The format of the settings objec is dependent upon this field. If your provider isn't listed, use the generic settings. enum: - gmail - yahoo - exchange - outlook - imap - icloud - hotmail - aol - office365 type: string settings: oneOf: - description: Google Settings properties: google_client_id: type: string google_client_secret: type: string google_refresh_token: type: string - description: Exchange Settings properties: username: type: string password: type: string exchange_server_host: type: string - description: Known IMAP properties: pasword: type: string - description: Generic IMAP properties: imap_host: type: string imap_port: type: string imap_username: type: string imap_password: type: string smtp_host: type: string smtp_port: type: string smtp_username: type: string smtp_password: type: string ssl_required: type: string - description: Office 365 properties: microsoft_client_id: type: string microsoft_client_secret: type: string microsoft_refresh_token: type: string redirect_uri: description: >- Redirect URI that the was originally used to get the refresh token. type: string - description: Office 365 Service Accounts OAuth properties: microsoft_client_id: type: string microsoft_client_secret: type: string microsoft_refresh_token: type: string redirect_uri: description: >- Redirect URI that the was originally used to get the refresh token. type: string service_accounts: default: 'true' type: string - description: Office 365 Service Account Password Authentication properties: username: type: string password: type: string service_account: default: 'true' type: string - description: G Suite Service Accounts properties: service_account_json: type: object properties: type: default: service_account type: string project_id: type: string example: metal-figure-239116 private_key_id: type: string example: 68ac9191dd3468915b4e52e0be785ba7c6873b14 private_key: type: string example: >- -----BEGIN PRIVATE KEY-----\nMI...J7tF8=\n-----END PRIVATE KEY-----\n client_email: type: string example: >- test-service-account@metal-figure-239116.iam.gserviceaccount.com client_id: type: string example: '105691998485416876281' auth_uri: type: string example: 'https://accounts.google.com/o/oauth2/auth' token_uri: type: string example: 'https://oauth2.googleapis.com/token' auth_provider_x509_cert_url: type: string example: 'https://www.googleapis.com/oauth2/v1/cert' client_x509_cert_url: type: string example: >- https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40metal-figure-239116.iam.gserviceaccount.com type: object scopes: description: >- Any combination of supported authentication scopes. Service accounts only support calendar scopes. type: string x-examples: {} Account-Get: title: Account-Get type: object properties: id: description: A globally unique object identifier. type: string example: awa6ltos76vz5hvphkp8k17nt object: description: A string describing the type of object. default: account type: string example: account account_id: description: ID of the account. type: string example: awa6ltos76vz5hvphkp8k17nt name: description: >- The full name of the user, used as the default from name when sending mail. type: string example: Dorothy Vaughan provider: description: >- Specifies the provider that backs the account. See [Supported Providers](#link) for a full list. type: string example: gmail organization_unit: description: >- Specify either label or folder, depending on the provider capabilities. See [Label vs. Folder](#link) for more. type: string example: label sync_state: description: >- The syncing status of the account. See the [Sync Status](#link) documentation for possible values. type: string example: running linked_at: format: int32 description: >- A Unix timestamp indicating when this account was originally connected to Nylas. type: integer example: 1470231381 email_address: description: >- The canonical email address of the account. For Gmail accounts, this removes periods and plus suffixes. type: string example: dorothy@spacetech.com description: '`/account`' Native-Auth-Token: title: Native-Auth-Token type: object properties: access_token: type: string account_id: type: string billing_state: type: string email_address: type: string id: type: string linked_at: type: integer name: type: string object: type: string organization_unit: type: string provider: type: string sync_state: type: string Application-Details-Get: description: '' type: object properties: application_name: type: string minLength: 1 description: The name of the Nylas application. icon_url: type: string minLength: 1 example: >- https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6 description: Icon URL of the Nylas application. redirect_uris: type: array description: >- Array of strings. Each string is a single redirect_uri for the application. items: type: string required: - application_name - icon_url - redirect_uris Thread-Object: description: '' type: object properties: account_id: type: string minLength: 1 description: Reference to parent account object draft_ids: type: array description: Array of IDs for unsent drafts in the thread. May be null or absent items: type: string first_message_timestamp: type: number description: Timestamp when the thread began. UNIX folders: type: array uniqueItems: true minItems: 1 description: >- The folder location(s) of a thread, present only if the parent account's organization_unit is folder. Note that threads can span folders, depending on the location of the thread's messages. See the folders docs for more info. items: type: object properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 has_attachments: type: boolean description: Indicates if the thread has files attached to it. id: type: string minLength: 1 description: Globally unique object identifier last_message_received_timestamp: type: number description: |- Timestamp of the most recently received message. (Excludes messages sent by the account.) UNIX last_message_sent_timestamp: type: number description: Timestamp of the most recently sent message in the thread. UNIX last_message_timestamp: type: number description: Timestamp of the most recent message. UNIX message_ids: type: array description: >- Array of IDs for messages within the thread, sorted by their timestamps items: type: string object: type: string minLength: 1 description: A string describing the type of object (value is "thread") default: thread participants: type: array uniqueItems: true minItems: 1 description: >- List of participant objects computed from all messages in the thread. items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 snippet: type: string minLength: 1 description: >- A shortened plain-text preview of the most recent message in the thread starred: type: boolean description: 'Indicates one or more messages are starred, aka flagged (mutable)' subject: type: string minLength: 1 description: Subject of the first message in the thread unread: type: boolean description: Indicates whether the thread contains unread messages (mutable) version: type: integer description: >- Incrementing value related to thread updates. You can use this to compare revisions, or invalidate your local cache. labels: type: array description: >- A list of label objects, present only if the parent account's organization_unit is label. These have Gmail-style semantics and can be arbitrarily added and removed from threads. items: type: string Thread-PUT: title: Thread-PUT type: object properties: unread: type: boolean description: Set to `true` to mark as unread; `false` to mark as read. starred: type: boolean description: Set to `true` to star a thread; `false` to un-star a thread. folder_id: type: string description: The ID of the folder to which to move this thread. label_ids: type: array description: >- The IDs of the labels to apply, overwriting all previous labels on the thread. items: type: string Message-PUT: title: Thread-PUT type: object properties: unread: type: boolean description: Set to `true` to mark as unread; `false` to mark as read. starred: type: boolean description: Set to `true` to star a thread; `false` to un-star a thread. folder_id: type: string description: The ID of the folder to which to move this thread. label_ids: type: array description: >- The IDs of the labels to apply, overwriting all previous labels on the thread. items: type: string Message-Object: description: '' type: object properties: account_id: type: string minLength: 1 description: Reference to a parent account object. bcc: type: array description: > An array of name+email pairs the message was bcc'd to. For received mail this is nearly always empty. items: type: object body: type: string minLength: 1 description: >- The full HTML message body. Messages with only plain-text representations are up-converted to HTML. cc: type: array description: An array of name+email pairs the message was cc'd to. items: type: object date: type: number description: >- A timestamp of the date the message was received by the mail server. This may be different from the unverified Date header in raw message object. UNIX events: type: array description: 'An array Event objects, if message includes calendar invites.' items: type: object files: type: array description: 'An array of File objects, if the message includes attachments.' items: type: object folder: type: object description: >- A single folder object indicating the location of the message. This is present only if the parent account's organization_unit is folder. This property can be changed to move the message to a different folder. properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 from: type: array uniqueItems: true minItems: 1 description: >- A list of name+email pairs the message was sent from. This is usually one object, but can be many. items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 id: type: string minLength: 1 description: A globally unique object identifier. object: type: string minLength: 1 description: A string describing the type of object (value is "message"). default: message reply_to: type: array uniqueItems: true minItems: 1 description: An array of name+email pairs replies should be sent to. items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 snippet: type: string minLength: 1 description: A shortened plain-text preview of the message body. starred: type: boolean description: Indicates the message is in a starred or flagged state (mutable). subject: type: string minLength: 1 description: The subject line of the message. thread_id: type: string minLength: 1 description: Reference to a parent thread object (all messages have a thread). to: type: array uniqueItems: true minItems: 1 description: An array of name+email pairs the message was sent to. items: type: object properties: email: type: string minLength: 1 name: type: string unread: type: boolean description: >- Indicates the message is unread. This is the default for new incoming mail (mutable). labels: type: array description: >- A list of Label objects. This is present only if the parent account's organization_unit is label. These are Gmail-style and can be arbitrarily added and removed from messages. items: type: string Labels-Object: description: '' type: object title: '' properties: account_id: type: string minLength: 1 example: aaz875kwuvxik6ku7pwkqp3ah description: Reference to parent account object. display_name: type: string minLength: 1 example: keep description: >- Localized name of label, matching what is presented in their other mail apps. If you are displaying labels, use this instead of name. default: label id: type: string minLength: 1 example: eluc9ishugbda9egbmtkkc934 description: Globally unique object identifier. name: type: string minLength: 1 example: 'null' description: >- Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154). If null, then a user-created label. enum: - inbox - all - trash - archive - drafts - sent - spam - important - 'null' object: type: string minLength: 1 example: label description: A string describing the type of object Drafts: description: '' type: object properties: account_id: type: string minLength: 1 description: A reference to the parent account object. bcc: type: array description: An array of name-email pairs of recipients to be bcc'd. items: type: object properties: name: type: string email: type: string body: type: string minLength: 1 description: The full HTML draft body text. cc: type: array description: An array of name-email pairs of recipients to be cc'd. items: type: object properties: name: type: string email: type: string date: type: number description: 'The UNIX timestamp of the last modification of the draft. ' events: type: array description: 'An array of event objects, if the draft includes calendar invites.' items: type: object files: type: array description: 'An array of file objects, if the draft includes attachments.' items: type: object from: type: array uniqueItems: true minItems: 1 description: Array containing a single name+email pair to set as the from header. items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 id: type: string minLength: 1 description: A globally unique object identifier. labels: type: array uniqueItems: true minItems: 1 description: >- A list of label objects, present only if the parent account's organization_unit is label. These have Gmail-style semantics and can be arbitrarily added and removed from messages. items: type: object properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 object: type: string minLength: 1 description: A string describing the type of object. default: draft reply_to: type: array description: >- An array of name-email pairs to set an alternative Reply-To header in the final sent message. items: type: object reply_to_message_id: description: >- The ID of a message to which this draft is a reply, allowing the sending API to include threading-specific headers for other mail clients. type: string snippet: type: string minLength: 1 description: A shortened plain-text preview of the draft body. starred: type: boolean description: Starred or flagged state (mutable). subject: type: string minLength: 1 description: The subject line of the draft. thread_id: type: string minLength: 1 description: >- A reference to the parent thread object. If this is a new draft, the thread will be empty. to: type: array uniqueItems: true minItems: 1 description: An array of name-email pairs of recipients. items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 unread: type: boolean description: Indicates an unread state for the draft. version: type: number description: >- Incrementing value related to draft updates. You can use this to compare revisions or to invalidate your local cache. folder: type: object description: >- A single folder object indicating the location of the draft, present only if the parent account's organization_unit is folder. Customarily this is a folder where name is drafts, but not always. properties: display_name: type: string id: type: string name: type: string Draft-Create: title: Draft-Create type: object properties: subject: type: string description: The subject line of the draft. example: From Nylas to: type: array description: The name-email pairs of the recipients. items: type: object properties: email: type: string example: swag@nylas.com name: type: string example: Nylas required: - email cc: type: array description: The name-email pairs of the recipients to be cc’d. items: type: object properties: name: type: string email: type: string bcc: type: array description: The name-email pairs of the recipients to be bcc’d. items: type: object properties: name: type: string email: type: string from: type: array description: >- An array containing a single name and email pair, to set as the from header. items: type: object properties: name: type: string example: you@example.com email: type: string example: Your Name reply_to: type: array description: >- An array of name and email pairs, to set an alternative Reply-To header in the final sent message. Note that not all providers support setting this in a draft. items: type: object properties: name: type: string example: Nylas email: type: string example: swag@nylas.com reply_to_message_id: type: string description: The ID of the message that this draft is a reply to. body: type: string description: The full HTML draft body text. example: >- This email was sent using the Nylas email API. Visit https://nylas.com for details. file_ids: type: array description: >- An array of IDs for the files to attach, if the draft includes attachments. Note that creating a draft will fail, if these files have not yet been uploaded. items: type: string Draft-Update: title: Draft-Update type: object properties: subject: type: string description: The subject line of the draft. example: From Nylas to: type: array description: The name-email pairs of the recipients. items: type: object properties: email: type: string example: swag@nylas.com name: type: string example: Nylas cc: type: array description: The name-email pairs of the recipients to be cc’d. items: type: object properties: name: type: string email: type: string bcc: type: array description: The name-email pairs of the recipients to be bcc’d. items: type: object properties: name: type: string email: type: string from: type: array description: >- An array containing a single name and email pair, to set as the from header. items: type: object properties: name: type: string example: you@example.com email: type: string example: Your Name reply_to: type: array description: >- An array of name and email pairs, to set an alternative Reply-To header in the final sent message. Note that not all providers support setting this in a draft. items: type: object properties: name: type: string example: Nylas email: type: string example: swag@nylas.com reply_to_message_id: type: string description: The ID of the message that this draft is a reply to. body: type: string description: The full HTML draft body text. example: >- This email was sent using the Nylas email API. Visit https://nylas.com for details. file_ids: type: array description: >- An array of IDs for the files to attach, if the draft includes attachments. Note that creating a draft will fail, if these files have not yet been uploaded. items: type: string version: type: number description: Version of the draft that you are modifying File-Object: description: '' type: object properties: account_id: type: string minLength: 1 example: 43jf3n4es3*** content_type: type: string minLength: 1 example: image/jpeg filename: type: string minLength: 1 example: image.jpg id: type: string minLength: 1 example: 9etjh6talp*** object: type: string minLength: 1 example: file size: type: number example: 72379 Calendar: description: '' type: object title: '' properties: description: type: string description: Description of the Calendar example: Emailed events id: type: string minLength: 1 example: 67qmz3fuk9wf*** description: Globally unique object identifier name: type: string minLength: 1 example: Calendar description: Name of the Calendar account_id: type: string minLength: 1 example: bh1vu31mw9ap*** description: Reference to parent account object object: type: string minLength: 1 example: calendar description: A string describing the type of object. default: calendar read_only: type: boolean description: True if the Calendar is read only Calendar-Create: description: '' type: object properties: name: type: string minLength: 1 description: Name of the Calendar example: My New Calendar description: type: string minLength: 1 description: Description of the Calendar example: Description of my new calendar location: type: string minLength: 1 description: Geographic location of the calendar as free-form text example: Location description timezone: type: string minLength: 1 description: >- [IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York). example: America/Los_Angeles required: - name - description - location - timezone Calendar-Create-Update-Response: description: '' type: object properties: account_id: type: string minLength: 1 description: Reference to parent account object example: eof2wrhqkl7kdwhy9hylpv9o9 description: type: string minLength: 1 description: Description of the Calendar example: Description of my new calendar id: type: string minLength: 1 description: Globally unique object identifier example: 8e570s302fdazx9zqwiuk9jqn is_primary: type: boolean description: >- A boolean denoting whether this is the primary calendar associated with a account job_status_id: type: string minLength: 1 description: Job status ID for the calendar modification. example: 48pp6ijzrxpw9jors9ylnsxnf location: type: string minLength: 1 description: Geographic location of the calendar as free-form text example: Location description name: type: string minLength: 1 description: Name of the Calendar example: My New Calendar object: type: string minLength: 1 description: A string describing the type of object default: calendar example: calendar read_only: type: boolean description: True if the Calendar is read only timezone: type: string minLength: 1 description: >- [IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York). example: America/Los_Angeles Events: description: '' type: object x-examples: {} properties: account_id: type: string minLength: 1 description: A reference to the parent account object. example: aaz875kwuvxik6ku7pwkqp3ah busy: type: boolean description: >- On shared or public calendars, indicates whether to show this event's time block as available. (Also called transparency in some systems.) calendar_id: type: string minLength: 1 description: A reference to the parent calendar object. example: 947kpa7ih22bfkeujpkfqn5bf description: type: string description: >- The description of the event, which may contain more details or an agenda. maxLength: 8192 example: Coffee meeting minLength: 0 ical_uid: nullable: true type: string minLength: 1 description: >- Unique identifier as defined in [RFC5545](https://tools.ietf.org/html/rfc5545#section-3.8.4.7). It is used to uniquely identify events across calendaring systems. example: 5i2voruhvks4pbt5ktngk28bc9@google.com id: type: string minLength: 1 description: A globally unique object identifier. example: 4t0kwb4qb6xr0pfzzook70nd8 location: nullable: true type: string description: 'A location, such as a physical address or meeting room name.' message_id: {} object: type: string minLength: 1 description: 'A string describing the type of object ' default: event example: event owner: type: string minLength: 1 description: >- The owner of the event, usually specified with their email or name and email. example: participants: type: array uniqueItems: true minItems: 1 description: >- An array of other participants invited to the event. Keys are `email`, `name`, `status`. Participants may also be rooms or resources. items: type: object properties: comment: nullable: true type: string description: A comment by the participant. email: type: string minLength: 1 description: The participant's email address. example: email@email.com name: nullable: true type: string status: type: string minLength: 1 description: The participant's attendance status. default: noreply enum: - 'yes' - maybe - 'no' - noreply example: noreply read_only: type: boolean description: Indicates whether the event can be modified. title: type: string minLength: 1 description: The title of the event. maxLength: 1024 example: 'Remote Event: Group Yoga Class' when: description: >- One of four sub-objects corresponding to the time and duration of an event: time, timespan, date, or datespan. anyOf: - properties: object: type: string default: time example: time description: A string describing the type of object. **Read Only** time: type: integer example: 1408875644 description: A UNIX timestamp (UTC). - properties: timespan: type: string default: timespan example: timespan description: A string describing the type of object. **Read Only** start_time: type: string example: '1409594400' description: The start time of the event. UNIX timestamp end_time: type: string example: '1409598000' description: The end time of the event. UNIX timestamp - properties: object: type: string example: date description: 'A string describing the type of object. ' default: date date: type: string example: '1912-06-23' description: >- Date of occurance in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates) format. - properties: datespan: type: string description: A string describing the type of object default: datespan example: datespan start_date: type: string description: The start date in ISO 8601 format. example: '1815-12-10' end_date: type: string description: The end date in ISO 8601 format. example: '1852-11-27' type: object status: type: string description: 'One of the following values: confirmed, tentative, or cancelled.' enum: - confirmed - tentative - cancelled example: confirmed Event-Create-Update: description: '' type: object x-examples: {} properties: title: type: string minLength: 1 description: >- Creates an event with the specified title. This value is usually short. example: Birthday Party calendar_id: type: string minLength: 1 description: >- Creates an event in the specified calendar ID. See Calendar for more info. example: 947kpa7ih22bfkeujpkfqn5bu status: type: string minLength: 1 example: confirmed enum: - status - confirmed - cancelled busy: type: boolean description: >- Creates an event with the specified busy state. This value determines whether to show this event’s time block as available on shared or public calendars. This is also called transparency in some systems. read_only: type: boolean participants: type: array uniqueItems: true minItems: 1 description: 'Creates an event with the specified participants. ' items: type: object properties: name: type: string minLength: 1 example: Aristotle email: type: string minLength: 1 example: aristotle@nylas.com status: type: string enum: - 'yes' - 'no' - maybe - noreply description: >- While it's possible to set participant statuses during event creation, this status may not be reflected in the invitee's calendar because it can be blocked due to calendar permissions settings, and is not supported for invitees with Exchange accounts. In most cases, the default value of noreply is the best option. comment: type: string required: - email - status description: type: string minLength: 1 description: >- Creates an event with the specified description. This value may contain more details about an event or an agenda. example: Come ready to skate when: description: >- One of four sub-objects corresponding to the time and duration of an event: time, timespan, date, or datespan. oneOf: - properties: object: type: string default: time example: time description: A string describing the type of object. **Read Only** time: type: integer example: 1408875644 description: A UNIX timestamp (UTC). - properties: timespan: type: string default: timespan example: timespan description: A string describing the type of object. **Read Only** start_time: type: string example: '1409594400' description: The start time of the event. UNIX timestamp end_time: type: string example: '1409598000' description: The end time of the event. UNIX timestamp - properties: object: type: string example: date description: 'A string describing the type of object. ' default: date date: type: string example: '1912-06-23' description: >- Date of occurance in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates) format. - properties: datespan: type: string description: A string describing the type of object default: datespan example: datespan start_date: type: string description: The start date in ISO 8601 format. example: '1815-12-10' end_date: type: string description: The end date in ISO 8601 format. example: '1852-11-27' type: object location: type: string description: >- Creates an event with the specified location. For example a physical address or meeting room name. example: Roller Rink recurrence: type: object properties: rrule: type: array description: >- An array of RRULE and EXDATE strings. See [RFC-5545](https://tools.ietf.org/html/rfc5545#section-3.8.5) for more details. Please note that EXRULE and RDATE strings are not supported for POST or PUT requests at this time. [RRULe Tool](http://jakubroztocil.github.io/rrule/) is helpful in understanding the RRULE spec. items: type: string example: 'RRULE:FREQ=WEEKLY;BYDAY=MO' timezone: type: string description: >- [IANA time zone](https://en.wikipedia.org/wiki/Tz_database) database formatted string. example: America/New_York required: - calendar_id - when Room-Resources: description: '' type: object properties: object: type: string minLength: 1 example: room_resource default: room_resource description: A string describing the type of object email: type: string minLength: 1 example: training-room-1A@google.com description: The email address of the resource. name: type: string minLength: 1 example: Training Room 1A description: The name of the resource. capacity: type: string minLength: 1 example: '8' description: The capacity of the room set the organization admin. building: type: string minLength: 1 description: The building identifier set by the organization admin. floor_name: type: string nullable: true minLength: 1 example: '7' description: >- Microsoft uses two fields to identify floors, floor name, and floor label. We use floor label to populate this field. GSuite will return the floor name. floor_number: type: string description: >- Microsoft uses floor number to popular this field. GSuite will always return null. example: '7' Contact: description: '' type: object x-examples: {} properties: account_id: type: string minLength: 1 description: A reference to the parent account object. example: x2x2x2x2x2x2x2x2x2x2x2 birthday: type: string minLength: 1 description: The birthday of contact in the format `YYYY-MM-DD`. example: '1960-12-31' company_name: type: string minLength: 1 description: The name of the company example: Nylas emails: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 description: The email address. This is a free-form string. example: john@doe.com type: type: string minLength: 1 description: The type of the email address. enum: - work - personal example: work given_name: type: string minLength: 1 description: The given name of the contact. example: John id: type: string minLength: 1 description: A globally unique object identifier. example: z3z3z3z3z3z3z3z3z3z3z3 im_addresses: type: array uniqueItems: true minItems: 1 items: type: object properties: type: type: string minLength: 1 description: The type of the IM address. enum: - gtalk - aim - yahoo - lync - skype - qq - msn - icc - jabber example: aim im_address: type: string minLength: 1 description: The IM address. This is a free-form string. example: myaimaddress job_title: type: string minLength: 1 description: The job title of the contact. example: Software Engineer manager_name: type: string minLength: 1 description: The name of the manager for the contact. example: Bill the manager middle_name: type: string minLength: 1 description: The middle name of the contact. example: Jacob nickname: type: string minLength: 1 description: The nickname of the contact. example: JD notes: type: string minLength: 1 description: Notes about the contact. This field has limited support. example: Loves ramen object: type: string minLength: 1 description: 'A string describing the type of object ' default: contact example: contact office_location: type: string minLength: 1 description: >- The location of the office for the contact. This is a free-form field. example: 123 Main Street phone_numbers: type: array uniqueItems: true minItems: 1 items: type: object properties: number: type: string minLength: 1 example: 1 800 123 4567 type: type: string minLength: 1 description: The type of phone number. enum: - business - home - mobile - page - business_fax - home_fax - organization_main - assistant - radio - other example: business physical_addresses: type: array items: type: object properties: format: type: string description: >- The format of the address. The value can be structured or unstructured. Currently only structured addresses are supported in PUT or POST calls to /contacts. type: type: string description: 'The type of the address. The value can be work, home or other.' enum: - work - home - other street_address: type: string description: >- The street address, which includes a house number and street name. city: type: string description: The city of the address. postal_code: type: string description: The postal code of the address. state: type: string description: >- The state of the address. This can be a full name or the state abbreviation. country: type: string description: >- The country of the address. This can be a full name or the country abbreviation. picture_url: type: string minLength: 1 description: >- The URL of endpoint for the contact's picture. See /contacts/{id}/picture for more. example: 'https://api.nylas.com/contacts/427abc427abc427abc/picture' suffix: type: string minLength: 1 description: 'The suffix of the contact. (e.g. Jr., Sr., III).' surname: type: string minLength: 1 description: The surname of the contact. web_pages: type: array items: type: object properties: type: type: string description: >- Type of Web Page. The default values are profile, blog, homepage or work. You can add in a custom type when creating a type and Nylas will read custom types from incoming contact data. enum: - profile - blog - homepage - work url: type: string description: The web page url. This is a free-form string. groups: type: array uniqueItems: true minItems: 1 items: type: object properties: id: type: string minLength: 1 description: A globally unique object identifier. object: type: string minLength: 1 description: A string describing the type of object. default: contact_group account_id: type: string minLength: 1 description: A reference to the parent account object. name: type: string minLength: 1 description: The name of the Contact Group. path: type: string minLength: 1 description: >- A fully qualified path of the Contact Group, if nesting is permitted by the account's provider. CreateAContact: description: '' type: object x-examples: {} properties: birthday: type: string minLength: 1 description: The birthday of contact in the format `YYYY-MM-DD`. example: '1960-12-31' company_name: type: string minLength: 1 description: The name of the company example: Nylas emails: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 description: The email address. This is a free-form string. example: john@doe.com type: type: string minLength: 1 description: The type of the email address. enum: - work - personal example: work given_name: type: string minLength: 1 description: The given name of the contact. example: John im_addresses: type: array uniqueItems: true minItems: 1 items: type: object properties: type: type: string minLength: 1 description: The type of the IM address. enum: - gtalk - aim - yahoo - lync - skype - qq - msn - icc - jabber example: aim im_address: type: string minLength: 1 description: The IM address. This is a free-form string. example: myaimaddress job_title: type: string minLength: 1 description: The job title of the contact. example: Software Engineer manager_name: type: string minLength: 1 description: The name of the manager for the contact. example: Bill the manager middle_name: type: string minLength: 1 description: The middle name of the contact. example: Jacob nickname: type: string minLength: 1 description: The nickname of the contact. example: JD notes: type: string minLength: 1 description: Notes about the contact. This field has limited support. example: Loves ramen office_location: type: string minLength: 1 description: >- The location of the office for the contact. This is a free-form field. example: 123 Main Street phone_numbers: type: array uniqueItems: true minItems: 1 items: type: object properties: number: type: string minLength: 1 example: 1 800 123 4567 type: type: string minLength: 1 description: The type of phone number. enum: - business - home - mobile - page - business_fax - home_fax - organization_main - assistant - radio - other example: business physical_addresses: type: array items: type: object properties: format: type: string description: >- The format of the address. The value can be structured or unstructured. Currently only structured addresses are supported in PUT or POST calls to /contacts. type: type: string description: 'The type of the address. The value can be work, home or other.' enum: - work - home - other street_address: type: string description: >- The street address, which includes a house number and street name. city: type: string description: The city of the address. postal_code: type: string description: The postal code of the address. state: type: string description: >- The state of the address. This can be a full name or the state abbreviation. country: type: string description: >- The country of the address. This can be a full name or the country abbreviation. suffix: type: string minLength: 1 description: 'The suffix of the contact. (e.g. Jr., Sr., III).' surname: type: string minLength: 1 description: The surname of the contact. web_pages: type: array items: type: object properties: type: type: string description: >- Type of Web Page. The default values are profile, blog, homepage or work. You can add in a custom type when creating a type and Nylas will read custom types from incoming contact data. enum: - profile - blog - homepage - work url: type: string description: The web page url. This is a free-form string. group: type: string description: Creates a new contact associated to the specified contact group id. Search-Messages: type: array description: '' minItems: 1 uniqueItems: true title: Search Messages x-examples: {} items: type: object properties: account_id: type: string minLength: 1 example: 43jf3n4es3*** bcc: type: array items: type: object body: type: string minLength: 1 example: 'Hello, how are you?' cc: type: array items: type: object date: type: number example: 1559770299 events: type: array items: type: object files: type: array items: type: object folder: type: object properties: display_name: type: string minLength: 1 example: Draft id: type: string minLength: 1 example: eeangfw9vm5*** name: type: string minLength: 1 example: drafts from: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 example: swag@nylas.com name: type: string minLength: 1 example: Nylas Swag id: type: string minLength: 1 example: 27hvuc1w2v85*** object: type: string minLength: 1 example: draft reply_to: type: array items: type: object reply_to_message_id: {} snippet: type: string minLength: 1 starred: type: boolean subject: type: string minLength: 1 thread_id: type: string minLength: 1 to: type: array uniqueItems: true minItems: 1 items: type: object properties: email: type: string minLength: 1 name: type: string minLength: 1 required: - email - name unread: type: boolean version: type: number required: - snippet - starred - subject - thread_id - to - unread - version Search-Threads: type: array description: '' minItems: 1 uniqueItems: true items: type: object properties: account_id: type: string minLength: 1 draft_ids: type: array items: type: string first_message_timestamp: type: number folders: type: array uniqueItems: true minItems: 1 items: type: object properties: display_name: type: string minLength: 1 id: type: string minLength: 1 name: type: string minLength: 1 has_attachments: type: boolean id: type: string minLength: 1 last_message_received_timestamp: {} last_message_sent_timestamp: {} last_message_timestamp: type: number message_ids: type: array items: type: object object: type: string minLength: 1 participants: type: array items: type: object snippet: type: string starred: type: boolean subject: type: string minLength: 1 unread: type: boolean version: type: number Webhooks-Object: description: '' type: object title: '' properties: application_id: type: string minLength: 1 description: A reference to the parent application object. example: 8eejdhpc5dv04w6ea8lzlxtkt callback_url: type: string minLength: 1 description: The URL where notifications are posted. example: 'https://97a5db5e7c59.ngrok.io/webhook' id: type: string minLength: 1 description: A globally unique object identifier. example: 7b5y8f25p344jy8yem6v5jir state: type: string minLength: 1 description: The state of the webhook. enum: - active - inactive - failing - failed example: active triggers: type: array description: >- An array containing a set of triggers, describing the notifications this webhook should receive. items: type: string example: message.created version: type: string minLength: 1 example: '2.0' description: A string describing the the webhook version. Job-Status: description: '' type: object properties: account_id: type: string minLength: 1 description: Reference to parent account object. example: eof2wrhqkl7kdwhy9hylpv9o9 action: type: string minLength: 1 description: Action performed on a given object enum: - create_calendar - update_calendar - delete_calendar - create_contact - update_contact - delete_contact - create_folder - update_folder - delete_folder - create_label - update_label - create_event - update_event - delete_event - update_message example: update_message created_at: type: number description: >- Timestamp indicating when the job status was created. UNIX timestamp example: 1592374298 id: type: string minLength: 1 description: A globally unique object identifier. example: 8e570s302fdazx9zqwiuk9jqn job_status_id: type: string minLength: 1 description: Globally unique id representing the job. example: 48pp6ijzrxpw9jors9ylnsxnf object: type: string minLength: 1 description: A string describing the type of object this job status refers to. enum: - message - calendar - folder - event - contact - label example: message status: type: string minLength: 1 description: >- A string indicating the job status. Can be successful, pending, or failed. enum: - pending - failed - successful example: successful securitySchemes: BASIC_AUTH: scheme: basic type: http ACCESS_TOKEN: scheme: bearer type: http responses: {} parameters: {} tags: - name: Folders description: >- Folders behave like normal IMAP or filesystem folders. A Message can only exist within one folder at a time, but a Thread with many messages may span several folders. Folders are only supported on accounts for which `organization_unit` is folder. You can check if an account supports labels by looking at the organization_unit property on the Account object. ## Nested Folders IMAP has very limited support for nested folders. It encodes a folder's path in its name. For example, the folder Accounting/Taxes will actually be named Accounting.Taxes or even INBOX.Accounting.Taxes depending on your IMAP server. To complicate things, different IMAP servers use different path separators. For example, Taxes.Accounting on server A may be Taxes\Accounting on server B. The Nylas API handles nested IMAP folders transparently. Creating a Taxes/Invoices folder using the API will create a folder with the right path separators. e.g: Depending on your server: INBOX.Taxes.Invoices or Taxes/Invoices. ## The Folders Object | Attribute | Type | Description | |----|---|----| | `id` | string | Globally unique object identifier. | | `object` | string | A string describing the type of object (value is "folder"). | `account_id` | string | Reference to parent account object. | | `name` | string | Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154).
Can be one of the following:
  • inbox
  • all
  • trash
  • archive
  • drafts
  • sent
  • spam
  • important
  • null (regular user-created folder)
| `display_name`| string | Localized name of folder, matching what is presented in their other mail apps. If you are displaying folders, use this instead of `name`. | - name: Hosted Authentication description: |- Nylas Hosted Authentication is the quickest way to setup authentication. Nylas handles directing your users to the login screen of their provider. Since Nylas handles the authentication, your users will see Nylas as part of the authentication process. To whitelabel authentication, we recommend using [Native Authentication](# link). Read our documentation on [Hosted Authentication](# link). - name: Native Authentication description: >- Native authentication is for developers who want to completely whitelabel the login experience through Nylas to match their application. If you are looking for the quickest way to setup authentication, review the [Hosted Authentication](# link) documentation. Read the [Native Authentication](# link) documentation. - name: Accounts description: |- An account corresponds to an email address, mailbox, and optionally a calendar. When connecting to the Nylas API, a specific access token gives you access to a specific account’s data. ## The Accounts Object | attribute | type | description | |----:|----|:----| | `id` | string | A globally unique object identifier. | | `object` | string | A string describing the type of object (value is `"account"`).| | `account_id` | string | A reference to the parent account object (self-referential in this case). | | `name` | string | The full name of the user, used as the default `"from"` name when sending mail. | | `email_address` | string | The canonical email address of the account. For Gmail accounts, this removes periods and plus suffixes. | | `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. | | `organization_unit` | string | Specify either `"label"` or `"folder"`, depending on the provider capabilities. | | `sync_state` | string | The syncing status of the account. See the [Sync status](ref:account-sync-status) documentation for possible values. | | `linked_at` | int32 | A Unix timestamp indicating when this account was originally connected to Nylas. - name: Threads description: >- Threads are first-class objects allowing you to build beautiful mail applications that behave the way users have come to expect. You can perform actions like archiving or deleting can be performed on threads or individual messages. Nylas threads messages together differently depending on the provider. On Gmail and Microsoft Exchange accounts, messages are threaded together as close as possible to the representation in those environments. For all other providers, messages are threaded using a custom[ JWZ-inspired algorithm](https://github.com/nylas/sync-engine/blob/master/inbox/util/threading.py#L11). To load all [messages](# link) for a given thread, you should instead use the messages endpoint with a `thread_id` filter parameter. ## The Thread Object |Attribute|Type|Description| |--- |--- |--- | |id|string|Globally unique object identifier| |object|string|A string describing the type of object (value is "thread")| |account_id|string|Reference to parent account object| |subject|string|Subject of the first message in the thread| |unread|boolean|Indicates whether the thread contains unread messages (mutable)| |starred|boolean|Indicates one or more messages are starred, aka flagged (mutable)| |last_message_timestamp|unix timestamp|Timestamp of the most recent message| |last_message_received_timestamp|unix timestamp|Timestamp of the most recently received message.(Excludes messages sent by the account.)| |last_message_sent_timestamp|unix timestamp|Timestamp of the most recently sent message in the thread| |first_message_timestamp|unix timestamp|Timestamp when the thread began| |participants|array|List of participant objects computed from all messages in the thread.| |snippet|string|A shortened plain-text preview of the most recent message in the thread| |message_ids|array|Array of IDs for messages within the thread, sorted by their timestamps| |draft_ids|array|Array of IDs for unsent drafts in the thread. May be null or absent| |version|integer|Incrementing value related to thread updates.You can use this to compare revisions, or invalidate your local cache.| |folders|array|The folder location(s) of a thread, present only if the parent account's organization_unit is folder. Note that threads can span folders, depending on the location of the thread's messages. See the folders docs for more info.| |labels|array|A list of label objects, present only if the parent account's organization_unit is label. These have Gmail-style semantics and can be arbitrarily added and removed from threads.| |has_attachments|boolean|Indicates if the thread has files attached to it.| - name: Application Management description: View and manage your Nylas applications. - name: Messages description: |- Messages are the fundamental object of the Nylas platform and the core building block for most email applications. They contain several pieces of information, such as when a message was sent, the sender's address, whom it was sent, and the message body. They can also contain file attachments, calendar event invitations, and more. ## Message Response The Nylas APIs expose a parsed and sanitized version of the original RFC-2822 email object, combined with the state from the mail server, such as unread status and folder location. This results in a simple and universal object type, that makes building applications a breeze. We still provide access to the RFC-2822 raw message object by passing in `Accept: message/rfc822` as the header. > Message Response Security > > Although message bodies are represented in HTML, they are generally not safe to directly inject into a web app. This could result in global styles being applied to your app, or the execution of arbitrary JavaScript. ## Message Views Messages support the use of [views](# link) by including the view query parameter in your request. The expanded message view exposes several additional RFC2822 headers, useful for implementing custom threading or cross-mailbox identification. Pass the `view=expanded` query parameter when making requests to messages. **Message View Example** ```json { "headers": { "In-Reply-To": "", "Message-Id": "<84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com>", "References": [""], } } ``` | Header | Requirement | Description | | ----------|-------|-------| | `Message-Id` | optional | Generated by clients while sending messages. It is different from a message's ID returned by the Nylas API (the message object's `id`). Unlike the `id`, the `Message-Id` header is *not* guaranteed to be unique since it is generated by clients. This field may be null. | | `In-Reply-To` | optional | The parent `Message-Id` to which this message replied. Expected `null` for messages that are not replies. | | `References` | optional | A list of `Message-Id`s related to a given message. Expected empty for messages which are not replies or related to existing messages. | > Message View Object > > These values are unrelated to Nylas object IDs. Since they are provided by clients without validation, there is no guarantee for their accuracy, uniqueness, or consistency. ## The Message Object | Attribute | Type | Description | |----:|---|:----| | `id` | string | A globally unique object identifier. | | `object` | string | A string describing the type of object (value is "message").| | `account_id` | string | Reference to a parent account object. | | `thread_id` | string | Reference to a parent thread object (all messages have a thread). | | `subject` | string | The subject line of the message. | | `from` | array | A list of name+email pairs the message was sent from. This is usually one object, but can be many. | | `to` | array | An array of name+email pairs the message was sent to. | | `cc` | array | An array of name+email pairs the message was cc'd to. | | `bcc` | array | An array of name+email pairs the message was bcc'd to. For received mail this is nearly always empty (for obvious reasons). | | `reply_to` | array | An array of name+email pairs replies should be sent to. | | `date` | unix timestamp | A timestamp of the date the message was received by the mail server. **Note:** This may be different from the unverified `Date` header in raw message object. | `unread` | boolean | Indicates the message is unread. This is the default for new incoming mail (mutable). | | `starred` | boolean | Indicates the message is in a starred or flagged state (mutable). | | `snippet` | string | A shortened plain-text preview of the message body. | `body` | string | The full HTML message body. Messages with only plain-text representations are up-converted to HTML. | `files` | array | An array of [File](ref:files) objects, if the message includes attachments. | `events` | array | An array [Event](ref:events) objects, if message includes calendar invites. | `folder` | folder object | A single folder object indicating the location of the message. This is present only if the parent account's `organization_unit` is `folder`. This property can be changed to move the message to a different folder. | `labels` | array | A list of [Label](ref:labels) objects. This is present only if the parent account's `organization_unit` is `label`. These have Gmail-style semantics and can be arbitrarily added and removed from messages. | - name: Labels description: >- Labels are equivalent to Gmail labels. Messages can have more than one label, which is popular for users who set up mail filters. Labels are only supported on accounts for which `organization_unit` is label. You can check if an account supports labels by the `organization_unit` property on the Account object. ## The Labels Object | Attribute | Type | Description | |----:|---|:----| | `id` | string | Globally unique object identifier | | `object` | string | A string describing the type of object (value is "label")| | `account_id` | string | Reference to parent account object | | `name` | string | Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154).
Can be one of the following:
  • inbox
  • all
  • trash
  • archive
  • drafts
  • sent
  • spam
  • important
  • null (regular user-created label)
| `display_name` | string | Localized name of label, matching what is presented in their other mail apps. If you are displaying labels, use this instead of `name`. | - name: Room Resources description: |- With the `/resources` endpoint, you can see which rooms a user can book within their GSuite or Office365 organization. To book an event in a room, including the room resource as a participant when creating the event with the `/events` endpoint. > Availability > > Room resources are not available for accounts that are authenticated via the Nylas dashboard. This feature is only available for accounts that authenticate via hosted or native auth. # Authentication Depending on if you are using GSuite or Microsoft Office 365 you'll need to enable certain permissions. ## Microsoft For Microsoft Office 365 you need to enable `Place.Read.All` as an admin to use Room Resources. See [Admin Approval](doc:admin-approval) for more. You also need to enable the `room_resources.read_only` scope. See the [authentication scopes](# link) guide for more info. ## GSuite You need to enable the `room_resources.read_only` scope. See the [authentication scopes](# link) guide for more info. ## The Room Resources Object | Attribute | Type | Description | |:----|:----|----| | `object` | string | A string describing the type of object (value is "room_resource") | `email` | string | The email address of the resource. | | `name` | string | The name of the resource. | | `capacity` | string | The capacity of the room set the organization admin.| | `building` | string | The building identifier set by the organization admin. | | `floor_name` | string | Microsoft uses two fields to identify floors, floor name, and floor label. We use floor label to populate this field. GSuite will return the floor name. | |` floor_number` | string |Microsoft uses floor number to popular this field. GSuite will always return null. | x-last-modified: 1605187354763 - name: Files description: |- The files endpoint manages data attached to messages. It allows you to download existing attachments from messages and threads, as well as upload new files to be sent. > Including File Attachments > > Before creating or modifying a draft to include an attachment, you must upload it using the files API and use the returned file ID. Actual attached files can be up to 25 MB, so this API has separate endpoints for requesting file [Metadata](# link) and [Downloading](# link) the actual file. Files can be downloaded by appending `/download` to the file metadata URI. If available, the response will include the filename in the `Content-Disposition` header. The [Upload](# link) endpoint is used to transfer files to Nylas, which must be done before adding them to a draft message. Data should be sent as multipart-form data with a single field named file. ## Content Types View a full list of content-types that correspond to file extensions. > Temporary File Store > > Please note that we only store files uploaded to the Nylas API, and those parsed from messages, for 7 days. After the file is removed from our cache, we will attempt to re-fetch it from the original mail provider if applicable ## The File Object | Attribute | Type | Description | |----:|:----| | `id` | string | Globally unique object identifier | | `object` | string | A string describing the type of object (value is "file")| | `account_id` | string | Reference to parent account object | | `filename` | string | Name of the file, if available | `size` | integer | Size of the file, in bytes | `content_type` | string | Content-Type of the file, sometimes also called [Internet media type](https://en.wikipedia.org/wiki/Internet_media_type) or MIME type. | `message_ids` | array | Array of identifiers for messages that contain this attachment. (Not guaranteed to be a complete set) | `content_id` | string | The Content-Id of the file. Sometimes this value will be empty. Using this value, your app can locate the associated [`cid` URL](https://tools.ietf.org/html/rfc2111) in the message body and embed the resource inline.| - name: Account Management description: |- These endpoints allow for account management outside the developer console interface. You can list, cancel, reactivate, and delete accounts associated with your application. ## Authentication for Account Management This endpoint uses the management API domain with different authentication from the rest of the Nylas API. * The account management API is prepended with /a, as opposed to the single account API, which does not have /a in its endpoint. * The account management API can send a request for all accounts with only the client ID and secret passed to it (unlike the account API, which requires an account access token). - name: Sending description: |- The Nylas platform provides two ways to send messages: * Sending an existing [draft](# link) * Sending a message [directly](# link) Both systems send mail through the account's original SMTP/ActiveSync gateway, just as if they were sent using any other app. This means messages sent through Nylas have very high deliverability, but may also be subject to backend provider rate-limiting and abuse detection. - name: Contacts description: >- The Nylas APIs provide access to the user's contacts, making it easy to add contact autocomplete, address book integration, and more to your application. > API Version 2.0 Only > > Our contacts support received a major upgrade in v2.0 of the API. This section pertains to the functionality in the v2.0 and beyond of the API. If you have not upgraded your API version yet, check out the [API Versioning ](# link)section. ## The Contact Object |Attribute|Type|Description| |--- |--- |--- | |id|string|A globally unique object identifier.| |object|string|A string describing the type of object (e.g "contact").| |account_id|string|A reference to the parent account object.| |given_name|string|The given name of the contact.| |middle_name|string|The middle name of the contact.| |surname|string|The surname of the contact.| |suffix|string|The suffix of the contact. (e.g. Jr., Sr., III).| |nickname|string|The nickname of the contact.| |birthday|string|The birthday of contact in the format YYYY-MM-DD.| |company_name|string|The name of the company, for which the contact works.| |job_title|string|The job title of the contact.| |manager_name|string|The name of the manager for the contact.| |office_location|string|The location of the office for the contact. This is a free-form field.| |notes|string|Notes about the contact. This field has limited support.| |picture_url|string|The URL of endpoint for the contact's picture. See GET `/contacts/picture` for more information.| |emails|List [Email](#link)|A list of email address objects. See Email for more information.| |im_addresses|List [IMAddress](# link)|A list of Instant Messaging (IM)Address objects. See IM Address for more information.| |physical_addresses|List [PhysicalAddress](# link)|A list of physical address objects. See Physical Address for more information.| |phone_numbers|List [PhoneNumber](# link)|A list of phone number objects.See Phone Number for more information.| |web_pages|List[WebPage](# link)|A list of web page objects. See Web Page for more information.| |groups|List[ContactGroup](# link)|A list of Contact Groups, to which the contact belongs. See Contact Group for more information.| |source|string|The source of the contact will be:
  • address_book-Denotes a user-created contact
  • inbox -Denotes a contact parsedfrom an email
| ### Email |Attribute|Type|Description| |--- |--- |--- | |type|string|The type of the email address. The value can be work or personal.| |email|string|The email address. This is a free-form string.| ### Instant Messenger (IM) Address |Attribute|Type|Description| |--- |--- |--- | |type|string|The type of the IM address. The value can be gtalk, aim, yahoo, lync, skype, qq, msn, icc, or jabber.| |im_address|string|The IM address. This is a free-form string.| ### Physical Address |Attribute|Type|Description| |--- |--- |--- | |format|string|The format of the address. The value can be structured or unstructured. Currently only structured addresses are supported in PUT or POST calls to /contacts.| |type|string|The type of the address. The value can be work, home or other.| |street_address|string|The street address, which includes a house number and street name.| |city|string|The city of the address.| |postal_code|string|The postal code of the address.| |state|string|The state of the address. This can be a full name or the state abbreviation.| |country|string|The country of the address. This can be a full name or the country abbreviation.| ### Phone Number |Attribute|Type|Description| |--- |--- |--- | |type|string|The type of phone number. The value can be business, home, mobile, pager, business_fax, home_fax, organization_main, assistant, radio or other.| |number|string|The phone number. This is a free-form string.| ### Web Page |Attribute|Type|Description| |--- |--- |--- | |type|string|Type of Web Page. The default values are profile, blog, homepage or work.You can add in a custom type when creating a type and Nylas will read custom types from incoming contact data.| |url|string|The web page url. This is a free-form string.| ### Contact Group |Attribute|Type|Description| |--- |--- |--- | |id|string|A globally unique object identifier.| |object|string|A string describing the type of object. The value is contact_group.| |account_id|string|A reference to the parent account object.| |name|string|The name of the Contact Group.| |path|string|A fully qualified path of the Contact Group, if nesting is permitted by the account's provider.| - name: Search description: >- The search endpoint is used to run a full-text search that is proxied to the account's provider. Results are matched with objects that have been synced, and then returned. Like other API endpoints, the search endpoint returns up to 100 results by default. This endpoint supports [Pagination](# link) so your application can request more objects, or iterate through all results. ## Query Syntax For details on the query syntax for the most commmon providers: * [Google](https://support.google.com/mail/answer/7190?hl=en) * [Exchange/Outlook](https://support.office.com/en-us/article/Learn-to-narrow-your-search-criteria-for-better-searches-in-Outlook-d824d1e9-a255-4c8a-8553-276fb895a8da) * [Yahoo](https://help.yahoo.com/kb/SLN4701.html) * [Generic IMAP](https://tools.ietf.org/html/rfc3501#section-6.4.4). > Message Reconciliation and Pagination > > Because the results are first returned and then matched with synced data, it's possible for fewer results to be returned than the page size, even if more results exist on the provider. - name: Calendar description: |- Each account connected to Nylas can have zero or more calendars, and each calendar has a collection of individual events. The calendar object is very simple, and mostly serves as a container for events. The `read_only` flag on a calendar indicates whether or not you can modify its properties or make changes to its events. **Related Documentation** * [Calendar API](# link) * [Virtual Calendar](# link) ## The Calendar Object |Attribute|Type|Description| |--- |--- |--- | |id|string|Globally unique object identifier| |object|string|A string describing the type of object (value is "file")| |account_id|string|Reference to parent account object| |name|string|Name of the Calendar| |description|string|Description of the Calendar| |read_only|boolean|True if the Calendar is read only| - name: Events description: >- Events are objects within a calendar, generally supporting all features of modern scheduling apps. Using the calendar APIs, your application can schedule events, send meeting invitations, RSVP, and more. **Related Documentation** * [Calendar APIs](# link) * [Virtual Calendars](# link) ## The Events Object |Attribute|Type|Description| |--- |--- |--- | |id|string|A globally unique object identifier.| |object|string|A string describing the type of object (value is "event").| |account_id|string|A reference to the parent account object.| |calendar_id|string|A reference to the parent calendar object.| |title|string|The title of the event, usually short (maximum string length of 1024 characters).| |description|string|The description of the event, which may contain more details or an agenda (maximum string length of 8192 characters).| |ical_uid|string|Unique identifier as defined in RFC5545. It is used to uniquely identify events across calendaring systems. Can be null.| |when|subobject|One of four sub-objects corresponding to the time and duration of an event: time, timespan, date, or datespan. | |location|string|A location, such as a physical address or meeting room name.| |owner|string|The owner of the event, usually specified with their email or name and email.| |participants|array|An array of other participants invited to the event. Keys are email, name, status. Participants may also be rooms or resources.| |status|string|One of the following values: confirmed, tentative, or cancelled.| |read_only|boolean|Indicates whether the event can be modified.| |busy|boolean|On shared or public calendars, indicates whether to show this event's time block as available. (Also called transparency in some systems.)| |recurrence|subobject|Included if the event is a master recurring event.| |master_event_id|string|Only included in exceptions (overrides) to recurring events, the ID of the recurring event.| |original_start_time|unix timestamp|Only included in exceptions (overrides) to recurring events, the start time of the recurring event.| - name: Webhooks description: >- Webhooks allow your application to receive notifications when certain events occur. For example, when a new email is received, Nylas will make a POST request to your URI endpoint, letting you know information about the new message. Webhooks are the recommended way to get notified of changes to the accounts you sync, because they are easier to integrate with your app and scale seamlessly with your growth. **Related Documentation** * [Webhooks](# link) * [Message Tracking](# link) * [Available Webhooks](# link) ## The Webhooks Object |Attribute|Type|Description| |--- |--- |--- | |id|string|A globally unique object identifier.| |application_id|string|A reference to the parent application object.| |callback_url|string|The URL where notifications are posted.| |state|string|The state of the webhook.| |triggers|array|An array containing a set of triggers, describing the notifications this webhook should receive. | |version|string|A string describing the the webhook version.| - name: Deltas description: >- Deltas let you steam changes about email accounts to build email applications that process new data quickly without fetching an index of the user's mailbox or performing a large number of API calls. **Related Documentation** * [Deltas](# link) > Webhooks and Deltas > > For most of our customers, Webhooks are the best option to stay up to date with all email, contact and calendar changes. If you're interested in using deltas, please [reach out to us](https://support.nylas.com/hc/en-us/requests/new) before starting your integration. ## The Delta Object |Attribute|Type|Description| |--- |--- |--- | |cursor|string|The cursor value for this delta.| |object|string|The object type of the changed object. (message, thread, etc.)| |id|string|The id of the changed object| |event|string|The type of change. Either create, modify, or delete.| |attributes||The current state of the object. Note this may be different from the state when the delta change actually happened.| - name: Job Statuses description: >- Job Statuses allow you to track whether a modification through the Nylas API has synced back to the account's provider. For example, if you make an API request to create a new Calendar for a Google account using POST /calendars, Nylas will immediately return the new Calendar ID before it is synced with Google. You can use the job status to check whether the `create_calendar` action has synced to Google. ## The Job Status Object |Attribute|Type|Description| |--- |--- |--- | |account_id|string|Reference to parent account object| |action|string|Action performed on a given object| |created_at|unix timestamp|Timestamp indicating when the job status was created.| |job_status_id|string|Globally unique id representing the job| |id|string|A globally unique object identifier.| |object|string|A string describing the type of object this job status refers to.| |status|string|A string indicating the job status. Can be successful, pending, or failed| - name: Drafts description: >- A draft is a special kind of message which has not been sent, and therefore its body contents and recipients are still mutable. The drafts endpoints let you read and modify existing drafts, create new drafts, send drafts, and delete drafts. ## The Draft Object |Attribute|Type|Description| |--- |--- |--- | |id|string|A globally unique object identifier.| |object|string|A string describing the type of object (value is "draft").| |account_id|string|A reference to the parent account object,| |thread_id|string|A reference to the parent thread object. If this is a new draft, the thread will be empty.| |subject|string|The subject line of the draft.| |reply_to_message_id|string|The ID of a message to which this draft is a reply, allowing the sending API to include threading-specific headers for other mail clients.| |from|array|Array containing a single name+email pair to set as the "from" header. (See Aliases.)| |reply_to|array|An array of name-email pairs to set an alternative Reply-To header in the final sent message.| |to|array|An array of name-email pairs of recipients.| |cc|array|An array of name-email pairs of recipients to be cc'd.| |bcc|array|An array of name-email pairs of recipients to be bcc'd.| |date|unix timestamp|The timestamp of the last modification of the draft.| |unread|boolean|Indicates an unread state for the draft.| |starred|boolean|Starred or flagged state (mutable).| |snippet|string|A shortened plain-text preview of the draft body.| |body|string|The full HTML draft body text.| |files|array|An array of file objects, if the draft includes attachments.| |events|array|An array of event objects, if the draft includes calendar invites.| |folder|folder object|A single folder object indicating the location of the draft, present only if the parent account's organization_unit is folder. Customarily this is a folder where name is drafts, but not always.| |labels|array|A list of label objects, present only if the parent account's organization_unit is "label". These have Gmail-style semantics and can be arbitrarily added and removed from messages.| |version|integer|Incrementing value related to draft updates.You can use this to compare revisions or to invalidate your local cache.| security: []