Nylas Docs

The Nylas Developer Hub

Welcome to the Nylas developer hub. You'll find comprehensive guides and documentation to help you start working with Nylas as quickly as possible, as well as support if you get stuck. Let's jump right in!

Developer Guide
<script id="readme-data-docs" type="application/json" data-json="[{"_id":"5e41e73d960b09003ca359ee","excerpt":"","link_external":false,"link_url":"","slug":"introduction","project":"59245c10200df13100c88563","__v":12,"body":"The Nylas Platform provides a modern API that works with existing email providers. Nylas makes it simple and fast to integrate your app with a user's email, contacts, or calendar data, and eliminates the complexity of working with old protocols like IMAP and MIME.\n\nThe API is designed around the [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer) ideology, providing simple and predictable URIs to access and modify objects. Requests support [standard HTTP methods](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) like GET, PUT, POST, and DELETE and [standard status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). Response bodies are always UTF-8 encoded JSON objects, unless explicitly documented otherwise.\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Hey there 👋\",\n \"body\": \"New here? Our [Getting Started](doc:getting-started) guide is a great place to begin. If you're looking for our API reference you're in the right place!\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"v2.1 of the API\",\n \"body\": \"These docs pertain to version 2.1 of the API. Check out the [API versioning](ref:api-versioning) section to learn more about how to switch between versions. You can find docs for version 1.0 [here](https://dash.readme.io/project/nylas/v1.0/dashboard).\"\n}\n[/block]\n\n[block:html]\n{\n \"html\": \"<di id=\\\"mobile-callout\\\">\\n <b>Please Note:</b> Most content in these docs is easily available on mobile devices, but we recommend using desktop view for the complete experience.\\n</div>\\n<style>\\n@media (min-width: 1000px){\\n#mobile-callout{\\n display:none;\\n}\\n}\\n</style>\"\n}\n[/block]","category":"5e41e73d960b09003ca3597e","createdAt":"2017-05-25T21:34:16.716Z","isReference":true,"next":{"pages":[],"description":""},"sync_unique":"","version":"5e41e73d960b09003ca35a9b","order":0,"updates":["5af03e4f746b3500038ebff2","5af03e5047537800035e59a1","5b5a54e97f39c90003a979e1","5cc207b54f92000024135f63","5cdec1bd366ac5003922e351","5d00b428a12048005da9f6c4","5d00b464a6c0ea00630708da","5e4ede16f70a6f00576dfdfc","5e4ee8c3cd15a2003bd7daf3","5e4f6149cb82fd004d497d5b","5ef38bf066bfa1005e0105f9","5fa49ad3eaca990012fa51af"],"api":{"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"language":"json","code":"{}","name":"","status":400}]},"auth":"required","params":[],"url":"","method":"get"},"githubsync":"","hidden":false,"title":"The Nylas APIs","type":"basic","user":"59245bff200df13100c88562","parentDoc":null,"updatedAt":"2020-02-10T23:33:40.953Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-11-05T23:40:51.182Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca35997","api":{"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"category":"5e41e73d960b09003ca3596c","createdAt":"2017-05-23T20:20:07.342Z","hidden":false,"link_url":"","next":{"pages":[],"description":""},"order":0,"user":"59245bff200df13100c88562","__v":4,"body":"There are two main authentication flows that allow you to start syncing account data with Nylas. You'll need to decide which method is best for the application that you're building. \n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"If you're new to Nylas, we recommend checking out our [authentication guide](doc:authentication-guide) for an overview of authentication methods and step by step instructions to get you up and running. If you're ready to dive right in, you can use the API reference below.\",\n \"title\": \"Getting started?\"\n}\n[/block]","link_external":false,"project":"59245c10200df13100c88563","sync_unique":"","updates":["5b5a4c5ba7e5320003413a4c","5c334c398bec1d006342dda1","5d6e4a702ec9e10018ec05ef","5f2b800b817de105d0148ce0"],"version":"5e41e73d960b09003ca35a9b","githubsync":"","isReference":true,"parentDoc":null,"slug":"authentication","title":"Introduction","excerpt":"","type":"basic","updatedAt":"2019-06-07T22:39:42.185Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-08-06T02:43:48.652Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca35995","api":{"method":"get","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":""},"hidden":false,"isReference":true,"link_external":false,"project":"59245c10200df13100c88563","type":"basic","category":"5e41e73d960b09003ca3596c","link_url":"","slug":"oauth","sync_unique":"","user":"59245bff200df13100c88562","version":"5e41e73d960b09003ca35a9b","__v":3,"body":"Check out this developer guide to get started with [Hosted Authentication](doc:hosted-authentication).","githubsync":"","next":{"pages":[],"description":""},"order":1,"updates":["599bfdd2e05fa5001911abf6","5e4ee602b3a1770056ec34b9","5f16dbfd96d981013e6074b3"],"createdAt":"2017-05-23T20:15:05.864Z","excerpt":"","parentDoc":null,"title":"Hosted Authentication","updatedAt":"2019-06-07T22:06:10.600Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T04:07:55.436Z","tutorials":[],"children":[{"_id":"5e41e73d960b09003ca35994","createdAt":"2017-05-23T20:06:27.889Z","hidden":false,"next":{"pages":[],"description":""},"category":"5e41e73d960b09003ca3596c","isReference":true,"slug":"oauthauthorize","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","__v":46,"excerpt":"","githubsync":"","order":0,"project":"59245c10200df13100c88563","title":"/oauth/authorize","type":"endpoint","updates":["5da9ad3a7e8463006be57bac","5e6ec7ebf73f74005e19751d","5f0bebaf5ae6fa00502547aa","5f0bf1a62c174c001116905e","5f2b8223da298b05bd915c4d","5fa4a7b14e615700568d18c3"],"api":{"examples":{"codes":[{"language":"curl","code":"curl -G \\\n --url 'https://api.nylas.com/oauth/authorize' \\\n -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \\\n -d 'client_id=nylas_client_id' \\\n -d 'redirect_uri=http://example.com/nylas_callback' \\\n -d 'response_type=code' \\\n -d 'scopes=email.read_only,calendar.read_only,contacts.read_only' \\\n -d 'login_hint=my_email@example.com' \\\n -d 'state=MyCustomStateString'\n \n# After your user authenticates, Nylas will return a unique, one-time-use code.\n# This code can be used to create an access token that grants access to the user account.\n# See: https://docs.nylas.com/reference#oauthtoken"},{"code":"from nylas import APIClient\n\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\nauth_url = nylas.authentication_url(\n \"http://example.com/login_callback\", # Required\n login_hint=\"your_email@example.com\", # Optional\n state=\"unique_identifier\", # Optional\n scopes='email, calendar, contacts' # Optional - Default is all scopes\n # A full list of available scopes can be found here:\n # https://docs.nylas.com/docs/authentication-scopes\n)\n\n# This is the URL you need to send the user to to authenticate their account.\nprint(auth_url)\n\n# After your user authenticates, Nylas will return a unique, one-time-use code.\n# This code can be used to create an access token that grants access to the user account.\n# See: https://docs.nylas.com/reference#oauthtoken","language":"python","name":"Python SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\noptions = {\n loginHint: 'you_email@example.com',\n redirectURI: 'https://localhost/callback',\n scopes: ['email.read_only', 'email.send'],\n};\n\n// Redirect your user to the auth_url\nauth_url = Nylas.urlForAuthentication(options);"},{"code":"GET /oauth/authorize?client_id=95fmk77lwy***&response_type=code&scope=email&redirect_uri&state HTTP/1.1\nHost: api.nylas.com\nAuthorization: Basic WVVUWj****==\ncache-control: no-cache\n\n","language":"http","name":"HTTP"},{"name":"Ruby SDK","language":"ruby","code":"use OmniAuth::Builder do\n provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'],\n { name: 'google', access_type: :offline, approval_prompt: \"force\", prompt: 'consent',\n scope: ['email', 'profile', 'https://mail.google.com/',\n 'https://www.google.com/m8/feeds/',\n 'calendar'].join(', ') }\nend\nget \"/\" do\n '<a href=\"/auth/google\">Authenticate a Google Account</a>'\nend\n\nget \"/auth/failure\" do\n params[:message]\nend"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.HostedAuthentication;\nimport com.nylas.Scope;\n\npublic class NylasExamples {\n public static void hostedAuthExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n\n HostedAuthentication authentication = application.hostedAuthentication();\n String hostedAuthUrl = authentication.urlBuilder()\n .redirectUri(\"https://example.com/redirect\")\n .responseType(\"code\") // Use token for client-side apps\n .scopes(Scope.EMAIL, Scope.CALENDAR, Scope.CONTACTS)\n .loginHint(\"nyla@nylas.com\")\n .state(\"example_csrf_token\")\n .buildUrl();\n \n // This is the URL you need to send the user to to authenticate their account.\n System.out.println(hostedAuthUrl);\n\n // After your user authenticates, Nylas will return a unique, one-time-use code.\n // This code can be used to create an access token that grants access to the user account.\n // See: https://docs.nylas.com/reference#oauthtoken\n }\n}"}]},"method":"get","params":[{"name":"client_id","type":"string","default":"","desc":"Your Nylas application's client ID.","required":true,"in":"query","ref":"","_id":"59249643be15290f00de871d"},{"name":"redirect_uri","type":"string","default":"","desc":"The URI to which the user will be redirected once authentication completes. This must match a URI registered in the developer dashboard.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f3ff"},{"name":"response_type","type":"string","default":"","desc":"`code` for server side, `token` for client side.","required":true,"in":"query","ref":"","_id":"5924968e8d340d0f0050cf6f"},{"name":"scopes","type":"string","default":"","desc":"Any combination of supported [authentication scopes](doc:authentication-scopes).","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f401"},{"name":"login_hint","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5924971058d2d40f0030f400"},{"name":"state","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5924971058d2d40f0030f3fe"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5e3b02a77d0119002e5880cf"}],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"language":"json","code":"<html>\n <head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">\n <meta name=\"viewport\" content=\"width=device-width, user-scalable=no\">\n <title>Sign in to your email</title>\n <link rel=\"stylesheet\" href=\"/static/fonts/Avenir.css\">\n <link rel=\"stylesheet\" href=\"/static/css/oauth.css\">\n <link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Open+Sans:300,400,600\" type=\"text/css\">\n\n\n </head>\n <body>\n <div id=\"container\">\n <form action=\"#\" method=\"post\">\n <div id=\"white-box\">\n <div id=\"user_action\" style=\"padding:30px;\">\n <h2>Error</h2>\n <p class=\"alert\">\n\t\t\t\tSorry, an error occurred :(\n\t\t\t\t</p>\n <p class=\"error-display\">Status 400:</p>\n <p class=\"error-display\">Error messages goes here</p>\n </div>\n </div>\n </form>\n </div>\n </div>\n</body>\n</html>","name":"","status":400}]},"url":"/oauth/authorize","auth":"never","apiSetting":"5e41e73d960b09003ca3598d"},"body":"","link_external":false,"link_url":"","parentDoc":"5e41e73d960b09003ca35995","sync_unique":"","updatedAt":"2019-12-09T17:45:25.255Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:19:38.194Z","tutorials":[],"swagger":{"path":"/oauth/authorize"}},{"_id":"5e41e73d960b09003ca35998","api":{"examples":{"codes":[{"code":"POST /oauth/token HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"client_id\": \"CLIENT_ID\",\n \"client_secret\": \"CLIENT_SECRET\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"AUTHORIZATION_CODE\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","language":"http","name":"HTTP"},{"code":"curl -X POST \\\n https://api.nylas.com/oauth/token \\\n -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \\\n -d '{\n \"client_id\": \"CLIENT_ID\",\n \"client_secret\": \"CLIENT_SECRET\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"AUTHORIZATION_CODE\"\n}'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\n\n# Create a client that has access to your Nylas app.\nnylas_app = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Get an access token that grants access to user data and functionality.\n# You need to generate a one-time-use code via Nylas to pass to this function.\n# See: https://docs.nylas.com/reference#oauthauthorize\nACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}')\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Now you have a Nylas client object that has access to user data and functionality\nprint(nylas.account)","language":"python","name":"Python SDK"},{"code":"nylas_token = api.authenticate(\n name: auth_hash[:info][:name],\n email_address: auth_hash[:info][:email],\n provider: :gmail,\n settings: { \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 }\n)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\n\n// Pass credentials to the Nylas client to manage authentication\nNylas.config({\nclientId: CLIENT_ID,\nclientSecret: CLIENT_SECRET,\n});\n\n// Get an access token that grants access to user data and functionality.\n// You need to generate a one-time-use code via Nylas to pass to this function.\n// See: https://docs.nylas.com/reference#oauthauthorize\nlet access_token;\nNylas.exchangeCodeForToken(NYLAS_CODE).then(resp => access_token = resp.access_token);\n\n// Pass access_token to the Nylas client\nconst nylas = Nylas.with(access_token);\n\n// Now your Nylas client object has access to user data and functionality\nnylas.calendars.list();","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.HostedAuthentication;\n\npublic class NylasExamples {\n public static void hostedTokenExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n\n // Create a client that has access to your Nylas app.\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n HostedAuthentication authentication = application.hostedAuthentication();\n\n // Get an access token that grants access to user data and functionality.\n // You need to generate a one-time-use code via Nylas to pass to this function.\n // See: https://docs.nylas.com/reference#oauthauthorize\n String accessToken = authentication.fetchToken(\"{code}\").getAccessToken();\n\n // Now you have a Nylas client object that has access to user data and functionality\n NylasAccount account = nylas.account(accessToken);\n } \n}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your Nylas application's client ID.","required":true,"in":"query","ref":"","_id":"59249643be15290f00de871d"},{"name":"client_secret","type":"string","default":"","desc":"Your Nylas Developer App client secret.","required":true,"in":"query","ref":"","_id":"5924968e8d340d0f0050cf6f"},{"name":"grant_type","type":"string","default":"authorization_code","desc":"Set to `authorization_code`.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f401"},{"name":"code","type":"string","default":"","desc":"The authorization code returned from `/oauth/authorize`.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f400"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](https://docs.nylas.com/docs/using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5f36ff165e7fb602cc20b594"}],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"url":"/oauth/token","auth":"never","apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596c","isReference":true,"order":1,"title":"/oauth/token","version":"5e41e73d960b09003ca35a9b","excerpt":"","body":"","githubsync":"","link_external":false,"next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","slug":"oauthtoken","updates":["5e4ee5cba797300028773288","5f0fe433ce2b8302c2971979","5f48730ed2b92b002bafa674"],"__v":21,"hidden":false,"link_url":"","parentDoc":"5e41e73d960b09003ca35995","sync_unique":"","type":"endpoint","user":"5f2067586dda9a0045009159","createdAt":"2017-05-23T22:28:50.327Z","updatedAt":"2019-12-09T17:45:25.256Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-15T13:22:55.371Z","tutorials":[],"swagger":{"path":"/oauth/token"}},{"_id":"5e41e73d960b09003ca3599c","__v":20,"excerpt":"","updates":["5ee6618515923a005935207a","5f0bec770253bc0061b96e15"],"title":"/oauth/revoke","user":"5d404909c2f77c0012211f3e","body":"You can easily revoke an access token by issuing a POST request to the following endpoint. Include the to-be-revoked access token as the HTTP Basic Auth username.\n\nA 200 status code response with a body of `{ \"success\": True }` signifies that the token has been successfully revoked and can no longer be used.\n\nIf needed, you can also [revoke all active access tokens](ref:revoke-all) by using the Account Management endpoints.","createdAt":"2017-05-24T16:58:33.657Z","link_external":false,"project":"59245c10200df13100c88563","next":{"pages":[],"description":""},"parentDoc":"5e41e73d960b09003ca35995","version":"5e41e73d960b09003ca35a9b","api":{"results":{"codes":[{"status":200,"language":"curl","code":"<No return response>","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/oauth/revoke","auth":"never","examples":{"codes":[{"code":"curl -X POST https://api.nylas.com/oauth/revoke --user ACCESS_TOKEN_TO_REVOKE:","language":"curl"},{"code":"POST /oauth/revoke HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"from nylas import APIClient\n\n# Pass the access token to the Nylas client to manage the account's tokens\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Revoke the access token that was passed to the Nylas client.\nnylas.revoke_token()\n\n# Revoke all access tokens for the user account.\nnylas.revoke_all_tokens()\n\n# You can also revoke all tokens except for one.\nnylas.revoke_all_tokens(keep_access_token='{ACCESS_TOKEN}')","language":"python","name":"Python SDK"},{"code":" # Revoke the nylas access token so it cannot be used in the future (you probably don't want to do this\n # unless people deactivate their account with your software)\n api.revoke(nylas_token)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\n\n// Pass credentials to the Nylas client to manage authentication\nNylas.config({\nclientId: CLIENT_ID,\nclientSecret: CLIENT_SECRET,\n});\n\n// Get the user account\nlet account;\nNylas.accounts.find(ACCOUNT_ID).then(resp => account = resp);\n\n// Revoke all access tokens for the user account.\naccount.revokeAll();\n\n// You can also revoke all tokens except for one.\nnylas.revokeAll(ACCESS_TOKEN);","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void revokeTokensExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Revoke all tokens for an account by providing its ID\n accounts.revokeAllTokensForAccount(\"{accountId}\", null);\n\n // Pass an optional access token to revoke all tokens except for one.\n accounts.revokeAllTokensForAccount(\"{accountId}\", \"{ACCESS_TOKEN}\");\n }\n}"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The access token, specified as the HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925bbe8639d4b1b005e29b2"}],"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596c","githubsync":"","link_url":"","slug":"oauthrevoke","sync_unique":"","type":"endpoint","hidden":false,"isReference":true,"order":2,"updatedAt":"2019-06-07T22:07:05.472Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:11:40.210Z","tutorials":[],"swagger":{"path":"/oauth/revoke"}},{"_id":"5e41e73d960b09003ca3599b","version":"5e41e73d960b09003ca35a9b","__v":0,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"order":3,"slug":"authorization-errors","sync_unique":"","title":"Authorization Errors","type":"basic","githubsync":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","user":"597fb20c6ec952001e63f8f3","updates":[],"body":"In some scenarios, authentication can fail and you must display an error message to the user. In these cases Nylas includes additional parameters when calling your `redirect_uri`. After presenting the error, restart the authorization process.\n\n| Attribute | Description\n|----:|:--|\n| `error` string | `access_denied`, or another error type |\n| `reason` string | A more detailed explanation of the error you may present to the end user.","createdAt":"2017-05-24T16:57:24.504Z","excerpt":"","hidden":false,"link_external":false,"parentDoc":"5e41e73d960b09003ca35995","category":"5e41e73d960b09003ca3596c","isReference":true,"link_url":"","updatedAt":"2019-06-14T19:43:49.351Z","metadata":{"title":"","description":"","image":[]},"tutorials":[]}],"childrenPages":[{"_id":"5e41e73d960b09003ca35994","createdAt":"2017-05-23T20:06:27.889Z","hidden":false,"next":{"pages":[],"description":""},"category":"5e41e73d960b09003ca3596c","isReference":true,"slug":"oauthauthorize","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","__v":46,"excerpt":"","githubsync":"","order":0,"project":"59245c10200df13100c88563","title":"/oauth/authorize","type":"endpoint","updates":["5da9ad3a7e8463006be57bac","5e6ec7ebf73f74005e19751d","5f0bebaf5ae6fa00502547aa","5f0bf1a62c174c001116905e","5f2b8223da298b05bd915c4d","5fa4a7b14e615700568d18c3"],"api":{"examples":{"codes":[{"language":"curl","code":"curl -G \\\n --url 'https://api.nylas.com/oauth/authorize' \\\n -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \\\n -d 'client_id=nylas_client_id' \\\n -d 'redirect_uri=http://example.com/nylas_callback' \\\n -d 'response_type=code' \\\n -d 'scopes=email.read_only,calendar.read_only,contacts.read_only' \\\n -d 'login_hint=my_email@example.com' \\\n -d 'state=MyCustomStateString'\n \n# After your user authenticates, Nylas will return a unique, one-time-use code.\n# This code can be used to create an access token that grants access to the user account.\n# See: https://docs.nylas.com/reference#oauthtoken"},{"code":"from nylas import APIClient\n\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\nauth_url = nylas.authentication_url(\n \"http://example.com/login_callback\", # Required\n login_hint=\"your_email@example.com\", # Optional\n state=\"unique_identifier\", # Optional\n scopes='email, calendar, contacts' # Optional - Default is all scopes\n # A full list of available scopes can be found here:\n # https://docs.nylas.com/docs/authentication-scopes\n)\n\n# This is the URL you need to send the user to to authenticate their account.\nprint(auth_url)\n\n# After your user authenticates, Nylas will return a unique, one-time-use code.\n# This code can be used to create an access token that grants access to the user account.\n# See: https://docs.nylas.com/reference#oauthtoken","language":"python","name":"Python SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\noptions = {\n loginHint: 'you_email@example.com',\n redirectURI: 'https://localhost/callback',\n scopes: ['email.read_only', 'email.send'],\n};\n\n// Redirect your user to the auth_url\nauth_url = Nylas.urlForAuthentication(options);"},{"code":"GET /oauth/authorize?client_id=95fmk77lwy***&response_type=code&scope=email&redirect_uri&state HTTP/1.1\nHost: api.nylas.com\nAuthorization: Basic WVVUWj****==\ncache-control: no-cache\n\n","language":"http","name":"HTTP"},{"name":"Ruby SDK","language":"ruby","code":"use OmniAuth::Builder do\n provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'],\n { name: 'google', access_type: :offline, approval_prompt: \"force\", prompt: 'consent',\n scope: ['email', 'profile', 'https://mail.google.com/',\n 'https://www.google.com/m8/feeds/',\n 'calendar'].join(', ') }\nend\nget \"/\" do\n '<a href=\"/auth/google\">Authenticate a Google Account</a>'\nend\n\nget \"/auth/failure\" do\n params[:message]\nend"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.HostedAuthentication;\nimport com.nylas.Scope;\n\npublic class NylasExamples {\n public static void hostedAuthExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n\n HostedAuthentication authentication = application.hostedAuthentication();\n String hostedAuthUrl = authentication.urlBuilder()\n .redirectUri(\"https://example.com/redirect\")\n .responseType(\"code\") // Use token for client-side apps\n .scopes(Scope.EMAIL, Scope.CALENDAR, Scope.CONTACTS)\n .loginHint(\"nyla@nylas.com\")\n .state(\"example_csrf_token\")\n .buildUrl();\n \n // This is the URL you need to send the user to to authenticate their account.\n System.out.println(hostedAuthUrl);\n\n // After your user authenticates, Nylas will return a unique, one-time-use code.\n // This code can be used to create an access token that grants access to the user account.\n // See: https://docs.nylas.com/reference#oauthtoken\n }\n}"}]},"method":"get","params":[{"name":"client_id","type":"string","default":"","desc":"Your Nylas application's client ID.","required":true,"in":"query","ref":"","_id":"59249643be15290f00de871d"},{"name":"redirect_uri","type":"string","default":"","desc":"The URI to which the user will be redirected once authentication completes. This must match a URI registered in the developer dashboard.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f3ff"},{"name":"response_type","type":"string","default":"","desc":"`code` for server side, `token` for client side.","required":true,"in":"query","ref":"","_id":"5924968e8d340d0f0050cf6f"},{"name":"scopes","type":"string","default":"","desc":"Any combination of supported [authentication scopes](doc:authentication-scopes).","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f401"},{"name":"login_hint","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5924971058d2d40f0030f400"},{"name":"state","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5924971058d2d40f0030f3fe"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5e3b02a77d0119002e5880cf"}],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"language":"json","code":"<html>\n <head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">\n <meta name=\"viewport\" content=\"width=device-width, user-scalable=no\">\n <title>Sign in to your email</title>\n <link rel=\"stylesheet\" href=\"/static/fonts/Avenir.css\">\n <link rel=\"stylesheet\" href=\"/static/css/oauth.css\">\n <link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Open+Sans:300,400,600\" type=\"text/css\">\n\n\n </head>\n <body>\n <div id=\"container\">\n <form action=\"#\" method=\"post\">\n <div id=\"white-box\">\n <div id=\"user_action\" style=\"padding:30px;\">\n <h2>Error</h2>\n <p class=\"alert\">\n\t\t\t\tSorry, an error occurred :(\n\t\t\t\t</p>\n <p class=\"error-display\">Status 400:</p>\n <p class=\"error-display\">Error messages goes here</p>\n </div>\n </div>\n </form>\n </div>\n </div>\n</body>\n</html>","name":"","status":400}]},"url":"/oauth/authorize","auth":"never","apiSetting":"5e41e73d960b09003ca3598d"},"body":"","link_external":false,"link_url":"","parentDoc":"5e41e73d960b09003ca35995","sync_unique":"","updatedAt":"2019-12-09T17:45:25.255Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:19:38.194Z","tutorials":[],"swagger":{"path":"/oauth/authorize"}},{"_id":"5e41e73d960b09003ca35998","api":{"examples":{"codes":[{"code":"POST /oauth/token HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"client_id\": \"CLIENT_ID\",\n \"client_secret\": \"CLIENT_SECRET\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"AUTHORIZATION_CODE\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","language":"http","name":"HTTP"},{"code":"curl -X POST \\\n https://api.nylas.com/oauth/token \\\n -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \\\n -d '{\n \"client_id\": \"CLIENT_ID\",\n \"client_secret\": \"CLIENT_SECRET\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"AUTHORIZATION_CODE\"\n}'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\n\n# Create a client that has access to your Nylas app.\nnylas_app = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Get an access token that grants access to user data and functionality.\n# You need to generate a one-time-use code via Nylas to pass to this function.\n# See: https://docs.nylas.com/reference#oauthauthorize\nACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}')\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Now you have a Nylas client object that has access to user data and functionality\nprint(nylas.account)","language":"python","name":"Python SDK"},{"code":"nylas_token = api.authenticate(\n name: auth_hash[:info][:name],\n email_address: auth_hash[:info][:email],\n provider: :gmail,\n settings: { \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 }\n)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\n\n// Pass credentials to the Nylas client to manage authentication\nNylas.config({\nclientId: CLIENT_ID,\nclientSecret: CLIENT_SECRET,\n});\n\n// Get an access token that grants access to user data and functionality.\n// You need to generate a one-time-use code via Nylas to pass to this function.\n// See: https://docs.nylas.com/reference#oauthauthorize\nlet access_token;\nNylas.exchangeCodeForToken(NYLAS_CODE).then(resp => access_token = resp.access_token);\n\n// Pass access_token to the Nylas client\nconst nylas = Nylas.with(access_token);\n\n// Now your Nylas client object has access to user data and functionality\nnylas.calendars.list();","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.HostedAuthentication;\n\npublic class NylasExamples {\n public static void hostedTokenExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n\n // Create a client that has access to your Nylas app.\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n HostedAuthentication authentication = application.hostedAuthentication();\n\n // Get an access token that grants access to user data and functionality.\n // You need to generate a one-time-use code via Nylas to pass to this function.\n // See: https://docs.nylas.com/reference#oauthauthorize\n String accessToken = authentication.fetchToken(\"{code}\").getAccessToken();\n\n // Now you have a Nylas client object that has access to user data and functionality\n NylasAccount account = nylas.account(accessToken);\n } \n}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your Nylas application's client ID.","required":true,"in":"query","ref":"","_id":"59249643be15290f00de871d"},{"name":"client_secret","type":"string","default":"","desc":"Your Nylas Developer App client secret.","required":true,"in":"query","ref":"","_id":"5924968e8d340d0f0050cf6f"},{"name":"grant_type","type":"string","default":"authorization_code","desc":"Set to `authorization_code`.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f401"},{"name":"code","type":"string","default":"","desc":"The authorization code returned from `/oauth/authorize`.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f400"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](https://docs.nylas.com/docs/using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5f36ff165e7fb602cc20b594"}],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"url":"/oauth/token","auth":"never","apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596c","isReference":true,"order":1,"title":"/oauth/token","version":"5e41e73d960b09003ca35a9b","excerpt":"","body":"","githubsync":"","link_external":false,"next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","slug":"oauthtoken","updates":["5e4ee5cba797300028773288","5f0fe433ce2b8302c2971979","5f48730ed2b92b002bafa674"],"__v":21,"hidden":false,"link_url":"","parentDoc":"5e41e73d960b09003ca35995","sync_unique":"","type":"endpoint","user":"5f2067586dda9a0045009159","createdAt":"2017-05-23T22:28:50.327Z","updatedAt":"2019-12-09T17:45:25.256Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-15T13:22:55.371Z","tutorials":[],"swagger":{"path":"/oauth/token"}},{"_id":"5e41e73d960b09003ca3599c","__v":20,"excerpt":"","updates":["5ee6618515923a005935207a","5f0bec770253bc0061b96e15"],"title":"/oauth/revoke","user":"5d404909c2f77c0012211f3e","body":"You can easily revoke an access token by issuing a POST request to the following endpoint. Include the to-be-revoked access token as the HTTP Basic Auth username.\n\nA 200 status code response with a body of `{ \"success\": True }` signifies that the token has been successfully revoked and can no longer be used.\n\nIf needed, you can also [revoke all active access tokens](ref:revoke-all) by using the Account Management endpoints.","createdAt":"2017-05-24T16:58:33.657Z","link_external":false,"project":"59245c10200df13100c88563","next":{"pages":[],"description":""},"parentDoc":"5e41e73d960b09003ca35995","version":"5e41e73d960b09003ca35a9b","api":{"results":{"codes":[{"status":200,"language":"curl","code":"<No return response>","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/oauth/revoke","auth":"never","examples":{"codes":[{"code":"curl -X POST https://api.nylas.com/oauth/revoke --user ACCESS_TOKEN_TO_REVOKE:","language":"curl"},{"code":"POST /oauth/revoke HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"from nylas import APIClient\n\n# Pass the access token to the Nylas client to manage the account's tokens\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Revoke the access token that was passed to the Nylas client.\nnylas.revoke_token()\n\n# Revoke all access tokens for the user account.\nnylas.revoke_all_tokens()\n\n# You can also revoke all tokens except for one.\nnylas.revoke_all_tokens(keep_access_token='{ACCESS_TOKEN}')","language":"python","name":"Python SDK"},{"code":" # Revoke the nylas access token so it cannot be used in the future (you probably don't want to do this\n # unless people deactivate their account with your software)\n api.revoke(nylas_token)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\n\n// Pass credentials to the Nylas client to manage authentication\nNylas.config({\nclientId: CLIENT_ID,\nclientSecret: CLIENT_SECRET,\n});\n\n// Get the user account\nlet account;\nNylas.accounts.find(ACCOUNT_ID).then(resp => account = resp);\n\n// Revoke all access tokens for the user account.\naccount.revokeAll();\n\n// You can also revoke all tokens except for one.\nnylas.revokeAll(ACCESS_TOKEN);","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void revokeTokensExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Revoke all tokens for an account by providing its ID\n accounts.revokeAllTokensForAccount(\"{accountId}\", null);\n\n // Pass an optional access token to revoke all tokens except for one.\n accounts.revokeAllTokensForAccount(\"{accountId}\", \"{ACCESS_TOKEN}\");\n }\n}"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The access token, specified as the HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925bbe8639d4b1b005e29b2"}],"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596c","githubsync":"","link_url":"","slug":"oauthrevoke","sync_unique":"","type":"endpoint","hidden":false,"isReference":true,"order":2,"updatedAt":"2019-06-07T22:07:05.472Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:11:40.210Z","tutorials":[],"swagger":{"path":"/oauth/revoke"}},{"_id":"5e41e73d960b09003ca3599b","version":"5e41e73d960b09003ca35a9b","__v":0,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"order":3,"slug":"authorization-errors","sync_unique":"","title":"Authorization Errors","type":"basic","githubsync":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","user":"597fb20c6ec952001e63f8f3","updates":[],"body":"In some scenarios, authentication can fail and you must display an error message to the user. In these cases Nylas includes additional parameters when calling your `redirect_uri`. After presenting the error, restart the authorization process.\n\n| Attribute | Description\n|----:|:--|\n| `error` string | `access_denied`, or another error type |\n| `reason` string | A more detailed explanation of the error you may present to the end user.","createdAt":"2017-05-24T16:57:24.504Z","excerpt":"","hidden":false,"link_external":false,"parentDoc":"5e41e73d960b09003ca35995","category":"5e41e73d960b09003ca3596c","isReference":true,"link_url":"","updatedAt":"2019-06-14T19:43:49.351Z","metadata":{"title":"","description":"","image":[]},"tutorials":[]}]},{"_id":"5e41e73d960b09003ca35994","createdAt":"2017-05-23T20:06:27.889Z","hidden":false,"next":{"pages":[],"description":""},"category":"5e41e73d960b09003ca3596c","isReference":true,"slug":"oauthauthorize","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","__v":46,"excerpt":"","githubsync":"","order":0,"project":"59245c10200df13100c88563","title":"/oauth/authorize","type":"endpoint","updates":["5da9ad3a7e8463006be57bac","5e6ec7ebf73f74005e19751d","5f0bebaf5ae6fa00502547aa","5f0bf1a62c174c001116905e","5f2b8223da298b05bd915c4d","5fa4a7b14e615700568d18c3"],"api":{"examples":{"codes":[{"language":"curl","code":"curl -G \\\n --url 'https://api.nylas.com/oauth/authorize' \\\n -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \\\n -d 'client_id=nylas_client_id' \\\n -d 'redirect_uri=http://example.com/nylas_callback' \\\n -d 'response_type=code' \\\n -d 'scopes=email.read_only,calendar.read_only,contacts.read_only' \\\n -d 'login_hint=my_email@example.com' \\\n -d 'state=MyCustomStateString'\n \n# After your user authenticates, Nylas will return a unique, one-time-use code.\n# This code can be used to create an access token that grants access to the user account.\n# See: https://docs.nylas.com/reference#oauthtoken"},{"code":"from nylas import APIClient\n\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\nauth_url = nylas.authentication_url(\n \"http://example.com/login_callback\", # Required\n login_hint=\"your_email@example.com\", # Optional\n state=\"unique_identifier\", # Optional\n scopes='email, calendar, contacts' # Optional - Default is all scopes\n # A full list of available scopes can be found here:\n # https://docs.nylas.com/docs/authentication-scopes\n)\n\n# This is the URL you need to send the user to to authenticate their account.\nprint(auth_url)\n\n# After your user authenticates, Nylas will return a unique, one-time-use code.\n# This code can be used to create an access token that grants access to the user account.\n# See: https://docs.nylas.com/reference#oauthtoken","language":"python","name":"Python SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\noptions = {\n loginHint: 'you_email@example.com',\n redirectURI: 'https://localhost/callback',\n scopes: ['email.read_only', 'email.send'],\n};\n\n// Redirect your user to the auth_url\nauth_url = Nylas.urlForAuthentication(options);"},{"code":"GET /oauth/authorize?client_id=95fmk77lwy***&response_type=code&scope=email&redirect_uri&state HTTP/1.1\nHost: api.nylas.com\nAuthorization: Basic WVVUWj****==\ncache-control: no-cache\n\n","language":"http","name":"HTTP"},{"name":"Ruby SDK","language":"ruby","code":"use OmniAuth::Builder do\n provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'],\n { name: 'google', access_type: :offline, approval_prompt: \"force\", prompt: 'consent',\n scope: ['email', 'profile', 'https://mail.google.com/',\n 'https://www.google.com/m8/feeds/',\n 'calendar'].join(', ') }\nend\nget \"/\" do\n '<a href=\"/auth/google\">Authenticate a Google Account</a>'\nend\n\nget \"/auth/failure\" do\n params[:message]\nend"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.HostedAuthentication;\nimport com.nylas.Scope;\n\npublic class NylasExamples {\n public static void hostedAuthExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n\n HostedAuthentication authentication = application.hostedAuthentication();\n String hostedAuthUrl = authentication.urlBuilder()\n .redirectUri(\"https://example.com/redirect\")\n .responseType(\"code\") // Use token for client-side apps\n .scopes(Scope.EMAIL, Scope.CALENDAR, Scope.CONTACTS)\n .loginHint(\"nyla@nylas.com\")\n .state(\"example_csrf_token\")\n .buildUrl();\n \n // This is the URL you need to send the user to to authenticate their account.\n System.out.println(hostedAuthUrl);\n\n // After your user authenticates, Nylas will return a unique, one-time-use code.\n // This code can be used to create an access token that grants access to the user account.\n // See: https://docs.nylas.com/reference#oauthtoken\n }\n}"}]},"method":"get","params":[{"name":"client_id","type":"string","default":"","desc":"Your Nylas application's client ID.","required":true,"in":"query","ref":"","_id":"59249643be15290f00de871d"},{"name":"redirect_uri","type":"string","default":"","desc":"The URI to which the user will be redirected once authentication completes. This must match a URI registered in the developer dashboard.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f3ff"},{"name":"response_type","type":"string","default":"","desc":"`code` for server side, `token` for client side.","required":true,"in":"query","ref":"","_id":"5924968e8d340d0f0050cf6f"},{"name":"scopes","type":"string","default":"","desc":"Any combination of supported [authentication scopes](doc:authentication-scopes).","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f401"},{"name":"login_hint","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5924971058d2d40f0030f400"},{"name":"state","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5924971058d2d40f0030f3fe"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5e3b02a77d0119002e5880cf"}],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"language":"json","code":"<html>\n <head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">\n <meta name=\"viewport\" content=\"width=device-width, user-scalable=no\">\n <title>Sign in to your email</title>\n <link rel=\"stylesheet\" href=\"/static/fonts/Avenir.css\">\n <link rel=\"stylesheet\" href=\"/static/css/oauth.css\">\n <link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Open+Sans:300,400,600\" type=\"text/css\">\n\n\n </head>\n <body>\n <div id=\"container\">\n <form action=\"#\" method=\"post\">\n <div id=\"white-box\">\n <div id=\"user_action\" style=\"padding:30px;\">\n <h2>Error</h2>\n <p class=\"alert\">\n\t\t\t\tSorry, an error occurred :(\n\t\t\t\t</p>\n <p class=\"error-display\">Status 400:</p>\n <p class=\"error-display\">Error messages goes here</p>\n </div>\n </div>\n </form>\n </div>\n </div>\n</body>\n</html>","name":"","status":400}]},"url":"/oauth/authorize","auth":"never","apiSetting":"5e41e73d960b09003ca3598d"},"body":"","link_external":false,"link_url":"","parentDoc":"5e41e73d960b09003ca35995","sync_unique":"","updatedAt":"2019-12-09T17:45:25.255Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:19:38.194Z","tutorials":[],"swagger":{"path":"/oauth/authorize"}},{"_id":"5e41e73d960b09003ca35998","api":{"examples":{"codes":[{"code":"POST /oauth/token HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"client_id\": \"CLIENT_ID\",\n \"client_secret\": \"CLIENT_SECRET\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"AUTHORIZATION_CODE\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","language":"http","name":"HTTP"},{"code":"curl -X POST \\\n https://api.nylas.com/oauth/token \\\n -H 'Authorization: Basic ENCODED_CLIENT_SECRET' \\\n -d '{\n \"client_id\": \"CLIENT_ID\",\n \"client_secret\": \"CLIENT_SECRET\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"AUTHORIZATION_CODE\"\n}'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\n\n# Create a client that has access to your Nylas app.\nnylas_app = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Get an access token that grants access to user data and functionality.\n# You need to generate a one-time-use code via Nylas to pass to this function.\n# See: https://docs.nylas.com/reference#oauthauthorize\nACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}')\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Now you have a Nylas client object that has access to user data and functionality\nprint(nylas.account)","language":"python","name":"Python SDK"},{"code":"nylas_token = api.authenticate(\n name: auth_hash[:info][:name],\n email_address: auth_hash[:info][:email],\n provider: :gmail,\n settings: { \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 }\n)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\n\n// Pass credentials to the Nylas client to manage authentication\nNylas.config({\nclientId: CLIENT_ID,\nclientSecret: CLIENT_SECRET,\n});\n\n// Get an access token that grants access to user data and functionality.\n// You need to generate a one-time-use code via Nylas to pass to this function.\n// See: https://docs.nylas.com/reference#oauthauthorize\nlet access_token;\nNylas.exchangeCodeForToken(NYLAS_CODE).then(resp => access_token = resp.access_token);\n\n// Pass access_token to the Nylas client\nconst nylas = Nylas.with(access_token);\n\n// Now your Nylas client object has access to user data and functionality\nnylas.calendars.list();","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.HostedAuthentication;\n\npublic class NylasExamples {\n public static void hostedTokenExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n\n // Create a client that has access to your Nylas app.\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n HostedAuthentication authentication = application.hostedAuthentication();\n\n // Get an access token that grants access to user data and functionality.\n // You need to generate a one-time-use code via Nylas to pass to this function.\n // See: https://docs.nylas.com/reference#oauthauthorize\n String accessToken = authentication.fetchToken(\"{code}\").getAccessToken();\n\n // Now you have a Nylas client object that has access to user data and functionality\n NylasAccount account = nylas.account(accessToken);\n } \n}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your Nylas application's client ID.","required":true,"in":"query","ref":"","_id":"59249643be15290f00de871d"},{"name":"client_secret","type":"string","default":"","desc":"Your Nylas Developer App client secret.","required":true,"in":"query","ref":"","_id":"5924968e8d340d0f0050cf6f"},{"name":"grant_type","type":"string","default":"authorization_code","desc":"Set to `authorization_code`.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f401"},{"name":"code","type":"string","default":"","desc":"The authorization code returned from `/oauth/authorize`.","required":true,"in":"query","ref":"","_id":"5924971058d2d40f0030f400"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](https://docs.nylas.com/docs/using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5f36ff165e7fb602cc20b594"}],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"url":"/oauth/token","auth":"never","apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596c","isReference":true,"order":1,"title":"/oauth/token","version":"5e41e73d960b09003ca35a9b","excerpt":"","body":"","githubsync":"","link_external":false,"next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","slug":"oauthtoken","updates":["5e4ee5cba797300028773288","5f0fe433ce2b8302c2971979","5f48730ed2b92b002bafa674"],"__v":21,"hidden":false,"link_url":"","parentDoc":"5e41e73d960b09003ca35995","sync_unique":"","type":"endpoint","user":"5f2067586dda9a0045009159","createdAt":"2017-05-23T22:28:50.327Z","updatedAt":"2019-12-09T17:45:25.256Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-15T13:22:55.371Z","tutorials":[],"swagger":{"path":"/oauth/token"}},{"_id":"5e41e73d960b09003ca3599c","__v":20,"excerpt":"","updates":["5ee6618515923a005935207a","5f0bec770253bc0061b96e15"],"title":"/oauth/revoke","user":"5d404909c2f77c0012211f3e","body":"You can easily revoke an access token by issuing a POST request to the following endpoint. Include the to-be-revoked access token as the HTTP Basic Auth username.\n\nA 200 status code response with a body of `{ \"success\": True }` signifies that the token has been successfully revoked and can no longer be used.\n\nIf needed, you can also [revoke all active access tokens](ref:revoke-all) by using the Account Management endpoints.","createdAt":"2017-05-24T16:58:33.657Z","link_external":false,"project":"59245c10200df13100c88563","next":{"pages":[],"description":""},"parentDoc":"5e41e73d960b09003ca35995","version":"5e41e73d960b09003ca35a9b","api":{"results":{"codes":[{"status":200,"language":"curl","code":"<No return response>","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/oauth/revoke","auth":"never","examples":{"codes":[{"code":"curl -X POST https://api.nylas.com/oauth/revoke --user ACCESS_TOKEN_TO_REVOKE:","language":"curl"},{"code":"POST /oauth/revoke HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"from nylas import APIClient\n\n# Pass the access token to the Nylas client to manage the account's tokens\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Revoke the access token that was passed to the Nylas client.\nnylas.revoke_token()\n\n# Revoke all access tokens for the user account.\nnylas.revoke_all_tokens()\n\n# You can also revoke all tokens except for one.\nnylas.revoke_all_tokens(keep_access_token='{ACCESS_TOKEN}')","language":"python","name":"Python SDK"},{"code":" # Revoke the nylas access token so it cannot be used in the future (you probably don't want to do this\n # unless people deactivate their account with your software)\n api.revoke(nylas_token)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\n\n// Pass credentials to the Nylas client to manage authentication\nNylas.config({\nclientId: CLIENT_ID,\nclientSecret: CLIENT_SECRET,\n});\n\n// Get the user account\nlet account;\nNylas.accounts.find(ACCOUNT_ID).then(resp => account = resp);\n\n// Revoke all access tokens for the user account.\naccount.revokeAll();\n\n// You can also revoke all tokens except for one.\nnylas.revokeAll(ACCESS_TOKEN);","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void revokeTokensExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Revoke all tokens for an account by providing its ID\n accounts.revokeAllTokensForAccount(\"{accountId}\", null);\n\n // Pass an optional access token to revoke all tokens except for one.\n accounts.revokeAllTokensForAccount(\"{accountId}\", \"{ACCESS_TOKEN}\");\n }\n}"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The access token, specified as the HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925bbe8639d4b1b005e29b2"}],"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596c","githubsync":"","link_url":"","slug":"oauthrevoke","sync_unique":"","type":"endpoint","hidden":false,"isReference":true,"order":2,"updatedAt":"2019-06-07T22:07:05.472Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:11:40.210Z","tutorials":[],"swagger":{"path":"/oauth/revoke"}},{"_id":"5e41e73d960b09003ca3599b","version":"5e41e73d960b09003ca35a9b","__v":0,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"order":3,"slug":"authorization-errors","sync_unique":"","title":"Authorization Errors","type":"basic","githubsync":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","user":"597fb20c6ec952001e63f8f3","updates":[],"body":"In some scenarios, authentication can fail and you must display an error message to the user. In these cases Nylas includes additional parameters when calling your `redirect_uri`. After presenting the error, restart the authorization process.\n\n| Attribute | Description\n|----:|:--|\n| `error` string | `access_denied`, or another error type |\n| `reason` string | A more detailed explanation of the error you may present to the end user.","createdAt":"2017-05-24T16:57:24.504Z","excerpt":"","hidden":false,"link_external":false,"parentDoc":"5e41e73d960b09003ca35995","category":"5e41e73d960b09003ca3596c","isReference":true,"link_url":"","updatedAt":"2019-06-14T19:43:49.351Z","metadata":{"title":"","description":"","image":[]},"tutorials":[]},{"_id":"5e41e73d960b09003ca35996","order":2,"project":"59245c10200df13100c88563","slug":"native-authentication-1","body":"To learn about general authentication flows, see the [Authentication](doc:authentication-guide) overview. If you'd like to get started with Native Authentication, begin with [this developer guide](doc:native-authentication).","category":"5e41e73d960b09003ca3596c","createdAt":"2017-05-23T20:16:54.054Z","githubsync":"","link_external":false,"updates":[],"hidden":false,"parentDoc":null,"type":"basic","__v":0,"sync_unique":"","title":"Native Authentication","user":"597fb20c6ec952001e63f8f3","version":"5e41e73d960b09003ca35a9b","api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"excerpt":"","isReference":true,"link_url":"","next":{"pages":[],"description":""},"updatedAt":"2019-06-14T19:44:13.546Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[{"_id":"5e41e73d960b09003ca35992","sync_unique":"","type":"endpoint","api":{"auth":"never","examples":{"codes":[{"name":"cURL","language":"curl","code":"# The following examples will return 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\n# Authenticate Google Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"gmail\",\n \"settings\": {\n \"google_client_id\": \"{google_api_client_id}\",\n \"google_client_secret\": \"{geoogle_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 Google Account using a Service Account\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@gmail.com\", # Account to be authenticated\n \"provider\": \"gmail\",\n \"settings\": {\n \"service_account_json\": { # Service account credentials\n \"type\": \"service_account\",\n \"project_id\": \"my-google-app-123456\",\n \"private_key_id\": \"68915b4e55baac9191dd32e0be784687c6873b14\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIE....fZ1F8=\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"test-service-account@my-google-app-123456.iam.gserviceaccount.com\",\n \"client_id\": \"10569134234239528168761\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40my-google-app-123456.iam.gserviceaccount.com\"\n }\n \"scopes\": \"calendar\"\n}'\n\n# Authenticate Office365 Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\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\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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 \"exchange_server_host\": \"exchange.nylas.com\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate Exchange Account using a Service Account via Password\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\", # Account to authenticate\n \"provider\": \"exchange\",\n \"settings\": {\n \"username\": \"username\", # Service account username\n \"password\": \"password\", # Service account password\n \"service_account\": true\n }\n \"scopes\": \"calendar.read_only\"\n}'\n\n# Authenticate Exchange Account using a Service Account via OAuth\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\", # Account to authenticate\n \"provider\": \"exchange\",\n \"settings\": {\n \"microsoft_client_id\": \"{microsoft_client_id}\",\n \"microsoft_client_secret\": \"{microsoft_client_secret}\",\n \"microsoft_refresh_token\": \"{microsoft_refresh_token}\", # Service account refresh token!\n \"redirect_uri\": \"https://example.com/redirect\",\n \"service_account\": true\n },\n \"scopes\": \"calendar\"\n}'\n\n# Authenticate Outlook Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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 \"exchange_server_host\": \"eas.outlook.com\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate known IMAP providers\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@aol.com\",\n \"provider\": \"aol\",\n \"settings\": {\n \"password\": \"MakeEmailSuckLess\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate a generic IMAP provider\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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.net\",\n \"smtp_port\": 587,\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}'\n\n# Virtual Calendars\n\ncurl --location --request POST 'https://api.nylas.com/connect/authorize' \\\n --data-raw '{\n \"client_id\": \"9df4ff17888f4729ad4e1463d2547d\",\n \"provider\": \"nylas\",\n \"scopes\": \"calendar\", \n \"email\": \"virtual_account_unique_id\",\n \"name\": \"Virtual Calendar\",\n \"settings\": {}\n }'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nimport requests\n\n# Create a client that has access to your Nylas app.\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Authenticate Gmail Accounts\ngmail_authentication = {\n # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-gmail\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"gmail\",\n \"settings\": { # See the Example above to learn more about these values\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,calendar,contacts\"\n}\n\n# Post the authentication payload to Nylas.\nnylas_authorization = requests.post(\n \"https://api.nylas.com/connect/authorize\", json=gmail_authentication\n)\n\n# This code can be exchanged for an account access token\nnylas_code = nylas_authorization.json()[\"code\"]\n\n# -------------------------------------------\n# The remainder contains examples of how to authenticate other types of accounts\n\n# Authenticate Exchange Accounts\nexchange_authentication = {\n # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-exchange\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"exchange\",\n \"settings\": {\n \"username\": \"nyla@exchange_server.com\",\n \"password\": \"MakeEmailSuckLess\",\n \"eas_server_host\": \"exchange.your_server.com\"\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate an Outlook Account\noutlook_authentication = {\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@outlook.com\",\n \"provider\": \"outlook\",\n \"settings\": { # Uses the same format as Exchange Servers\n \"username\": \"nyla@outlook.com\",\n \"password\": \"MakeEmailSuckLess\",\n \"eas_server_host\": \"outlook.com\"\n\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate an account from a known IMAP provider\nknown_imap_authentication = {\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@yahoo.com\",\n \"provider\": \"yahoo\", # can also be aol, icloud, or hotmail\n \"settings\": {\n \"password\": \"MakeEmailSuckLess\"\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate any other IMAP account\ngeneric_imap_authentication = {\n \"client_id\": CLIENT_ID,\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\": 12345,\n \"imap_username\": \"nyla\",\n \"imap_password\": \"MakeEmailSuckLess\",\n \"smtp_host\": \"smtp.nylas.net\",\n \"smtp_port\": 12346,\n \"smtp_username\": \"nyla\",\n \"smtp_password\": \"MakeEmailSuckLess\",\n \"ssl_required\": 'true'\n },\n \"scopes\": \"email,calendar,contacts\"\n}"},{"name":"Node.js SDK","language":"javascript","code":"// 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});"},{"code":"nylas_token = api.authenticate(\n name: auth_hash[:info][:name], \n email_address: auth_hash[:info][:email],\n provider: :gmail,\n settings: {\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 }\n)\n","language":"ruby","name":"Ruby SDK"},{"name":"Java SDK","language":"java","code":"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}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your client ID from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592468630f7f402f001618a1"},{"name":"name","type":"string","default":"","desc":"The full name of the user (e.g. “John Snow”).","required":true,"in":"body","ref":"","_id":"592468630f7f402f001618a0"},{"name":"email_address","type":"string","default":"","desc":"The user’s email address. If you are creating a [Virtual Calendar](https://docs.nylas.com/docs/how-to-use-virtual-calendars#step-2-create-a-virtual-calendar), use a `virtual_account_unique_id`.","required":true,"in":"body","ref":"","_id":"592468630f7f402f0016189f"},{"name":"provider","type":"string","default":"","desc":"One of `gmail`, `yahoo`, `exchange`, `outlook`, `imap`, `icloud`, `hotmail`, `aol`, or `office365`. Note that the format of the settings object below is dependent upon this field. If your provider isn't listed, use the generic settings","required":true,"in":"body","ref":"","_id":"592468630f7f402f0016189e"},{"name":"settings","type":"object","default":"","desc":"Dependent on the provider to which you are connecting. See [provider specific settings](#section-provider-specific-settings).","required":true,"in":"body","ref":"google-settings","_id":"5924a305aeb5eb0f0093e2cc"},{"name":"scopes","type":"string","default":"","desc":"Any combination of supported [authentication scopes](doc:authentication-scopes). Service accounts only support calendar scopes.","required":false,"in":"body","ref":"","_id":"5bfc75a40a284b0021524466"}],"results":{"codes":[{"status":200,"language":"json","code":"{\"code\": \"one-time-use-code\"}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Please include the missing fields\", \n \"type\": \"auth_error\", \n \"missing_fields\": [\"provider\"], \n \"error\": \"Missing fields.\"\n}","name":"Missing provider"},{"status":403,"language":"json","code":"{\n\t\"message\": \"Specific info about the error included here\",\n \"type\": \"auth_error\",\n \"error\": \"authentication_failed\"\n}"}]},"url":"/connect/authorize","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"This endpoint is where your application sends mailbox credentials to verify they are correct. This begins the connection process.\n\nA 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.\n\nEach provider requires different `settings`. Review the [Provider Specific Settings](#section-provider-specific-settings) for more information.","githubsync":"","hidden":false,"link_external":false,"link_url":"","version":"5e41e73d960b09003ca35a9b","__v":93,"body":"# Provider Specific Settings\n\nDepending on the `provider` body parameter you include, you must send a different `settings` object in your request to `/connect/authorize`. These are the possible `settings` objects you may need to include:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"\\\"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 \"language\": \"json\",\n \"name\": \"Example Google Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"username\\\": \\\"erlich@aviato.com\\\",\\n \\\"password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"exchange_server_host\\\": \\\"exchange.aviato.com\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Exchange Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n\\t\\\"password\\\": \\\"makingtheworldabetterplace\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Known IMAP Provider Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"imap_host\\\": \\\"imap.aviato.com\\\",\\n \\\"imap_port\\\": 12345,\\n \\\"imap_username\\\": \\\"erlich.bachman\\\",\\n \\\"imap_password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"smtp_host\\\": \\\"smtp.aviato.net\\\",\\n \\\"smtp_port\\\": 12346,\\n \\\"smtp_username\\\": \\\"erlich.bachman\\\",\\n \\\"smtp_password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"ssl_required\\\": true\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Generic IMAP Provider Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"microsoft_client_id\\\": \\\"\\\",\\n \\\"microsoft_client_secret\\\": \\t\\\"\\\",\\n \\\"microsoft_refresh_token\\\": \\t\\\"\\\",\\n \\\"redirect_uri\\\": \\\"\\\" # Redirect URI that the was originally used to get the refresh token\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Office365 Settings\"\n },\n {\n \"code\": \"# Using OAuth authentication\\n\\\"settings\\\": {\\n \\\"microsoft_client_id\\\": \\\"\\\",\\n \\\"microsoft_client_secret\\\": \\t\\\"\\\",\\n \\\"microsoft_refresh_token\\\": \\t\\\"\\\",\\n \\\"redirect_uri\\\": \\\"\\\", # Redirect URI that the was originally used to get the refresh token\\n \\\"service_account\\\": true\\n}\\n\\n# Using password authentication\\n\\\"settings\\\": {\\n \\\"username\\\": \\\"service_account@example.com\\\",\\n \\\"password\\\": \\\"serviceaccountpassword\\\",\\n \\\"service_account\\\": true\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Office365 Service Account Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n\\t\\\"service_account_json\\\": {\\n \\t\\\"type\\\": \\\"service_account\\\",\\n \\t\\\"project_id\\\": \\\"metal-figure-239116\\\",\\n \\\"private_key_id\\\": \\\"68ac9191dd3468915b4e52e0be785ba7c6873b14\\\",\\n \\t\\\"private_key\\\": \\\"-----BEGIN PRIVATE KEY-----\\\\nMI...J7tF8=\\\\n-----END PRIVATE KEY-----\\\\n\\\",\\n \\\"client_email\\\": \\\"test-service-account@metal-figure-239116.iam.gserviceaccount.com\\\",\\n \\\"client_id\\\": \\\"105691998485416876281\\\",\\n \\\"auth_uri\\\": \\\"https://accounts.google.com/o/oauth2/auth\\\",\\n \\\"token_uri\\\": \\\"https://oauth2.googleapis.com/token\\\",\\n \\\"auth_provider_x509_cert_url\\\": \\\"https://www.googleapis.com/oauth2/v1/certs\\\",\\n \\\"client_x509_cert_url\\\": \\\"https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40metal-figure-239116.iam.gserviceaccount.com\\\"\\n }\\n}\",\n \"language\": \"json\",\n \"name\": \"Example G Suite Service Account Settings\"\n }\n ]\n}\n[/block]\n## Exchange Auto-discovery\n\nNylas will try to detect the provider. You can turn off auto-discovery for Exchange accounts by specifying the `exchange_server_host`.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Notice about POSTing to /connect/authorize\",\n \"body\": \"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!)\"\n}\n[/block]","isReference":true,"next":{"description":"","pages":[]},"slug":"connectauthorize","category":"5e41e73d960b09003ca3596c","parentDoc":"5e41e73d960b09003ca35996","project":"59245c10200df13100c88563","updates":["5aa69cf5b57adf002c23337b","5aa69cfb5a9d650012f35a85","5e5190f9ba6b50003c47a83a"],"createdAt":"2017-05-23T16:50:43.978Z","order":0,"title":"/connect/authorize","user":"5f2067586dda9a0045009159","updatedAt":"2020-10-08T14:39:42.700Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.262Z","tutorials":[],"swagger":{"path":"/connect/authorize"}},{"_id":"5e41e73d960b09003ca35993","githubsync":"","isReference":true,"updates":["5e310898717d9400612d1049","5f2b66dd3a0f87045036f69f"],"user":"5d404909c2f77c0012211f3e","slug":"connecttoken","body":"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`.\n\nYou can remove this account from your Nylas Cloud app in the Nylas API console.\n[block:callout]\n{\n \"type\": \"danger\",\n \"body\": \"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 JS code should securely send the received code in the previous step to your web app, which in turn makes the request to `/connect/token`.\",\n \"title\": \"Never send your client secret to a browser!\"\n}\n[/block]","category":"5e41e73d960b09003ca3596c","excerpt":"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.","hidden":false,"link_external":false,"parentDoc":"5e41e73d960b09003ca35996","title":"/connect/token","type":"endpoint","next":{"pages":[],"description":""},"order":1,"sync_unique":"","version":"5e41e73d960b09003ca35a9b","__v":22,"api":{"auth":"never","examples":{"codes":[{"code":"POST /connect/token HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n{\n \"client_id\": \"95fm****\",\n \"client_secret\": \"5s827****\",\n \"code\": \"fZztR****\"\n}\n\n","language":"http"},{"code":"curl -X POST \"https://api.nylas.com/connect/token\" -d '{\n \"client_id\": \"{client-id}\",\n \"client_secret\": \"{client-secret}\",\n \"code\": \"{nylas_code}\"\n}'\n","language":"curl"},{"code":"from nylas import APIClient\n\n# Create a client that has access to your Nylas app.\nnylas_app = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Get an access token that grants access to user data and functionality.\n# You need to generate a one-time-use code via Nylas to pass to this function.\n# See: https://docs.nylas.com/reference#connectauthorize\nACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}')\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Now you have a Nylas client object that has access to user data and functionality\nprint(nylas.account)","language":"python","name":"Python SDK"},{"code":"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)","language":"ruby","name":"Ruby SDK"},{"code":"// The following examples will return a Promise, which resolves to a Nylas account, complete with account id and access token.\n// This access token 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// First, you need to generate a one-time-use code via Nylas\n// See: https://docs.nylas.com/reference#connectauthorize\nlet access_code;\n\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}).then(resp => access_code = resp.code);\n\n// Use this code to connect the account to your Nylas Application\nlet account;\nNylas.connect.token(access_code).then(resp => account = resp);\n\n// Use the account's access token to get a Nylas client with access to the account's data and functionality\nconst nylas = Nylas.with(account.access_token);\nnylas.calendars.list().then(resp => console.log(resp));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.NativeAuthentication;\n\n\npublic class NylasExamples {\n public static void nativeTokenExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n // Create a client that has access to your Nylas app.\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n NativeAuthentication authentication = application.nativeAuthentication();\n\n // Get an access token that grants access to user data and functionality.\n // You need to generate a one-time-use code via Nylas to pass to this function.\n // See: https://docs.nylas.com/reference#connectauthorize\n String accessToken = authentication.fetchToken(\"{code}\").getAccessToken();\n\n // Now you have a Nylas client object that has access to user data and functionality\n NylasAccount account = nylas.account(accessToken);\n }\n}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your client ID from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3fb"},{"name":"client_secret","type":"string","default":"","desc":"Your client secret from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3fa"},{"name":"code","type":"string","default":"","desc":"The value returned from calling `/connect/authorize`.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3f9"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"access_token\": \"token\",\n \"account_id\": \"account-id\",\n \"billing_state\": \"paid\",\n \"email_address\": \"nyla@nylas.com\",\n \"id\": \"id\",\n \"linked_at\": 1563496685,\n \"name\": \"Nyla The Cheeta\",\n \"object\": \"account\",\n \"organization_unit\": \"label\",\n \"provider\": \"google\",\n \"sync_state\": \"running\"\n}","name":""},{"language":"json","code":"{}","name":"","status":400}]},"url":"/connect/token","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-23T20:04:01.374Z","link_url":"","project":"59245c10200df13100c88563","updatedAt":"2019-12-10T15:59:09.756Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T20:09:20.253Z","tutorials":[],"swagger":{"path":"/connect/token"}}],"childrenPages":[{"_id":"5e41e73d960b09003ca35992","sync_unique":"","type":"endpoint","api":{"auth":"never","examples":{"codes":[{"name":"cURL","language":"curl","code":"# The following examples will return 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\n# Authenticate Google Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"gmail\",\n \"settings\": {\n \"google_client_id\": \"{google_api_client_id}\",\n \"google_client_secret\": \"{geoogle_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 Google Account using a Service Account\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@gmail.com\", # Account to be authenticated\n \"provider\": \"gmail\",\n \"settings\": {\n \"service_account_json\": { # Service account credentials\n \"type\": \"service_account\",\n \"project_id\": \"my-google-app-123456\",\n \"private_key_id\": \"68915b4e55baac9191dd32e0be784687c6873b14\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIE....fZ1F8=\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"test-service-account@my-google-app-123456.iam.gserviceaccount.com\",\n \"client_id\": \"10569134234239528168761\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40my-google-app-123456.iam.gserviceaccount.com\"\n }\n \"scopes\": \"calendar\"\n}'\n\n# Authenticate Office365 Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\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\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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 \"exchange_server_host\": \"exchange.nylas.com\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate Exchange Account using a Service Account via Password\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\", # Account to authenticate\n \"provider\": \"exchange\",\n \"settings\": {\n \"username\": \"username\", # Service account username\n \"password\": \"password\", # Service account password\n \"service_account\": true\n }\n \"scopes\": \"calendar.read_only\"\n}'\n\n# Authenticate Exchange Account using a Service Account via OAuth\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\", # Account to authenticate\n \"provider\": \"exchange\",\n \"settings\": {\n \"microsoft_client_id\": \"{microsoft_client_id}\",\n \"microsoft_client_secret\": \"{microsoft_client_secret}\",\n \"microsoft_refresh_token\": \"{microsoft_refresh_token}\", # Service account refresh token!\n \"redirect_uri\": \"https://example.com/redirect\",\n \"service_account\": true\n },\n \"scopes\": \"calendar\"\n}'\n\n# Authenticate Outlook Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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 \"exchange_server_host\": \"eas.outlook.com\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate known IMAP providers\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@aol.com\",\n \"provider\": \"aol\",\n \"settings\": {\n \"password\": \"MakeEmailSuckLess\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate a generic IMAP provider\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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.net\",\n \"smtp_port\": 587,\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}'\n\n# Virtual Calendars\n\ncurl --location --request POST 'https://api.nylas.com/connect/authorize' \\\n --data-raw '{\n \"client_id\": \"9df4ff17888f4729ad4e1463d2547d\",\n \"provider\": \"nylas\",\n \"scopes\": \"calendar\", \n \"email\": \"virtual_account_unique_id\",\n \"name\": \"Virtual Calendar\",\n \"settings\": {}\n }'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nimport requests\n\n# Create a client that has access to your Nylas app.\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Authenticate Gmail Accounts\ngmail_authentication = {\n # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-gmail\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"gmail\",\n \"settings\": { # See the Example above to learn more about these values\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,calendar,contacts\"\n}\n\n# Post the authentication payload to Nylas.\nnylas_authorization = requests.post(\n \"https://api.nylas.com/connect/authorize\", json=gmail_authentication\n)\n\n# This code can be exchanged for an account access token\nnylas_code = nylas_authorization.json()[\"code\"]\n\n# -------------------------------------------\n# The remainder contains examples of how to authenticate other types of accounts\n\n# Authenticate Exchange Accounts\nexchange_authentication = {\n # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-exchange\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"exchange\",\n \"settings\": {\n \"username\": \"nyla@exchange_server.com\",\n \"password\": \"MakeEmailSuckLess\",\n \"eas_server_host\": \"exchange.your_server.com\"\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate an Outlook Account\noutlook_authentication = {\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@outlook.com\",\n \"provider\": \"outlook\",\n \"settings\": { # Uses the same format as Exchange Servers\n \"username\": \"nyla@outlook.com\",\n \"password\": \"MakeEmailSuckLess\",\n \"eas_server_host\": \"outlook.com\"\n\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate an account from a known IMAP provider\nknown_imap_authentication = {\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@yahoo.com\",\n \"provider\": \"yahoo\", # can also be aol, icloud, or hotmail\n \"settings\": {\n \"password\": \"MakeEmailSuckLess\"\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate any other IMAP account\ngeneric_imap_authentication = {\n \"client_id\": CLIENT_ID,\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\": 12345,\n \"imap_username\": \"nyla\",\n \"imap_password\": \"MakeEmailSuckLess\",\n \"smtp_host\": \"smtp.nylas.net\",\n \"smtp_port\": 12346,\n \"smtp_username\": \"nyla\",\n \"smtp_password\": \"MakeEmailSuckLess\",\n \"ssl_required\": 'true'\n },\n \"scopes\": \"email,calendar,contacts\"\n}"},{"name":"Node.js SDK","language":"javascript","code":"// 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});"},{"code":"nylas_token = api.authenticate(\n name: auth_hash[:info][:name], \n email_address: auth_hash[:info][:email],\n provider: :gmail,\n settings: {\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 }\n)\n","language":"ruby","name":"Ruby SDK"},{"name":"Java SDK","language":"java","code":"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}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your client ID from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592468630f7f402f001618a1"},{"name":"name","type":"string","default":"","desc":"The full name of the user (e.g. “John Snow”).","required":true,"in":"body","ref":"","_id":"592468630f7f402f001618a0"},{"name":"email_address","type":"string","default":"","desc":"The user’s email address. If you are creating a [Virtual Calendar](https://docs.nylas.com/docs/how-to-use-virtual-calendars#step-2-create-a-virtual-calendar), use a `virtual_account_unique_id`.","required":true,"in":"body","ref":"","_id":"592468630f7f402f0016189f"},{"name":"provider","type":"string","default":"","desc":"One of `gmail`, `yahoo`, `exchange`, `outlook`, `imap`, `icloud`, `hotmail`, `aol`, or `office365`. Note that the format of the settings object below is dependent upon this field. If your provider isn't listed, use the generic settings","required":true,"in":"body","ref":"","_id":"592468630f7f402f0016189e"},{"name":"settings","type":"object","default":"","desc":"Dependent on the provider to which you are connecting. See [provider specific settings](#section-provider-specific-settings).","required":true,"in":"body","ref":"google-settings","_id":"5924a305aeb5eb0f0093e2cc"},{"name":"scopes","type":"string","default":"","desc":"Any combination of supported [authentication scopes](doc:authentication-scopes). Service accounts only support calendar scopes.","required":false,"in":"body","ref":"","_id":"5bfc75a40a284b0021524466"}],"results":{"codes":[{"status":200,"language":"json","code":"{\"code\": \"one-time-use-code\"}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Please include the missing fields\", \n \"type\": \"auth_error\", \n \"missing_fields\": [\"provider\"], \n \"error\": \"Missing fields.\"\n}","name":"Missing provider"},{"status":403,"language":"json","code":"{\n\t\"message\": \"Specific info about the error included here\",\n \"type\": \"auth_error\",\n \"error\": \"authentication_failed\"\n}"}]},"url":"/connect/authorize","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"This endpoint is where your application sends mailbox credentials to verify they are correct. This begins the connection process.\n\nA 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.\n\nEach provider requires different `settings`. Review the [Provider Specific Settings](#section-provider-specific-settings) for more information.","githubsync":"","hidden":false,"link_external":false,"link_url":"","version":"5e41e73d960b09003ca35a9b","__v":93,"body":"# Provider Specific Settings\n\nDepending on the `provider` body parameter you include, you must send a different `settings` object in your request to `/connect/authorize`. These are the possible `settings` objects you may need to include:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"\\\"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 \"language\": \"json\",\n \"name\": \"Example Google Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"username\\\": \\\"erlich@aviato.com\\\",\\n \\\"password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"exchange_server_host\\\": \\\"exchange.aviato.com\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Exchange Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n\\t\\\"password\\\": \\\"makingtheworldabetterplace\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Known IMAP Provider Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"imap_host\\\": \\\"imap.aviato.com\\\",\\n \\\"imap_port\\\": 12345,\\n \\\"imap_username\\\": \\\"erlich.bachman\\\",\\n \\\"imap_password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"smtp_host\\\": \\\"smtp.aviato.net\\\",\\n \\\"smtp_port\\\": 12346,\\n \\\"smtp_username\\\": \\\"erlich.bachman\\\",\\n \\\"smtp_password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"ssl_required\\\": true\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Generic IMAP Provider Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"microsoft_client_id\\\": \\\"\\\",\\n \\\"microsoft_client_secret\\\": \\t\\\"\\\",\\n \\\"microsoft_refresh_token\\\": \\t\\\"\\\",\\n \\\"redirect_uri\\\": \\\"\\\" # Redirect URI that the was originally used to get the refresh token\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Office365 Settings\"\n },\n {\n \"code\": \"# Using OAuth authentication\\n\\\"settings\\\": {\\n \\\"microsoft_client_id\\\": \\\"\\\",\\n \\\"microsoft_client_secret\\\": \\t\\\"\\\",\\n \\\"microsoft_refresh_token\\\": \\t\\\"\\\",\\n \\\"redirect_uri\\\": \\\"\\\", # Redirect URI that the was originally used to get the refresh token\\n \\\"service_account\\\": true\\n}\\n\\n# Using password authentication\\n\\\"settings\\\": {\\n \\\"username\\\": \\\"service_account@example.com\\\",\\n \\\"password\\\": \\\"serviceaccountpassword\\\",\\n \\\"service_account\\\": true\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Office365 Service Account Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n\\t\\\"service_account_json\\\": {\\n \\t\\\"type\\\": \\\"service_account\\\",\\n \\t\\\"project_id\\\": \\\"metal-figure-239116\\\",\\n \\\"private_key_id\\\": \\\"68ac9191dd3468915b4e52e0be785ba7c6873b14\\\",\\n \\t\\\"private_key\\\": \\\"-----BEGIN PRIVATE KEY-----\\\\nMI...J7tF8=\\\\n-----END PRIVATE KEY-----\\\\n\\\",\\n \\\"client_email\\\": \\\"test-service-account@metal-figure-239116.iam.gserviceaccount.com\\\",\\n \\\"client_id\\\": \\\"105691998485416876281\\\",\\n \\\"auth_uri\\\": \\\"https://accounts.google.com/o/oauth2/auth\\\",\\n \\\"token_uri\\\": \\\"https://oauth2.googleapis.com/token\\\",\\n \\\"auth_provider_x509_cert_url\\\": \\\"https://www.googleapis.com/oauth2/v1/certs\\\",\\n \\\"client_x509_cert_url\\\": \\\"https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40metal-figure-239116.iam.gserviceaccount.com\\\"\\n }\\n}\",\n \"language\": \"json\",\n \"name\": \"Example G Suite Service Account Settings\"\n }\n ]\n}\n[/block]\n## Exchange Auto-discovery\n\nNylas will try to detect the provider. You can turn off auto-discovery for Exchange accounts by specifying the `exchange_server_host`.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Notice about POSTing to /connect/authorize\",\n \"body\": \"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!)\"\n}\n[/block]","isReference":true,"next":{"description":"","pages":[]},"slug":"connectauthorize","category":"5e41e73d960b09003ca3596c","parentDoc":"5e41e73d960b09003ca35996","project":"59245c10200df13100c88563","updates":["5aa69cf5b57adf002c23337b","5aa69cfb5a9d650012f35a85","5e5190f9ba6b50003c47a83a"],"createdAt":"2017-05-23T16:50:43.978Z","order":0,"title":"/connect/authorize","user":"5f2067586dda9a0045009159","updatedAt":"2020-10-08T14:39:42.700Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.262Z","tutorials":[],"swagger":{"path":"/connect/authorize"}},{"_id":"5e41e73d960b09003ca35993","githubsync":"","isReference":true,"updates":["5e310898717d9400612d1049","5f2b66dd3a0f87045036f69f"],"user":"5d404909c2f77c0012211f3e","slug":"connecttoken","body":"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`.\n\nYou can remove this account from your Nylas Cloud app in the Nylas API console.\n[block:callout]\n{\n \"type\": \"danger\",\n \"body\": \"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 JS code should securely send the received code in the previous step to your web app, which in turn makes the request to `/connect/token`.\",\n \"title\": \"Never send your client secret to a browser!\"\n}\n[/block]","category":"5e41e73d960b09003ca3596c","excerpt":"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.","hidden":false,"link_external":false,"parentDoc":"5e41e73d960b09003ca35996","title":"/connect/token","type":"endpoint","next":{"pages":[],"description":""},"order":1,"sync_unique":"","version":"5e41e73d960b09003ca35a9b","__v":22,"api":{"auth":"never","examples":{"codes":[{"code":"POST /connect/token HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n{\n \"client_id\": \"95fm****\",\n \"client_secret\": \"5s827****\",\n \"code\": \"fZztR****\"\n}\n\n","language":"http"},{"code":"curl -X POST \"https://api.nylas.com/connect/token\" -d '{\n \"client_id\": \"{client-id}\",\n \"client_secret\": \"{client-secret}\",\n \"code\": \"{nylas_code}\"\n}'\n","language":"curl"},{"code":"from nylas import APIClient\n\n# Create a client that has access to your Nylas app.\nnylas_app = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Get an access token that grants access to user data and functionality.\n# You need to generate a one-time-use code via Nylas to pass to this function.\n# See: https://docs.nylas.com/reference#connectauthorize\nACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}')\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Now you have a Nylas client object that has access to user data and functionality\nprint(nylas.account)","language":"python","name":"Python SDK"},{"code":"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)","language":"ruby","name":"Ruby SDK"},{"code":"// The following examples will return a Promise, which resolves to a Nylas account, complete with account id and access token.\n// This access token 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// First, you need to generate a one-time-use code via Nylas\n// See: https://docs.nylas.com/reference#connectauthorize\nlet access_code;\n\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}).then(resp => access_code = resp.code);\n\n// Use this code to connect the account to your Nylas Application\nlet account;\nNylas.connect.token(access_code).then(resp => account = resp);\n\n// Use the account's access token to get a Nylas client with access to the account's data and functionality\nconst nylas = Nylas.with(account.access_token);\nnylas.calendars.list().then(resp => console.log(resp));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.NativeAuthentication;\n\n\npublic class NylasExamples {\n public static void nativeTokenExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n // Create a client that has access to your Nylas app.\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n NativeAuthentication authentication = application.nativeAuthentication();\n\n // Get an access token that grants access to user data and functionality.\n // You need to generate a one-time-use code via Nylas to pass to this function.\n // See: https://docs.nylas.com/reference#connectauthorize\n String accessToken = authentication.fetchToken(\"{code}\").getAccessToken();\n\n // Now you have a Nylas client object that has access to user data and functionality\n NylasAccount account = nylas.account(accessToken);\n }\n}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your client ID from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3fb"},{"name":"client_secret","type":"string","default":"","desc":"Your client secret from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3fa"},{"name":"code","type":"string","default":"","desc":"The value returned from calling `/connect/authorize`.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3f9"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"access_token\": \"token\",\n \"account_id\": \"account-id\",\n \"billing_state\": \"paid\",\n \"email_address\": \"nyla@nylas.com\",\n \"id\": \"id\",\n \"linked_at\": 1563496685,\n \"name\": \"Nyla The Cheeta\",\n \"object\": \"account\",\n \"organization_unit\": \"label\",\n \"provider\": \"google\",\n \"sync_state\": \"running\"\n}","name":""},{"language":"json","code":"{}","name":"","status":400}]},"url":"/connect/token","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-23T20:04:01.374Z","link_url":"","project":"59245c10200df13100c88563","updatedAt":"2019-12-10T15:59:09.756Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T20:09:20.253Z","tutorials":[],"swagger":{"path":"/connect/token"}}]},{"_id":"5e41e73d960b09003ca35992","sync_unique":"","type":"endpoint","api":{"auth":"never","examples":{"codes":[{"name":"cURL","language":"curl","code":"# The following examples will return 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\n# Authenticate Google Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"gmail\",\n \"settings\": {\n \"google_client_id\": \"{google_api_client_id}\",\n \"google_client_secret\": \"{geoogle_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 Google Account using a Service Account\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@gmail.com\", # Account to be authenticated\n \"provider\": \"gmail\",\n \"settings\": {\n \"service_account_json\": { # Service account credentials\n \"type\": \"service_account\",\n \"project_id\": \"my-google-app-123456\",\n \"private_key_id\": \"68915b4e55baac9191dd32e0be784687c6873b14\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIE....fZ1F8=\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"test-service-account@my-google-app-123456.iam.gserviceaccount.com\",\n \"client_id\": \"10569134234239528168761\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40my-google-app-123456.iam.gserviceaccount.com\"\n }\n \"scopes\": \"calendar\"\n}'\n\n# Authenticate Office365 Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\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\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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 \"exchange_server_host\": \"exchange.nylas.com\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate Exchange Account using a Service Account via Password\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\", # Account to authenticate\n \"provider\": \"exchange\",\n \"settings\": {\n \"username\": \"username\", # Service account username\n \"password\": \"password\", # Service account password\n \"service_account\": true\n }\n \"scopes\": \"calendar.read_only\"\n}'\n\n# Authenticate Exchange Account using a Service Account via OAuth\ncurl -X POST https://api.nylas.com/connect/authorize -d '{ \n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@nylas.com\", # Account to authenticate\n \"provider\": \"exchange\",\n \"settings\": {\n \"microsoft_client_id\": \"{microsoft_client_id}\",\n \"microsoft_client_secret\": \"{microsoft_client_secret}\",\n \"microsoft_refresh_token\": \"{microsoft_refresh_token}\", # Service account refresh token!\n \"redirect_uri\": \"https://example.com/redirect\",\n \"service_account\": true\n },\n \"scopes\": \"calendar\"\n}'\n\n# Authenticate Outlook Accounts\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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 \"exchange_server_host\": \"eas.outlook.com\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate known IMAP providers\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\n \"name\": \"Nyla the Cheetah\",\n \"email_address\": \"nyla@aol.com\",\n \"provider\": \"aol\",\n \"settings\": {\n \"password\": \"MakeEmailSuckLess\"\n },\n \"scopes\": \"email.read_only,calendar.read_only,contacts.read_only\"\n}'\n\n# Authenticate a generic IMAP provider\ncurl -X POST https://api.nylas.com/connect/authorize -d '{\n \"client_id\": \"nylas_client_id\",\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.net\",\n \"smtp_port\": 587,\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}'\n\n# Virtual Calendars\n\ncurl --location --request POST 'https://api.nylas.com/connect/authorize' \\\n --data-raw '{\n \"client_id\": \"9df4ff17888f4729ad4e1463d2547d\",\n \"provider\": \"nylas\",\n \"scopes\": \"calendar\", \n \"email\": \"virtual_account_unique_id\",\n \"name\": \"Virtual Calendar\",\n \"settings\": {}\n }'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nimport requests\n\n# Create a client that has access to your Nylas app.\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Authenticate Gmail Accounts\ngmail_authentication = {\n # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-gmail\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"gmail\",\n \"settings\": { # See the Example above to learn more about these values\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,calendar,contacts\"\n}\n\n# Post the authentication payload to Nylas.\nnylas_authorization = requests.post(\n \"https://api.nylas.com/connect/authorize\", json=gmail_authentication\n)\n\n# This code can be exchanged for an account access token\nnylas_code = nylas_authorization.json()[\"code\"]\n\n# -------------------------------------------\n# The remainder contains examples of how to authenticate other types of accounts\n\n# Authenticate Exchange Accounts\nexchange_authentication = {\n # Example: https://github.com/nylas/nylas-python/tree/master/examples/native-authentication-exchange\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@nylas.com\",\n \"provider\": \"exchange\",\n \"settings\": {\n \"username\": \"nyla@exchange_server.com\",\n \"password\": \"MakeEmailSuckLess\",\n \"eas_server_host\": \"exchange.your_server.com\"\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate an Outlook Account\noutlook_authentication = {\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@outlook.com\",\n \"provider\": \"outlook\",\n \"settings\": { # Uses the same format as Exchange Servers\n \"username\": \"nyla@outlook.com\",\n \"password\": \"MakeEmailSuckLess\",\n \"eas_server_host\": \"outlook.com\"\n\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate an account from a known IMAP provider\nknown_imap_authentication = {\n \"client_id\": CLIENT_ID,\n \"name\": \"Nyla The Cheetah\",\n \"email_address\": \"nyla@yahoo.com\",\n \"provider\": \"yahoo\", # can also be aol, icloud, or hotmail\n \"settings\": {\n \"password\": \"MakeEmailSuckLess\"\n },\n \"scopes\": \"email,calendar,contacts\"\n}\n\n# Authenticate any other IMAP account\ngeneric_imap_authentication = {\n \"client_id\": CLIENT_ID,\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\": 12345,\n \"imap_username\": \"nyla\",\n \"imap_password\": \"MakeEmailSuckLess\",\n \"smtp_host\": \"smtp.nylas.net\",\n \"smtp_port\": 12346,\n \"smtp_username\": \"nyla\",\n \"smtp_password\": \"MakeEmailSuckLess\",\n \"ssl_required\": 'true'\n },\n \"scopes\": \"email,calendar,contacts\"\n}"},{"name":"Node.js SDK","language":"javascript","code":"// 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});"},{"code":"nylas_token = api.authenticate(\n name: auth_hash[:info][:name], \n email_address: auth_hash[:info][:email],\n provider: :gmail,\n settings: {\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 }\n)\n","language":"ruby","name":"Ruby SDK"},{"name":"Java SDK","language":"java","code":"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}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your client ID from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592468630f7f402f001618a1"},{"name":"name","type":"string","default":"","desc":"The full name of the user (e.g. “John Snow”).","required":true,"in":"body","ref":"","_id":"592468630f7f402f001618a0"},{"name":"email_address","type":"string","default":"","desc":"The user’s email address. If you are creating a [Virtual Calendar](https://docs.nylas.com/docs/how-to-use-virtual-calendars#step-2-create-a-virtual-calendar), use a `virtual_account_unique_id`.","required":true,"in":"body","ref":"","_id":"592468630f7f402f0016189f"},{"name":"provider","type":"string","default":"","desc":"One of `gmail`, `yahoo`, `exchange`, `outlook`, `imap`, `icloud`, `hotmail`, `aol`, or `office365`. Note that the format of the settings object below is dependent upon this field. If your provider isn't listed, use the generic settings","required":true,"in":"body","ref":"","_id":"592468630f7f402f0016189e"},{"name":"settings","type":"object","default":"","desc":"Dependent on the provider to which you are connecting. See [provider specific settings](#section-provider-specific-settings).","required":true,"in":"body","ref":"google-settings","_id":"5924a305aeb5eb0f0093e2cc"},{"name":"scopes","type":"string","default":"","desc":"Any combination of supported [authentication scopes](doc:authentication-scopes). Service accounts only support calendar scopes.","required":false,"in":"body","ref":"","_id":"5bfc75a40a284b0021524466"}],"results":{"codes":[{"status":200,"language":"json","code":"{\"code\": \"one-time-use-code\"}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Please include the missing fields\", \n \"type\": \"auth_error\", \n \"missing_fields\": [\"provider\"], \n \"error\": \"Missing fields.\"\n}","name":"Missing provider"},{"status":403,"language":"json","code":"{\n\t\"message\": \"Specific info about the error included here\",\n \"type\": \"auth_error\",\n \"error\": \"authentication_failed\"\n}"}]},"url":"/connect/authorize","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"This endpoint is where your application sends mailbox credentials to verify they are correct. This begins the connection process.\n\nA 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.\n\nEach provider requires different `settings`. Review the [Provider Specific Settings](#section-provider-specific-settings) for more information.","githubsync":"","hidden":false,"link_external":false,"link_url":"","version":"5e41e73d960b09003ca35a9b","__v":93,"body":"# Provider Specific Settings\n\nDepending on the `provider` body parameter you include, you must send a different `settings` object in your request to `/connect/authorize`. These are the possible `settings` objects you may need to include:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"\\\"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 \"language\": \"json\",\n \"name\": \"Example Google Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"username\\\": \\\"erlich@aviato.com\\\",\\n \\\"password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"exchange_server_host\\\": \\\"exchange.aviato.com\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Exchange Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n\\t\\\"password\\\": \\\"makingtheworldabetterplace\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Known IMAP Provider Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"imap_host\\\": \\\"imap.aviato.com\\\",\\n \\\"imap_port\\\": 12345,\\n \\\"imap_username\\\": \\\"erlich.bachman\\\",\\n \\\"imap_password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"smtp_host\\\": \\\"smtp.aviato.net\\\",\\n \\\"smtp_port\\\": 12346,\\n \\\"smtp_username\\\": \\\"erlich.bachman\\\",\\n \\\"smtp_password\\\": \\\"makingtheworldabetterplace\\\",\\n \\\"ssl_required\\\": true\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Generic IMAP Provider Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n \\\"microsoft_client_id\\\": \\\"\\\",\\n \\\"microsoft_client_secret\\\": \\t\\\"\\\",\\n \\\"microsoft_refresh_token\\\": \\t\\\"\\\",\\n \\\"redirect_uri\\\": \\\"\\\" # Redirect URI that the was originally used to get the refresh token\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Office365 Settings\"\n },\n {\n \"code\": \"# Using OAuth authentication\\n\\\"settings\\\": {\\n \\\"microsoft_client_id\\\": \\\"\\\",\\n \\\"microsoft_client_secret\\\": \\t\\\"\\\",\\n \\\"microsoft_refresh_token\\\": \\t\\\"\\\",\\n \\\"redirect_uri\\\": \\\"\\\", # Redirect URI that the was originally used to get the refresh token\\n \\\"service_account\\\": true\\n}\\n\\n# Using password authentication\\n\\\"settings\\\": {\\n \\\"username\\\": \\\"service_account@example.com\\\",\\n \\\"password\\\": \\\"serviceaccountpassword\\\",\\n \\\"service_account\\\": true\\n}\",\n \"language\": \"json\",\n \"name\": \"Example Office365 Service Account Settings\"\n },\n {\n \"code\": \"\\\"settings\\\": {\\n\\t\\\"service_account_json\\\": {\\n \\t\\\"type\\\": \\\"service_account\\\",\\n \\t\\\"project_id\\\": \\\"metal-figure-239116\\\",\\n \\\"private_key_id\\\": \\\"68ac9191dd3468915b4e52e0be785ba7c6873b14\\\",\\n \\t\\\"private_key\\\": \\\"-----BEGIN PRIVATE KEY-----\\\\nMI...J7tF8=\\\\n-----END PRIVATE KEY-----\\\\n\\\",\\n \\\"client_email\\\": \\\"test-service-account@metal-figure-239116.iam.gserviceaccount.com\\\",\\n \\\"client_id\\\": \\\"105691998485416876281\\\",\\n \\\"auth_uri\\\": \\\"https://accounts.google.com/o/oauth2/auth\\\",\\n \\\"token_uri\\\": \\\"https://oauth2.googleapis.com/token\\\",\\n \\\"auth_provider_x509_cert_url\\\": \\\"https://www.googleapis.com/oauth2/v1/certs\\\",\\n \\\"client_x509_cert_url\\\": \\\"https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40metal-figure-239116.iam.gserviceaccount.com\\\"\\n }\\n}\",\n \"language\": \"json\",\n \"name\": \"Example G Suite Service Account Settings\"\n }\n ]\n}\n[/block]\n## Exchange Auto-discovery\n\nNylas will try to detect the provider. You can turn off auto-discovery for Exchange accounts by specifying the `exchange_server_host`.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Notice about POSTing to /connect/authorize\",\n \"body\": \"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!)\"\n}\n[/block]","isReference":true,"next":{"description":"","pages":[]},"slug":"connectauthorize","category":"5e41e73d960b09003ca3596c","parentDoc":"5e41e73d960b09003ca35996","project":"59245c10200df13100c88563","updates":["5aa69cf5b57adf002c23337b","5aa69cfb5a9d650012f35a85","5e5190f9ba6b50003c47a83a"],"createdAt":"2017-05-23T16:50:43.978Z","order":0,"title":"/connect/authorize","user":"5f2067586dda9a0045009159","updatedAt":"2020-10-08T14:39:42.700Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.262Z","tutorials":[],"swagger":{"path":"/connect/authorize"}},{"_id":"5e41e73d960b09003ca35993","githubsync":"","isReference":true,"updates":["5e310898717d9400612d1049","5f2b66dd3a0f87045036f69f"],"user":"5d404909c2f77c0012211f3e","slug":"connecttoken","body":"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`.\n\nYou can remove this account from your Nylas Cloud app in the Nylas API console.\n[block:callout]\n{\n \"type\": \"danger\",\n \"body\": \"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 JS code should securely send the received code in the previous step to your web app, which in turn makes the request to `/connect/token`.\",\n \"title\": \"Never send your client secret to a browser!\"\n}\n[/block]","category":"5e41e73d960b09003ca3596c","excerpt":"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.","hidden":false,"link_external":false,"parentDoc":"5e41e73d960b09003ca35996","title":"/connect/token","type":"endpoint","next":{"pages":[],"description":""},"order":1,"sync_unique":"","version":"5e41e73d960b09003ca35a9b","__v":22,"api":{"auth":"never","examples":{"codes":[{"code":"POST /connect/token HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n{\n \"client_id\": \"95fm****\",\n \"client_secret\": \"5s827****\",\n \"code\": \"fZztR****\"\n}\n\n","language":"http"},{"code":"curl -X POST \"https://api.nylas.com/connect/token\" -d '{\n \"client_id\": \"{client-id}\",\n \"client_secret\": \"{client-secret}\",\n \"code\": \"{nylas_code}\"\n}'\n","language":"curl"},{"code":"from nylas import APIClient\n\n# Create a client that has access to your Nylas app.\nnylas_app = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Get an access token that grants access to user data and functionality.\n# You need to generate a one-time-use code via Nylas to pass to this function.\n# See: https://docs.nylas.com/reference#connectauthorize\nACCESS_TOKEN = nylas_app.token_for_code('{code_from_nylas}')\n\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Now you have a Nylas client object that has access to user data and functionality\nprint(nylas.account)","language":"python","name":"Python SDK"},{"code":"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)","language":"ruby","name":"Ruby SDK"},{"code":"// The following examples will return a Promise, which resolves to a Nylas account, complete with account id and access token.\n// This access token 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// First, you need to generate a one-time-use code via Nylas\n// See: https://docs.nylas.com/reference#connectauthorize\nlet access_code;\n\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}).then(resp => access_code = resp.code);\n\n// Use this code to connect the account to your Nylas Application\nlet account;\nNylas.connect.token(access_code).then(resp => account = resp);\n\n// Use the account's access token to get a Nylas client with access to the account's data and functionality\nconst nylas = Nylas.with(account.access_token);\nnylas.calendars.list().then(resp => console.log(resp));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasAccount;\nimport com.nylas.NativeAuthentication;\n\n\npublic class NylasExamples {\n public static void nativeTokenExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n // Create a client that has access to your Nylas app.\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n NativeAuthentication authentication = application.nativeAuthentication();\n\n // Get an access token that grants access to user data and functionality.\n // You need to generate a one-time-use code via Nylas to pass to this function.\n // See: https://docs.nylas.com/reference#connectauthorize\n String accessToken = authentication.fetchToken(\"{code}\").getAccessToken();\n\n // Now you have a Nylas client object that has access to user data and functionality\n NylasAccount account = nylas.account(accessToken);\n }\n}"}]},"method":"post","params":[{"name":"client_id","type":"string","default":"","desc":"Your client ID from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3fb"},{"name":"client_secret","type":"string","default":"","desc":"Your client secret from the Nylas Developer console.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3fa"},{"name":"code","type":"string","default":"","desc":"The value returned from calling `/connect/authorize`.","required":true,"in":"body","ref":"","_id":"592495b158d2d40f0030f3f9"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"access_token\": \"token\",\n \"account_id\": \"account-id\",\n \"billing_state\": \"paid\",\n \"email_address\": \"nyla@nylas.com\",\n \"id\": \"id\",\n \"linked_at\": 1563496685,\n \"name\": \"Nyla The Cheeta\",\n \"object\": \"account\",\n \"organization_unit\": \"label\",\n \"provider\": \"google\",\n \"sync_state\": \"running\"\n}","name":""},{"language":"json","code":"{}","name":"","status":400}]},"url":"/connect/token","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-23T20:04:01.374Z","link_url":"","project":"59245c10200df13100c88563","updatedAt":"2019-12-10T15:59:09.756Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T20:09:20.253Z","tutorials":[],"swagger":{"path":"/connect/token"}},{"_id":"5e41e73d960b09003ca35999","version":"5e41e73d960b09003ca35a9b","excerpt":"","githubsync":"","order":0,"project":"59245c10200df13100c88563","next":{"pages":[],"description":""},"parentDoc":null,"slug":"accounts","title":"Accounts","__v":5,"api":{"method":"get","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"","auth":"required","examples":{"codes":[]}},"body":"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.\n\n## The Account object\n\nResponses for the Account object are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|----|:----|\n| `id` | string | A globally unique object identifier. |\n| `object` | string | A string describing the type of object (value is `\"account\"`).\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `name` | string | The full name of the user, used as the default `\"from\"` name when sending mail. |\n| `email_address` | string | The canonical email address of the account. For Gmail accounts, this removes periods and plus suffixes. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `organization_unit` | string | Specify either `\"label\"` or `\"folder\"`, depending on the provider capabilities. |\n| `sync_state` | string | The syncing status of the account. See the [Sync status](ref:account-sync-status) documentation for possible values. |\n| `linked_at` | int32 | A Unix timestamp indicating when this account was originally connected to Nylas.\n\n\n## Folders vs. Labels\n\nMessages and threads in accounts can either be organized around folders, or around labels. This depends on the backend provider. For example, Gmail uses labels, whereas Yahoo! Mail uses folders.\n\nLabels and folders have fundamentally different semantics, and these are preserved in the API. The core difference is that a message can have more than one label, as opposed to only having one folder.\n\nThe `organization_unit` attribute on the account object indicates whether the account supports folders or labels. The possible values of this attribute are `folder` or `label`. For more details on format and usage, see the related documentation for [Folders](ref:folders) and [Labels](ref:labels).","isReference":true,"type":"basic","updates":["5960155aec222f001b884124","5e4edf23f70a6f00576dfe17","5e4ee7e48b3e25006be1eac3","5e4fb69610419a0038e311ee","5f0bf40313f50d0038b518af"],"hidden":false,"link_external":false,"link_url":"","user":"59245bff200df13100c88562","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-23T22:40:19.946Z","sync_unique":"","updatedAt":"2019-07-02T23:21:24.284Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-12T23:58:38.048Z","tutorials":[],"children":[{"_id":"5e41e73d960b09003ca3599a","user":"5f2067586dda9a0045009159","createdAt":"2017-05-23T22:46:01.083Z","excerpt":"An access token can be used to request information about the account it corresponds to. This includes information such as the end-user’s name, email address, and backend mailbox provider.","githubsync":"","hidden":false,"order":0,"parentDoc":"5e41e73d960b09003ca35999","type":"endpoint","__v":27,"category":"5e41e73d960b09003ca3596d","isReference":true,"slug":"account","sync_unique":"","title":"/account","body":"## Response\n\nReturns an [Accounts](ref:accounts#the-account-object) object.","link_url":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","updates":[],"api":{"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5a7361894842060020710a2e"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"account\",\n \"name\": \"Ben Bitdiddle\",\n \"email_address\": \"benbitdiddle@gmail.com\",\n \"provider\": \"gmail\",\n \"organization_unit\": \"label\",\n \t\"sync_state\": \"running\",\n \"linked_at\": 1470231381,\n}","name":""},{"code":"{}","name":"","status":400,"language":"json"}]},"url":"/account","auth":"required","examples":{"codes":[{"language":"http","code":"GET /account HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic SVNzc****\ncache-control: no-cache"},{"language":"curl","code":"curl -X GET \\\n https://api.nylas.com/account \\\n -H 'Authorization: Basic SVNz****' \\\n -H 'Content-Type: application/json' \\\n -H 'cache-control: no-cache'"},{"name":"Python SDK","language":"python","code":"nylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n \tACCESS_TOKEN\n)\naccount = nylas.account\n\n# The following attributes are available for the Account object\naccount.id\naccount.account_id\naccount.object\naccount.name\naccount.email_address\naccount.provider\naccount.organization_unit\naccount.sync_state\naccount.linked_at"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET,\n access_token: ACCESS_TOKEN\n)\n\naccount = nylas.current_account\n\n# The following attributes are available for the Account object\naccount.id\naccount.account_id\naccount.object\naccount.name\naccount.email_address\naccount.provider\naccount.organization_unit\naccount.sync_state\naccount.linked_at"},{"name":"Node.js SDK","language":"javascript","code":"nylas.account.get().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.object\naccount.name\naccount.emailAddress\naccount.provider\naccount.organizationUnit\naccount.syncState\naccount.linkedAt"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.AccountDetail;\nimport com.nylas.NylasClient;\n\npublic class DocExamples {\n public static void getAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n AccountDetail account = nylas.account(\"{ACCESS_TOKEN}\").fetchAccountByAccessToken();\n \n // The following attributes are available for the account object\n account.getId();\n account.getName();\n account.getEmailAddress();\n account.getProvider();\n account.getOrganizationUnit();\n account.getSyncState();\n account.getLinkedAt();\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"link_external":false,"version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-05-21T14:02:28.777Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.716Z","tutorials":[],"swagger":{"path":"/account"}},{"_id":"5e41e73d960b09003ca35a03","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca3596d","user":"597fb20c6ec952001e63f8f3","updates":["5f0bec1b3878440030713b16"],"next":{"pages":[],"description":""},"createdAt":"2017-09-06T18:56:25.255Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":1,"body":"The `sync_state` field for an account can have one of the following status values:\n\n| Status | Action required |\n| --- | --- |\n| `running` | The sync is successfully running. No action is required. |\n| `invalid` | There is an authentication failure with the mail server. Prompt the user to re-authorize. |\n| `stopped` | The sync is stopped. This can happen for a variety of reasons. If you are adding accounts beyond the limits of the free tier, some may be stopped until you upgrade your Nylas application. It can also occur when we encounter unexpected errors. These unexpected errors most commonly originate from incompatibilities with upstream providers or temporary outages. |\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Sync States\",\n \"body\": \"The `sync_state` for this individual account endpoint is a simplified set of values, relative to the `sync_state` that is available from the [Account Management sync state](ref:account-sync-status). We recommend using the Account Management API to get the best understanding of an account's health.\"\n}\n[/block]","excerpt":"","slug":"single-account-sync-states","type":"basic","title":"Single Account Sync States","__v":1,"parentDoc":"5e41e73d960b09003ca35999","updatedAt":"2019-06-14T19:52:58.721Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:11:39.760Z","tutorials":[]}],"childrenPages":[{"_id":"5e41e73d960b09003ca3599a","user":"5f2067586dda9a0045009159","createdAt":"2017-05-23T22:46:01.083Z","excerpt":"An access token can be used to request information about the account it corresponds to. This includes information such as the end-user’s name, email address, and backend mailbox provider.","githubsync":"","hidden":false,"order":0,"parentDoc":"5e41e73d960b09003ca35999","type":"endpoint","__v":27,"category":"5e41e73d960b09003ca3596d","isReference":true,"slug":"account","sync_unique":"","title":"/account","body":"## Response\n\nReturns an [Accounts](ref:accounts#the-account-object) object.","link_url":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","updates":[],"api":{"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5a7361894842060020710a2e"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"account\",\n \"name\": \"Ben Bitdiddle\",\n \"email_address\": \"benbitdiddle@gmail.com\",\n \"provider\": \"gmail\",\n \"organization_unit\": \"label\",\n \t\"sync_state\": \"running\",\n \"linked_at\": 1470231381,\n}","name":""},{"code":"{}","name":"","status":400,"language":"json"}]},"url":"/account","auth":"required","examples":{"codes":[{"language":"http","code":"GET /account HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic SVNzc****\ncache-control: no-cache"},{"language":"curl","code":"curl -X GET \\\n https://api.nylas.com/account \\\n -H 'Authorization: Basic SVNz****' \\\n -H 'Content-Type: application/json' \\\n -H 'cache-control: no-cache'"},{"name":"Python SDK","language":"python","code":"nylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n \tACCESS_TOKEN\n)\naccount = nylas.account\n\n# The following attributes are available for the Account object\naccount.id\naccount.account_id\naccount.object\naccount.name\naccount.email_address\naccount.provider\naccount.organization_unit\naccount.sync_state\naccount.linked_at"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET,\n access_token: ACCESS_TOKEN\n)\n\naccount = nylas.current_account\n\n# The following attributes are available for the Account object\naccount.id\naccount.account_id\naccount.object\naccount.name\naccount.email_address\naccount.provider\naccount.organization_unit\naccount.sync_state\naccount.linked_at"},{"name":"Node.js SDK","language":"javascript","code":"nylas.account.get().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.object\naccount.name\naccount.emailAddress\naccount.provider\naccount.organizationUnit\naccount.syncState\naccount.linkedAt"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.AccountDetail;\nimport com.nylas.NylasClient;\n\npublic class DocExamples {\n public static void getAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n AccountDetail account = nylas.account(\"{ACCESS_TOKEN}\").fetchAccountByAccessToken();\n \n // The following attributes are available for the account object\n account.getId();\n account.getName();\n account.getEmailAddress();\n account.getProvider();\n account.getOrganizationUnit();\n account.getSyncState();\n account.getLinkedAt();\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"link_external":false,"version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-05-21T14:02:28.777Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.716Z","tutorials":[],"swagger":{"path":"/account"}},{"_id":"5e41e73d960b09003ca35a03","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca3596d","user":"597fb20c6ec952001e63f8f3","updates":["5f0bec1b3878440030713b16"],"next":{"pages":[],"description":""},"createdAt":"2017-09-06T18:56:25.255Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":1,"body":"The `sync_state` field for an account can have one of the following status values:\n\n| Status | Action required |\n| --- | --- |\n| `running` | The sync is successfully running. No action is required. |\n| `invalid` | There is an authentication failure with the mail server. Prompt the user to re-authorize. |\n| `stopped` | The sync is stopped. This can happen for a variety of reasons. If you are adding accounts beyond the limits of the free tier, some may be stopped until you upgrade your Nylas application. It can also occur when we encounter unexpected errors. These unexpected errors most commonly originate from incompatibilities with upstream providers or temporary outages. |\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Sync States\",\n \"body\": \"The `sync_state` for this individual account endpoint is a simplified set of values, relative to the `sync_state` that is available from the [Account Management sync state](ref:account-sync-status). We recommend using the Account Management API to get the best understanding of an account's health.\"\n}\n[/block]","excerpt":"","slug":"single-account-sync-states","type":"basic","title":"Single Account Sync States","__v":1,"parentDoc":"5e41e73d960b09003ca35999","updatedAt":"2019-06-14T19:52:58.721Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:11:39.760Z","tutorials":[]}]},{"_id":"5e41e73d960b09003ca3599a","user":"5f2067586dda9a0045009159","createdAt":"2017-05-23T22:46:01.083Z","excerpt":"An access token can be used to request information about the account it corresponds to. This includes information such as the end-user’s name, email address, and backend mailbox provider.","githubsync":"","hidden":false,"order":0,"parentDoc":"5e41e73d960b09003ca35999","type":"endpoint","__v":27,"category":"5e41e73d960b09003ca3596d","isReference":true,"slug":"account","sync_unique":"","title":"/account","body":"## Response\n\nReturns an [Accounts](ref:accounts#the-account-object) object.","link_url":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","updates":[],"api":{"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5a7361894842060020710a2e"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"account\",\n \"name\": \"Ben Bitdiddle\",\n \"email_address\": \"benbitdiddle@gmail.com\",\n \"provider\": \"gmail\",\n \"organization_unit\": \"label\",\n \t\"sync_state\": \"running\",\n \"linked_at\": 1470231381,\n}","name":""},{"code":"{}","name":"","status":400,"language":"json"}]},"url":"/account","auth":"required","examples":{"codes":[{"language":"http","code":"GET /account HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic SVNzc****\ncache-control: no-cache"},{"language":"curl","code":"curl -X GET \\\n https://api.nylas.com/account \\\n -H 'Authorization: Basic SVNz****' \\\n -H 'Content-Type: application/json' \\\n -H 'cache-control: no-cache'"},{"name":"Python SDK","language":"python","code":"nylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n \tACCESS_TOKEN\n)\naccount = nylas.account\n\n# The following attributes are available for the Account object\naccount.id\naccount.account_id\naccount.object\naccount.name\naccount.email_address\naccount.provider\naccount.organization_unit\naccount.sync_state\naccount.linked_at"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET,\n access_token: ACCESS_TOKEN\n)\n\naccount = nylas.current_account\n\n# The following attributes are available for the Account object\naccount.id\naccount.account_id\naccount.object\naccount.name\naccount.email_address\naccount.provider\naccount.organization_unit\naccount.sync_state\naccount.linked_at"},{"name":"Node.js SDK","language":"javascript","code":"nylas.account.get().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.object\naccount.name\naccount.emailAddress\naccount.provider\naccount.organizationUnit\naccount.syncState\naccount.linkedAt"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.AccountDetail;\nimport com.nylas.NylasClient;\n\npublic class DocExamples {\n public static void getAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n AccountDetail account = nylas.account(\"{ACCESS_TOKEN}\").fetchAccountByAccessToken();\n \n // The following attributes are available for the account object\n account.getId();\n account.getName();\n account.getEmailAddress();\n account.getProvider();\n account.getOrganizationUnit();\n account.getSyncState();\n account.getLinkedAt();\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"link_external":false,"version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-05-21T14:02:28.777Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.716Z","tutorials":[],"swagger":{"path":"/account"}},{"_id":"5e41e73d960b09003ca35a03","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca3596d","user":"597fb20c6ec952001e63f8f3","updates":["5f0bec1b3878440030713b16"],"next":{"pages":[],"description":""},"createdAt":"2017-09-06T18:56:25.255Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":1,"body":"The `sync_state` field for an account can have one of the following status values:\n\n| Status | Action required |\n| --- | --- |\n| `running` | The sync is successfully running. No action is required. |\n| `invalid` | There is an authentication failure with the mail server. Prompt the user to re-authorize. |\n| `stopped` | The sync is stopped. This can happen for a variety of reasons. If you are adding accounts beyond the limits of the free tier, some may be stopped until you upgrade your Nylas application. It can also occur when we encounter unexpected errors. These unexpected errors most commonly originate from incompatibilities with upstream providers or temporary outages. |\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Sync States\",\n \"body\": \"The `sync_state` for this individual account endpoint is a simplified set of values, relative to the `sync_state` that is available from the [Account Management sync state](ref:account-sync-status). We recommend using the Account Management API to get the best understanding of an account's health.\"\n}\n[/block]","excerpt":"","slug":"single-account-sync-states","type":"basic","title":"Single Account Sync States","__v":1,"parentDoc":"5e41e73d960b09003ca35999","updatedAt":"2019-06-14T19:52:58.721Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-13T00:11:39.760Z","tutorials":[]},{"_id":"5e41e73d960b09003ca3599e","githubsync":"","link_external":false,"title":"Account Management","user":"5d404909c2f77c0012211f3e","api":{"method":"get","results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":""},"slug":"account-management","sync_unique":"","body":"These endpoints allow for account management outside the developer console interface. You can list, cancel, reactivate, and delete accounts associated with your application.\n[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"This endpoint uses the management API domain with different authentication from the rest of the Nylas API.\\n\\n* The account management API is prepended with `/a`, as opposed to the single account API, which does not have `/a` in its endpoint.\\n* 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).\",\n \"title\": \"Special Authentication Needed\"\n}\n[/block]","excerpt":"","isReference":true,"link_url":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","type":"basic","updates":[],"__v":0,"category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:21:52.020Z","hidden":false,"order":1,"parentDoc":null,"version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-09-30T16:27:36.313Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[{"_id":"5e41e73d960b09003ca3599f","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","api":{"auth":"required","examples":{"codes":[{"language":"http","code":"GET /a/95fm****/accounts/ HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tj****\ncache-control: no-cache"},{"language":"curl","code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/ \\\n\t-H 'Authorization: Basic ENCODED_SECRET'"},{"name":"Python SDK","language":"python","code":"nylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Return a list of dictionary objects that represent all accounts connected to an app\naccounts = nylas.accounts.all()\n\n# Return an account specified by a specific id\naccount = nylas.accounts.get('{id}')\n\n# Return the first account\naccount = nylas.accounts.first()\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: CLIENT_ID,\n app_secret: CLIENT_SECRET\n)\n\n# Return a list of dictionary objects that represent all accounts connected to an app\naccounts = nylas.accounts\n\n# Return an account specified by a specific id\naccount = nylas.accounts.find('{id}')\n\n# Return the first account\naccount = nylas.accounts.first\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\nNylas.accounts.list().then(accounts => console.log(accounts));\n\n// Get an account specified by a specific id\nNylas.accounts.find('accountId').then(account => console.log(account));\n\n// Get the first account\nNylas.accounts.first().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.billingState\naccount.emailAddress\naccount.provider\naccount.syncState\naccount.trial\naccount.clientId"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Account;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void getAccountsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n \n // Return all accounts connected to your Nylas app\n accounts.list();\n\n // Return an account by specifying its ID\n Account account = accounts.get(\"{accountId}\");\n \n // The following attributes are available for the account object\n account.getBillingState();\n account.getEmail();\n account.getProvider();\n account.getSyncState();\n account.getTrial();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c406ceaef40f009db69f"},{"name":"limit","type":"int","default":"","desc":"The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies.","required":false,"in":"query","ref":"","_id":"5d8516e3fe3b12001a754e69"},{"name":"offset","type":"int","default":"","desc":"Zero-based offset from default object sorting. See [pagination](ref:pagination) for more information.","required":false,"in":"query","ref":"","_id":"5d8516e3fe3b12001a754e68"}],"results":{"codes":[{"name":"","status":200,"language":"json","code":"[\n {\n \"account_id\": \"622x1k5v1ujh55t6ucel7av4\",\n \"billing_state\": \"free\",\n \"email\": \"example@example.com\",\n \"id\": \"622x1k5v1ujh55t6ucel7av4\",\n \"provider\": \"yahoo\",\n \"sync_state\": \"running\",\n \"trial\": false\n },\n {\n \"account_id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"billing_state\": \"paid\",\n \"email\": \"example@example.com\",\n \"id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"provider\": \"gmail\",\n \"sync_state\": \"running\",\n \"trial\": false\n }\n]"},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"","hidden":false,"link_url":"","next":{"pages":[],"description":""},"order":0,"body":"Often you may want to retrieve a list of all users who have connected to your application. You can use the `/accounts` endpoint within your application namespace. This will list the accounts associated with your Nylas developer application. \n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Default Limit\",\n \"body\": \"Note that the default limit is set to 100 accounts in the response object. Please see our [pagination](https://docs.nylas.com/reference#pagination) section to modify that limit.\"\n}\n[/block]\n\n\nInstead of using a connected email account’s token, you use your `client_secret` for the Basic Auth username which can be found in the developer console.\n\n## Response\n\nReturns an array of objects describing the accounts. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `billing_state`| string | The billing state for the account. Values are `paid`, `cancelled`, or `deleted`.\n| `email` | string | The email address of the account. |\n| `id` | string | A globally unique object identifier. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `sync_state` | string | The current sync state for the account. See [sync states](https://docs.nylas.com/reference#account-sync-status) |\n| `trial` | boolean | The trial state for the application. |","title":"Listing all accounts","__v":47,"createdAt":"2017-05-24T17:22:14.262Z","isReference":true,"link_external":false,"sync_unique":"","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","githubsync":"","parentDoc":"5e41e73d960b09003ca3599e","slug":"aclient_idaccounts","type":"endpoint","updates":["5a3472a100bf0400120c57c1","5aa92269ecfafe004a6cf582","5e4ec444d2d8fb01dcdf0a83"],"updatedAt":"2020-02-07T17:24:36.606Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:08:19.962Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts"}},{"_id":"5e41e73d960b09003ca359a0","body":"## Response\n\nReturns an object describing the account. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `billing_state`| string | The billing state for the account. Values are `paid`, `cancelled`, or `deleted`.\n| `email` | string | The email address of the account. |\n| `id` | string | A globally unique object identifier. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `sync_state` | string | The current sync state for the account. See [sync states](#account-sync-status). |\n| `trial` | boolean | The trial state for the application. |","isReference":true,"parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","sync_unique":"","updates":["5e98c1e94e7575045517eaa0","5ef3682058c02c005fd6a6bc"],"__v":28,"githubsync":"","link_external":false,"order":1,"title":"Listing an account","type":"endpoint","version":"5e41e73d960b09003ca35a9b","api":{"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account for which to return information.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"billing_state\": \"paid\",\n \"email\": \"example@example.com\",\n \"id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"provider\": \"gmail\",\n \"sync_state\": \"running\",\n \"trial\": false\n}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}","auth":"required","examples":{"codes":[{"code":"GET /a/95fm****/accounts/43jf3**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tjb****\ncache-control: no-cache\n","language":"http"},{"code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/{id} \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Return an account specified by a specific id\naccount = nylas.accounts.get('{id}')\n\n# Return the first account\naccount = nylas.accounts.first()\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial","language":"python","name":"Python SDK"},{"code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'})\n\n// Get an account specified by a specific id\nNylas.accounts.find('accountId').then(account => console.log(account));\n\n// Get the first account\nNylas.accounts.first().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.billingState\naccount.emailAddress\naccount.provider\naccount.syncState\naccount.trial\naccount.clientId","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\n\nimport com.nylas.Account;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void getAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Return an account by specifying its ID\n Account account = accounts.get(\"{accountId}\");\n \n // The following attributes are available for the account object\n account.getBillingState();\n account.getEmail();\n account.getProvider();\n account.getSyncState();\n account.getTrial();\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T17:25:17.635Z","excerpt":"Get information for a single Nylas account.","hidden":false,"link_url":"","slug":"aclient_idaccountsid","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","next":{"pages":[],"description":""},"updatedAt":"2020-04-22T16:11:42.150Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.433Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}"}},{"_id":"5e41e73d960b09003ca359a1","excerpt":"Cancels a paid account.","githubsync":"","link_external":false,"order":2,"sync_unique":"","title":"Cancel an account","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","isReference":true,"next":{"pages":[],"description":""},"slug":"cancel-an-account","type":"endpoint","__v":24,"updates":[],"hidden":false,"body":"","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:38:32.710Z","link_url":"","parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","api":{"auth":"required","examples":{"codes":[{"code":"POST /a/{client_id}/accounts/{account_id}/downgrade HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n","language":"http"},{"code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/downgrade \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n# Cancel an account, replace {id} with the appropriate account id\naccount = nylas.accounts.get('{id}')\naccount.downgrade()","language":"python"},{"name":"Ruby SDK","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)\n# Cancel an account, replace {id} with the appropriate account id\naccount = nylas.accounts.find('{id}')\naccount.downgrade","language":"ruby"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\n// Cancel an account, replace {id} with the appropriate account id\nNylas.accounts\n .find('{id}')\n .then(account => account.downgrade())\n .then(response => console.log(response));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void cancelAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n // Cancel an account by providing its ID\n accounts.downgrade(\"{accountId}\");\n\n }\n}\n"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account to cancel.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}/downgrade","apiSetting":"5e41e73d960b09003ca3598d"},"updatedAt":"2019-12-09T17:45:25.269Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.304Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/downgrade"}},{"_id":"5e41e73d960b09003ca359a2","link_url":"","next":{"pages":[],"description":""},"api":{"auth":"required","examples":{"codes":[{"language":"http","code":"POST /a/{client_id}/accounts/{id}/upgrade HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tjb****\ncache-control: no-cache"},{"language":"curl","code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/upgrade \\\n -H 'Authorization: Basic ENCODED_SECRET'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\naccount = nylas.accounts.get('{id}')\naccount.upgrade()"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)\n\naccount = nylas.accounts.find('{id}')\naccount.upgrade"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\nNylas.accounts\n.find('{id}')\n.then(account => account.upgrade());"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void upgradeAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Reactivate an account by providing its ID\n accounts.upgrade(\"{accountId}\");\n\n }\n}\n"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account to reactivate.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}/upgrade","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"Reactivates a cancelled account to make it active again.","hidden":false,"isReference":true,"order":3,"slug":"re-activate-an-account","sync_unique":"","user":"5f2067586dda9a0045009159","__v":24,"body":"","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:39:25.015Z","githubsync":"","link_external":false,"parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","type":"endpoint","title":"Reactivate an account","updates":[],"version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-08-17T21:45:20.286Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.768Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/upgrade"}},{"_id":"5e41e73d960b09003ca35a42","version":"5e41e73d960b09003ca35a9b","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","parentDoc":"5e41e73d960b09003ca3599e","user":"5d404909c2f77c0012211f3e","updates":["5d851e0c476295003fa65dd9","5debc70fc5ec580011a65e47"],"next":{"pages":[],"description":""},"createdAt":"2019-01-08T21:38:18.842Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"code":"# Indicates that no valid tokens exist to revoke\n{\n \"message\": \"No tokens found for that account id\",\n \"type\": \"api_error\"\n}","language":"curl","status":404}]},"examples":{"codes":[{"language":"http","code":"POST /a/95fm****/accounts/43jf****/revoke-all HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n{\n \"keep_access_token\": \"asdb****\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","name":"Java SDK"},{"language":"curl","code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \\\n -H 'Authorization: Basic ENCODED_SECRET'\n\n# Alternatively, pass an access token to revoke all except the provided token\ncurl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \\\n -H 'Authorization: Basic ENCODED_SECRET' \\\n -d '{\n \"keep_access_token\": \"ACCESS_TOKEN\"\n}'"},{"language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Revoke all tokens\nnylas.revoke_all_tokens()\n\n# Revoke all tokens except for one\nnylas.revoke_all_tokens(keep_access_token=ACCESS_TOKEN)","name":"Python SDK"},{"language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET,\n access_token: ACCESS_TOKEN\n)\n\naccount = nylas.accounts.find('{id}')\n\n# Revoke all tokens\naccount.revoke_all\n\n# Revoke all tokens except for one\naccount.revoke_all(keep_access_token: ACCESS_TOKEN)","name":"Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\n// Revoke all tokens\nNylas.accounts\n.find('accountId')\n.then(account => account.revokeAll());\n\n// Revoke all tokens except for one\nNylas.accounts\n.find('accountId')\n.then(account => account.revokeAll('kept_access_token'));"},{"name":"Java SDK","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void revokeTokensExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Revoke all tokens for an account by providing its ID\n accounts.revokeAllTokensForAccount(\"{accountId}\", null);\n\n // Pass an optional access token to revoke all tokens except for one.\n accounts.revokeAllTokensForAccount(\"{accountId}\", \"{ACCESS_TOKEN}\");\n }\n}","language":"java"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of an account for which to revoke all tokens.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"},{"name":"keep_access_token","type":"string","default":"","desc":"Include a single access token here if you'd like it to remain active while all other access tokens are revoked.","required":false,"in":"body","ref":"","_id":"5c35184a2b35680043455189"}],"url":"/a/{client_id}/accounts/{id}/revoke-all","method":"post"},"isReference":true,"order":4,"body":"You can easily revoke all access token's by issuing a `POST` request to the following endpoint. This endpoint can help ensure that you only have one access token active at any time. Note that this endpoint revokes all access tokens for a given account and client ID (Nylas Application). If you have authenticated the same account to different applications within your Nylas organization, you must revoke the tokens for each respective app.\n\nIf you only need to revoke a single access token, you can do so using the regular [/oauth/revoke](ref:oauthrevoke) endpoint.\n[block:callout]\n{\n \"type\": \"success\",\n \"body\": \"If you want to keep your current access token, you may use the optional parameter `keep_access_token` to revoke all tokens except this one.\",\n \"title\": \"Revoke-all but one!\"\n}\n[/block]\nInclude the `client_secret` as the HTTP Basic Auth username. A `200` HTTP status code response with a body of `{ \"success\": True }` signifies that all tokens except the value for `keep_access_token`, if the parameter was used, have been successfully revoked and can no longer be used.","excerpt":"Revoke all tokens for an account, similar to /oauth/revoke.","slug":"revoke-all","type":"endpoint","title":"Revoke all tokens","__v":41,"updatedAt":"2019-09-20T18:54:32.541Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-20T00:36:15.130Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/revoke-all"}},{"_id":"5e41e73d960b09003ca359a3","order":5,"api":{"results":{"codes":[{"code":"{ \"success\": \"true\" }","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"examples":{"codes":[]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"`client_secret` passed as HTTP Basic Auth username","required":false,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The `client_id` of your Nylas developer application","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The `account_id`","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"url":"/a/{client_id}/accounts/{id}/upgrade","method":"get"},"next":{"pages":[],"description":""},"parentDoc":"5e41e73d960b09003ca3599e","sync_unique":"","updates":[],"version":"5e41e73d960b09003ca35a9b","link_url":"","createdAt":"2017-05-24T17:41:49.323Z","githubsync":"","isReference":true,"link_external":false,"project":"59245c10200df13100c88563","title":"Deleting an account","body":"If you would like for an account's data to be completely removed from Nylas' servers, follow these steps to queue the account for deletion:\n\n1. [Revoke](ref:oauthrevoke) the account's access token, or [revoke all tokens](ref:revoke-all).\n2. [Cancel](ref:cancel-an-account) the account.\n\n**Please note:** Once you follow these steps, the account will be queued for deletion. It can take up to 30 days for an account's data to be completely removed. Furthermore, if the user re-connects their account and authenticates again, their account will not be deleted.\n[block:callout]\n{\n \"type\": \"danger\",\n \"title\": \"GDPR Deletions\",\n \"body\": \"For GDPR purposes, if you must confirm a deletion within 30 days, please [contact us](https://support.nylas.com/hc/en-us/requests/new) and make a request for GDPR deletion.\"\n}\n[/block]","category":"5e41e73d960b09003ca3596d","excerpt":"","hidden":false,"slug":"deleting-an-account","type":"basic","user":"5dfbae85310d180024013fe2","__v":6,"updatedAt":"2020-05-19T00:02:03.014Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"tutorials":[]},{"_id":"5e41e73d960b09003ca359e8","__v":4,"api":{"params":[],"url":"","method":"get","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required"},"createdAt":"2017-05-25T20:44:06.084Z","githubsync":"","link_url":"","next":{"description":"","pages":[]},"parentDoc":"5e41e73d960b09003ca3599e","sync_unique":"","version":"5e41e73d960b09003ca35a9b","excerpt":"","link_external":false,"project":"59245c10200df13100c88563","title":"Account Sync Status","user":"5d404909c2f77c0012211f3e","body":"Sometimes, syncing for an account can not complete successfully, or it might get interrupted. In the event of a recoverable failure, you will see a notification in the [Nylas dashboard](https://dashboard.nylas.com/) and one of the following status messages in the [Accounts](ref:accounts) API:\n\n| Status | Action required |\n| --- | --- |\n| initializing | The account is freshly connected with no known problems. This should be the very first momentary state of an account, and is part of the normal operation process. |\n| downloading | The account is in a normal operation state, but has not yet finished its initial sync. |\n| running | Sync is successfully running. No action is required. This means we are up to date and listening for new changes. |\n| invalid-credentials | This is an authenticating failure with the mail server. You should prompt the user to re-authorize. |\n| stopped | The sync is stopped. This can happen for a variety of reasons. If you are adding accounts beyond the limits of your free trial period, some syncing may be stopped until you upgrade your Nylas application. It can also occur when we repeatedly encounter unexpected errors. These errors most commonly originate from incompatibilities with upstream providers or temporary outages. |\n| exception | This can occur if an upstream provider returns an error that our sync engine does not yet understand. Please [contact us](https://support.nylas.com/hc/en-us/requests/new) for accounts in this state. |\n| sync-error | This means an unexpected error was raised while syncing an account. Please [contact us](https://support.nylas.com/hc/en-us/requests/new) for accounts in this state. |\n\nMost sync and connection failures are temporary, but if they persist, check our [status page](https://status.nylas.com) for any known problems and/or [contact support](https://support.nylas.com/hc/en-us/requests/new).\n\n\n## Credential errors\n\nThese occur when the user's account fails authorization. Usually this is because the user has changed their password, revoked their OAuth credentials, or their IMAP/ SMTP or Exchange server endpoint has changed.\n\nWithout authorization, no mail operations can successfully complete. In order to make the account active again, you will need to re-authorize the user by asking them to [reauthenticate](https://docs.nylas.com/docs/handling-account-re-authentications) and going through the authentication flow again.","category":"5e41e73d960b09003ca3596d","slug":"account-sync-status","updates":["59c150bca811850030a04a21","5bef303aed817f00fd2fff3c","5f2b80b46cc1010021bf3d53","5f3462c52a8c410abe14d4e6"],"hidden":false,"isReference":true,"order":6,"type":"basic","updatedAt":"2020-08-12T22:21:04.800Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-08-06T03:49:07.278Z","tutorials":[]},{"_id":"5e41e73d960b09003ca35a40","version":"5e41e73d960b09003ca35a9b","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","user":"5d404909c2f77c0012211f3e","parentDoc":"5e41e73d960b09003ca3599e","updates":["5e470334099e25046bdd71e1"],"next":{"pages":[],"description":""},"createdAt":"2018-12-13T19:09:05.765Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"code":"GET /a/95fmk****/ip_addresses HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic NXM4M****\ncache-control: no-cache","language":"http"},{"code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/ip_addresses \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"name":"Python SDK","code":"print(client.ip_addresses())","language":"python"},{"name":"Ruby SDK","code":"puts api.ip_addresses","language":"ruby"},{"code":"Nylas.accounts.first()\n .then(account => account.ipAddresses())\n .then(response => console.log(response));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.IPAddressWhitelist;\n\npublic class NylasExamples {\n public static void ipAddressesExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n\n IPAddressWhitelist ipAddresses = application.fetchIpAddressWhitelist();\n\n // The following attributes are available for the IPAddressWhitelist object\n ipAddresses.getIpAddresses();\n ipAddresses.getUpdatedAt();\n }\n}"}]},"results":{"codes":[{"name":"Abridged Response Example","code":"{\n \"ip_addresses\": [\n \"52.25.153.17\",\n \"52.26.120.161\",\n \"52.39.252.208\",\n \"54.71.62.98\",\n \"34.208.138.149\",\n \"52.88.199.110\",\n \"54.69.11.122\",\n \"54.149.110.158\"\n ],\n \"updated_at\": 1544658529\n}","language":"json","status":200}]},"auth":"required","params":[{"name":"client_id","type":"string","default":"","desc":"The client ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5c12ae516a3e7a019f96fbcd"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5c12ae516a3e7a019f96fbcc"}],"url":"/a/{client_id}/ip_addresses","method":"get"},"isReference":true,"order":7,"body":"[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note\",\n \"body\": \"This endpoint can only be accessed by paid applications.\"\n}\n[/block]\n## Overview \nIn some cases, mail servers and other service providers only allow connections from whitelisted IP addresses. Nylas has a variety of services that sync account data across a range of IP addresses, and these IP addresses can change at any moment. \n\nThis endpoint provides a dynamic list of IP addresses that Nylas might use to reach out to do things like send mail, perform proxied searches, send webhooks, etc. The JSON response object will contain an array of IP addresses and a timestamp of the last time it was updated. \n\nInstead of using a connected email account’s token, use your `client_secret` for the Basic Auth username which can be found in the developer console.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Rate limits\",\n \"body\": \"This endpoint has specific rate limits. Please see [rate limiting](ref:rate-limiting) for more information and make sure your application stays within the limit.\"\n}\n[/block]\n\n## Response\n\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `ip_addresses` | array | Array of IP addresses. |\n| `updated_at`| unix timestamp | Timestamp of the last time the list of IP addresses was updated. |","excerpt":"","slug":"get-ip-addresses","type":"endpoint","title":"IP Addresses","__v":32,"updatedAt":"2019-07-26T16:32:59.063Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:41:48.858Z","tutorials":[],"swagger":{"path":"/a/{client_id}/ip_addresses"}},{"_id":"5e41e73d960b09003ca35a6f","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-07-24T17:57:18.983Z","createdAt":"2019-07-24T17:23:19.122Z","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","parentDoc":"5e41e73d960b09003ca3599e","user":"5d404909c2f77c0012211f3e","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"language":"curl","code":"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}'"},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"Nylas.accounts\n .first()\n .then(account => account.tokenInfo())\n .then(response => console.log(response));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\nimport com.nylas.TokenInfo;\n\npublic class NylasExamples {\n public static void tokenInfoExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n TokenInfo tokenInfo = accounts.tokenInfo(\"{accountId}\", \"{ACCESS_TOKEN}\");\n\n // The following attributes are available for the TokenInfo object\n tokenInfo.getCreatedAt();\n tokenInfo.getScopes();\n tokenInfo.getState();\n tokenInfo.getUpdatedAt();\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"created_at\": 1563496685,\n \"scopes\": \"calendar,email,contacts\",\n \"state\": \"valid\",\n \"updated_at\": 1563496685\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"No access_token passed.\",\n \"type\": \"api_error\"\n}","name":""},{"status":404,"language":"json","code":"{\n \"message\": \"No such token found for that account\",\n \"type\": \"api_error\"\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The id of the account for which to return information.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"},{"name":"access_token","type":"string","default":"","desc":"The account's `access_token` value that is returned during authentication.","required":true,"in":"body","ref":"","_id":"5d3895b593bd6502ea859479"}],"url":"/a/{client_id}/accounts/{id}/token-info","method":"post"},"isReference":true,"order":8,"body":"## Response\n\nReturns an object describing the account's `access_token`. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `created_at` | unix timestamp | Timestamp indicating when the access_token was created. |\n| `scopes` | string | Which authentications scopes are allowed with this token. See [authentication scopes](doc:authentication-scopes) for a list of possible `scopes` values. |\n| `state` | string | Can be `valid` or `inactive`. Using an inactive token will return an authorization error. |\n| `updated_at` | unix timestamp | Timestamp indicating when the token object was updated, typically reflecting a change in the token's `state`. |","excerpt":"Get information about an account's `access_token`","slug":"token-info","type":"endpoint","title":"/token-info","__v":13,"metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.631Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/token-info"}}],"childrenPages":[{"_id":"5e41e73d960b09003ca3599f","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","api":{"auth":"required","examples":{"codes":[{"language":"http","code":"GET /a/95fm****/accounts/ HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tj****\ncache-control: no-cache"},{"language":"curl","code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/ \\\n\t-H 'Authorization: Basic ENCODED_SECRET'"},{"name":"Python SDK","language":"python","code":"nylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Return a list of dictionary objects that represent all accounts connected to an app\naccounts = nylas.accounts.all()\n\n# Return an account specified by a specific id\naccount = nylas.accounts.get('{id}')\n\n# Return the first account\naccount = nylas.accounts.first()\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: CLIENT_ID,\n app_secret: CLIENT_SECRET\n)\n\n# Return a list of dictionary objects that represent all accounts connected to an app\naccounts = nylas.accounts\n\n# Return an account specified by a specific id\naccount = nylas.accounts.find('{id}')\n\n# Return the first account\naccount = nylas.accounts.first\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\nNylas.accounts.list().then(accounts => console.log(accounts));\n\n// Get an account specified by a specific id\nNylas.accounts.find('accountId').then(account => console.log(account));\n\n// Get the first account\nNylas.accounts.first().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.billingState\naccount.emailAddress\naccount.provider\naccount.syncState\naccount.trial\naccount.clientId"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Account;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void getAccountsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n \n // Return all accounts connected to your Nylas app\n accounts.list();\n\n // Return an account by specifying its ID\n Account account = accounts.get(\"{accountId}\");\n \n // The following attributes are available for the account object\n account.getBillingState();\n account.getEmail();\n account.getProvider();\n account.getSyncState();\n account.getTrial();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c406ceaef40f009db69f"},{"name":"limit","type":"int","default":"","desc":"The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies.","required":false,"in":"query","ref":"","_id":"5d8516e3fe3b12001a754e69"},{"name":"offset","type":"int","default":"","desc":"Zero-based offset from default object sorting. See [pagination](ref:pagination) for more information.","required":false,"in":"query","ref":"","_id":"5d8516e3fe3b12001a754e68"}],"results":{"codes":[{"name":"","status":200,"language":"json","code":"[\n {\n \"account_id\": \"622x1k5v1ujh55t6ucel7av4\",\n \"billing_state\": \"free\",\n \"email\": \"example@example.com\",\n \"id\": \"622x1k5v1ujh55t6ucel7av4\",\n \"provider\": \"yahoo\",\n \"sync_state\": \"running\",\n \"trial\": false\n },\n {\n \"account_id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"billing_state\": \"paid\",\n \"email\": \"example@example.com\",\n \"id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"provider\": \"gmail\",\n \"sync_state\": \"running\",\n \"trial\": false\n }\n]"},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"","hidden":false,"link_url":"","next":{"pages":[],"description":""},"order":0,"body":"Often you may want to retrieve a list of all users who have connected to your application. You can use the `/accounts` endpoint within your application namespace. This will list the accounts associated with your Nylas developer application. \n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Default Limit\",\n \"body\": \"Note that the default limit is set to 100 accounts in the response object. Please see our [pagination](https://docs.nylas.com/reference#pagination) section to modify that limit.\"\n}\n[/block]\n\n\nInstead of using a connected email account’s token, you use your `client_secret` for the Basic Auth username which can be found in the developer console.\n\n## Response\n\nReturns an array of objects describing the accounts. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `billing_state`| string | The billing state for the account. Values are `paid`, `cancelled`, or `deleted`.\n| `email` | string | The email address of the account. |\n| `id` | string | A globally unique object identifier. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `sync_state` | string | The current sync state for the account. See [sync states](https://docs.nylas.com/reference#account-sync-status) |\n| `trial` | boolean | The trial state for the application. |","title":"Listing all accounts","__v":47,"createdAt":"2017-05-24T17:22:14.262Z","isReference":true,"link_external":false,"sync_unique":"","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","githubsync":"","parentDoc":"5e41e73d960b09003ca3599e","slug":"aclient_idaccounts","type":"endpoint","updates":["5a3472a100bf0400120c57c1","5aa92269ecfafe004a6cf582","5e4ec444d2d8fb01dcdf0a83"],"updatedAt":"2020-02-07T17:24:36.606Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:08:19.962Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts"}},{"_id":"5e41e73d960b09003ca359a0","body":"## Response\n\nReturns an object describing the account. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `billing_state`| string | The billing state for the account. Values are `paid`, `cancelled`, or `deleted`.\n| `email` | string | The email address of the account. |\n| `id` | string | A globally unique object identifier. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `sync_state` | string | The current sync state for the account. See [sync states](#account-sync-status). |\n| `trial` | boolean | The trial state for the application. |","isReference":true,"parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","sync_unique":"","updates":["5e98c1e94e7575045517eaa0","5ef3682058c02c005fd6a6bc"],"__v":28,"githubsync":"","link_external":false,"order":1,"title":"Listing an account","type":"endpoint","version":"5e41e73d960b09003ca35a9b","api":{"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account for which to return information.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"billing_state\": \"paid\",\n \"email\": \"example@example.com\",\n \"id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"provider\": \"gmail\",\n \"sync_state\": \"running\",\n \"trial\": false\n}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}","auth":"required","examples":{"codes":[{"code":"GET /a/95fm****/accounts/43jf3**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tjb****\ncache-control: no-cache\n","language":"http"},{"code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/{id} \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Return an account specified by a specific id\naccount = nylas.accounts.get('{id}')\n\n# Return the first account\naccount = nylas.accounts.first()\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial","language":"python","name":"Python SDK"},{"code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'})\n\n// Get an account specified by a specific id\nNylas.accounts.find('accountId').then(account => console.log(account));\n\n// Get the first account\nNylas.accounts.first().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.billingState\naccount.emailAddress\naccount.provider\naccount.syncState\naccount.trial\naccount.clientId","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\n\nimport com.nylas.Account;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void getAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Return an account by specifying its ID\n Account account = accounts.get(\"{accountId}\");\n \n // The following attributes are available for the account object\n account.getBillingState();\n account.getEmail();\n account.getProvider();\n account.getSyncState();\n account.getTrial();\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T17:25:17.635Z","excerpt":"Get information for a single Nylas account.","hidden":false,"link_url":"","slug":"aclient_idaccountsid","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","next":{"pages":[],"description":""},"updatedAt":"2020-04-22T16:11:42.150Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.433Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}"}},{"_id":"5e41e73d960b09003ca359a1","excerpt":"Cancels a paid account.","githubsync":"","link_external":false,"order":2,"sync_unique":"","title":"Cancel an account","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","isReference":true,"next":{"pages":[],"description":""},"slug":"cancel-an-account","type":"endpoint","__v":24,"updates":[],"hidden":false,"body":"","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:38:32.710Z","link_url":"","parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","api":{"auth":"required","examples":{"codes":[{"code":"POST /a/{client_id}/accounts/{account_id}/downgrade HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n","language":"http"},{"code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/downgrade \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n# Cancel an account, replace {id} with the appropriate account id\naccount = nylas.accounts.get('{id}')\naccount.downgrade()","language":"python"},{"name":"Ruby SDK","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)\n# Cancel an account, replace {id} with the appropriate account id\naccount = nylas.accounts.find('{id}')\naccount.downgrade","language":"ruby"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\n// Cancel an account, replace {id} with the appropriate account id\nNylas.accounts\n .find('{id}')\n .then(account => account.downgrade())\n .then(response => console.log(response));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void cancelAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n // Cancel an account by providing its ID\n accounts.downgrade(\"{accountId}\");\n\n }\n}\n"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account to cancel.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}/downgrade","apiSetting":"5e41e73d960b09003ca3598d"},"updatedAt":"2019-12-09T17:45:25.269Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.304Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/downgrade"}},{"_id":"5e41e73d960b09003ca359a2","link_url":"","next":{"pages":[],"description":""},"api":{"auth":"required","examples":{"codes":[{"language":"http","code":"POST /a/{client_id}/accounts/{id}/upgrade HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tjb****\ncache-control: no-cache"},{"language":"curl","code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/upgrade \\\n -H 'Authorization: Basic ENCODED_SECRET'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\naccount = nylas.accounts.get('{id}')\naccount.upgrade()"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)\n\naccount = nylas.accounts.find('{id}')\naccount.upgrade"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\nNylas.accounts\n.find('{id}')\n.then(account => account.upgrade());"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void upgradeAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Reactivate an account by providing its ID\n accounts.upgrade(\"{accountId}\");\n\n }\n}\n"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account to reactivate.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}/upgrade","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"Reactivates a cancelled account to make it active again.","hidden":false,"isReference":true,"order":3,"slug":"re-activate-an-account","sync_unique":"","user":"5f2067586dda9a0045009159","__v":24,"body":"","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:39:25.015Z","githubsync":"","link_external":false,"parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","type":"endpoint","title":"Reactivate an account","updates":[],"version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-08-17T21:45:20.286Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.768Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/upgrade"}},{"_id":"5e41e73d960b09003ca35a42","version":"5e41e73d960b09003ca35a9b","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","parentDoc":"5e41e73d960b09003ca3599e","user":"5d404909c2f77c0012211f3e","updates":["5d851e0c476295003fa65dd9","5debc70fc5ec580011a65e47"],"next":{"pages":[],"description":""},"createdAt":"2019-01-08T21:38:18.842Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"code":"# Indicates that no valid tokens exist to revoke\n{\n \"message\": \"No tokens found for that account id\",\n \"type\": \"api_error\"\n}","language":"curl","status":404}]},"examples":{"codes":[{"language":"http","code":"POST /a/95fm****/accounts/43jf****/revoke-all HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n{\n \"keep_access_token\": \"asdb****\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","name":"Java SDK"},{"language":"curl","code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \\\n -H 'Authorization: Basic ENCODED_SECRET'\n\n# Alternatively, pass an access token to revoke all except the provided token\ncurl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \\\n -H 'Authorization: Basic ENCODED_SECRET' \\\n -d '{\n \"keep_access_token\": \"ACCESS_TOKEN\"\n}'"},{"language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Revoke all tokens\nnylas.revoke_all_tokens()\n\n# Revoke all tokens except for one\nnylas.revoke_all_tokens(keep_access_token=ACCESS_TOKEN)","name":"Python SDK"},{"language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET,\n access_token: ACCESS_TOKEN\n)\n\naccount = nylas.accounts.find('{id}')\n\n# Revoke all tokens\naccount.revoke_all\n\n# Revoke all tokens except for one\naccount.revoke_all(keep_access_token: ACCESS_TOKEN)","name":"Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\n// Revoke all tokens\nNylas.accounts\n.find('accountId')\n.then(account => account.revokeAll());\n\n// Revoke all tokens except for one\nNylas.accounts\n.find('accountId')\n.then(account => account.revokeAll('kept_access_token'));"},{"name":"Java SDK","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void revokeTokensExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Revoke all tokens for an account by providing its ID\n accounts.revokeAllTokensForAccount(\"{accountId}\", null);\n\n // Pass an optional access token to revoke all tokens except for one.\n accounts.revokeAllTokensForAccount(\"{accountId}\", \"{ACCESS_TOKEN}\");\n }\n}","language":"java"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of an account for which to revoke all tokens.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"},{"name":"keep_access_token","type":"string","default":"","desc":"Include a single access token here if you'd like it to remain active while all other access tokens are revoked.","required":false,"in":"body","ref":"","_id":"5c35184a2b35680043455189"}],"url":"/a/{client_id}/accounts/{id}/revoke-all","method":"post"},"isReference":true,"order":4,"body":"You can easily revoke all access token's by issuing a `POST` request to the following endpoint. This endpoint can help ensure that you only have one access token active at any time. Note that this endpoint revokes all access tokens for a given account and client ID (Nylas Application). If you have authenticated the same account to different applications within your Nylas organization, you must revoke the tokens for each respective app.\n\nIf you only need to revoke a single access token, you can do so using the regular [/oauth/revoke](ref:oauthrevoke) endpoint.\n[block:callout]\n{\n \"type\": \"success\",\n \"body\": \"If you want to keep your current access token, you may use the optional parameter `keep_access_token` to revoke all tokens except this one.\",\n \"title\": \"Revoke-all but one!\"\n}\n[/block]\nInclude the `client_secret` as the HTTP Basic Auth username. A `200` HTTP status code response with a body of `{ \"success\": True }` signifies that all tokens except the value for `keep_access_token`, if the parameter was used, have been successfully revoked and can no longer be used.","excerpt":"Revoke all tokens for an account, similar to /oauth/revoke.","slug":"revoke-all","type":"endpoint","title":"Revoke all tokens","__v":41,"updatedAt":"2019-09-20T18:54:32.541Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-20T00:36:15.130Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/revoke-all"}},{"_id":"5e41e73d960b09003ca359a3","order":5,"api":{"results":{"codes":[{"code":"{ \"success\": \"true\" }","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"examples":{"codes":[]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"`client_secret` passed as HTTP Basic Auth username","required":false,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The `client_id` of your Nylas developer application","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The `account_id`","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"url":"/a/{client_id}/accounts/{id}/upgrade","method":"get"},"next":{"pages":[],"description":""},"parentDoc":"5e41e73d960b09003ca3599e","sync_unique":"","updates":[],"version":"5e41e73d960b09003ca35a9b","link_url":"","createdAt":"2017-05-24T17:41:49.323Z","githubsync":"","isReference":true,"link_external":false,"project":"59245c10200df13100c88563","title":"Deleting an account","body":"If you would like for an account's data to be completely removed from Nylas' servers, follow these steps to queue the account for deletion:\n\n1. [Revoke](ref:oauthrevoke) the account's access token, or [revoke all tokens](ref:revoke-all).\n2. [Cancel](ref:cancel-an-account) the account.\n\n**Please note:** Once you follow these steps, the account will be queued for deletion. It can take up to 30 days for an account's data to be completely removed. Furthermore, if the user re-connects their account and authenticates again, their account will not be deleted.\n[block:callout]\n{\n \"type\": \"danger\",\n \"title\": \"GDPR Deletions\",\n \"body\": \"For GDPR purposes, if you must confirm a deletion within 30 days, please [contact us](https://support.nylas.com/hc/en-us/requests/new) and make a request for GDPR deletion.\"\n}\n[/block]","category":"5e41e73d960b09003ca3596d","excerpt":"","hidden":false,"slug":"deleting-an-account","type":"basic","user":"5dfbae85310d180024013fe2","__v":6,"updatedAt":"2020-05-19T00:02:03.014Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"tutorials":[]},{"_id":"5e41e73d960b09003ca359e8","__v":4,"api":{"params":[],"url":"","method":"get","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required"},"createdAt":"2017-05-25T20:44:06.084Z","githubsync":"","link_url":"","next":{"description":"","pages":[]},"parentDoc":"5e41e73d960b09003ca3599e","sync_unique":"","version":"5e41e73d960b09003ca35a9b","excerpt":"","link_external":false,"project":"59245c10200df13100c88563","title":"Account Sync Status","user":"5d404909c2f77c0012211f3e","body":"Sometimes, syncing for an account can not complete successfully, or it might get interrupted. In the event of a recoverable failure, you will see a notification in the [Nylas dashboard](https://dashboard.nylas.com/) and one of the following status messages in the [Accounts](ref:accounts) API:\n\n| Status | Action required |\n| --- | --- |\n| initializing | The account is freshly connected with no known problems. This should be the very first momentary state of an account, and is part of the normal operation process. |\n| downloading | The account is in a normal operation state, but has not yet finished its initial sync. |\n| running | Sync is successfully running. No action is required. This means we are up to date and listening for new changes. |\n| invalid-credentials | This is an authenticating failure with the mail server. You should prompt the user to re-authorize. |\n| stopped | The sync is stopped. This can happen for a variety of reasons. If you are adding accounts beyond the limits of your free trial period, some syncing may be stopped until you upgrade your Nylas application. It can also occur when we repeatedly encounter unexpected errors. These errors most commonly originate from incompatibilities with upstream providers or temporary outages. |\n| exception | This can occur if an upstream provider returns an error that our sync engine does not yet understand. Please [contact us](https://support.nylas.com/hc/en-us/requests/new) for accounts in this state. |\n| sync-error | This means an unexpected error was raised while syncing an account. Please [contact us](https://support.nylas.com/hc/en-us/requests/new) for accounts in this state. |\n\nMost sync and connection failures are temporary, but if they persist, check our [status page](https://status.nylas.com) for any known problems and/or [contact support](https://support.nylas.com/hc/en-us/requests/new).\n\n\n## Credential errors\n\nThese occur when the user's account fails authorization. Usually this is because the user has changed their password, revoked their OAuth credentials, or their IMAP/ SMTP or Exchange server endpoint has changed.\n\nWithout authorization, no mail operations can successfully complete. In order to make the account active again, you will need to re-authorize the user by asking them to [reauthenticate](https://docs.nylas.com/docs/handling-account-re-authentications) and going through the authentication flow again.","category":"5e41e73d960b09003ca3596d","slug":"account-sync-status","updates":["59c150bca811850030a04a21","5bef303aed817f00fd2fff3c","5f2b80b46cc1010021bf3d53","5f3462c52a8c410abe14d4e6"],"hidden":false,"isReference":true,"order":6,"type":"basic","updatedAt":"2020-08-12T22:21:04.800Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-08-06T03:49:07.278Z","tutorials":[]},{"_id":"5e41e73d960b09003ca35a40","version":"5e41e73d960b09003ca35a9b","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","user":"5d404909c2f77c0012211f3e","parentDoc":"5e41e73d960b09003ca3599e","updates":["5e470334099e25046bdd71e1"],"next":{"pages":[],"description":""},"createdAt":"2018-12-13T19:09:05.765Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"code":"GET /a/95fmk****/ip_addresses HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic NXM4M****\ncache-control: no-cache","language":"http"},{"code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/ip_addresses \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"name":"Python SDK","code":"print(client.ip_addresses())","language":"python"},{"name":"Ruby SDK","code":"puts api.ip_addresses","language":"ruby"},{"code":"Nylas.accounts.first()\n .then(account => account.ipAddresses())\n .then(response => console.log(response));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.IPAddressWhitelist;\n\npublic class NylasExamples {\n public static void ipAddressesExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n\n IPAddressWhitelist ipAddresses = application.fetchIpAddressWhitelist();\n\n // The following attributes are available for the IPAddressWhitelist object\n ipAddresses.getIpAddresses();\n ipAddresses.getUpdatedAt();\n }\n}"}]},"results":{"codes":[{"name":"Abridged Response Example","code":"{\n \"ip_addresses\": [\n \"52.25.153.17\",\n \"52.26.120.161\",\n \"52.39.252.208\",\n \"54.71.62.98\",\n \"34.208.138.149\",\n \"52.88.199.110\",\n \"54.69.11.122\",\n \"54.149.110.158\"\n ],\n \"updated_at\": 1544658529\n}","language":"json","status":200}]},"auth":"required","params":[{"name":"client_id","type":"string","default":"","desc":"The client ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5c12ae516a3e7a019f96fbcd"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5c12ae516a3e7a019f96fbcc"}],"url":"/a/{client_id}/ip_addresses","method":"get"},"isReference":true,"order":7,"body":"[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note\",\n \"body\": \"This endpoint can only be accessed by paid applications.\"\n}\n[/block]\n## Overview \nIn some cases, mail servers and other service providers only allow connections from whitelisted IP addresses. Nylas has a variety of services that sync account data across a range of IP addresses, and these IP addresses can change at any moment. \n\nThis endpoint provides a dynamic list of IP addresses that Nylas might use to reach out to do things like send mail, perform proxied searches, send webhooks, etc. The JSON response object will contain an array of IP addresses and a timestamp of the last time it was updated. \n\nInstead of using a connected email account’s token, use your `client_secret` for the Basic Auth username which can be found in the developer console.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Rate limits\",\n \"body\": \"This endpoint has specific rate limits. Please see [rate limiting](ref:rate-limiting) for more information and make sure your application stays within the limit.\"\n}\n[/block]\n\n## Response\n\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `ip_addresses` | array | Array of IP addresses. |\n| `updated_at`| unix timestamp | Timestamp of the last time the list of IP addresses was updated. |","excerpt":"","slug":"get-ip-addresses","type":"endpoint","title":"IP Addresses","__v":32,"updatedAt":"2019-07-26T16:32:59.063Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:41:48.858Z","tutorials":[],"swagger":{"path":"/a/{client_id}/ip_addresses"}},{"_id":"5e41e73d960b09003ca35a6f","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-07-24T17:57:18.983Z","createdAt":"2019-07-24T17:23:19.122Z","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","parentDoc":"5e41e73d960b09003ca3599e","user":"5d404909c2f77c0012211f3e","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"language":"curl","code":"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}'"},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"Nylas.accounts\n .first()\n .then(account => account.tokenInfo())\n .then(response => console.log(response));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\nimport com.nylas.TokenInfo;\n\npublic class NylasExamples {\n public static void tokenInfoExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n TokenInfo tokenInfo = accounts.tokenInfo(\"{accountId}\", \"{ACCESS_TOKEN}\");\n\n // The following attributes are available for the TokenInfo object\n tokenInfo.getCreatedAt();\n tokenInfo.getScopes();\n tokenInfo.getState();\n tokenInfo.getUpdatedAt();\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"created_at\": 1563496685,\n \"scopes\": \"calendar,email,contacts\",\n \"state\": \"valid\",\n \"updated_at\": 1563496685\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"No access_token passed.\",\n \"type\": \"api_error\"\n}","name":""},{"status":404,"language":"json","code":"{\n \"message\": \"No such token found for that account\",\n \"type\": \"api_error\"\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The id of the account for which to return information.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"},{"name":"access_token","type":"string","default":"","desc":"The account's `access_token` value that is returned during authentication.","required":true,"in":"body","ref":"","_id":"5d3895b593bd6502ea859479"}],"url":"/a/{client_id}/accounts/{id}/token-info","method":"post"},"isReference":true,"order":8,"body":"## Response\n\nReturns an object describing the account's `access_token`. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `created_at` | unix timestamp | Timestamp indicating when the access_token was created. |\n| `scopes` | string | Which authentications scopes are allowed with this token. See [authentication scopes](doc:authentication-scopes) for a list of possible `scopes` values. |\n| `state` | string | Can be `valid` or `inactive`. Using an inactive token will return an authorization error. |\n| `updated_at` | unix timestamp | Timestamp indicating when the token object was updated, typically reflecting a change in the token's `state`. |","excerpt":"Get information about an account's `access_token`","slug":"token-info","type":"endpoint","title":"/token-info","__v":13,"metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.631Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/token-info"}}]},{"_id":"5e41e73d960b09003ca3599f","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","api":{"auth":"required","examples":{"codes":[{"language":"http","code":"GET /a/95fm****/accounts/ HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tj****\ncache-control: no-cache"},{"language":"curl","code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/ \\\n\t-H 'Authorization: Basic ENCODED_SECRET'"},{"name":"Python SDK","language":"python","code":"nylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Return a list of dictionary objects that represent all accounts connected to an app\naccounts = nylas.accounts.all()\n\n# Return an account specified by a specific id\naccount = nylas.accounts.get('{id}')\n\n# Return the first account\naccount = nylas.accounts.first()\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: CLIENT_ID,\n app_secret: CLIENT_SECRET\n)\n\n# Return a list of dictionary objects that represent all accounts connected to an app\naccounts = nylas.accounts\n\n# Return an account specified by a specific id\naccount = nylas.accounts.find('{id}')\n\n# Return the first account\naccount = nylas.accounts.first\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\nNylas.accounts.list().then(accounts => console.log(accounts));\n\n// Get an account specified by a specific id\nNylas.accounts.find('accountId').then(account => console.log(account));\n\n// Get the first account\nNylas.accounts.first().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.billingState\naccount.emailAddress\naccount.provider\naccount.syncState\naccount.trial\naccount.clientId"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Account;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void getAccountsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n \n // Return all accounts connected to your Nylas app\n accounts.list();\n\n // Return an account by specifying its ID\n Account account = accounts.get(\"{accountId}\");\n \n // The following attributes are available for the account object\n account.getBillingState();\n account.getEmail();\n account.getProvider();\n account.getSyncState();\n account.getTrial();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c406ceaef40f009db69f"},{"name":"limit","type":"int","default":"","desc":"The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies.","required":false,"in":"query","ref":"","_id":"5d8516e3fe3b12001a754e69"},{"name":"offset","type":"int","default":"","desc":"Zero-based offset from default object sorting. See [pagination](ref:pagination) for more information.","required":false,"in":"query","ref":"","_id":"5d8516e3fe3b12001a754e68"}],"results":{"codes":[{"name":"","status":200,"language":"json","code":"[\n {\n \"account_id\": \"622x1k5v1ujh55t6ucel7av4\",\n \"billing_state\": \"free\",\n \"email\": \"example@example.com\",\n \"id\": \"622x1k5v1ujh55t6ucel7av4\",\n \"provider\": \"yahoo\",\n \"sync_state\": \"running\",\n \"trial\": false\n },\n {\n \"account_id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"billing_state\": \"paid\",\n \"email\": \"example@example.com\",\n \"id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"provider\": \"gmail\",\n \"sync_state\": \"running\",\n \"trial\": false\n }\n]"},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"","hidden":false,"link_url":"","next":{"pages":[],"description":""},"order":0,"body":"Often you may want to retrieve a list of all users who have connected to your application. You can use the `/accounts` endpoint within your application namespace. This will list the accounts associated with your Nylas developer application. \n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Default Limit\",\n \"body\": \"Note that the default limit is set to 100 accounts in the response object. Please see our [pagination](https://docs.nylas.com/reference#pagination) section to modify that limit.\"\n}\n[/block]\n\n\nInstead of using a connected email account’s token, you use your `client_secret` for the Basic Auth username which can be found in the developer console.\n\n## Response\n\nReturns an array of objects describing the accounts. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `billing_state`| string | The billing state for the account. Values are `paid`, `cancelled`, or `deleted`.\n| `email` | string | The email address of the account. |\n| `id` | string | A globally unique object identifier. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `sync_state` | string | The current sync state for the account. See [sync states](https://docs.nylas.com/reference#account-sync-status) |\n| `trial` | boolean | The trial state for the application. |","title":"Listing all accounts","__v":47,"createdAt":"2017-05-24T17:22:14.262Z","isReference":true,"link_external":false,"sync_unique":"","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","githubsync":"","parentDoc":"5e41e73d960b09003ca3599e","slug":"aclient_idaccounts","type":"endpoint","updates":["5a3472a100bf0400120c57c1","5aa92269ecfafe004a6cf582","5e4ec444d2d8fb01dcdf0a83"],"updatedAt":"2020-02-07T17:24:36.606Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:08:19.962Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts"}},{"_id":"5e41e73d960b09003ca359a0","body":"## Response\n\nReturns an object describing the account. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `account_id` | string | A reference to the parent account object (self-referential in this case). |\n| `billing_state`| string | The billing state for the account. Values are `paid`, `cancelled`, or `deleted`.\n| `email` | string | The email address of the account. |\n| `id` | string | A globally unique object identifier. |\n| `provider` | string | Specifies the provider that backs the account (e.g. `gmail` or `eas`). See [Supported Providers](ref:supported-providers) for a full list. |\n| `sync_state` | string | The current sync state for the account. See [sync states](#account-sync-status). |\n| `trial` | boolean | The trial state for the application. |","isReference":true,"parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","sync_unique":"","updates":["5e98c1e94e7575045517eaa0","5ef3682058c02c005fd6a6bc"],"__v":28,"githubsync":"","link_external":false,"order":1,"title":"Listing an account","type":"endpoint","version":"5e41e73d960b09003ca35a9b","api":{"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account for which to return information.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"billing_state\": \"paid\",\n \"email\": \"example@example.com\",\n \"id\": \"123rvgm1iccsgnjj7nn6jwu1\",\n \"provider\": \"gmail\",\n \"sync_state\": \"running\",\n \"trial\": false\n}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}","auth":"required","examples":{"codes":[{"code":"GET /a/95fm****/accounts/43jf3**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tjb****\ncache-control: no-cache\n","language":"http"},{"code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/accounts/{id} \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n\n# Return an account specified by a specific id\naccount = nylas.accounts.get('{id}')\n\n# Return the first account\naccount = nylas.accounts.first()\n\n# The following attributes are available for the account object\naccount.email\naccount.id\naccount.sync_state\naccount.billing_state\naccount.trial","language":"python","name":"Python SDK"},{"code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'})\n\n// Get an account specified by a specific id\nNylas.accounts.find('accountId').then(account => console.log(account));\n\n// Get the first account\nNylas.accounts.first().then(account => console.log(account));\n\n// The following attributes are available for the Account object\naccount.id\naccount.accountId\naccount.billingState\naccount.emailAddress\naccount.provider\naccount.syncState\naccount.trial\naccount.clientId","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\n\nimport com.nylas.Account;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void getAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Return an account by specifying its ID\n Account account = accounts.get(\"{accountId}\");\n \n // The following attributes are available for the account object\n account.getBillingState();\n account.getEmail();\n account.getProvider();\n account.getSyncState();\n account.getTrial();\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T17:25:17.635Z","excerpt":"Get information for a single Nylas account.","hidden":false,"link_url":"","slug":"aclient_idaccountsid","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","next":{"pages":[],"description":""},"updatedAt":"2020-04-22T16:11:42.150Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.433Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}"}},{"_id":"5e41e73d960b09003ca359a1","excerpt":"Cancels a paid account.","githubsync":"","link_external":false,"order":2,"sync_unique":"","title":"Cancel an account","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","isReference":true,"next":{"pages":[],"description":""},"slug":"cancel-an-account","type":"endpoint","__v":24,"updates":[],"hidden":false,"body":"","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:38:32.710Z","link_url":"","parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","api":{"auth":"required","examples":{"codes":[{"code":"POST /a/{client_id}/accounts/{account_id}/downgrade HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n","language":"http"},{"code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/downgrade \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\n# Cancel an account, replace {id} with the appropriate account id\naccount = nylas.accounts.get('{id}')\naccount.downgrade()","language":"python"},{"name":"Ruby SDK","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)\n# Cancel an account, replace {id} with the appropriate account id\naccount = nylas.accounts.find('{id}')\naccount.downgrade","language":"ruby"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\n// Cancel an account, replace {id} with the appropriate account id\nNylas.accounts\n .find('{id}')\n .then(account => account.downgrade())\n .then(response => console.log(response));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void cancelAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n // Cancel an account by providing its ID\n accounts.downgrade(\"{accountId}\");\n\n }\n}\n"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account to cancel.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}/downgrade","apiSetting":"5e41e73d960b09003ca3598d"},"updatedAt":"2019-12-09T17:45:25.269Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.304Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/downgrade"}},{"_id":"5e41e73d960b09003ca359a2","link_url":"","next":{"pages":[],"description":""},"api":{"auth":"required","examples":{"codes":[{"language":"http","code":"POST /a/{client_id}/accounts/{id}/upgrade HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic e3tjb****\ncache-control: no-cache"},{"language":"curl","code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/upgrade \\\n -H 'Authorization: Basic ENCODED_SECRET'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET\n)\naccount = nylas.accounts.get('{id}')\naccount.upgrade()"},{"name":"Ruby SDK","language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET\n)\n\naccount = nylas.accounts.find('{id}')\naccount.upgrade"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\nNylas.accounts\n.find('{id}')\n.then(account => account.upgrade());"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void upgradeAccountExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Reactivate an account by providing its ID\n accounts.upgrade(\"{accountId}\");\n\n }\n}\n"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of the account to reactivate.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"url":"/a/{client_id}/accounts/{id}/upgrade","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"Reactivates a cancelled account to make it active again.","hidden":false,"isReference":true,"order":3,"slug":"re-activate-an-account","sync_unique":"","user":"5f2067586dda9a0045009159","__v":24,"body":"","category":"5e41e73d960b09003ca3596d","createdAt":"2017-05-24T17:39:25.015Z","githubsync":"","link_external":false,"parentDoc":"5e41e73d960b09003ca3599e","project":"59245c10200df13100c88563","type":"endpoint","title":"Reactivate an account","updates":[],"version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-08-17T21:45:20.286Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.768Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/upgrade"}},{"_id":"5e41e73d960b09003ca35a42","version":"5e41e73d960b09003ca35a9b","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","parentDoc":"5e41e73d960b09003ca3599e","user":"5d404909c2f77c0012211f3e","updates":["5d851e0c476295003fa65dd9","5debc70fc5ec580011a65e47"],"next":{"pages":[],"description":""},"createdAt":"2019-01-08T21:38:18.842Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","results":{"codes":[{"status":200,"language":"json","code":"{ \"success\": \"true\" }","name":""},{"code":"# Indicates that no valid tokens exist to revoke\n{\n \"message\": \"No tokens found for that account id\",\n \"type\": \"api_error\"\n}","language":"curl","status":404}]},"examples":{"codes":[{"language":"http","code":"POST /a/95fm****/accounts/43jf****/revoke-all HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n{\n \"keep_access_token\": \"asdb****\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","name":"Java SDK"},{"language":"curl","code":"curl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \\\n -H 'Authorization: Basic ENCODED_SECRET'\n\n# Alternatively, pass an access token to revoke all except the provided token\ncurl -X POST \\\n https://api.nylas.com/a/{client_id}/accounts/{id}/revoke-all \\\n -H 'Authorization: Basic ENCODED_SECRET' \\\n -d '{\n \"keep_access_token\": \"ACCESS_TOKEN\"\n}'"},{"language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Revoke all tokens\nnylas.revoke_all_tokens()\n\n# Revoke all tokens except for one\nnylas.revoke_all_tokens(keep_access_token=ACCESS_TOKEN)","name":"Python SDK"},{"language":"ruby","code":"nylas = Nylas::API.new(\n app_id: APP_ID,\n app_secret: APP_SECRET,\n access_token: ACCESS_TOKEN\n)\n\naccount = nylas.accounts.find('{id}')\n\n# Revoke all tokens\naccount.revoke_all\n\n# Revoke all tokens except for one\naccount.revoke_all(keep_access_token: ACCESS_TOKEN)","name":"Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\n\n// Revoke all tokens\nNylas.accounts\n.find('accountId')\n.then(account => account.revokeAll());\n\n// Revoke all tokens except for one\nNylas.accounts\n.find('accountId')\n.then(account => account.revokeAll('kept_access_token'));"},{"name":"Java SDK","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\n\npublic class NylasExamples {\n public static void revokeTokensExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n\n // Revoke all tokens for an account by providing its ID\n accounts.revokeAllTokensForAccount(\"{accountId}\", null);\n\n // Pass an optional access token to revoke all tokens except for one.\n accounts.revokeAllTokensForAccount(\"{accountId}\", \"{ACCESS_TOKEN}\");\n }\n}","language":"java"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The ID of an account for which to revoke all tokens.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"},{"name":"keep_access_token","type":"string","default":"","desc":"Include a single access token here if you'd like it to remain active while all other access tokens are revoked.","required":false,"in":"body","ref":"","_id":"5c35184a2b35680043455189"}],"url":"/a/{client_id}/accounts/{id}/revoke-all","method":"post"},"isReference":true,"order":4,"body":"You can easily revoke all access token's by issuing a `POST` request to the following endpoint. This endpoint can help ensure that you only have one access token active at any time. Note that this endpoint revokes all access tokens for a given account and client ID (Nylas Application). If you have authenticated the same account to different applications within your Nylas organization, you must revoke the tokens for each respective app.\n\nIf you only need to revoke a single access token, you can do so using the regular [/oauth/revoke](ref:oauthrevoke) endpoint.\n[block:callout]\n{\n \"type\": \"success\",\n \"body\": \"If you want to keep your current access token, you may use the optional parameter `keep_access_token` to revoke all tokens except this one.\",\n \"title\": \"Revoke-all but one!\"\n}\n[/block]\nInclude the `client_secret` as the HTTP Basic Auth username. A `200` HTTP status code response with a body of `{ \"success\": True }` signifies that all tokens except the value for `keep_access_token`, if the parameter was used, have been successfully revoked and can no longer be used.","excerpt":"Revoke all tokens for an account, similar to /oauth/revoke.","slug":"revoke-all","type":"endpoint","title":"Revoke all tokens","__v":41,"updatedAt":"2019-09-20T18:54:32.541Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-20T00:36:15.130Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/revoke-all"}},{"_id":"5e41e73d960b09003ca359a3","order":5,"api":{"results":{"codes":[{"code":"{ \"success\": \"true\" }","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"examples":{"codes":[]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"`client_secret` passed as HTTP Basic Auth username","required":false,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The `client_id` of your Nylas developer application","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The `account_id`","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"}],"url":"/a/{client_id}/accounts/{id}/upgrade","method":"get"},"next":{"pages":[],"description":""},"parentDoc":"5e41e73d960b09003ca3599e","sync_unique":"","updates":[],"version":"5e41e73d960b09003ca35a9b","link_url":"","createdAt":"2017-05-24T17:41:49.323Z","githubsync":"","isReference":true,"link_external":false,"project":"59245c10200df13100c88563","title":"Deleting an account","body":"If you would like for an account's data to be completely removed from Nylas' servers, follow these steps to queue the account for deletion:\n\n1. [Revoke](ref:oauthrevoke) the account's access token, or [revoke all tokens](ref:revoke-all).\n2. [Cancel](ref:cancel-an-account) the account.\n\n**Please note:** Once you follow these steps, the account will be queued for deletion. It can take up to 30 days for an account's data to be completely removed. Furthermore, if the user re-connects their account and authenticates again, their account will not be deleted.\n[block:callout]\n{\n \"type\": \"danger\",\n \"title\": \"GDPR Deletions\",\n \"body\": \"For GDPR purposes, if you must confirm a deletion within 30 days, please [contact us](https://support.nylas.com/hc/en-us/requests/new) and make a request for GDPR deletion.\"\n}\n[/block]","category":"5e41e73d960b09003ca3596d","excerpt":"","hidden":false,"slug":"deleting-an-account","type":"basic","user":"5dfbae85310d180024013fe2","__v":6,"updatedAt":"2020-05-19T00:02:03.014Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"tutorials":[]},{"_id":"5e41e73d960b09003ca359e8","__v":4,"api":{"params":[],"url":"","method":"get","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required"},"createdAt":"2017-05-25T20:44:06.084Z","githubsync":"","link_url":"","next":{"description":"","pages":[]},"parentDoc":"5e41e73d960b09003ca3599e","sync_unique":"","version":"5e41e73d960b09003ca35a9b","excerpt":"","link_external":false,"project":"59245c10200df13100c88563","title":"Account Sync Status","user":"5d404909c2f77c0012211f3e","body":"Sometimes, syncing for an account can not complete successfully, or it might get interrupted. In the event of a recoverable failure, you will see a notification in the [Nylas dashboard](https://dashboard.nylas.com/) and one of the following status messages in the [Accounts](ref:accounts) API:\n\n| Status | Action required |\n| --- | --- |\n| initializing | The account is freshly connected with no known problems. This should be the very first momentary state of an account, and is part of the normal operation process. |\n| downloading | The account is in a normal operation state, but has not yet finished its initial sync. |\n| running | Sync is successfully running. No action is required. This means we are up to date and listening for new changes. |\n| invalid-credentials | This is an authenticating failure with the mail server. You should prompt the user to re-authorize. |\n| stopped | The sync is stopped. This can happen for a variety of reasons. If you are adding accounts beyond the limits of your free trial period, some syncing may be stopped until you upgrade your Nylas application. It can also occur when we repeatedly encounter unexpected errors. These errors most commonly originate from incompatibilities with upstream providers or temporary outages. |\n| exception | This can occur if an upstream provider returns an error that our sync engine does not yet understand. Please [contact us](https://support.nylas.com/hc/en-us/requests/new) for accounts in this state. |\n| sync-error | This means an unexpected error was raised while syncing an account. Please [contact us](https://support.nylas.com/hc/en-us/requests/new) for accounts in this state. |\n\nMost sync and connection failures are temporary, but if they persist, check our [status page](https://status.nylas.com) for any known problems and/or [contact support](https://support.nylas.com/hc/en-us/requests/new).\n\n\n## Credential errors\n\nThese occur when the user's account fails authorization. Usually this is because the user has changed their password, revoked their OAuth credentials, or their IMAP/ SMTP or Exchange server endpoint has changed.\n\nWithout authorization, no mail operations can successfully complete. In order to make the account active again, you will need to re-authorize the user by asking them to [reauthenticate](https://docs.nylas.com/docs/handling-account-re-authentications) and going through the authentication flow again.","category":"5e41e73d960b09003ca3596d","slug":"account-sync-status","updates":["59c150bca811850030a04a21","5bef303aed817f00fd2fff3c","5f2b80b46cc1010021bf3d53","5f3462c52a8c410abe14d4e6"],"hidden":false,"isReference":true,"order":6,"type":"basic","updatedAt":"2020-08-12T22:21:04.800Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-08-06T03:49:07.278Z","tutorials":[]},{"_id":"5e41e73d960b09003ca35a40","version":"5e41e73d960b09003ca35a9b","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","user":"5d404909c2f77c0012211f3e","parentDoc":"5e41e73d960b09003ca3599e","updates":["5e470334099e25046bdd71e1"],"next":{"pages":[],"description":""},"createdAt":"2018-12-13T19:09:05.765Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"code":"GET /a/95fmk****/ip_addresses HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic NXM4M****\ncache-control: no-cache","language":"http"},{"code":"curl -X GET \\\n https://api.nylas.com/a/{client_id}/ip_addresses \\\n -H 'Authorization: Basic ENCODED_SECRET'","language":"curl"},{"name":"Python SDK","code":"print(client.ip_addresses())","language":"python"},{"name":"Ruby SDK","code":"puts api.ip_addresses","language":"ruby"},{"code":"Nylas.accounts.first()\n .then(account => account.ipAddresses())\n .then(response => console.log(response));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.IPAddressWhitelist;\n\npublic class NylasExamples {\n public static void ipAddressesExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n\n IPAddressWhitelist ipAddresses = application.fetchIpAddressWhitelist();\n\n // The following attributes are available for the IPAddressWhitelist object\n ipAddresses.getIpAddresses();\n ipAddresses.getUpdatedAt();\n }\n}"}]},"results":{"codes":[{"name":"Abridged Response Example","code":"{\n \"ip_addresses\": [\n \"52.25.153.17\",\n \"52.26.120.161\",\n \"52.39.252.208\",\n \"54.71.62.98\",\n \"34.208.138.149\",\n \"52.88.199.110\",\n \"54.69.11.122\",\n \"54.149.110.158\"\n ],\n \"updated_at\": 1544658529\n}","language":"json","status":200}]},"auth":"required","params":[{"name":"client_id","type":"string","default":"","desc":"The client ID of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5c12ae516a3e7a019f96fbcd"},{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5c12ae516a3e7a019f96fbcc"}],"url":"/a/{client_id}/ip_addresses","method":"get"},"isReference":true,"order":7,"body":"[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note\",\n \"body\": \"This endpoint can only be accessed by paid applications.\"\n}\n[/block]\n## Overview \nIn some cases, mail servers and other service providers only allow connections from whitelisted IP addresses. Nylas has a variety of services that sync account data across a range of IP addresses, and these IP addresses can change at any moment. \n\nThis endpoint provides a dynamic list of IP addresses that Nylas might use to reach out to do things like send mail, perform proxied searches, send webhooks, etc. The JSON response object will contain an array of IP addresses and a timestamp of the last time it was updated. \n\nInstead of using a connected email account’s token, use your `client_secret` for the Basic Auth username which can be found in the developer console.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Rate limits\",\n \"body\": \"This endpoint has specific rate limits. Please see [rate limiting](ref:rate-limiting) for more information and make sure your application stays within the limit.\"\n}\n[/block]\n\n## Response\n\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `ip_addresses` | array | Array of IP addresses. |\n| `updated_at`| unix timestamp | Timestamp of the last time the list of IP addresses was updated. |","excerpt":"","slug":"get-ip-addresses","type":"endpoint","title":"IP Addresses","__v":32,"updatedAt":"2019-07-26T16:32:59.063Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:41:48.858Z","tutorials":[],"swagger":{"path":"/a/{client_id}/ip_addresses"}},{"_id":"5e41e73d960b09003ca35a6f","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-07-24T17:57:18.983Z","createdAt":"2019-07-24T17:23:19.122Z","project":"59245c10200df13100c88563","category":"5e41e73d960b09003ca3596d","parentDoc":"5e41e73d960b09003ca3599e","user":"5d404909c2f77c0012211f3e","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"language":"curl","code":"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}'"},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"Nylas.accounts\n .first()\n .then(account => account.tokenInfo())\n .then(response => console.log(response));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasApplication;\nimport com.nylas.NylasClient;\nimport com.nylas.Accounts;\nimport com.nylas.TokenInfo;\n\npublic class NylasExamples {\n public static void tokenInfoExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasApplication application = nylas.application(\"{CLIENT_ID}\", \"{CLIENT_SECRET}\");\n Accounts accounts = application.accounts();\n TokenInfo tokenInfo = accounts.tokenInfo(\"{accountId}\", \"{ACCESS_TOKEN}\");\n\n // The following attributes are available for the TokenInfo object\n tokenInfo.getCreatedAt();\n tokenInfo.getScopes();\n tokenInfo.getState();\n tokenInfo.getUpdatedAt();\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"created_at\": 1563496685,\n \"scopes\": \"calendar,email,contacts\",\n \"state\": \"valid\",\n \"updated_at\": 1563496685\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"No access_token passed.\",\n \"type\": \"api_error\"\n}","name":""},{"status":404,"language":"json","code":"{\n \"message\": \"No such token found for that account\",\n \"type\": \"api_error\"\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The Nylas app client secret, passed as an encoded HTTP username and password. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"id","type":"string","default":"","desc":"The id of the account for which to return information.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087e"},{"name":"access_token","type":"string","default":"","desc":"The account's `access_token` value that is returned during authentication.","required":true,"in":"body","ref":"","_id":"5d3895b593bd6502ea859479"}],"url":"/a/{client_id}/accounts/{id}/token-info","method":"post"},"isReference":true,"order":8,"body":"## Response\n\nReturns an object describing the account's `access_token`. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `created_at` | unix timestamp | Timestamp indicating when the access_token was created. |\n| `scopes` | string | Which authentications scopes are allowed with this token. See [authentication scopes](doc:authentication-scopes) for a list of possible `scopes` values. |\n| `state` | string | Can be `valid` or `inactive`. Using an inactive token will return an authorization error. |\n| `updated_at` | unix timestamp | Timestamp indicating when the token object was updated, typically reflecting a change in the token's `state`. |","excerpt":"Get information about an account's `access_token`","slug":"token-info","type":"endpoint","title":"/token-info","__v":13,"metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.631Z","tutorials":[],"swagger":{"path":"/a/{client_id}/accounts/{id}/token-info"}},{"_id":"5e41e73d960b09003ca35a98","version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-06-17T14:45:46.957Z","createdAt":"2019-12-09T17:41:04.161Z","project":"59245c10200df13100c88563","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":2,"body":"These endpoints allow you to view and manage the Nylas apps that are available via the [Nylas dashboard](https://dashboard.nylas.com).","excerpt":"View and edit Nylas Apps","slug":"application-management","type":"basic","metadata":{"description":"","title":"","image":[]},"title":"Application Management","__v":0,"parentDoc":null,"pendingAlgoliaPublish":false,"tutorials":[],"children":[{"_id":"5e41e73d960b09003ca35a94","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-11-06T18:10:58.128Z","createdAt":"2019-11-06T18:04:55.391Z","project":"59245c10200df13100c88563","parentDoc":"5e41e73d960b09003ca35a98","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{\n \"application_name\": \"Moon Indigo ✨\",\n \"icon_url\": \"https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6\",\n \"redirect_uris\": [\n \"http://localhost:5555/login_callback\",\n \"localhost\"\n ]\n}","name":""}]},"examples":{"codes":[{"language":"curl","code":"curl -X GET \"https://api.nylas.com/a/2ajt9foi41hf90hr50rj6flvr\" \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Basic mysUp3RS3crEtCl1EntS3crET=\""},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// list application details\nNylas.application().then(resp => console.log(resp));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.ApplicationDetail;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasApplication;\n\npublic class NylasExamples {\n public static void getApplicationDetails() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasApplication application = client.application(\n \"{CLIENT_ID}\", \n \"{CLIENT_SECRET}\");\n ApplicationDetail detail = application.getApplicationDetail();\n\n\t\t\t\t// The following attributes are available for the ApplicationDetail Class\n detail.getName();\n detail.getRedirectUris();\n detail.getIconUrl();\n\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d","auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The client secret, passed as an HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"}],"url":"/a/{client_id}/","method":"get"},"isReference":true,"order":0,"body":"## Response\n\nReturns an `Application` object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `application_name` | string | The name of the Nylas application. |\n| `icon_url` | string | Icon URL of the Nylas application. |\n| `redirect_uris` | array | Array of strings. Each string is a single redirect_uri for the application. |","excerpt":"List information about a Nylas application","slug":"list-app-details","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"List Application Details","__v":5,"pendingAlgoliaPublish":false,"tutorials":[],"swagger":{"path":"/a/{client_id}/"}},{"_id":"5e41e73d960b09003ca35a95","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-12-10T15:51:42.601Z","createdAt":"2019-11-06T18:16:11.101Z","project":"59245c10200df13100c88563","parentDoc":"5e41e73d960b09003ca35a98","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"language":"curl","code":"curl -X PUT \"https://api.nylas.com/a/{client_id}\" \\\n-H \"Authorization: Basic mysUp3RS3crEtCl1EntS3crET=\" \\\n-d '{\n \"application_name\": \"My New App Name\",\n \"redirect_uris\": [\n\t \"http://localhost:5555/login_callback\",\n\t \"localhost\",\n \"https://customerA.myapplication.com/login_callback\"\n\t]\n}'"},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// update application details\nNylas.application(\n {\n \tapplicationName: 'Updated name', \n \tredirectUris: [\n \t\"http://localhost:5555/login_callback\",\n\t \t\"localhost\",\n \t\"https://customerA.myapplication.com/login_callback\"\n ]\n }).then(response => console.log(response))"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.ApplicationDetail;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasApplication;\n\npublic class NylasExamples {\n public static void updateApplicationDetails() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasApplication application = client.application(\n \"{CLIENT_ID}\", \n \"{CLIENT_SECRET}\"); \n\n application.setName(\"My Nylas APP\");\n application.addRedirectUri(\"https://example.com/my_redirect\");\n application.removeRedirectUri(\"https://example.com/my_redirect\");\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"application_name\": \"My New App Name\",\n \"icon_url\": \"https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6\",\n \"redirect_uris\": [\n\t \"http://localhost:5555/login_callback\",\n\t \"localhost\",\n \"https://customerA.myapplication.com/login_callback\"\n ]\n}","name":""}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The client secret, passed as an HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"application_name","type":"string","default":"","desc":"Optionally include application_name to update the app's name. If this field isn't included, no changes will be made to the application name.","required":false,"in":"body","ref":"","_id":"5dc30deb9c8aa002e2825241"},{"name":"redirect_uris","type":"array_string","default":"","desc":"Array of strings. Each string is a single redirect_uri for the application. If `redirect_uris` is included in the request, existing redirect URIs will be overwritten with the contents of this array. This entire array must not exceed 64kb in size.","required":false,"in":"body","ref":"","_id":"5dc30deb9c8aa002e2825240"}],"url":"/a/{client_id}/","method":"put"},"isReference":true,"order":1,"body":"## Response\n\nReturns an `Application` object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `application_name` | string | The name of the Nylas application. |\n| `icon_url` | string | Icon URL of the Nylas application. |\n| `redirect_uris` | array | Array of strings. Each string is a single redirect_uri for the application. |","excerpt":"Update details of a Nylas application","slug":"update-application-details","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"Update Application Details","__v":11,"pendingAlgoliaPublish":false,"tutorials":[],"swagger":{"path":"/a/{client_id}/"}}],"childrenPages":[{"_id":"5e41e73d960b09003ca35a94","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-11-06T18:10:58.128Z","createdAt":"2019-11-06T18:04:55.391Z","project":"59245c10200df13100c88563","parentDoc":"5e41e73d960b09003ca35a98","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{\n \"application_name\": \"Moon Indigo ✨\",\n \"icon_url\": \"https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6\",\n \"redirect_uris\": [\n \"http://localhost:5555/login_callback\",\n \"localhost\"\n ]\n}","name":""}]},"examples":{"codes":[{"language":"curl","code":"curl -X GET \"https://api.nylas.com/a/2ajt9foi41hf90hr50rj6flvr\" \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Basic mysUp3RS3crEtCl1EntS3crET=\""},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// list application details\nNylas.application().then(resp => console.log(resp));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.ApplicationDetail;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasApplication;\n\npublic class NylasExamples {\n public static void getApplicationDetails() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasApplication application = client.application(\n \"{CLIENT_ID}\", \n \"{CLIENT_SECRET}\");\n ApplicationDetail detail = application.getApplicationDetail();\n\n\t\t\t\t// The following attributes are available for the ApplicationDetail Class\n detail.getName();\n detail.getRedirectUris();\n detail.getIconUrl();\n\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d","auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The client secret, passed as an HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"}],"url":"/a/{client_id}/","method":"get"},"isReference":true,"order":0,"body":"## Response\n\nReturns an `Application` object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `application_name` | string | The name of the Nylas application. |\n| `icon_url` | string | Icon URL of the Nylas application. |\n| `redirect_uris` | array | Array of strings. Each string is a single redirect_uri for the application. |","excerpt":"List information about a Nylas application","slug":"list-app-details","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"List Application Details","__v":5,"pendingAlgoliaPublish":false,"tutorials":[],"swagger":{"path":"/a/{client_id}/"}},{"_id":"5e41e73d960b09003ca35a95","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-12-10T15:51:42.601Z","createdAt":"2019-11-06T18:16:11.101Z","project":"59245c10200df13100c88563","parentDoc":"5e41e73d960b09003ca35a98","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"language":"curl","code":"curl -X PUT \"https://api.nylas.com/a/{client_id}\" \\\n-H \"Authorization: Basic mysUp3RS3crEtCl1EntS3crET=\" \\\n-d '{\n \"application_name\": \"My New App Name\",\n \"redirect_uris\": [\n\t \"http://localhost:5555/login_callback\",\n\t \"localhost\",\n \"https://customerA.myapplication.com/login_callback\"\n\t]\n}'"},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// update application details\nNylas.application(\n {\n \tapplicationName: 'Updated name', \n \tredirectUris: [\n \t\"http://localhost:5555/login_callback\",\n\t \t\"localhost\",\n \t\"https://customerA.myapplication.com/login_callback\"\n ]\n }).then(response => console.log(response))"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.ApplicationDetail;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasApplication;\n\npublic class NylasExamples {\n public static void updateApplicationDetails() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasApplication application = client.application(\n \"{CLIENT_ID}\", \n \"{CLIENT_SECRET}\"); \n\n application.setName(\"My Nylas APP\");\n application.addRedirectUri(\"https://example.com/my_redirect\");\n application.removeRedirectUri(\"https://example.com/my_redirect\");\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"application_name\": \"My New App Name\",\n \"icon_url\": \"https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6\",\n \"redirect_uris\": [\n\t \"http://localhost:5555/login_callback\",\n\t \"localhost\",\n \"https://customerA.myapplication.com/login_callback\"\n ]\n}","name":""}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The client secret, passed as an HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"application_name","type":"string","default":"","desc":"Optionally include application_name to update the app's name. If this field isn't included, no changes will be made to the application name.","required":false,"in":"body","ref":"","_id":"5dc30deb9c8aa002e2825241"},{"name":"redirect_uris","type":"array_string","default":"","desc":"Array of strings. Each string is a single redirect_uri for the application. If `redirect_uris` is included in the request, existing redirect URIs will be overwritten with the contents of this array. This entire array must not exceed 64kb in size.","required":false,"in":"body","ref":"","_id":"5dc30deb9c8aa002e2825240"}],"url":"/a/{client_id}/","method":"put"},"isReference":true,"order":1,"body":"## Response\n\nReturns an `Application` object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `application_name` | string | The name of the Nylas application. |\n| `icon_url` | string | Icon URL of the Nylas application. |\n| `redirect_uris` | array | Array of strings. Each string is a single redirect_uri for the application. |","excerpt":"Update details of a Nylas application","slug":"update-application-details","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"Update Application Details","__v":11,"pendingAlgoliaPublish":false,"tutorials":[],"swagger":{"path":"/a/{client_id}/"}}]},{"_id":"5e41e73d960b09003ca35a94","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-11-06T18:10:58.128Z","createdAt":"2019-11-06T18:04:55.391Z","project":"59245c10200df13100c88563","parentDoc":"5e41e73d960b09003ca35a98","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{\n \"application_name\": \"Moon Indigo ✨\",\n \"icon_url\": \"https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6\",\n \"redirect_uris\": [\n \"http://localhost:5555/login_callback\",\n \"localhost\"\n ]\n}","name":""}]},"examples":{"codes":[{"language":"curl","code":"curl -X GET \"https://api.nylas.com/a/2ajt9foi41hf90hr50rj6flvr\" \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Basic mysUp3RS3crEtCl1EntS3crET=\""},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// list application details\nNylas.application().then(resp => console.log(resp));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.ApplicationDetail;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasApplication;\n\npublic class NylasExamples {\n public static void getApplicationDetails() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasApplication application = client.application(\n \"{CLIENT_ID}\", \n \"{CLIENT_SECRET}\");\n ApplicationDetail detail = application.getApplicationDetail();\n\n\t\t\t\t// The following attributes are available for the ApplicationDetail Class\n detail.getName();\n detail.getRedirectUris();\n detail.getIconUrl();\n\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d","auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The client secret, passed as an HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"}],"url":"/a/{client_id}/","method":"get"},"isReference":true,"order":0,"body":"## Response\n\nReturns an `Application` object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `application_name` | string | The name of the Nylas application. |\n| `icon_url` | string | Icon URL of the Nylas application. |\n| `redirect_uris` | array | Array of strings. Each string is a single redirect_uri for the application. |","excerpt":"List information about a Nylas application","slug":"list-app-details","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"List Application Details","__v":5,"pendingAlgoliaPublish":false,"tutorials":[],"swagger":{"path":"/a/{client_id}/"}},{"_id":"5e41e73d960b09003ca35a95","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-12-10T15:51:42.601Z","createdAt":"2019-11-06T18:16:11.101Z","project":"59245c10200df13100c88563","parentDoc":"5e41e73d960b09003ca35a98","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca3596d","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"language":"curl","code":"curl -X PUT \"https://api.nylas.com/a/{client_id}\" \\\n-H \"Authorization: Basic mysUp3RS3crEtCl1EntS3crET=\" \\\n-d '{\n \"application_name\": \"My New App Name\",\n \"redirect_uris\": [\n\t \"http://localhost:5555/login_callback\",\n\t \"localhost\",\n \"https://customerA.myapplication.com/login_callback\"\n\t]\n}'"},{"name":"Python SDK","language":"python","code":"# This feature is not yet available in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"# This feature is not yet available in the Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// update application details\nNylas.application(\n {\n \tapplicationName: 'Updated name', \n \tredirectUris: [\n \t\"http://localhost:5555/login_callback\",\n\t \t\"localhost\",\n \t\"https://customerA.myapplication.com/login_callback\"\n ]\n }).then(response => console.log(response))"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.ApplicationDetail;\nimport com.nylas.NylasClient;\nimport com.nylas.NylasApplication;\n\npublic class NylasExamples {\n public static void updateApplicationDetails() throws IOException, RequestFailedException {\n NylasClient client = new NylasClient();\n NylasApplication application = client.application(\n \"{CLIENT_ID}\", \n \"{CLIENT_SECRET}\"); \n\n application.setName(\"My Nylas APP\");\n application.addRedirectUri(\"https://example.com/my_redirect\");\n application.removeRedirectUri(\"https://example.com/my_redirect\");\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"application_name\": \"My New App Name\",\n \"icon_url\": \"https://inbox-developer-resources.s3.amazonaws.com/icons/da5b3a1c-448c-11e7-872b-0625ca014fd6\",\n \"redirect_uris\": [\n\t \"http://localhost:5555/login_callback\",\n\t \"localhost\",\n \"https://customerA.myapplication.com/login_callback\"\n ]\n}","name":""}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The client secret, passed as an HTTP Basic Auth username.","required":true,"in":"header","ref":"","_id":"5925c1c23b8c27250014c506"},{"name":"client_id","type":"string","default":"","desc":"The client_id of your Nylas developer application.","required":false,"in":"path","ref":"","_id":"5925c459504e52390038087f"},{"name":"application_name","type":"string","default":"","desc":"Optionally include application_name to update the app's name. If this field isn't included, no changes will be made to the application name.","required":false,"in":"body","ref":"","_id":"5dc30deb9c8aa002e2825241"},{"name":"redirect_uris","type":"array_string","default":"","desc":"Array of strings. Each string is a single redirect_uri for the application. If `redirect_uris` is included in the request, existing redirect URIs will be overwritten with the contents of this array. This entire array must not exceed 64kb in size.","required":false,"in":"body","ref":"","_id":"5dc30deb9c8aa002e2825240"}],"url":"/a/{client_id}/","method":"put"},"isReference":true,"order":1,"body":"## Response\n\nReturns an `Application` object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|---|:----|\n| `application_name` | string | The name of the Nylas application. |\n| `icon_url` | string | Icon URL of the Nylas application. |\n| `redirect_uris` | array | Array of strings. Each string is a single redirect_uri for the application. |","excerpt":"Update details of a Nylas application","slug":"update-application-details","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"Update Application Details","__v":11,"pendingAlgoliaPublish":false,"tutorials":[],"swagger":{"path":"/a/{client_id}/"}},{"_id":"5e41e73d960b09003ca359e9","createdAt":"2017-05-25T20:44:35.813Z","link_external":false,"project":"59245c10200df13100c88563","title":"Configuration Problems","type":"basic","__v":0,"category":"5e41e73d960b09003ca3596d","isReference":true,"updates":[],"user":"597fb20c6ec952001e63f8f3","version":"5e41e73d960b09003ca35a9b","api":{"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"name":"","status":400,"language":"json","code":"{}"}]},"auth":"required","params":[],"url":"","method":"get"},"excerpt":"","hidden":false,"sync_unique":"","body":"Sometimes you might run into trouble when trying to sync accounts. Here is a list of common problems you might run into.\n\n# 'All Mail' folder disabled\n\nFor Gmail and Google Apps accounts, the Nylas Sync Engine synchronizes the 'All Mail' folder. If a user has disabled IMAP access for this folder, synchronization will fail.\n\nTo fix it, the user needs to make sure the 'All Mail' folder has 'Show in IMAP' checked in their [Gmail settings](https://mail.google.com/mail/u/0/#settings/labels). After enabling it, re-authorize the user by restarting the authorization flow.\n\n# Full IMAP not enabled\n\nAs the Nylas Sync Engine synchronizes mail over IMAP, if IMAP access is not properly enabled for an account or a domain, synchronization will fail. **Note:** This does not apply to Microsoft Exchange accounts.\n\nThe user needs to ensure IMAP is fully enabled for their account. This may involve contacting their domain administrator or hosting provider. Once it is enabled, re-authorize the user.\n\n# Connection and sync errors\n\nIf temporary connection issues persist, contact [support](mailto:support@nylas.com) for assistance. Outages or other unscheduled service interruptions are posted on [Nylas Status](http://status.nylas.com).\n\n# Too many connections\n\nSome IMAP configurations limit the number of connections which can be made. If a user has several programs accessing their email account via IMAP, they may run into this error with the Nylas Sync Engine. To resolve this, the user must close other programs which may be accessing their account via IMAP. Gmail users can check which [applications they have authorized](https://security.google.com/settings/security/permissions?pli=1), and remove any that are no longer being used.","githubsync":"","next":{"pages":[],"description":""},"slug":"configuration-problems","link_url":"","order":3,"parentDoc":null,"updatedAt":"2019-06-13T19:26:20.869Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359a4","sync_unique":"","body":"Threads are `first-class` objects allowing you to build beautiful mail applications, that behave the way users have come to expect. Actions like archiving or deleting can be performed on threads or individual messages.\n\nNylas threads messages together using a variety of heuristics. On Gmail and Microsoft Exchange accounts, messages will be threaded together as close as possible to the representation in those environments. For all other providers (including generic IMAP), messages are threaded using a custom JWZ-inspired algorithm. (Open source code is available [here](https://github.com/nylas/sync-engine/blob/master/inbox/util/threading.py#L11), for the curious.)\n\nTo load all messages for a given thread, you should instead use the [messages](ref:introduction-1) endpoint with a `thread_id` filter parameter.\n\n## The Thread Object\n\nResponses from the `/threads` endpoint are encoded as UTF-8 JSON objects with the following attributes:\n\n| attribute | type | description |\n|----:|:----|:----|\n| `id` | string | Globally unique object identifier |\n| `object` | string | A string describing the type of object (value is \"thread\") |\n| `account_id` | string | Reference to parent account object |\n| `subject` | string | Subject of the first message in the thread |\n| `unread` | boolean | Indicates whether the thread contains unread messages (mutable) |\n| `starred` | boolean | Indicates one or more messages are starred, aka flagged (mutable) |\n| `last_message_timestamp` | unix timestamp | Timestamp of the most recent message |\n| `last_message_received_timestamp` | unix timestamp | Timestamp of the most recently received message.<br>(Excludes messages sent by the account.) |\n| `last_message_sent_timestamp` | unix timestamp | Timestamp of the most recently sent message in the thread |\n| `first_message_timestamp` | unix timestamp | Timestamp when the thread began |\n| `participants` | array | List of participant objects computed from all messages in the thread.|\n| `snippet` | string | A shortened plain-text preview of the most recent message in the thread |\n| `message_ids` | array | Array of IDs for messages within the thread, sorted by their timestamps |\n| `draft_ids` | array | Array of IDs for unsent drafts in the thread. May be null or absent |\n| `version` | integer | Incrementing value related to thread updates.<br>You can use this to compare revisions, or invalidate your local cache. |\n| `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](ref:folders) docs for more info. |\n| `labels` | array | A list of [label](ref:labels) 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. |\n| `has_attachments` | boolean | Indicates if the thread has files attached to it. | \n\n\n## Supported Modifications\n\nYou can make many modifications to the state of threads:\n\n1. Modify the unread status.\n2. Star or unstar the thread.\n3. Move the thread to a different folder.\n4. Modify the thread's labels.\n\nTo make these modifications, make a HTTP PUT request to `/threads/{id}` with any combination of the body parameters [specified here](ref:threadsid-1).\n[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"An operation on a thread is performed on all the messages in the thread. It is a convenient shortcut to perform bulk operations on messages, which is what users have come to expect with modern mail applications.\",\n \"title\": \"A note about thread modifications\"\n}\n[/block]\n## Filtering, Pagination, and Views with Threads\n\nThe threads endpoint supports [Filters](ref:filters), [Pagination](ref:pagination), and [Views](ref:views), making it easy to return a subset of threads in a specific folder, from a certain address, with a specific subject, etc.\n\n### Thread Filtering\n\nThreads support various combinations of [Filters](ref:filters). Check all the query parameters on the [/threads](ref:threads-1) endpoint for more information.\n\n### Thread Pagination\n\nBy default the `/threads` endpoint will return a maximum of 100 objects. You should paginate through an entire user's mailbox by using the `limit` and `offset` URL query parameters. See [Pagination](ref:pagination) for more details about pagination. Check all the query parameters on the [/threads](ref:threads-1) endpoint for more information.\n\n### Thread Views\n\nThreads support the use of [Views](ref:views) by including the `view` query parameter in your request.\n\nThe Expanded Threads View expands the threads response to contain message and draft sub-objects. Adding `view=expanded` will remove `message_ids` and `draft_ids`, and include `messages` and `drafts`. Note the message and draft sub-objects do not include a `body` parameter.","link_external":false,"link_url":"","order":0,"parentDoc":null,"next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","slug":"threads","type":"basic","version":"5e41e73d960b09003ca35a9b","createdAt":"2017-05-24T17:45:23.323Z","excerpt":"","hidden":false,"isReference":true,"updates":[],"user":"59245bff200df13100c88562","__v":0,"api":{"url":"","method":"get","results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[]},"category":"5e41e73d960b09003ca3596e","githubsync":"","title":"Introduction","updatedAt":"2019-07-08T22:36:40.034Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359a5","body":"## Response\n\nReturns an array of [Thread](ref:threads#the-thread-object) objects.","category":"5e41e73d960b09003ca3596e","updates":[],"user":"5e98c0e3f880e50292a15648","__v":44,"api":{"url":"/threads","auth":"required","examples":{"codes":[{"language":"http","code":"GET /threads?view=count&amp; limit=10 HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache"},{"language":"curl","code":"\n# Get all threads found in the user's inbox\ncurl -X GET 'https://api.nylas.com/threads' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \n\n# Get threads that are filtered by specified arguments\n# Available filters: subject, to, from, cc, bcc, in, unread,\n# starred, filename, last_message_before, last_message_after, started_before, started_after\ncurl -X GET 'https://api.nylas.com/threads?to=swag@nylas.com' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Use offset, and limit to control pagination\ncurl -X GET 'https://api.nylas.com/threads?limit=5&offset=10' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Get all threads that meet a specified search criteria\ncurl -X GET 'https://api.nylas.com/threads/search?q=agenda' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all threads found in the user's inbox\nnylas.threads.all()\n\n# Return threads that are filtered by specified arguments\nnylas.threads.where(to='swag@nylas.com')\n# Available filters: subject, to, from_, cc, bcc, in_, unread,\n# starred, filename, last_message_before, last_message_after, started_before, started_after\n\n# Use offset, and limit to control pagination\nnylas.threads.where(limit=10, offset=5)\n\n# Return all threads that meet a specified search criteria\nnylas.threads.search('swag@nylas.com')\n\n# Return the most recent thread\nthread = nylas.threads.first()\n\n# The following attributes are available for the thread object\nthread.subject\nthread.message_ids\nthread.unread\nthread.labels # Gmail accounts only\nthread.folders # All providers other than Gmail\nthread.last_message_timestamp\nthread.last_message_received_timestamp\nthread.account_id\nthread.object\nthread.first_message_at\nthread.id\nthread.snippet\nthread.participants\nthread.draft_ids\nthread.last_message_received_at\nthread.version\nthread.last_message_at\nthread.first_message_timestamp\nthread.starred\nthread.has_attachments"},{"name":"Ruby SDK","language":"ruby","code":"# Return all threads found in the user's inbox\nnylas.threads\n\n# Return threads that are filtered by specified arguments\nnylas.threads.where(to: 'swag@nylas.com')\n# Available filters: subject, to, from, cc, bcc, in, unread,\n# starred, filename, last_message_before, last_message_after, started_before, started_after\n\n# Use offset, and limit to control pagination\nnylas.threads.limit(10).offset(5)\n\n# Return all threads that meet a specified search criteria\nnylas.threads.search('swag@nylas.com')\n\n# Return the most recent thread\nthread = nylas.threads.first\n\n# The following attributes are available for the thread object\nthread.subject\nthread.message_ids\nthread.unread\nthread.labels # Gmail accounts only\nthread.folders # All providers other than Gmail\nthread.last_message_timestamp\nthread.last_message_received_timestamp\nthread.account_id\nthread.object\nthread.first_message_timestamp\nthread.id\nthread.snippet\nthread.participants\nthread.draft_ids\nthread.last_message_received_timestamp\nthread.version\nthread.last_message_timestamp\nthread.starred"},{"name":"Node.js SDK","language":"javascript","code":"// Get all threads found in the user's inbox\nnylas.threads.list().then(threads => console.log(threads))\n\n// Get threads that are filtered by specified arguments\nnylas.threads.list({to: 'swag@nylas.com'}).then(resp => console.log(resp));\n// Available filters: subject, to, from_, cc, bcc, in_, unread,\n// starred, filename, last_message_before, last_message_after, started_before, started_after\n\n// Use offset, and limit to control pagination\nnylas.threads.list({limit: 5}).then(threads => console.log(threads))\n\n// Get all threads that meet a specified search criteria\nnylas.threads.search('Debrief').then(threads => console.log(threads));\n\n// Get the most recent thread\nnylas.threads.first().then(thread => console.log(thread));\n\n// The following attributes are available for the thread object\nthread.id\nthread.object\nthread.accountId\nthread.subject\nthread.participants\nthread.lastMessageTimestamp\nthread.lastMessageReceivedTimestamp\nthread.lastMessageSentTimestamp\nthread.firstMessageTimestamp\nthread.snippet\nthread.unread\nthread.starred\nthread.hasAttachments\nthread.version\nthread.labels\nthread.messageIds\nthread.draftIds"},{"name":"Java SDK","language":"java","code":"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}"}]},"method":"get","params":[{"name":"view","type":"string","default":"","desc":"Can be one of `ids`, `count`, or `expanded`. See [Views](ref:views) for more information.","required":false,"in":"query","ref":"","_id":"5925cf6538d6340f00dc05e9"},{"name":"limit","type":"int","default":"","desc":"The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies.","required":false,"in":"query","ref":"","_id":"5925d01dcaf08d250018c111"},{"name":"offset","type":"int","default":"","desc":"Zero-based offset from default object sorting. See [pagination](ref:pagination) for more information.","required":false,"in":"query","ref":"","_id":"5925d01dcaf08d250018c110"},{"name":"subject","type":"string","default":"","desc":"Return threads with a matching literal subject.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81f"},{"name":"any_email","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81e"},{"name":"to","type":"string","default":"","desc":"Return threads containing messages sent to this email address.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81d"},{"name":"from","type":"string","default":"","desc":"Return threads containing messages sent from this email address.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81c"},{"name":"cc","type":"string","default":"","desc":"Return threads containing messages that were CC'd to this email address.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81b"},{"name":"bcc","type":"string","default":"","desc":"Return threads containing messages that were BCC'd to this email address, likely sent from the parent account. (Most SMTP gateways remove BCC information.)","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81a"},{"name":"in","type":"string","default":"","desc":"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. **Note:** To get all drafts, use the `/drafts` endpoint.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db819"},{"name":"unread","type":"boolean","default":"","desc":"Return threads with one or more unread messages.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db818"},{"name":"starred","type":"boolean","default":"","desc":"Return threads with one or more starred messages.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db817"},{"name":"filename","type":"string","default":"","desc":"Return threads that contain attachments with the given filename.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db816"},{"name":"last_message_before","type":"int","default":"","desc":"Return threads whose most recent message was received before this Unix-based timestamp.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db815"},{"name":"last_message_after","type":"int","default":"","desc":"Return threads whose most recent message was received after this Unix-based timestamp.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db814"},{"name":"started_before","type":"int","default":"","desc":"Return threads whose first message was received before this Unix-based timestamp.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db813"},{"name":"started_after","type":"int","default":"","desc":"Return threads whose first message was received after this Unix-based timestamp.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db812"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5ad69f4480a5b20003a4ec4b"}],"results":{"codes":[{"status":200,"language":"json","code":"[\n {\n \"account_id\": \"1234***\",\n \"draft_ids\": [],\n \"first_message_timestamp\": 1557950729,\n \"folders\": [\n {\n \"display_name\": \"Inbox\",\n \"id\": \"4567****\",\n \"name\": \"inbox\"\n }\n ],\n \"has_attachments\": false,\n \"id\": \"4312****\",\n \"last_message_received_timestamp\": 1557950729,\n \"last_message_sent_timestamp\": null,\n \"last_message_timestamp\": 1557950729,\n \"message_ids\": [\n \"5634***\"\n ],\n \"object\": \"thread\",\n \"participants\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n },\n {\n \"email\": \"james****@yahoo.com\",\n \"name\": \"\"\n }\n ],\n \"snippet\": \"Hi James, welcome.\",\n \"starred\": false,\n \"subject\": \"Security settings changed on your Yahoo account\",\n \"unread\": false,\n \"version\": 1\n }\n]","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T17:51:44.956Z","excerpt":"Returns one or more threads that match the filter specified by the query parameters.","isReference":true,"link_external":false,"order":1,"project":"59245c10200df13100c88563","sync_unique":"","githubsync":"","hidden":false,"parentDoc":null,"type":"endpoint","version":"5e41e73d960b09003ca35a9b","link_url":"","next":{"pages":[],"description":""},"slug":"get-threads","title":"/threads","updatedAt":"2019-05-20T20:00:50.774Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.629Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/threads"}},{"_id":"5e41e73d960b09003ca359a6","title":"/threads/{id}","api":{"auth":"required","examples":{"codes":[{"language":"http","code":"GET /threads/4312**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic SVNzcT...\ncache-control: no-cache\n"},{"language":"curl","code":"curl -X GET 'https://api.nylas.com/threads/{thread_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Return a single thread, replace {id} with the appropriate value\nnylas.threads.get('{id}')\n\n# The following attributes are available for the thread object\nthread.subject\nthread.message_ids\nthread.unread\nthread.labels # Gmail accounts only\nthread.folders # All providers other than Gmail\nthread.last_message_timestamp\nthread.last_message_received_timestamp\nthread.account_id\nthread.object\nthread.first_message_at\nthread.id\nthread.snippet\nthread.participants\nthread.draft_ids\nthread.last_message_received_at\nthread.version\nthread.last_message_at\nthread.first_message_timestamp\nthread.starred\nthread.has_attachments"},{"name":"Ruby SDK","language":"ruby","code":"# Return a single thread, replace {id} with the appropriate value\nnylas.threads.find('{id}')\n\n# The following attributes are available for the thread object\nthread.subject\nthread.message_ids\nthread.unread\nthread.labels # Gmail accounts only\nthread.folders # All providers other than Gmail\nthread.last_message_timestamp\nthread.last_message_received_timestamp\nthread.account_id\nthread.object\nthread.first_message_timestamp\nthread.id\nthread.snippet\nthread.participants\nthread.draft_ids\nthread.last_message_received_timestamp\nthread.version\nthread.last_message_timestamp\nthread.starred"},{"name":"Node.js SDK","language":"javascript","code":"// Get a single thread, by its id\nnylas.threads.find('{id}').then(thread => console.log(thread));\n\n// The following attributes are available for the thread object\nthread.id\nthread.object\nthread.accountId\nthread.subject\nthread.participants\nthread.lastMessageTimestamp\nthread.lastMessageReceivedTimestamp\nthread.lastMessageSentTimestamp\nthread.firstMessageTimestamp\nthread.snippet\nthread.unread\nthread.starred\nthread.hasAttachments\nthread.version\nthread.labels\nthread.messageIds\nthread.draftIds"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Thread;\nimport com.nylas.Threads;\n\npublic class NylasExamples {\n public static void getThreadExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Threads threads = account.threads();\n // Replace '{id}' with the appropriate value\n Thread thread = threads.get(\"{id}\");\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 thread.getId();\n thread.getSnippet();\n thread.getParticipants();\n thread.getDraftIds();\n thread.getVersion();\n thread.isStarred();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the thread to return.","required":false,"in":"path","ref":"","_id":"5925d1b838d6340f00dc0611"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"1234***\",\n \"draft_ids\": [],\n \"first_message_timestamp\": 1557950729,\n \"folders\": [\n {\n \"display_name\": \"Inbox\",\n \"id\": \"4567****\",\n \"name\": \"inbox\"\n }\n ],\n \"has_attachments\": false,\n \"id\": \"4312****\",\n \"last_message_received_timestamp\": 1557950729,\n \"last_message_sent_timestamp\": null,\n \"last_message_timestamp\": 1557950729,\n \"message_ids\": [\n \"5634***\"\n ],\n \"object\": \"thread\",\n \"participants\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n },\n {\n \"email\": \"james****@yahoo.com\",\n \"name\": \"\"\n }\n ],\n \"snippet\": \"Hi James, welcome.\",\n \"starred\": false,\n \"subject\": \"Security settings changed on your Yahoo account\",\n \"unread\": false,\n \"version\": 1\n}","name":""},{"code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":"","status":400,"language":"json"}]},"url":"/threads/{id}","apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"Returns the thread identified by the specified thread ID.","link_external":false,"order":2,"parentDoc":null,"sync_unique":"","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","isReference":true,"link_url":"","next":{"pages":[],"description":""},"__v":32,"body":"## Response\nReturns a [Thread](ref:threads#the-thread-object) object.","category":"5e41e73d960b09003ca3596e","githubsync":"","hidden":false,"createdAt":"2017-05-24T18:32:24.755Z","project":"59245c10200df13100c88563","slug":"threadsid","type":"endpoint","updates":[],"updatedAt":"2019-05-20T20:00:00.798Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:47.753Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/threads/{id}"}},{"_id":"5e41e73d960b09003ca359aa","slug":"threadsid-1","sync_unique":"","updates":[],"version":"5e41e73d960b09003ca35a9b","createdAt":"2017-05-24T19:30:07.776Z","excerpt":"Updates the specified thread (e.g. moves a thread to a new folder).","isReference":true,"order":3,"next":{"pages":[],"description":""},"__v":40,"category":"5e41e73d960b09003ca3596e","githubsync":"","link_url":"","parentDoc":null,"title":"/threads/{id}","type":"endpoint","user":"5d404909c2f77c0012211f3e","body":"## Response\nReturns the updated [Thread](ref:threads#the-thread-object) object.\n \n## Unread status\nThe `unread` attribute is set to `true` if any of the thread's messages are unread. To mark all underlying messages as read, your application should change the `unread` attribute to `false` on the thread. Any change to a thread's `unread` status will cascade to all messages in the thread.\n\nChanges to the unread status will propagate to the backend mailbox provider, such as Gmail or Exchange.\n\n## Starring (flags)\n\nStars, also known as *flags*, are displayed in nearly every mail app, and are an easy way to highlight a specific message. Although most apps usually show stars at the thread level, they are actually an attribute of messages themselves. Changing the starred property of a thread will cause all messages in that thread to be starred or unstarred.\n\nThe `starred` property in the Nylas API is equivalent to stars in Gmail, the [IMAP flagged message attribute](https://tools.ietf.org/html/rfc3501#section-2.3.2) and Microsoft Exchange message flags.\n\nChanges to the starred value will propagate to the backend mailbox provider, such as Gmail or Exchange.\n\n## Moving a thread\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"This is only supported for accounts where the `organization_unit` is set to `folder`. Generally this is all non-Gmail/Google Apps accounts. You can check if an account supports folders by the `organization_unit` property on the [Account](ref:account) object.\",\n \"title\": \"Note about thread folders\"\n}\n[/block]\nThe `folders` attribute of a thread contains an array of folder objects. This is the union of all folders containing messages in the thread. For example, an ongoing discussion thread would likely have messages in the Inbox, Sent Mail, and perhaps the Archive folders.\n\nYour application can move a thread to a new folder by specifying a `folder_id`, and this will perform the operation on all messages within that thread. Using the Inbox folder ID will move all messages of the thread to the Inbox. \n\nNote that messages in the sent folder are not moved via this batch action.\n\n## Modifying labels\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"This is only supported for accounts where the `organization_unit` is set to `label`. Generally this is only Gmail/Google Apps accounts. You can check if an account supports labels by the organization_unit property on the [Account](ref:account) object.\",\n \"title\": \"Note about labels\"\n}\n[/block]\nLabels are a Gmail-specific way of organizing messages. A message or thread can have multiple labels, enabling more complex queries and email management workflows. The `labels` attribute of a thread contains an array of [Label](ref:labels) objects. This is the union of all labels on messages in the thread.\n\nThe Nylas platform lets you easily change the labels associated with a message. This change will propagate to the backend mailbox provider (Gmail).","hidden":false,"link_external":false,"api":{"url":"/threads/{id}","method":"put","results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"6534****\",\n \"draft_ids\": [],\n \"first_message_timestamp\": 1557950729,\n \"folders\": [\n {\n \"display_name\": \"Inbox\",\n \"id\": \"3245****\",\n \"name\": \"inbox\"\n }\n ],\n \"has_attachments\": false,\n \"id\": \"4312****\",\n \"last_message_received_timestamp\": 1557950729,\n \"last_message_sent_timestamp\": null,\n \"last_message_timestamp\": 1557950729,\n \"message_ids\": [\n \"87567****\"\n ],\n \"object\": \"thread\",\n \"participants\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n },\n {\n \"email\": \"james****@yahoo.com\",\n \"name\": \"\"\n }\n ],\n \"snippet\": \"Hi James, welcome.\",\n \"starred\": false,\n \"subject\": \"Security settings changed on your Yahoo account\",\n \"unread\": true,\n \"version\": 2\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"examples":{"codes":[{"code":"PUT /threads/4312**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic SVNzc****\ncache-control: no-cache\n{\n \"unread\": true\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","language":"http"},{"code":"# 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}'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Replace '{id}' with the appropriate value\nthread = client.threads.get('{id}')\n\n# Mark thread read\nthread.mark_as_read()\n\n# Mark thread unread\nthread.mark_as_unread()\n\n# Star a thread\nthread.star()\n\n# Unstar a thread\nthread.unstar()\n\n# Add a new label to a thread (Gmail)\nthread.add_label('{label_id}')\n\n# Remove a label from a thread (Gmail)\nthread.remove_label('{label_id}')\n\n# Batch update labels on a thread (Gmail)\nthread.update_labels(['{label_id}', '{another_label_id}'])\n\n# Move a thread to a different folder (Non-Gmail)\nthread.update_folder('{folder_id}')","language":"python"},{"name":"Ruby SDK","code":"# Replace '{id}' with the appropriate value\nthread = client.threads.find('{id}')\n\n# Mark thread read\nthread.update(unread: false)\n\n# Mark thread unread\nthread.update(unread: true)\n\n# Star a thread\nthread.update(starred: true)\n\n# Unstar a thread\nthread.update(starred: false)\n\n# Batch update labels on a thread (Gmail)\nthread.update(label_ids: ['first-label-id'])","language":"ruby"},{"code":"// Get a single thread, by its id\nnylas.threads.find('{id}').then(thread => {\n \n // mark as unread (false for read)\n thread.unread = true;\n \n // mark as starred (false for unstarred)\n thread.starred = true;\n \n // add label\n const existingLabel = nylas.labels.build({displayName: 'Reminders', id: '<labelId>'});\n thread.labels.push(existingLabel);\n \n // remove label\n thread.labels = thread.labels.filter(function(value, index, arr){\n return value.displayName != 'Important';\n });\n \n // save updates\n thread.save();\n})","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.util.Arrays;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Threads;\n\npublic class NylasExamples {\n public static void putThreadExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Threads threads = account.threads();\n \n // Mark thread read\n threads.setUnread(\"{thread_id}\", false);\n \n // Mark thread unread\n threads.setUnread(\"{thread_id}\", true);\n \n // Star a thread\n threads.setStarred(\"{thread_id}\", true);\n \n // Unstar a thread\n threads.setStarred(\"{thread_id}\", false);\n \n // Update labels on a thread (Gmail)\n threads.setLabelIds(\"{thread_id}\", Arrays.asList(\"{label_id}\", \"{another_label_id}\"));\n \n // Move a thread to a different folder (Non-Gmail)\n threads.setFolderId(\"{thread_id}\", \"{folder_id}\");\n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The thread ID.","required":false,"in":"path","ref":"","_id":"5925d1b838d6340f00dc0611"},{"name":"unread","type":"boolean","default":"","desc":"Set to `true` to mark as unread; `false` to mark as read.","required":false,"in":"body","ref":"","_id":"5925df3f0f38120f00db3769"},{"name":"starred","type":"boolean","default":"","desc":"Set to `true`to star a thread; `false` to un-star a thread.","required":false,"in":"body","ref":"","_id":"5925df3f0f38120f00db3768"},{"name":"folder_id","type":"string","default":"","desc":"The ID of the folder to which to move this thread.","required":false,"in":"body","ref":"","_id":"5925df3f0f38120f00db3767"},{"name":"label_ids","type":"array_string","default":"","desc":"The IDs of the labels to apply, overwriting all previous labels on the thread.","required":false,"in":"body","ref":"","_id":"5925df3f0f38120f00db3766"}],"apiSetting":"5e41e73d960b09003ca3598d"},"project":"59245c10200df13100c88563","updatedAt":"2019-05-22T16:21:29.790Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:07:30.771Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/threads/{id}"}},{"_id":"5e41e73d960b09003ca359a7","title":"Introduction","createdAt":"2017-05-24T18:54:24.049Z","excerpt":"","order":0,"slug":"messages","api":{"params":[],"url":"","method":"get","results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required"},"category":"5e41e73d960b09003ca3596f","user":"5f2067586dda9a0045009159","version":"5e41e73d960b09003ca35a9b","__v":0,"isReference":true,"sync_unique":"","link_url":"","next":{"pages":[],"description":""},"parentDoc":null,"project":"59245c10200df13100c88563","body":"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, to whom it was sent, and the message body. They can also contain files (attachments), calendar event invitations, and more.\n[block:callout]\n{\n \"type\": \"danger\",\n \"body\": \"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.\",\n \"title\": \"Security notice about message bodies\"\n}\n[/block]\n## The Message Object\n\nResponses from the `/messages` endpoint are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----|---|----|\n| `id` | string | A globally unique object identifier. |\n| `object` | string | A string describing the type of object (value is \"message\").\n| `account_id` | string | Reference to a parent account object. |\n| `thread_id` | string | Reference to a parent thread object (all messages have a thread). |\n| `subject` | string | The subject line of the message. |\n| `from` | array | A list of name+email pairs the message was sent from. This is usually one object, but can be many. |\n| `to` | array | An array of name+email pairs the message was sent to. |\n| `cc` | array | An array of name+email pairs the message was cc'd to. |\n| `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). |\n| `reply_to` | array | An array of name+email pairs replies should be sent to. |\n| `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.\n| `unread` | boolean | Indicates the message is unread. This is the default for new incoming mail (mutable). |\n| `starred` | boolean | Indicates the message is in a starred or flagged state (mutable). |\n| `snippet` | string | A shortened plain-text preview of the message body.\n| `body` | string | The full HTML message body. Messages with only plain-text representations are up-converted to HTML.\n| `files` | array | An array of [File](ref:files) objects, if the message includes attachments.\n| `events` | array | An array [Event](ref:events) objects, if message includes calendar invites.\n| `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.\n| `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. |\n\n## Supported Modifications\n\nLike [Threads](ref:threads), you can make many modifications to the state of messages. You can:\n\n1. Modify the unread status.\n2. Star or unstar the message.\n3. Move the message to a different folder.\n4. Modify the message's labels.\n\nTo make these modifications, make a HTTP PUT request to `/messages/{id}` with any combination of the body parameters [specified here](ref:messagesid-1).\n\nThe Nylas APIs expose a parsed and sanitized version of the original [RFC-2822](https://www.ietf.org/rfc/rfc2822.txt) 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.\n\nWe still provide access to the [RFC-2822 raw message](ref:raw-message-contents) object, if needed.\n\n## Filtering, Pagination, and Views with Messages\n\nThe messages endpoint supports [Filters](ref:filters), [Pagination](ref:pagination), and [Views](ref:views), making it easy to return a subset of messages in a specific folder, from a certain address, with a specific subject, etc.\n\n### Message Filtering\n\nMessages support various combinations of [Filters](ref:filters). Check all the query parameters on the [/messages](ref:messages-1) endpoint for more information.\n\n### Message Pagination\n\nBy default the `/messages` endpoint will return a maximum of 100 objects. You should paginate through an entire user's mailbox by using the `limit` and `offset` URL query parameters. See [Pagination](ref:pagination) for more details about pagination. Check all the query parameters on the [/messages](ref:messages-1) endpoint for more information.\n\n### Message Views\n\nMessages support the use of [Views](ref:views) by including the `view` query parameter in your request.\n\nThe 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` and `/messages/{id}`.\n\nThe following block is an example of what is added to the message object when using the expanded view.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"headers\\\": {\\n \\\"In-Reply-To\\\": \\\"<evh5uy0shhpm5d0le89goor17-0@mailer.nylas.com>\\\",\\n \\\"Message-Id\\\": \\\"<84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com>\\\",\\n \\\"References\\\": [\\\"<evh5uy0shhpm5d0le89goor17-0@mailer.nylas.com>\\\"],\\n }\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n| Header | Requirement | Description |\n| ----------|-------|-------| \n| `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. |\n| `In-Reply-To` | optional | The parent `Message-Id` to which this message replied. Expected `null` for messages that are not replies. |\n| `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. |\n[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"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.\",\n \"title\": \"A note about expanded message view\"\n}\n[/block]","githubsync":"","hidden":false,"link_external":false,"type":"basic","updates":[],"updatedAt":"2020-12-01T19:01:53.648Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-08-19T20:27:06.575Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359a8","parentDoc":null,"type":"endpoint","updates":["5e4ee8a8ffda0b006722e398"],"body":"## Response\n\nReturns an array of [Message](ref:messages#the-messages-object) objects.","link_external":false,"project":"59245c10200df13100c88563","link_url":"","next":{"pages":[],"description":""},"title":"/messages","__v":37,"api":{"auth":"required","examples":{"codes":[{"language":"http","code":"GET /messages?limit=10 HTTP/1.1\nHost: api.nylas.com\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n"},{"language":"curl","code":"\n# Get all threads found in the user's inbox\ncurl -X GET 'https://api.nylas.com/messages' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \n\n# Get threads that are filtered by specified arguments\n# Available filters: subject, to, from_, cc, bcc, in_, unread,\n# starred, filename, last_message_before, last_message_after, started_before, started_after\ncurl -X GET 'https://api.nylas.com/messages?to=swag@nylas.com' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Use offset, and limit to control pagination\ncurl -X GET 'https://api.nylas.com/messages?limit=5&offset=10' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Use view to expand\ncurl -X GET 'https://api.nylas.com/messages?view=expanded' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Get all threads that meet a specified search criteria\ncurl -X GET 'https://api.nylas.com/messages/search?q=agenda' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Return all messages found in the user's inbox\nnylas.messages.all()\n\n# Return messages that are filtered by specified arguments\nnylas.messages.where(to='swag@nylas.com')\n# Available filters: subject, to, from_, cc, bcc, in_, unread,\n# starred, filename, thread_id, received_before, received_after\n\n# Use offset, and limit to paginate the results\nnylas.messages.where(limit=10, offset=5)\n\n# Expanded view returns additional header information (see below)\nnylas.messages.where(view='expanded')\n\n# Return all messages that meet a specified search criteria\nnylas.messages.search('swag@nylas.com')\n\n# Return the most recent message\nmessage = nylas.messages.first()\n\n\n# The following attributes are available for the message object\nmessage.id\nmessage.object\nmessage.account_id\nmessage.thread_id\nmessage.subject\nmessage.from_\nmessage.to\nmessage.cc\nmessage.bcc\nmessage.date\nmessage.unread\nmessage.starred\nmessage.snippet\nmessage.body\nmessage.files\nmessage.events\nmessage.folder\nmessage.labels\nmessage.received_at\n\n# These are available in expanded view only.\nmessage.headers['Message-Id']\nmessage.headers['References']\nmessage.headers['In-Reply-To']"},{"name":"Ruby SDK","language":"ruby","code":"# Return all messages found in the user's inbox\nnylas.messages\n\n# Return messages that are filtered by specified arguments\nnylas.messages.where(to: 'swag@nylas.com')\n# Available filters: subject, to, from, cc, bcc, in, unread,\n# starred, filename, thread_id, received_before, received_after\n\n# Use offset, and limit to paginate the results\nnylas.messages.limit(10).offset(5)\n\n# Expanded view returns additional header information (see below)\nnylas.messages.where(view: 'expanded')\n\n# Return all messages that meet a specified search criteria\nnylas.messages.search('swag@nylas.com')\n\n# Return the most recent message\nmessage = nylas.messages.first\n\n\n# The following attributes are available for the message object\nmessage.id\nmessage.object\nmessage.account_id\nmessage.thread_id\nmessage.subject\nmessage.from\nmessage.to\nmessage.cc\nmessage.bcc\nmessage.date\nmessage.unread\nmessage.starred\nmessage.snippet\nmessage.body\nmessage.files\nmessage.events\nmessage.folder\nmessage.labels\nmessage.received_date\n\n# These are available in expanded view only.\nmessage.headers.message_id\nmessage.headers.references\nmessage.headers.in_reply_to"},{"name":"Node.js SDK","language":"javascript","code":"// Get all messages found in the user's inbox\nnylas.messages.list().then(messages => console.log(messages));\n\n// Get messages that are filtered by specified arguments\nnylas.messages.list({to: 'swag@nylas.com'}).then(resp => console.log(resp));\n// Available filters: subject, to, from, cc, bcc, in, unread,\n// starred, filename, last_message_before, last_message_after, started_before, started_after\n\n// Use offset and limit to control pagination\nnylas.messages.list({limit: 5}).then(messages => console.log(messages));\n\n// Expanded view returns additional header information (see below)\nnylas.messages.list({view: 'expanded'}).then(resp => console.log(resp));\n\n// Get all messages that meet a specified search criteria\nnylas.messages.search('Debrief').then(messages => console.log(messages));\n\n// The following attributes are available for the message object\nmessage.id\nmessage.object\nmessage.accountId\nmessage.threadId\nmessage.subject\nmessage.from\nmessage.to\nmessage.replyTo\nmessage.cc\nmessage.bcc\nmessage.date\nmessage.unread\nmessage.starred\nmessage.snippet\nmessage.body\nmessage.files\nmessage.events\nmessage.folder\nmessage.labels\n\n// These are available in expanded view only.\nmessage.headers['Message-Id']\nmessage.headers['References']\nmessage.headers['In-Reply-To']"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Message;\nimport com.nylas.MessageQuery;\nimport com.nylas.Messages;\n\npublic class NylasExamples {\n public static void getMessagesExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Messages messages = account.messages();\n \n // Return all messages found in the user's inbox \n messages.list();\n \n // Return messages that are filtered by specified arguments\n // Available Filters: anyEmail, bcc, cc, filename, \n // from, hasAttachment, in, receivedAfter, receivedBefore, \n // starred, subject, threadId, to, unread\n messages.list(new MessageQuery().to(\"swag@nylas.com\"));\n \n // Use offset, and limit to control pagination\n messages.list(new MessageQuery().limit(10).offset(10));\n \n // Return all messages that meet a specified search criteria\n messages.search(\"swag@nylas.com\");\n \n // Return the most recent message\n Message message = messages.list(new MessageQuery().limit(1)).get(0);\n \n // The following attributes are available for the message object\n message.getSubject();\n message.getSnippet();\n message.getBody();\n message.getFiles();\n message.getFrom();\n message.getTo();\n message.getCc();\n message.getBcc();\n message.getUnread();\n message.getDate();\n message.getLabels(); // Gmail accounts only\n message.getFolder(); // All providers other than Gmail\n message.getReplyTo();\n message.getAccountId();\n message.getObjectType();\n message.getId();\n message.getSnippet();\n message.getStarred();\n message.getThreadId();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"view","type":"string","default":"","desc":"Can be one of `ids`, `count`, or `expanded`. See [Views](ref:views) for more information.","required":false,"in":"query","ref":"","_id":"5925cf6538d6340f00dc05e9"},{"name":"limit","type":"int","default":"","desc":"The number of objects to return. Defaults to 100. If set too high, requests may fail to prevent excessively large response bodies.","required":false,"in":"query","ref":"","_id":"5925d01dcaf08d250018c111"},{"name":"offset","type":"int","default":"","desc":"The zero-based offset for the default object sorting. See [pagination](ref:pagination) for more information.","required":false,"in":"query","ref":"","_id":"5925d01dcaf08d250018c110"},{"name":"subject","type":"string","default":"","desc":"Return messages with a matching literal subject.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81f"},{"name":"any_email","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81e"},{"name":"to","type":"string","default":"","desc":"Return messages sent to this email address.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81d"},{"name":"from","type":"string","default":"","desc":"Return messages sent from this email address.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81c"},{"name":"cc","type":"string","default":"","desc":"Return messages that were CC'd to this email address.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81b"},{"name":"bcc","type":"string","default":"","desc":"Return messages that were BCC'd to this email address, likely sent from the parent account. (Most SMTP gateways remove BCC information.)","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db81a"},{"name":"in","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db819"},{"name":"unread","type":"boolean","default":"","desc":"Return unread messages","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db818"},{"name":"starred","type":"boolean","default":"","desc":"Return starred messages.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db817"},{"name":"filename","type":"string","default":"","desc":"Return messages that contain attachments with the given filename.","required":false,"in":"query","ref":"","_id":"5925d15eceaef40f009db816"},{"name":"thread_id","type":"string","default":"","desc":"Return messages belonging to a specific thread.","required":false,"in":"query","ref":"","_id":"5925d7baa935a90f0059be68"},{"name":"received_before","type":"string","default":"","desc":"Return messages received before this unix timestamp.","required":false,"in":"query","ref":"","_id":"5925d7baa935a90f0059be67"},{"name":"received_after","type":"string","default":"","desc":"Return messages received after this unix timestamp.","required":false,"in":"query","ref":"","_id":"5925d7baa935a90f0059be66"},{"name":"has_attachment","type":"boolean","default":"","desc":"Return only messages that have attachments (only true is supported).","required":false,"in":"query","ref":"","_id":"5a95f10b4091e600125d01d6"}],"results":{"codes":[{"code":"[\n {\n \"account_id\": \"43jf****\",\n \"bcc\": [],\n \"body\": \"<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 ... </html>\",\n \"cc\": [],\n \"date\": 1557950729,\n \"events\": [],\n \"files\": [],\n \"folder\": {\n \"display_name\": \"Inbox\",\n \"id\": \"7hcg****\",\n \"name\": \"inbox\"\n },\n \"from\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n }\n ],\n \"id\": \"7a8939****\",\n \"object\": \"message\",\n \"reply_to\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n }\n ],\n \"snippet\": \"Hi James, james****@yahoo.com. Welcome.\",\n \"starred\": false,\n \"subject\": \"Welcome\",\n \"thread_id\": \"cvsp****\",\n \"to\": [\n {\n \"email\": \"james****@yahoo.com\",\n \"name\": \"\"\n }\n ],\n \"unread\": true\n }\n]","language":"json","status":200,"name":""},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"url":"/messages","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T18:54:56.654Z","hidden":false,"isReference":true,"sync_unique":"","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca3596f","excerpt":"Searches for messages using the specified filter criteria.","githubsync":"","order":1,"slug":"messages-1","updatedAt":"2019-05-21T16:26:09.835Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.895Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/messages"}},{"_id":"5e41e73d960b09003ca359a9","api":{"auth":"required","examples":{"codes":[{"language":"http","code":"GET /messages/7a8939**** HTTP/1.1\nHost: api.nylas.com\nAuthorization: Basic WVVUWj****==\ncache-control: no-cache\n"},{"language":"curl","code":"curl -X GET 'https://api.nylas.com/messages/{message_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate message id\nmessage = nylas.messages.get('{id}')\n\n# The following attributes are available for the message object\nmessage.id\nmessage.object\nmessage.account_id\nmessage.thread_id\nmessage.subject\nmessage.from_\nmessage.to\nmessage.cc\nmessage.bcc\nmessage.date\nmessage.unread\nmessage.starred\nmessage.snippet\nmessage.body\nmessage.files\nmessage.events\nmessage.folder\nmessage.labels\nmessage.received_at\n\n# These are available in expanded view only.\nmessage.headers['Message-Id']\nmessage.headers['References']\nmessage.headers['In-Reply-To']","name":"Python SDK"},{"language":"ruby","code":"# Replace {id} with the appropriate message id\nmessage = nylas.messages.find('{id}')\n\n# The following attributes are available for the message object\nmessage.id\nmessage.object\nmessage.account_id\nmessage.thread_id\nmessage.subject\nmessage.from\nmessage.to\nmessage.cc\nmessage.bcc\nmessage.date\nmessage.unread\nmessage.starred\nmessage.snippet\nmessage.body\nmessage.files\nmessage.events\nmessage.folder\nmessage.labels\nmessage.received_date\n\n# These are available in expanded view only.\nmessage.headers.message_id\nmessage.headers.references\nmessage.headers.in_reply_to","name":"Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"// Replace {id} with the appropriate message id\nnylas.messages.find('{id}').then(message =>{\n // The following attributes are available for the message object\n message.id\n message.object\n message.accountId\n message.threadId\n message.subject\n message.from\n message.to\n message.replyTo\n message.cc\n message.bcc\n message.date\n message.unread\n message.starred\n message.snippet\n message.body\n message.files\n message.events\n message.folder\n message.labels\n\n // These are available in expanded view only.\n message.headers['Message-Id']\n message.headers['References']\n message.headers['In-Reply-To']\n});"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Message;\nimport com.nylas.Messages;\n\npublic class NylasExamples {\n public static void getMessageExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Messages messages = account.messages();\n \n // Replace '{id}' with the appropriate value\n Message message = messages.get(\"{id}\");\n \n // The following attributes are available for the message object\n message.getSubject();\n message.getSnippet();\n message.getBody();\n message.getFiles();\n message.getFrom();\n message.getTo();\n message.getCc();\n message.getBcc();\n message.getUnread();\n message.getDate();\n message.getLabels(); // Gmail accounts only\n message.getFolder(); // All providers other than Gmail\n message.getReplyTo();\n message.getAccountId();\n message.getObjectType();\n message.getId();\n message.getSnippet();\n message.getStarred();\n message.getThreadId();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the message for which to search.","required":false,"in":"path","ref":"","_id":"5ce6d4eed969a102a2a244dd"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"43jf3****\",\n \"bcc\": [],\n \"body\": \"<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</title>\\n ... </html>\",\n \"cc\": [],\n \"date\": 1557950729,\n \"events\": [],\n \"files\": [],\n \"folder\": {\n \"display_name\": \"Inbox\",\n \"id\": \"7hcg****\",\n \"name\": \"inbox\"\n },\n \"from\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n }\n ],\n \"id\": \"7a8939****\",\n \"object\": \"message\",\n \"reply_to\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n }\n ],\n \"snippet\": \"Hi James, james****@yahoo.com Welcome.\",\n \"starred\": false,\n \"subject\": \"Welcome to...\",\n \"thread_id\": \"cvsppk****\",\n \"to\": [\n {\n \"email\": \"james****@yahoo.com\",\n \"name\": \"\"\n }\n ],\n \"unread\": true\n}","name":""},{"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":"","status":400}]},"url":"/messages/{object_id}","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T19:20:35.365Z","link_external":false,"updates":["5e53dfcffd1a4e015bf2f287","5f2b8142fa4119016dab7045"],"githubsync":"","isReference":true,"slug":"messagesid","version":"5e41e73d960b09003ca35a9b","excerpt":"Searches for a message identified by the specified message ID.","category":"5e41e73d960b09003ca3596f","link_url":"","sync_unique":"","type":"endpoint","__v":39,"hidden":false,"next":{"pages":[],"description":""},"order":2,"parentDoc":null,"project":"59245c10200df13100c88563","title":"/messages/{id}","user":"5d404909c2f77c0012211f3e","body":"## Response\n\nReturns a [Message](ref:messages#the-messages-object) object.\n\n\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note for attributes available in expanded view only.\",\n \"body\": \"These attributes are not available in the many of the SDKs since it is not possible to specify the expanded view for the client get method. Instead, you can use the client where method or parse the message.raw object for the headers you desire.\"\n}\n[/block]","updatedAt":"2020-03-31T13:50:36.392Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.731Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/messages/{object_id}"}},{"_id":"5e41e73d960b09003ca359ab","project":"59245c10200df13100c88563","sync_unique":"","version":"5e41e73d960b09003ca35a9b","excerpt":"Updates the specified message (e.g. move a message to a new folder).","hidden":false,"parentDoc":null,"order":3,"slug":"messagesid-1","title":"/messages/{id}","type":"endpoint","body":"## Response\n\nReturns the updated [Message](ref:messages#the-messages-object) object.\n\n## Unread status\n\nIn most systems, incoming mail is given an \"unread\" status to help the user triage messages. When viewing a message, it's customary for a mail app to automatically modify this \"unread\" attribute and remove the notification or highlight.\n\nHowever, unlike its literal meaning, the unread value is mutable, and so it's possible to manually change a message back to \"unread.\" Users will often do this as a reminder to follow up or triage a message later.\n\nThe Nylas platform lets you easily change the unread property of a message. This change will propagate to the backend mailbox provider, such as Gmail or Exchange.\n\n## Starring (flags)\n\nStars, also know as \"flags\", are displayed in nearly every mail app, and are an easy way to highlight a specific message. Although most apps usually show stars at the thread level, they are actually an attribute of messages themselves. (e.g. If one message in a thread is starred, the entire thread is shown as starred.)\n\nThe starred property in the Nylas API is equivalent to stars in Gmail, the [IMAP flagged message attribute](https://tools.ietf.org/html/rfc3501#section-2.3.2) and Microsoft Exchange message \"flags.\"\n\nThey Nylas platform lets you easily change the starred property of a message. This change will propagate to the backend mailbox provider, such as Gmail or Exchange.\n\n## Moving a message\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note about moving messages\",\n \"body\": \"This is only supported for accounts where the `organization_unit` is set to `folder`. Generally this is all non-Gmail/Google Apps accounts. You can check if an account supports folders by the organization_unit property on the [Account](ref:account) object.\"\n}\n[/block]\nFolders are a common way to organize email messages. A mailbox usually has a set of standard folders like Inbox, Sent Mail, and Trash, along with any number of user-created folders. For more information about types and capabilities, see the [Folders](ref:folders) section.\n\nNylas supports moving messages between folders with a single, simple API call. Note that messages can only exist within one folder.\n\n## Modifying labels\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note about modifying message labels\",\n \"body\": \"This is only supported for accounts where the `organization_unit` is set to `label`. Generally this is only Gmail/Google Apps accounts. You can check if an account supports labels by the organization_unit property on the [Account](ref:account) object.\"\n}\n[/block]\nLabels are a Gmail-specific way of organizing messages. A message or thread can have multiple labels, enabling more complex queries and email management workflows.\n\nThe Nylas platform lets you easily change the labels associated with a message. This change will propagate to the backend mailbox provider (Gmail).","isReference":true,"link_url":"","next":{"pages":[],"description":""},"user":"5d404909c2f77c0012211f3e","link_external":false,"__v":30,"api":{"method":"put","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the message to update.","required":false,"in":"path","ref":"","_id":"5925dd037fbe3b190096bdcc"},{"name":"unread","type":"boolean","default":"","desc":"Set to `true` to mark as unread; `false` to mark as read.","required":false,"in":"body","ref":"","_id":"5925f49aa668b80f00e2e6e6"},{"name":"starred","type":"boolean","default":"","desc":"Set to `true`to star a message; `false` to un-star a message.","required":false,"in":"body","ref":"","_id":"5925f49aa668b80f00e2e6e5"},{"name":"folder_id","type":"string","default":"","desc":"The ID of the folder to which to move this message.","required":false,"in":"body","ref":"","_id":"5925f49aa668b80f00e2e6e4"},{"name":"label_ids","type":"string","default":"","desc":"The IDs of the labels to apply, overwriting all previous labels on the message.","required":false,"in":"body","ref":"","_id":"5925f49aa668b80f00e2e6e3"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"account_id\": \"43jf3****\",\n \"bcc\": [],\n \"body\": \"<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</title>\\n ... </html>\",\n \"cc\": [],\n \"date\": 1557950729,\n \"events\": [],\n \"files\": [],\n \"folder\": {\n \"display_name\": \"Inbox\",\n \"id\": \"7hcg****\",\n \"name\": \"inbox\"\n },\n \"from\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n }\n ],\n \"id\": \"7a8939****\",\n \"object\": \"message\",\n \"reply_to\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"Yahoo\"\n }\n ],\n \"snippet\": \"Hi James, james****@yahoo.com Welcome.\",\n \"starred\": false,\n \"subject\": \"Welcome to...\",\n \"thread_id\": \"cvsppk****\",\n \"to\": [\n {\n \"email\": \"james****@yahoo.com\",\n \"name\": \"\"\n }\n ],\n \"unread\": true\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"url":"/messages/{id}","auth":"required","examples":{"codes":[{"code":"PUT /messages/7a893**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"unread\": true\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","language":"http"},{"code":"# 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}'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace '{id}' with the appropriate value\nmessage = client.messages.get('{id}')\n\n# Mark message read\nmessage.mark_as_read()\n\n# Mark message unread\nmessage.mark_as_unread()\n\n# Star a message\nmessage.star()\n\n# Unstar a message\nmessage.unstar()\n\n# Add a new label to a message (Gmail)\nmessage.add_label('{label_id}')\n\n# Remove a label from a message (Gmail)\nmessage.remove_label('{label_id}')\n\n# Batch update labels on a message (Gmail)\nmessage.update_labels(['{label_id}', '{another_label_id}'])\n\n# Move a message to a different folder (Non-Gmail)\nmessage.update_folder('{folder_id}')\n\n# All message changes must be saved to be synced to the third party provider\nmessage.save()","language":"python"},{"name":"Ruby SDK","code":"# Replace '{id}' with the appropriate value\nmessage = client.messages.find('{id}')\n\n# Mark message read\nmessage.update(unread: false)\n\n# Mark message unread\nmessage.update(unread: true)\n\n# Star a message\nmessage.update(starred: true)\n\n# Unstar a message\nmessage.update(starred: false)\n\n# Batch update labels on a message (Gmail)\nmessage.update(label_ids: ['label-id'])\n\n# All message changes must be saved to be synced to the third party provider\nmessage.save","language":"ruby"},{"code":"// Get a single message, by its id\nnylas.messages.find('{id}').then(message => {\n \n // mark as unread (false for read)\n message.unread = true;\n \n // mark as starred (false for unstarred)\n message.starred = true;\n \n // add a label to a message\n const existingLabel = nylas.labels.find('{labelId}');\n message.labels.push(existingLabel);\n \n // remove label\n message.labels = message.labels.filter(function(value, index, arr){\n return value.displayName != 'Important';\n });\n \n // save your updates to the email provider\n message.save();\n})","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.util.Arrays;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Messages;\n\npublic class NylasExamples {\n public static void putMessageExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Messages messages = account.messages();\n \n // Mark message read\n messages.setUnread(\"{message_id}\", false);\n \n // Mark message unread\n messages.setUnread(\"{message_id}\", true);\n \n // Star a message\n messages.setStarred(\"{message_id}\", true);\n \n // Unstar a message\n messages.setStarred(\"{message_id}\", false);\n \n // Update labels on a message (Gmail)\n messages.setLabelIds(\"{message_id}\", Arrays.asList(\"{label_id}\", \"{another_label_id}\"));\n \n // Move a message to a different folder (Non-Gmail)\n messages.setFolderId(\"{message_id}\", \"{folder_id}\");\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596f","createdAt":"2017-05-24T20:59:23.735Z","githubsync":"","updates":[],"updatedAt":"2019-05-21T17:06:05.769Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.737Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/messages/{id}"}},{"_id":"5e41e73d960b09003ca359ac","project":"59245c10200df13100c88563","user":"5d404909c2f77c0012211f3e","title":"Raw message contents","api":{"auth":"required","params":[{"name":"Accept","type":"string","default":"message/rfc822","desc":"","required":true,"in":"header","ref":"","_id":"5925f84e1b02090f008e1226"},{"name":"Authorization","type":"string","default":"","desc":"The access token, passed as an HTTP Basic Auth username. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925f84e1b02090f008e1225"},{"name":"id","type":"string","default":"","desc":"The message ID.","required":false,"in":"path","ref":"","_id":"5925f84e1b02090f008e1224"}],"url":"/messages/{id}","method":"get","examples":{"codes":[{"language":"http","code":"GET /messages/7a8939*** HTTP/1.1\nHost: api.nylas.com\nAccept: message/rfc822\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache\n"},{"code":"curl -X GET 'https://api.nylas.com/messages/{message_id}' \\\n-H 'Accept: message/rfc822' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\nmessage = nylas.messages.get('{id}')\n# retrieve the raw message\nprint(message.raw)\n","language":"python"},{"name":"Ruby SDK","code":"raw_message = nylas.messages.raw.find('{id}')\n\n# print the raw message\nputs raw_message","language":"ruby"},{"code":"// Retrieve raw MIME for a message\nnylas.messages\n .first()\n .then(message => message.getRaw())\n .then(rawMessage => console.log(rawMessage));","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Messages;\n\npublic class NylasExamples {\n public static void getMessageExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Messages messages = account.messages();\n \n String rawMessage = messages.getRaw(\"{messageId}\"}\n }\n}"}]},"results":{"codes":[{"code":"X-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</title>\n </head>\n<body style=\"font-family:Helvetica Neue;\">\n\n\t...\n\n</body>\n</html>\n","language":"text","status":200,"name":""},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca3596f","githubsync":"","isReference":true,"slug":"raw-message-contents","updates":[],"link_external":false,"link_url":"","next":{"pages":[],"description":""},"sync_unique":"","type":"endpoint","hidden":false,"order":4,"parentDoc":null,"__v":21,"body":"## Response\n\nIf you need to access some specific email headers or data that is not exposed by the standard message API, you can request the original raw message data originally downloaded from the mail server. Setting the `Accept` header to `message/rfc822` will return the entire raw message object in [RFC 2822 format](https://www.ietf.org/rfc/rfc2822.txt), including all MIME body subtypes and attachments.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Note\",\n \"body\": \"The Message ID header is distinct from Nylas Message ID.\"\n}\n[/block]","createdAt":"2017-05-24T21:17:02.163Z","excerpt":"Returns the (raw) RFC-2822 message object.","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-05-30T18:48:42.802Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.185Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/messages/{id}"}},{"_id":"5e41e73d960b09003ca359ad","isReference":true,"link_external":false,"next":{"pages":[],"description":""},"parentDoc":null,"sync_unique":"","user":"597fb20c6ec952001e63f8f3","api":{"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"language":"json","code":"{}","name":"","status":400}]},"auth":"required","params":[],"url":"","method":"get"},"createdAt":"2017-05-24T21:23:04.110Z","excerpt":"","title":"Introduction","type":"basic","category":"5e41e73d960b09003ca35970","link_url":"","version":"5e41e73d960b09003ca35a9b","__v":1,"body":"Folders behave like normal IMAP or filesystem folders. A [Message](ref:messages) can only exist within one folder at a time, but a [Thread](ref:threads) with many messages may span several folders.\n\nFolders 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](ref:account) object.\n\nFolders support basic [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations outlined in the endpoints below.\n\n## Using [Filters](ref:filters) with Folders\n\nThe endpoints for [Messages](ref:messages), [Threads](ref:threads), and [Files](ref:files) support [Filters](ref:filters) for folders using the `in` query parameter. Simply pass a `folder_id`, `name`, or `display_name` value when calling those endpoints. This conveniently has the same format for both labels and folders, so your application can specify a single filtering request that is independent of organization unit. See the [Filters](ref:filters) documentation for more details.\n\n## Nested Folders\n\nIMAP 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.\n\nThe 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`.","order":0,"project":"59245c10200df13100c88563","slug":"folders","updates":["5ca63fc3c8d479000ecccc14"],"githubsync":"","hidden":false,"updatedAt":"2019-06-13T19:53:31.249Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359ae","order":1,"parentDoc":null,"project":"59245c10200df13100c88563","sync_unique":"","user":"5d404909c2f77c0012211f3e","__v":23,"isReference":true,"link_external":false,"excerpt":"Returns information about all folders.","hidden":false,"link_url":"","next":{"pages":[],"description":""},"title":"/folders","api":{"examples":{"codes":[{"code":"GET /folders HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache\n","language":"http"},{"code":"# Return all folders found in the user's inbox\ncurl -X GET 'https://api.nylas.com/folders' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Use offset, and limit to paginate the results\ncurl -X GET 'https://api.nylas.com/folders?limit=2&offset=4' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all folders found in the user's inbox\nnylas.folders.all()\n\n# Use offset, and limit to paginate the results\nnylas.folders.where(limit=2, offset=4)\n\n# Return the first folder\nfolder = nylas.folders.first()\n\n# The following attributes are available for the folder object\nfolder.display_name\nfolder.name\nfolder.object\nfolder.account_id\nfolder.id","language":"python"},{"name":"Ruby SDK","code":"# Return all folders found in the user's inbox\nnylas.folders\n\n# Use offset, and limit to paginate the results\nnylas.folders.limit(2).offset(4)\n\n# Return the last folder\nnylas.folders.last\n\n# Return the first folder\nfolder = nylas.folders.first\n\n# The following attributes are available for the folder object\nfolder.display_name\nfolder.name\nfolder.object\nfolder.account_id\nfolder.id","language":"ruby"},{"code":"// Return all folders found in the user's inbox\nnylas.folders.list().then(folders => console.log(folders));\n\n// Use offset, and limit to paginate the results\nnylas.folders.list({limit: 2, offset: 4}).then(folders => console.log(folders))\n\n// Return the first folder\nnylas.folders.first().then(folder => console.log(folder));\n\n// The following attributes are available for the folder object\nfolder.id\nfolder.object\nfolder.accountId\nfolder.name\nfolder.displayName","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Folder;\nimport com.nylas.FolderQuery;\nimport com.nylas.Folders;\n\npublic class NylasExamples {\n public static void getFoldersExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Folders folders = account.folders();\n \n // Return all folders found in the user's inbox \n folders.list();\n \n // Use offset, and limit to control pagination\n folders.list(new FolderQuery().limit(2).offset(4));\n \n // Return the first folder\n Folder folder = folders.list(new FolderQuery().limit(1)).get(0);\n \n // The following attributes are available for the folder object\n folder.getDisplayName();\n folder.getName();\n folder.getObject();\n folder.getId();\n folder.getAccountId();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"}],"results":{"codes":[{"status":200,"language":"json","code":"[\n {\n \"id\": \"4zv7p****\",\n \"object\": \"folder\",\n \"name\": \"inbox\",\n \"display_name\": \"INBOX\",\n \"account_id\": \"awa6lt****\"\n },\n {\n \"id\": \"76zrf****\",\n \"name\": \"archive\",\n \"display_name\": \"2015 Archive\",\n \"account_id\": \"awa6lto****\",\n \"object\": \"folder\"\n }\n]","name":""},{"name":"","status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}"}]},"url":"/folders","auth":"required","apiSetting":"5e41e73d960b09003ca3598d"},"body":"## Response\n\nReturns an array of Folder objects. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|---|:----|\n| `id` | string | Globally unique object identifier. |\n| `object` | string | A string describing the type of object (value is \"folder\").\n| `account_id` | string | Reference to parent account object. |\n| `name` | string | Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154). <br>Can be one of the following: <ul><li>inbox</li><li>all</li><li>trash</li><li>archive</li><li>drafts</li><li>sent</li><li>spam</li><li>important</li><li>null (regular user-created folder)</li></ul>\n| `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`. |","createdAt":"2017-05-24T21:32:44.521Z","type":"endpoint","slug":"get-folders","updates":["5f2b82b3dfac5500517e1a2b"],"version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35970","githubsync":"","updatedAt":"2019-05-21T18:00:34.921Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.723Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/folders"}},{"_id":"5e41e73d960b09003ca359af","__v":24,"body":"## Response\n\nReturns a Folder object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|---|:----|\n| `id` | string | Globally unique object identifier. |\n| `object` | string | A string describing the type of object (value is \"folder\").\n| `account_id` | string | Reference to parent account object. |\n| `name` | string | Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154). <br>Can be one of the following: <ul><li>inbox</li><li>all</li><li>trash</li><li>archive</li><li>drafts</li><li>sent</li><li>spam</li><li>important</li><li>null (regular user-created folder)</li></ul>\n| `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`. |","isReference":true,"link_external":false,"user":"5d404909c2f77c0012211f3e","updates":[],"version":"5e41e73d960b09003ca35a9b","link_url":"","next":{"pages":[],"description":""},"parentDoc":null,"slug":"get-folder","type":"endpoint","sync_unique":"","api":{"examples":{"codes":[{"code":"GET /folders/4zv7p**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache","language":"http"},{"code":"curl -X GET 'https://api.nylas.com/folders/{folder_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Replace {id} with the appropriate folder id\nfolder = nylas.folders.get('{id}')\n\n\n# The following attributes are available for the folder object\nfolder.display_name\nfolder.name\nfolder.object\nfolder.account_id\nfolder.id","language":"python","name":"Python SDK"},{"code":"# Replace {id} with the appropriate folder id\nfolder = nylas.folders.find('{id}')\n\n\n# The following attributes are available for the folder object\nfolder.display_name\nfolder.name\nfolder.object\nfolder.account_id\nfolder.id","language":"ruby","name":"Ruby SDK"},{"code":"# Replace {id} with the appropriate folder id\nnylas.folders.find('{id}').then(folder => console.log(folder));\n\n\n# The following attributes are available for the folder object\nfolder.id\nfolder.object\nfolder.accountId\nfolder.name\nfolder.displayName","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Folder;\nimport com.nylas.Folders;\n\npublic class NylasExamples {\n public static void getFolderExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Folders folders = account.folders();\n \n // Replace {id} with the appropriate folder id\n Folder folder = folders.get(\"{id}\");\n\n // The following attributes are available for the folder object\n folder.getDisplayName();\n folder.getName();\n folder.getId();\n folder.getAccountId();\n folder.getObject();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the folder for which to return information.","required":false,"in":"path","ref":"","_id":"5925fd706980110f0018d938"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"4zv7p****\",\n \"object\": \"folder\",\n \"name\": \"inbox\",\n \"display_name\": \"INBOX\",\n \"account_id\": \"awa6****\"\n}","name":""},{"name":"","status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}"}]},"url":"/folders/{id}","auth":"required","apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca35970","excerpt":"Returns information about a folder identified by the specified folder ID.","githubsync":"","project":"59245c10200df13100c88563","createdAt":"2017-05-24T21:38:02.016Z","hidden":false,"order":2,"title":"/folders/{id}","updatedAt":"2019-05-21T18:00:15.855Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:11:55.713Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/folders/{id}"}},{"_id":"5e41e73d960b09003ca359b6","api":{"examples":{"codes":[{"code":"POST /folders HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"display_name\": \"My New Folder\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--","language":"http"},{"code":"# Create a new folder\ncurl -X POST 'https://api.nylas.com/folders' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"display_name\": \"My New Folder\"\n}'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Create a new folder\nfolder = nylas.folders.create()\n\n# The following attributes can be set for a new folder object\nfolder.display_name = \"My Custom Folder\"\n\n# Save the folder to Nylas and the 3rd party provider\n# Note: folder.display_name must be assigned a value before you can save the folder\nfolder.save()\n","language":"python"},{"name":"Ruby SDK","code":"# Create a new folder\nfolder = nylas.folders.create(display_name: 'My Custom Folder')\n\n# The following attributes can be set for a new folder object\nfolder.display_name = \"My Custom Folder\"\n\n# Save the folder to Nylas and the 3rd party provider\n# Note: folder.display_name must be assigned a value before you can save the folder\nfolder.save","language":"ruby"},{"code":"// Create a new folder\nlet folder = nylas.folders.build();\n\n// The following attributes can be set for a new folder object\nfolder.displayName = 'My Custom Folder';\n\n// Save the folder to Nylas and the 3rd party provider\n// Note: folder.displayName must be assigned a value before you can save the folder\nfolder.save();","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Folder;\nimport com.nylas.Folders;\n\npublic class NylasExamples {\n public static void postFolderExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Folders folders = account.folders();\n \n // Create a new folder with the provided display name\n Folder folder = folders.create(\"My Custom Folder\");\n }\n}"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"display_name","type":"string","default":"","desc":"The human-readable name for the new folder.","required":false,"in":"body","ref":"","_id":"5925fe647dc56b0f00935741"}],"results":{"codes":[{"name":"","code":"{\n \"id\": \"d121c****\",\n \"name\": null,\n \"display_name\": \"My New Folder\",\n \"account_id\": \"awa6l****\",\n \"object\": \"folder\"\n}","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"url":"/folders","auth":"required","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T21:58:55.013Z","parentDoc":null,"slug":"post-folder","title":"/folders","updates":[],"category":"5e41e73d960b09003ca35970","hidden":false,"order":3,"project":"59245c10200df13100c88563","sync_unique":"","excerpt":"Creates a new folder.","link_url":"","type":"endpoint","user":"5d404909c2f77c0012211f3e","link_external":false,"next":{"pages":[],"description":""},"version":"5e41e73d960b09003ca35a9b","__v":20,"body":"## Response\n\nReturns the new Folder object. Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|---|:----|\n| `id` | string | Globally unique object identifier. |\n| `object` | string | A string describing the type of object (value is \"folder\").\n| `account_id` | string | Reference to parent account object. |\n| `name` | string | Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154). <br>Can be one of the following: <ul><li>inbox</li><li>all</li><li>trash</li><li>archive</li><li>drafts</li><li>sent</li><li>spam</li><li>important</li><li>null (regular user-created folder)</li></ul>\n| `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`. |\n\nAn error will be returned if the supplied `display_name` is too long, or a conflicting folder already exists.","githubsync":"","isReference":true,"updatedAt":"2019-05-21T18:03:42.957Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:29:46.270Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/folders"}},{"_id":"5e41e73d960b09003ca359b0","sync_unique":"","title":"/folders/{id}","api":{"url":"/folders/{id}","auth":"required","examples":{"codes":[{"language":"http","code":"PUT /folders/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVU****\nAccept: */*\nCache-Control: no-cache\nHost: api.nylas.com\naccept-encoding: gzip, deflate\ncontent-length: 43\nConnection: keep-alive\ncache-control: no-cache\n\n{\n \"display_name\": \"My Renamed Folder\"\n}"},{"code":"# Replace {id} to get a specific folder\ncurl -X PUT 'https://api.nylas.com/folders/{folder_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"display_name\": \"My New Folder Renamed\"\n}'","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Replace {id} to get a specific folder\nfolder = nylas.folders.get('{id}')\n\n# The following attributes can be set for a new folder object\nfolder.display_name = \"My Custom Folder\"\n\n# Save folder changes to Nylas and the 3rd party provider\n# display_name must be set before calling this function\nfolder.save()","language":"python"},{"name":"Ruby SDK","code":"# Replace {id} to get a specific folder\nfolder = nylas.folders.find('{id}')\n\n# The following attributes can be set for a new folder object\nfolder.display_name = \"My Custom Folder\"\n\n# Save folder changes to Nylas and the 3rd party provider\nfolder.save","language":"ruby"},{"code":"// Replace {id} to get a specific folder\nlet folder;\nnylas.folders.find('{id}').then(res => folder = res);\n\n// The following attributes can be set for a new folder object\nfolder.displayName = 'My Custom Folder';\n\n// Save folder changes to Nylas and the 3rd party provider\nfolder.save();","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Folders;\n\npublic class NylasExamples {\n public static void putFolderExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Folders folders = account.folders();\n\n // Update a folder's display name by passing the folder ID and the new name.\n folders.setDisplayName(\"{folder_id}\", \"My Custom Label\");\n }\n}"}]},"method":"put","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the folder to update.","required":false,"in":"path","ref":"","_id":"5925fd706980110f0018d938"},{"name":"display_name","type":"string","default":"","desc":"The human-readable name for the new folder.","required":false,"in":"body","ref":"","_id":"5925fe647dc56b0f00935741"},{"name":"name","type":"string","default":"","desc":"Specify `sent` to update this folder as the primary sent folder. This feature is supported for custom IMAP accounts only.","required":false,"in":"body","ref":"","_id":"5ca670c234563b002f382257"}],"results":{"codes":[{"name":"","code":"{\n \"id\": \"51si****\",\n \"name\": null,\n \"display_name\": \"My Renamed Folder\",\n \"account_id\": \"awa***\",\n \"object\": \"folder\"\n}","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes here\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca35970","project":"59245c10200df13100c88563","slug":"put-folder","type":"endpoint","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","body":"The `display_name` attribute of a folder can be modified, and these changes will propagate back to the account provider. Note that the core folders such as INBOX, Trash, etc. often cannot be renamed.\n\nIMAP account can update `name` attribute of none-core folders as \"sent\" to update that folder as the primary sent folder for messages sent through Nylas. This feature is only supported on custom IMAP accounts and not supported for Exchange and Google accounts.\n\nA successful request will return the full updated folder object.","link_url":"","next":{"pages":[],"description":""},"order":4,"isReference":true,"updates":[],"__v":37,"createdAt":"2017-05-24T21:43:00.473Z","excerpt":"Updates an existing folder identified by the specified folder ID.","githubsync":"","hidden":false,"link_external":false,"parentDoc":null,"updatedAt":"2019-12-09T17:45:25.292Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:38.871Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/folders/{id}"}},{"_id":"5e41e73d960b09003ca359b1","__v":22,"category":"5e41e73d960b09003ca35970","createdAt":"2017-05-24T21:44:46.503Z","title":"/folders/{id}","user":"5d404909c2f77c0012211f3e","api":{"url":"/folders/{id}","method":"delete","results":{"codes":[{"name":"","code":"200 OK","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"examples":{"codes":[{"code":"DELETE /folders/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache","language":"http","name":null},{"code":"curl -X DELETE 'https://api.nylas.com/folders/{folder_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' ","language":"curl"},{"name":"Python SDK","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Delete folders by specifying the appropriate id\nnylas.folders.delete('{id}')","language":"python"},{"name":"Ruby SDK","code":"# Replace {id} to get a specific folder\nfolder = nylas.folders.find('{id}')\n\n# Delete folder\nfolder.destroy","language":"ruby"},{"code":"// Delete folders by specifying the appropriate id\nnylas.folders.delete('{id}');","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Folders;\n\npublic class NylasExamples {\n public static void deleteFolderExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Folders folders = account.folders();\n\n // Delete folders by specifying the appropriate id\n folders.delete(\"{folder_id}\");\n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the folder to delete.","required":false,"in":"path","ref":"","_id":"5925fd706980110f0018d938"}],"apiSetting":"5e41e73d960b09003ca3598d"},"body":"[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"Folders must be emptied before being deleted to prevent the accidental deletion of threads. If the requested folder is not empty, the server will respond with a Forbidden error.\",\n \"title\": \"Note about deleting folders\"\n}\n[/block]","hidden":false,"link_url":"","order":5,"parentDoc":null,"project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","excerpt":"Deletes an existing folder identified by the specified folder ID.","githubsync":"","link_external":false,"next":{"pages":[],"description":""},"type":"endpoint","isReference":true,"slug":"delete-folder","sync_unique":"","updates":[],"updatedAt":"2019-12-09T17:45:25.293Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.493Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/folders/{id}"}},{"_id":"5e41e73d960b09003ca359b2","body":"Labels are equivalent to [Gmail labels](https://support.google.com/mail/answer/118708?vid=1-635753225987705200-13718710208494330662&rd=1). Messages can have more than one label, which is popular for users who set up mail filters.\n\nLabels 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](ref:account) object.\n\nLabels support basic [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations outlined in the endpoints below.\n\n## Using [Filters](ref:filters) with Labels\n\nThe endpoints for [Messages](ref:messages), [Threads](ref:threads), and [Files](ref:files) support [Filters](ref:filters) for labels using the `in` query parameter. Simply pass a label `id`, `name`, or `display_name` value when calling those endpoints. This conveniently has the same format for both labels and folders, so your application can specify a single filtering request that is independent of organization unit. See the [Filters](ref:filters) documentation for more details.","category":"5e41e73d960b09003ca35971","excerpt":"","githubsync":"","isReference":true,"link_external":false,"link_url":"","api":{"method":"get","results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":""},"order":0,"next":{"pages":[],"description":""},"parentDoc":null,"project":"59245c10200df13100c88563","sync_unique":"","title":"Introduction","type":"basic","createdAt":"2017-05-24T21:46:54.586Z","hidden":false,"slug":"labels","updates":[],"user":"597fb20c6ec952001e63f8f3","version":"5e41e73d960b09003ca35a9b","__v":0,"updatedAt":"2019-06-13T19:54:43.375Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359b4","updates":[],"user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","excerpt":"Searches for labels using the specified filter criteria.","isReference":true,"project":"59245c10200df13100c88563","title":"/labels","order":1,"__v":20,"category":"5e41e73d960b09003ca35971","githubsync":"","hidden":false,"body":"Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|---|:----|\n| `id` | string | Globally unique object identifier |\n| `object` | string | A string describing the type of object (value is \"label\")\n| `account_id` | string | Reference to parent account object |\n| `name` | string | Standard categories type, based on [RFC-6154](http://tools.ietf.org/html/rfc6154). <br>Can be one of the following: <ul><li>inbox</li><li>all</li><li>trash</li><li>archive</li><li>drafts</li><li>sent</li><li>spam</li><li>important</li><li>null (regular user-created label)</li></ul>\n| `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`. |","createdAt":"2017-05-24T21:52:37.757Z","next":{"pages":[],"description":""},"type":"endpoint","parentDoc":null,"slug":"get-labels","sync_unique":"","api":{"auth":"required","examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /labels HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"# Return all labels found in the user's inbox\ncurl -X GET 'https://api.nylas.com/labels' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Use offset, and limit to paginate the results\ncurl --location --request GET 'https://api.nylas.com/labels?limit=2&offset=4' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all labels found in the user's inbox\nnylas.labels.all()\n\n# Use offset, and limit to paginate the results\nnylas.labels.where(limit=2, offset=4)\n\n# Return the first label\nlabel = nylas.labels.first()\n\n# The following attributes are available for the label object\nlabel.display_name\nlabel.name\nlabel.object\nlabel.account_id\nlabel.id"},{"name":"Ruby SDK","language":"ruby","code":"label = api.labels.last\n\n# Return all labels found in the user's inbox\nnylas.labels\n\n# Use offset, and limit to paginate the results\nnylas.labels.limit(2).offset(4)\n\n# Return the last label\nnylas.labels.last\n\n# Return the first label\nlabel = nylas.labels.first\n\n# The following attributes are available for the label object\nlabel.display_name\nlabel.name\nlabel.object\nlabel.account_id\nlabel.id"},{"name":"Node.js SDK","language":"javascript","code":"// Return all labels found in the user's inbox\nnylas.labels.list().then(labels => console.log(labels));\n\n// Use offset, and limit to paginate the results\nnylas.labels.list({limit: 2, offset: 4}).then(labels => console.log(labels));\n\n// Return the first label\nnylas.labels.first().then(label => console.log(label);\n\n// The following attributes are available for the label object\nlabel.displayName\nlabel.name\nlabel.object\nlabel.accountId\nlabel.id"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Label;\nimport com.nylas.LabelQuery;\nimport com.nylas.Labels;\n\npublic class NylasExamples {\n public static void getLabelsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Labels labels = account.labels();\n \n // Return all labels found in the user's inbox \n labels.list();\n \n // Use offset, and limit to control pagination\n labels.list(new LabelQuery().limit(2).offset(4));\n \n // Return the first label\n Label label = labels.list(new LabelQuery().limit(1)).get(0);\n \n // The following attributes are available for the label object\n label.getDisplayName();\n label.getName();\n label.getId();\n label.getAccountId();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"}],"results":{"codes":[{"language":"json","status":200,"name":"","code":""},{"status":400,"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json"}]},"url":"/labels","apiSetting":"5e41e73d960b09003ca3598d"},"link_external":false,"link_url":"","updatedAt":"2019-12-09T17:45:25.294Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.531Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/labels"}},{"_id":"5e41e73d960b09003ca359b3","version":"5e41e73d960b09003ca35a9b","__v":18,"link_external":false,"link_url":"","parentDoc":null,"type":"endpoint","updates":[],"api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /labels/4zv7p**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"curl -X GET 'https://api.nylas.com/labels/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate message id\nlabel = nylas.labels.get('{id}')\n\n\n# The following attributes are available for the label object\nlabel.display_name\nlabel.name\nlabel.object\nlabel.account_id\nlabel.id"},{"name":"Ruby SDK","language":"ruby","code":"# Replace {id} with the appropriate message id\nlabel = nylas.labels.find('{id}')\n\n\n# The following attributes are available for the label object\nlabel.display_name\nlabel.name\nlabel.object\nlabel.account_id\nlabel.id"},{"name":"Node.js SDK","language":"javascript","code":"// Replace {id} with the appropriate message id\nnylas.labels.find('{id}').then(label => console.log(label);\n\n// The following attributes are available for the label object\nlabel.displayName\nlabel.name\nlabel.object\nlabel.accountId\nlabel.id"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Label;\nimport com.nylas.Labels;\n\npublic class NylasExamples {\n public static void getLabelExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Labels labels = account.labels();\n \n // Replace '{id}' with the appropriate label ID\n Label label = labels.get(\"{id}\");\n\n // The following attributes are available for the label object\n label.getDisplayName();\n label.getName();\n label.getId();\n label.getAccountId();\n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the label for which to search.","required":false,"in":"path","ref":"","_id":"5925fd706980110f0018d938"}],"url":"/labels/{id}","method":"get","results":{"codes":[{"code":"{\n \"display_name\": \"homework\",\n \"id\": \"56po63srws43nht7owyt5knz4\",\n \"name\": null,\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"label\"\n}","name":"","status":200,"language":"json"},{"name":"","status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"body":"","category":"5e41e73d960b09003ca35971","isReference":true,"order":2,"user":"5d404909c2f77c0012211f3e","next":{"description":"","pages":[]},"project":"59245c10200df13100c88563","sync_unique":"","createdAt":"2017-05-24T21:51:55.643Z","excerpt":"Searches for a label identified by the specified label ID.","githubsync":"","hidden":false,"slug":"get-label","title":"/labels/{id}","updatedAt":"2019-12-09T17:45:25.295Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:49.164Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/labels/{id}"}},{"_id":"5e41e73d960b09003ca359b5","link_external":false,"next":{"pages":[],"description":""},"order":3,"updates":["5eb4ff6761168500409a6544"],"hidden":false,"link_url":"","type":"endpoint","api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /labels HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"display_name\": \"My New Label\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--"},{"name":"cURL","language":"curl","code":"curl -X POST 'https://api.nylas.com/labels' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"display_name\": \"My New Label\"\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Create a new label\nlabel = nylas.labels.create()\n\n# The following attributes can be set for a new label object\nlabel.display_name = \"My Custom label\"\n\n# Save the label to Nylas and the 3rd party provider\n# Note: label.display_name must be assigned a value before you can save the label\nlabel.save()"},{"name":"Ruby SDK","language":"ruby","code":"# Create a new label\nlabel = nylas.labels.create(display_name: \"My Custom label\")\n\n# The following attributes can be set for a new label object\nlabel.display_name = \"My Custom label\"\n\n# Save the label to Nylas and the 3rd party provider\n# Note: label.display_name must be assigned a value before you can save the label\nlabel.save"},{"name":"Node.js SDK","language":"javascript","code":"// Create a new label\nlabel = nylas.labels.build();\n\n// The following attributes can be set for a new label object\nlabel.displayName = 'My Custom label';\n\n// Save the label to Nylas and the 3rd party provider\n// Note: label.displayName must be assigned a value before you can save the label\nlabel.save();"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Label;\nimport com.nylas.LabelQuery;\nimport com.nylas.Labels;\n\npublic class NylasExamples {\n public static void postLabelExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Labels labels = account.labels();\n \n // Create a new label by specifying a display name\n Label label = labels.create(\"My Custom Label\");\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"d121cvdyjhgacaqyymzjg5prl\",\n \"name\": null,\n \"display_name\": \"My New Label\",\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"label\"\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"display_name","type":"string","default":"","desc":"The human-readable name for the new label.","required":true,"in":"body","ref":"","_id":"5926019a6980110f0018d99e"}],"url":"/labels","method":"post","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T21:56:42.603Z","excerpt":"Creates a new label.","githubsync":"","version":"5e41e73d960b09003ca35a9b","__v":18,"body":"You can easily create new labels on accounts where the `organization_unit` is set to `label`. Generally this is only Gmail/Google Apps accounts.\n\nThis endpoint will return a new label object upon success. An error will be returned if the supplied `display_name` is too long, or a conflicting label already exists.","project":"59245c10200df13100c88563","slug":"post-label","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca35971","isReference":true,"parentDoc":null,"sync_unique":"","title":"/labels","updatedAt":"2019-12-09T17:45:25.296Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.347Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/labels"}},{"_id":"5e41e73d960b09003ca359b7","user":"5d404909c2f77c0012211f3e","body":"The display_name attribute of a label can modified, and these changes will propagate back to the account provider. Note that the core labels such as Inbox, Trash, etc. cannot be renamed.\n\nA successful request will return the full updated label object.","isReference":true,"updates":[],"api":{"auth":"required","examples":{"codes":[{"name":"HTTP","language":"http","code":"PUT /labels/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVU****\nUser-Agent: PostmanRuntime/7.13.0\nAccept: */*\nCache-Control: no-cache\nHost: api.nylas.com\naccept-encoding: gzip, deflate\ncontent-length: 43\nConnection: keep-alive\ncache-control: no-cache\n\n{\n \"display_name\": \"My Renamed Label\"\n}"},{"name":"cURL","language":"curl","code":"curl -X PUT 'https://api.nylas.com/labels/{label_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"display_name\": \"My New Label Renamed\"\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate message id\nlabel = nylas.labels.get('{id}')\n\n# The following attributes can be set for a new label object\nlabel.display_name = \"My Custom label\"\n\n# Save the label to Nylas and the 3rd party provider\n# Note: label.display_name must be assigned a value before you can save the label\nlabel.save()"},{"name":"Ruby SDK","language":"ruby","code":"# Replace {id} with the appropriate message id\nlabel = nylas.labels.find('{id}')\n\n# The following attributes can be set for a new label object\nlabel.display_name = \"My Custom label\"\n\n# Save the label to Nylas and the 3rd party provider\n# Note: label.display_name must be assigned a value before you can save the label\nlabel.save"},{"name":"Node.js SDK","language":"javascript","code":"// Replace {id} with the appropriate message id\nlet label;\nnylas.labels.find('{id}').then(res => label = res);\n\n// The following attributes can be set for a new label object\nlabel.displayName = \"My Custom label\"\n\n// Save the label to Nylas and the 3rd party provider\n// Note: label.displayName must be assigned a value before you can save the label\nlabel.save()"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Labels;\n\npublic class NylasExamples {\n public static void putLabelExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Labels labels = account.labels();\n\n // Update a label's display name by passing the label ID and the new display name.\n labels.setDisplayName(\"{label_id}\", \"My Custom Label\");\n }\n}"}]},"method":"put","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"display_name","type":"string","default":"","desc":"The human-readable name for the new label.","required":true,"in":"body","ref":"","_id":"5926019a6980110f0018d99e"},{"name":"id","type":"string","default":"","desc":"The ID of the label to update.","required":false,"in":"path","ref":"","_id":"592602cf6b4a1c0f00e01787"}],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{\n \"id\": \"d121cvdyjhgacaqyymzjg5prl\",\n \"name\": null,\n \"display_name\": \"My New Label\",\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"label\"\n}"},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"url":"/labels","apiSetting":"5e41e73d960b09003ca3598d"},"githubsync":"","hidden":false,"type":"endpoint","parentDoc":null,"project":"59245c10200df13100c88563","slug":"put-label","title":"/labels/{id}","category":"5e41e73d960b09003ca35971","excerpt":"Updates an existing label identified by the specified label ID.","next":{"pages":[],"description":""},"order":4,"version":"5e41e73d960b09003ca35a9b","sync_unique":"","__v":20,"createdAt":"2017-05-24T22:01:51.422Z","link_external":false,"link_url":"","updatedAt":"2019-12-09T17:45:25.297Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.830Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/labels"}},{"_id":"5e41e73d960b09003ca359b8","updates":[],"excerpt":"Deletes an existing label identified by the specified label ID.","isReference":true,"next":{"description":"","pages":[]},"slug":"delete-label","title":"/labels/{id}","__v":18,"githubsync":"","order":5,"user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","type":"endpoint","api":{"method":"delete","results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"d121cvdyjhgacaqyymzjg5prl\",\n \"name\": null,\n \"display_name\": \"My New Label\",\n \"account_id\": \"awa6ltos76vz5hvphkp8k17nt\",\n \"object\": \"label\"\n}","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"DELETE /labels/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"\ncurl -X DELETE 'https://api.nylas.com/labels/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' "},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Delete labels by specifying the appropriate id\nnylas.labels.delete('{id}')"},{"name":"Ruby SDK","language":"ruby","code":"# Replace {id} with the appropriate message id\nlabel = nylas.labels.find('{id}')\n\n# Delete label\nlabel.destroy"},{"name":"Node.js SDK","language":"javascript","code":"// Delete labels by specifying the appropriate id\nnylas.labels.delete('{id}')"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Labels;\n\npublic class NylasExamples {\n public static void deleteLabelsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Labels labels = account.labels();\n\n // Delete labels by specifying the appropriate id\n labels.delete(\"{label_id}\");\n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the label to delete.","required":false,"in":"path","ref":"","_id":"592602cf6b4a1c0f00e01787"}],"url":"/labels","apiSetting":"5e41e73d960b09003ca3598d"},"body":"Labels can be deleted by issuing a DELETE request to the label’s URI. A label can be deleted even if it still has associated messages.","createdAt":"2017-05-24T22:03:07.982Z","parentDoc":null,"project":"59245c10200df13100c88563","sync_unique":"","category":"5e41e73d960b09003ca35971","hidden":false,"link_external":false,"link_url":"","updatedAt":"2019-12-09T17:45:25.298Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:27:17.446Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/labels"}},{"_id":"5e41e73d960b09003ca359b9","category":"5e41e73d960b09003ca35972","createdAt":"2017-05-24T22:03:51.503Z","isReference":true,"link_external":false,"project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","__v":0,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"title":"Introduction","type":"basic","user":"59245bff200df13100c88562","excerpt":"","sync_unique":"","next":{"pages":[],"description":""},"parentDoc":null,"hidden":false,"link_url":"","githubsync":"","order":0,"slug":"drafts","updates":[],"body":"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. \n\nNylas supports full bi-directional sync across all email service providers.","updatedAt":"2020-03-03T02:02:02.954Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359ba","__v":25,"isReference":true,"parentDoc":null,"sync_unique":"","updates":[],"category":"5e41e73d960b09003ca35972","hidden":false,"link_external":false,"project":"59245c10200df13100c88563","slug":"get-drafts","title":"/drafts","excerpt":"Searches for drafts using the specified filter criteria.","githubsync":"","next":{"pages":[],"description":""},"order":1,"user":"5d404909c2f77c0012211f3e","api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /drafts HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"curl -X GET 'https://api.nylas.com/drafts/' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all drafts found for a user account\nnylas.drafts.all()\n\n# Use queries to filter results\nnylas.drafts.where(any_email=\"swag@nylas.com\")\n# Available filters include to, cc, bcc, unread, starred, subject\n\n# Use offset, and limit to paginate the results\nnylas.drafts.where(limit=1, offset=2)\n\ndraft = nylas.drafts.first()\n\n\n# The following attributes are available for the draft object\ndraft.subject\ndraft.to\ndraft.cc\ndraft.bcc\ndraft.reply_to_message_id\ndraft.files\ndraft.body\ndraft.date\ndraft.reply_to\ndraft.starred\ndraft.thread_id\ndraft.id\ndraft.last_modified_at\ndraft.snippet\ndraft.version\ndraft.from_\ndraft.account_id\ndraft.object\ndraft.unread"},{"name":"Ruby SDK","language":"ruby","code":"draft = api.drafts.last"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// Get all drafts found in the user's account\nnylas.drafts.list().then(drafts => console.log(drafts));\n\n// Use queries to filter results\n// Available filters include to, cc, bcc, unread, starred, subject\nnylas.drafts.list({to: 'support@nylas.com'}).then(resp => console.log(resp));\n\n// Use offset and limit to paginate the results\nnylas.drafts.list({limit: 10, offset: 100}).then(resp => console.log(resp));\n\n// Get the first draft\nnylas.drafts.first().then(draft => console.log(draft));\n\n// The following attributes are available for the draft object\ndraft.id\ndraft.object\ndraft.accountId\ndraft.subject\ndraft.from\ndraft.replyTo\ndraft.to\ndraft.cc\ndraft.bcc\ndraft.date\ndraft.threadId\ndraft.snippet\ndraft.body\ndraft.unread\ndraft.starred\ndraft.files\ndraft.events\ndraft.labels\ndraft.version\ndraft.replyToMessageId"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Draft;\nimport com.nylas.DraftQuery;\nimport com.nylas.Drafts;\n\npublic class NylasExamples {\n public static void getDraftsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Drafts drafts = account.drafts();\n\n // Return all drafts found in the user's inbox \n drafts.list();\n\n // Return drafts that are filtered by specified arguments\n drafts.list(new DraftQuery().to(\"swag@nylas.com\"));\n // Available Filters: to, cc, bcc, unread, starred, subject\n\n // Use offset, and limit to control pagination\n drafts.list(new DraftQuery().limit(10).offset(10));\n\n // Return all drafts that meet a specified search criteria\n drafts.search(\"swag@nylas.com\");\n\n // Return the most recent draft\n Draft draft = drafts.list(new DraftQuery().limit(1)).get(0);\n\n // The following attributes are available for the draft object\n draft.getSubject();\n draft.getSnippet();\n draft.getBody();\n draft.getFiles();\n draft.getFrom();\n draft.getTo();\n draft.getCc();\n draft.getBcc();\n draft.getUnread();\n draft.getDate();\n draft.getReplyToMessageId();\n draft.getVersion();\n draft.getLabels(); // Gmail accounts only\n draft.getFolder(); // All providers other than Gmail\n draft.getAccountId();\n draft.getObjectType();\n draft.getId();\n draft.getSnippet();\n draft.getStarred();\n draft.getThreadId();\n }\n}\n"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"any_email","type":"string","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"5aea0c3ece3de500039f33f4"}],"url":"/drafts","method":"get","results":{"codes":[{"name":"","code":"[\n {\n \"account_id\": \"43jf3n4***\",\n \"bcc\": [],\n \"body\": \"Hello, how are you?\",\n \"cc\": [],\n \"date\": 1559763005,\n \"events\": [],\n \"files\": [],\n \"folder\": null,\n \"from\": [\n {\n \"email\": \"nylastest***@yahoo.com\",\n \"name\": \"John Doe\"\n }\n ],\n \"id\": \"43vfrmdu1***\",\n \"object\": \"draft\",\n \"reply_to\": [],\n \"reply_to_message_id\": null,\n \"snippet\": \"Hello, how are you?\",\n \"starred\": false,\n \"subject\": \"ugh?\",\n \"thread_id\": \"46wnzkxa***\",\n \"to\": [\n {\n \"email\": \"{{email}}\",\n \"name\": \"{{name}}\"\n }\n ],\n \"unread\": false,\n \"version\": 0\n },\n {\n \"account_id\": \"43jf3n4***\",\n \"bcc\": [],\n \"body\": \"Hello, how are you?\",\n \"cc\": [],\n \"date\": 1559762902,\n \"events\": [],\n \"files\": [],\n \"folder\": {\n \"display_name\": \"Draft\",\n \"id\": \"eeangfw9vm***\",\n \"name\": \"drafts\"\n },\n \"from\": [\n {\n \"email\": \"nylastest***@yahoo.com\",\n \"name\": \"John Doe\"\n }\n ],\n \"id\": \"92c7gucghzh***\",\n \"object\": \"draft\",\n \"reply_to\": [],\n \"reply_to_message_id\": null,\n \"snippet\": \"Hello, how are you?\",\n \"starred\": false,\n \"subject\": \"Hello\",\n \"thread_id\": \"e48pmw615r2****\",\n \"to\": [\n {\n \"email\": \"{{email}}\",\n \"name\": \"{{name}}\"\n }\n ],\n \"unread\": false,\n \"version\": 0\n }\n]","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"apiSetting":"5e41e73d960b09003ca3598d"},"body":"Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|:----|:----|\n| `id` | string | A globally unique object identifier. |\n| `object` | string | A string describing the type of object (value is \"draft\").\n| `account_id` | string | A reference to the parent account object, |\n| `thread_id` | string | A reference to the parent thread object. If this is a new draft, the thread will be empty.\n| `subject` | string | The subject line of the draft. |\n| `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. |\n| `from` | array | Array containing a single name+email pair to set as the \"from\" header. (See [Aliases](#section-aliases).) |\n| `reply_to` | array | An array of name-email pairs to set an alternative `Reply-To` header in the final sent message. |\n| `to` | array | An array of name-email pairs of recipients. |\n| `cc` | array | An array of name-email pairs of recipients to be cc'd. |\n| `bcc` | array | An array of name-email pairs of recipients to be bcc'd. |\n| `date` | unix timestamp | The timestamp of the last modification of the draft. |\n| `unread` | boolean | Indicates an unread state for the draft. |\n| `starred` | boolean | Starred or flagged state (mutable). |\n| `snippet` | string | A shortened plain-text preview of the draft body. |\n| `body` | string | The full HTML draft body text. |\n| `files` | array | An array of [file](#files) objects, if the draft includes attachments. |\n| `events` | array | An array of [event](#events) objects, if the draft includes calendar invites. |\n| `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. |\n| `labels` | array | A list of [label](#labels) 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. |\n| `version` | integer | Incrementing value related to draft updates.<br>You can use this to compare revisions or to invalidate your local cache. |","createdAt":"2017-05-24T22:06:40.534Z","link_url":"","type":"endpoint","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-05-30T22:21:26.903Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.723Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/drafts"}},{"_id":"5e41e73d960b09003ca359bb","api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /drafts/4zv7p**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"curl -X GET 'https://api.nylas.com/drafts/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate draft id\ndraft = nylas.drafts.get('{id}')\n\n\n# The following attributes are available for the draft object\ndraft.subject\ndraft.to\ndraft.cc\ndraft.bcc\ndraft.reply_to_message_id\ndraft.files\ndraft.body\ndraft.date\ndraft.reply_to\ndraft.starred\ndraft.thread_id\ndraft.id\ndraft.last_modified_at\ndraft.snippet\ndraft.version\ndraft.from_\ndraft.account_id\ndraft.object\ndraft.unread"},{"name":"Ruby SDK","language":"ruby","code":"draft = api.drafts.find(draft.id)"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// Replace {id} with the appropriate draft id\nnylas.drafts.find('{id}').then(draft => console.log(draft));\n\n// The following attributes are available for the draft object\ndraft.id\ndraft.object\ndraft.accountId\ndraft.subject\ndraft.from\ndraft.replyTo\ndraft.to\ndraft.cc\ndraft.bcc\ndraft.date\ndraft.threadId\ndraft.snippet\ndraft.body\ndraft.unread\ndraft.starred\ndraft.files\ndraft.events\ndraft.labels\ndraft.version\ndraft.replyToMessageId"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Draft;\n\npublic class NylasExamples {\n public static void getDraftExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n \n // Replace '{id}' with the appropriate value\n Draft draft = drafts.get(\"{id}\");\n \n // The following attributes are available for the draft object\n draft.getSubject();\n draft.getSnippet();\n draft.getBody();\n draft.getFiles();\n draft.getFrom();\n draft.getTo();\n draft.getCc();\n draft.getBcc();\n draft.getUnread();\n draft.getDate();\n draft.getLabels(); // Gmail accounts only\n draft.getFolder(); // All providers other than Gmail\n draft.getReplyTo();\n draft.getAccountId();\n draft.getObjectType();\n draft.getId();\n draft.getSnippet();\n draft.getVersion();\n draft.getStarred();\n draft.getThreadId();\n }\n}"}]},"results":{"codes":[{"name":"","code":"{\n \"account_id\": \"43jf3n4e***\",\n \"bcc\": [],\n \"body\": \"Hello, how are you?\",\n \"cc\": [],\n \"date\": 1559763005,\n \"events\": [],\n \"files\": [],\n \"folder\": {\n \"display_name\": \"Draft\",\n \"id\": \"eeangfw9***\",\n \"name\": \"drafts\"\n },\n \"from\": [\n {\n \"email\": \"nylastest***@yahoo.com\",\n \"name\": \"John Doe\"\n }\n ],\n \"id\": \"43vfrmdu1***\",\n \"object\": \"draft\",\n \"reply_to\": [],\n \"reply_to_message_id\": null,\n \"snippet\": \"Hello, how are you?\",\n \"starred\": false,\n \"subject\": \"ugh?\",\n \"thread_id\": \"46wnzkxaz***\",\n \"to\": [\n {\n \"email\": \"{{email}}\",\n \"name\": \"{{name}}\"\n }\n ],\n \"unread\": false,\n \"version\": 0\n}","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the draft for which to search.","required":false,"in":"path","ref":"","_id":"5926041746820d0f0099181f"}],"url":"/drafts/{id}","method":"get","apiSetting":"5e41e73d960b09003ca3598d"},"body":"","title":"/drafts/{id}","__v":15,"hidden":false,"link_external":false,"next":{"pages":[],"description":""},"sync_unique":"","updates":[],"createdAt":"2017-05-24T22:07:19.218Z","excerpt":"Searches for a draft identified by the specified draft ID.","githubsync":"","link_url":"","parentDoc":null,"slug":"get-draft","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca35972","isReference":true,"order":2,"project":"59245c10200df13100c88563","type":"endpoint","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-12-09T17:45:25.300Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.716Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/drafts/{id}"}},{"_id":"5e41e73d960b09003ca359bc","createdAt":"2017-05-24T22:13:57.762Z","hidden":false,"next":{"pages":[],"description":""},"order":3,"updates":[],"user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35972","link_url":"","__v":27,"githubsync":"","link_external":false,"slug":"post-draft","api":{"url":"/drafts","auth":"required","examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /drafts HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"display_name\": \"My New Draft\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--"},{"name":"cURL","language":"curl","code":"curl -X POST 'https://api.nylas.com/drafts/' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{ \n \"body\":\"This email was sent using the Nylas email API. Visit https://nylas.com for details.\",\n \"reply_to\": [{\n 'email': 'you@example.com', 'name': 'Your Name'\n }],\n \"from\": [{\n 'email': 'you@example.com', 'name': 'Your Name'\n }],\n \"to\": [\n {\n {'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}\n }\n ], \n \"subject\": \"With Love, From Nylas\",\n \"file_ids\": [\"{file_id}\"]\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Create a new draft object\ndraft = nylas.drafts.create()\n\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.reply_to = [{'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'}]\n\n# Replace {id} with the appropriate id for a file that you want to attach to a draft\nfile = nylas.files.get('{id}')\n\n# Attach a file to a draft\ndraft.attach(file)\n\n# Remove a file attachment from a draft\ndraft.detach(file)\n\n# You must save the draft for changes to take effect\ndraft.save()\n# Note: Nylas saves all drafts, but not all providers\n# display the drafts on their user interface"},{"name":"Ruby SDK","language":"ruby","code":"api.drafts.create(display_name: \"My New Draft\")"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// Create a new draft object\nconst draft = nylas.drafts.build({\nto: [{ name: 'Nylas Swag', email: 'swag@nylas.com' }],\nsubject: 'With Love, From Nylas',\nbody: 'This email was sent using the Nylas email API. Visit https://nylas.com for details.',\nfileIds: ['{existingFileId}']\n});\n\n// Save the draft to send it to Nylas\ndraft.save()"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.util.Arrays;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Draft;\nimport com.nylas.NameEmail;\nimport com.nylas.File;\n\npublic class NylasExamples {\n public static void postDraftExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n \n // Create a new draft object\n Draft draft = new Draft();\n \n draft.setSubject(\"With Love, From Nylas\");\n draft.setTo(Arrays.asList(new NameEmail(\"My Nylas Friend\", \"swag@nylas.com\")));\n // setCc(), setBcc(), work in the same manner as setTo().\n draft.setBody(\"This email was sent using the Nylas email API. Visit https://nylas.com for details.\");\n draft.setReplyTo(new NameEmail(\"Your Name\", \"you@example.com\"));\n // Note: changing the from email address to somthing different may cause deliverability issues\n draft.setFrom(new NameEmail(\"Your Name\", \"you@example.com\"));\n \n // Replace {id} with the appropriate id for a file that you want to attach to a draft\n File file = account.files().get(\"{id}\");\n \n // Attach a file to a draft\n draft.attach(file);\n \n // Remove a file attachment from a draft\n draft.detach(file);\n \n // You must save the draft for changes to take effect\n draft = account.drafts().save(draft);\n // Note: Nylas saves all drafts, but not all providers\n // display the drafts on their user interface\n }\n}"}]},"method":"post","params":[{"name":"subject","type":"string","default":"","desc":"The subject line of the draft.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d1822"},{"name":"to","type":"array_object","default":"","desc":"The name-email pairs of the recipients.","required":false,"in":"body","ref":"NameEmailPair","_id":"592605a5ca32040f000d1821"},{"name":"cc","type":"array_object","default":"","desc":"The name-email pairs of the recipients to be cc’d.","required":false,"in":"body","ref":"NameEmailPair","_id":"592605a5ca32040f000d1820"},{"name":"bcc","type":"array_object","default":"","desc":"The name-email pairs of the recipients to be bcc’d.","required":false,"in":"body","ref":"NameEmailPair","_id":"592605a5ca32040f000d181f"},{"name":"from","type":"array_object","default":"","desc":"An array containing a single name and email pair, to set as the “from” header. (See [Aliases](#section-aliases)). Note that not all providers support setting this in a draft.","required":false,"in":"body","ref":"NameEmailPair","_id":"592605a5ca32040f000d181e"},{"name":"reply_to","type":"array_object","default":"","desc":"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.","required":false,"in":"body","ref":"NameEmailPair","_id":"592605a5ca32040f000d181d"},{"name":"reply_to_message_id","type":"string","default":"","desc":"The ID of the message that this draft is a reply to.","required":false,"in":"body","ref":"","_id":"5e2f89c168635b002ca9fc32"},{"name":"body","type":"string","default":"","desc":"The full HTML draft body text.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181c"},{"name":"file_ids","type":"array_string","default":"","desc":"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.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181b"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"}],"results":{"codes":[{"name":"","code":"{\n \"account_id\": \"43jf3n4***\",\n \"bcc\": [],\n \"body\": \"Hello, how are you?\",\n \"cc\": [],\n \"date\": 1559762901,\n \"events\": [],\n \"files\": [],\n \"folder\": null,\n \"from\": [\n {\n \"email\": \"nylastest***@yahoo.com\",\n \"name\": \"John Doe\"\n }\n ],\n \"id\": \"92c7gucg***\",\n \"object\": \"draft\",\n \"reply_to\": [],\n \"reply_to_message_id\": null,\n \"snippet\": \"Hello, how are you?\",\n \"starred\": false,\n \"subject\": \"Hello\",\n \"thread_id\": \"e48pmw61***\",\n \"to\": [\n {\n \"email\": \"{{email}}\",\n \"name\": \"{{name}}\"\n }\n ],\n \"unread\": false,\n \"version\": 0\n}","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"apiSetting":"5e41e73d960b09003ca3598d"},"body":"[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Note about creating drafts\",\n \"body\": \"All body params optional though if omitted, an empty draft will still be created. A successful response will contain the newly created draft object. At least one recipient in `to`, `cc`, or `bcc` must be specified before sending.\"\n}\n[/block]\n## Attachments\n\nCreating a draft will fail if the files with the referenced `file_ids` have not been uploaded. See [Files](ref:files) for more details on how to upload and reference attachments.\n\n## Replies\n\nIf the draft is a response to an existing message, you should provide the message's ID as a `reply_to_message_id` attribute and omit the `subject` parameter. Note that you still must explicitly specify the message's recipients in the `to`, `cc` or `bcc` fields of the post body. (This is by design to prevent any ambiguity about whom the message will be sent to.)\n\n## Aliases\n\nIf you would like to use an alias for sending and/or receiving emails, you can optionally set the `from` or `reply_to` fields. Note that if the given address is actually not an alias, most SMTP servers will either reject the message or silently replace it with the primary sending address.\n\nIf the `from` and `reply_to` fields are omitted, the account's default sending name and address will be used.","excerpt":"Creates a new draft.","isReference":true,"parentDoc":null,"project":"59245c10200df13100c88563","sync_unique":"","title":"/drafts","type":"endpoint","updatedAt":"2019-12-09T17:45:25.301Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.493Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/drafts"}},{"_id":"5e41e73d960b09003ca359bd","body":"The request body must contain the `version` of the draft you wish to update. Other fields are optional and will overwrite previous values.\n\nUpdating a draft returns a draft object with the same `id` but different version. When submitting subsequent send or save actions, you must use this new version.","link_external":false,"project":"59245c10200df13100c88563","slug":"put-draft","sync_unique":"","title":"/drafts/{id}","updates":[],"order":4,"user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","__v":27,"githubsync":"","hidden":false,"isReference":true,"link_url":"","parentDoc":null,"type":"endpoint","api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"PUT /drafts/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVU****\nUser-Agent: PostmanRuntime/7.13.0\nAccept: */*\nCache-Control: no-cache\nHost: api.nylas.com\naccept-encoding: gzip, deflate\ncontent-length: 43\nConnection: keep-alive\ncache-control: no-cache\n{\n \"version\": 0,\n \"subject\": \"Dinner on Friday?\",\n \"to\": [\n {\n \"name\": \"{{name}}\",\n \"email\": \"{{email}}\"\n }\n ],\n \"cc\": [],\n \"bcc\": [],\n \"body\": \"Let's go to dinner on Friday\"\n}"},{"name":"cURL","language":"curl","code":"curl -X PUT 'https://api.nylas.com/drafts/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{ \n \"body\":\"This revised email was sent using the Nylas email API. Visit https://nylas.com for details.\",\n \"reply_to\": [{\n 'email': 'you@example.com', 'name': 'Your Name'\n }],\n \"from\": [{\n 'email': 'you@example.com', 'name': 'Your Name'\n }],\n \"to\": [\n {\n {'email': 'swag@nylas.com', 'name': 'My Nylas Friend'}\n }\n ], \n \"subject\": \"With Love, From Nylas\",\n \"file_ids\": [\"{file_id}\"],\n \"version\": 0\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate draft id\ndraft = nylas.drafts.get('{id}')\n\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.reply_to = [{'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'}]\n\n# Replace {id} with the appropriate id for a file that you want to attach to a draft\nfile = nylas.files.get('{id}')\n\n# Attach a file to a draft\ndraft.attach(file)\n\n# Remove a file attachment from a draft\ndraft.detach(file)\n\n# You must save the draft for changes to take effect\ndraft.save()\n# Note: Nylas saves all drafts, but not all providers display the drafts on their user interface"},{"name":"Ruby SDK","language":"ruby","code":"draft_to_change = api.drafts.find(\"51si***\")\ndraft_to_change.update(display_name: \"My Renamed Draft\")"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// You need a draft's id and its version to update it.\n// All other fields are optional\nconst draft = nylas.drafts.build({\nid: '{id}',\nversion: 0\n});\n\n// Update any fields you want to change\ndraft.subject = 'Updated subject: Hello World!';\n\n// Save the draft to persist your updates\ndraft.save()"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.util.Arrays;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Draft;\nimport com.nylas.NameEmail;\nimport com.nylas.File;\n\npublic class NylasExamples {\n public static void putDraftExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n \n // Replace '{id}' with the appropriate value\n Draft draft = account.drafts().get(\"{id}\");\n \n draft.setSubject(\"With Love, From Nylas\");\n draft.setTo(Arrays.asList(new NameEmail(\"My Nylas Friend\", \"swag@nylas.com\")));\n /// setCc(), setBcc(), work in the same manner as setTo().\n draft.setBody(\"This email was sent using the Nylas email API. Visit https://nylas.com for details.\");\n draft.setReplyTo(new NameEmail(\"Your Name\", \"you@example.com\"));\n // Note: changing the from email address to somthing different may cause deliverability issues\n draft.setFrom(new NameEmail(\"Your Name\", \"you@example.com\"));\n \n // Replace {id} with the appropriate id for a file that you want to attach to a draft\n File file = account.files().get(\"{id}\");\n \n // Attach a file to a draft\n draft.attach(file);\n \n // Remove a file attachment from a draft\n draft.detach(file);\n \n // You must save the draft for changes to take effect\n draft = account.drafts().save(draft);\n // Note: Nylas saves all drafts, but not all providers\n // display the drafts on their user interface\n }\n}"}]},"method":"put","params":[{"name":"id","type":"string","default":"","desc":"The ID of the draft for which to update.","required":false,"in":"path","ref":"","_id":"59260629d235fa0f002c19b2"},{"name":"subject","type":"string","default":"","desc":"The subject line of the draft.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d1822"},{"name":"to","type":"array_string","default":"","desc":"The name and email pairs of the recipients.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d1821"},{"name":"cc","type":"array_string","default":"","desc":"The name and email pairs of the recipients to be cc’d.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d1820"},{"name":"bcc","type":"array_string","default":"","desc":"The name and email pairs of the recipients to be bcc’d.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181f"},{"name":"from","type":"array_string","default":"","desc":"An array containing a single name and email pair, to set as the “from” header. (See “Aliases” below.) Note that not all providers support setting this in a draft.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181e"},{"name":"reply_to","type":"array_string","default":"","desc":"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.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181d"},{"name":"reply_to_message_id","type":"string","default":"","desc":"The ID of the message that this draft is a reply to.","required":false,"in":"body","ref":"","_id":"5e2f89e7b18c7c004c532d4a"},{"name":"body","type":"string","default":"","desc":"The full HTML draft body text.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181c"},{"name":"file_ids","type":"array_string","default":"","desc":"An array of file IDs, if the draft includes attachments. Note that creating a draft will fail, if these files have not yet been uploaded.","required":false,"in":"body","ref":"","_id":"592605a5ca32040f000d181b"},{"name":"version","type":"int","default":"","desc":"Version of the draft that you are modifying","required":true,"in":"body","ref":"","_id":"59260629d235fa0f002c19b1"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"}],"results":{"codes":[{"language":"json","code":"{\n \"account_id\": \"43jf3n4***\",\n \"bcc\": [],\n \"body\": \"Let's go to dinner on Friday\",\n \"cc\": [],\n \"date\": 1559764011,\n \"events\": [],\n \"files\": [],\n \"folder\": {\n \"display_name\": \"Draft\",\n \"id\": \"eeangfw9v***\",\n \"name\": \"drafts\"\n },\n \"from\": [\n {\n \"email\": \"nylastest***@yahoo.com\",\n \"name\": \"John Doe\"\n }\n ],\n \"id\": \"43vfrmdu1xy***\",\n \"object\": \"draft\",\n \"reply_to\": [],\n \"reply_to_message_id\": null,\n \"snippet\": \"Let's go to dinner on Friday\",\n \"starred\": false,\n \"subject\": \"Dinner on Friday?\",\n \"thread_id\": \"46wnzkxazzc***\",\n \"to\": [\n {\n \"email\": \"{{email}}\",\n \"name\": \"{{name}}\"\n }\n ],\n \"unread\": false,\n \"version\": 1\n}","name":"","status":200},{"name":"","status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}"}]},"url":"/drafts/{id}","auth":"required","apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca35972","createdAt":"2017-05-24T22:16:09.885Z","excerpt":"Updates an existing draft identified by the specified draft ID.","next":{"pages":[],"description":""},"updatedAt":"2019-12-09T17:45:25.302Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.347Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/drafts/{id}"}},{"_id":"5e41e73d960b09003ca359be","createdAt":"2017-05-24T22:16:35.886Z","isReference":true,"updates":[],"project":"59245c10200df13100c88563","slug":"draftsid","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca35972","excerpt":"Deletes an existing draft identified by the specified draft ID.","githubsync":"","link_external":false,"version":"5e41e73d960b09003ca35a9b","type":"endpoint","api":{"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the draft to delete.","required":false,"in":"path","ref":"","_id":"5926041746820d0f0099181f"},{"name":"version","type":"int","default":"","desc":"Version of the draft that you are modifying.","required":true,"in":"body","ref":"","_id":"5942eeae50b8a900373cea05"}],"url":"/drafts/{id}","method":"delete","results":{"codes":[{"name":"","code":"","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"DELETE /drafts/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache\n\n{\n\t\"version\": 1\n}"},{"name":"cURL","language":"curl","code":"curl -X DELETE 'https://api.nylas.com/drafts/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"version\": 0\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\ndraft = nylas.drafts.get(\"{id}\")\ndraft.delete()"},{"name":"Ruby SDK","language":"ruby","code":"draft = api.drafts.find(draft.id)\ndraft.destroy"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// Delete a draft (draft.version must be valid)\nconst options = {\nitem: draft,\ncallback: optionalCallback\n}\nnylas.drafts.deleteItem(options);\n\n// Delete a draft by its id and version\nnylas.drafts.delete('{id}', { version: 0 }, optionalCallback);"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Drafts;\n\npublic class NylasExamples {\n public static void deleteDraftExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Drafts drafts = account.drafts();\n\n // Delete drafts by specifying the appropriate id\n drafts.delete(\"{draft_id}\"); \n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"link_url":"","next":{"pages":[],"description":""},"order":5,"title":"/drafts/{id}","__v":25,"body":"Drafts can be deleting by issuing a DELETE request to the draft’s URI. The request body must contain a JSON object specifying the latest version, or deletion will fail. This is to prevent accidental deletion of drafts which have been updated.","hidden":false,"parentDoc":null,"sync_unique":"","updatedAt":"2019-12-09T17:45:25.306Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:46.731Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/drafts/{id}"}},{"_id":"5e41e73d960b09003ca359bf","isReference":true,"link_external":false,"link_url":"","order":0,"sync_unique":"","version":"5e41e73d960b09003ca35a9b","body":"The Nylas platform provides two ways to send messages: Sending an existing draft or sending a message directly. 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 (i.e. not landing in Gmail's promotions tab), but may also be subject to backend provider rate-limiting and abuse detection. Ensure you send messages wisely!\n[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"A successful request to the send endpoint can sometimes take up to two minutes for self-hosted Exchange accounts, though the average send time is around 2 seconds. We recommend that you set a minimum timeout of 150 seconds, to ensure you receive a response from us.\",\n \"title\": \"Sending timeouts\"\n}\n[/block]\nAll sending operations are synchronous, meaning the request will block until the submission has succeeded or failed. In the event of failure, the sending API will not automatically retry.\n\nWe recommend that you apply backoff when HTTP 503s are returned. Your app may need to wait 10-20 minutes, or SMTP servers may continue to refuse connections for a particular account. For some providers like Gmail, there are [hard limits](https://support.google.com/a/answer/166852?hl=en) on the number of messages you can send per day.\n\nIf large-volume sending continues to fail for your application, we recommend switching to a transactional sending service like Mailgun, Sendgrid, Mandrill, or Amazon SES.\n[block:api-header]\n{\n \"title\": \"Sending Errors\"\n}\n[/block]\nSometimes message delivery can fail if the user’s email gateway rejects the message. This could happen for a number of reasons, including illegal attachment data, bad credentials, or rate limiting. If your message is submitted successfully, the server will respond with a HTTP response code of 200 OK. If your message could not be submitted, the server will respond with an appropriate error code.\n\n|Status Code | | Reason|\n|-----:|-|: --|\n|`200` |OK | Your message was submitted successfully for sending.|\n|`400`| Bad Request | Your request was malformed, or contained an invalid parameter. The most common issue is invalid JSON.|\n|`402` |Message Rejected | The mail provider rejected your message because of its content or recipients. **Note:** If the message includes \"Sending to at least one recipient failed\", it means that your message may have been delivered to only a subset of participants.|\n|`403`| Unauthorized | The server was unable to authenticate with the user's mail provider. Re-authenticate the user and try again.|\n|`422` |Mail provider error | An error occurred while the mail provider was sending the message. See the `server_error` value in the response body JSON for more information.|\n|`429`| Quota Exceeded | The user has exceeded their mail provider's sending quota. Unfortunately there is no reliable way to determine these limits. Wait and try again later.|\n|`429`| Account Throttled | The account is in a throttled state and the mail server has asked us to temporarily stop making requests. Wait and try again later.|\n|`429`| Nylas API Rate Limit | You've made too many requests to the Nylas API too quickly. Wait and try again later. See [Rate limiting](ref:rate-limiting).|\n|`503`| Service Unavailable | There was an error connecting to the user's mail provider. Wait and try again.|\n\nIn addition, the response body contains a JSON object with information about the specific error, including the following attributes:\n\n| Status Code | Type | Reason |\n| -- | -- |--|\n| `type` | string | Error type |\n|`message` | string | A brief human-readable description of the error. | \n|`server_error`| string (optional) | The original error returned by the user's mail server.|\n[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"If any of the recipient addresses contain non-ASCII characters (such as characters with accents or other diacritics), these recipients will be among those to whom delivery failed. Nylas is not currently able to send messages to such email addresses.\",\n \"title\": \"402 errors with \\\"Sending to at least one recipient failed\\\"\"\n}\n[/block]\nSee [Errors](ref:errors) for more information about error responses and how to handle them.\n\n# Sending inline images\n\nYou can send image attachments inline with the body of your emails. Simply reference one of the attached `file_ids` in an `img` tag. For example, if one of your attachments has `file_id = '472ypl5vqbnh0l2ac3y71cdks'` then you could display it inline like following example. Remember to prepend the `file_id` with `cid:` for the `src` attribute.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"<div>\\n <p>Before image</p>\\n \\t<img src=\\\"cid:472ypl5vqbnh0l2ac3y71cdks\\\">\\n <p>After image</p>\\n</div>\",\n \"language\": \"html\",\n \"name\": \"example inline image html\"\n }\n ]\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Message Body Size Limit\",\n \"body\": \"While Nylas is permissive about attachment size, the maximum size allowed for the body of an email message is 30MB. Inline images will be included as part of this limit, since the image will be rendered in the body. Please keep this limit in mind, and optimize your images before you upload them for use with Nylas.\"\n}\n[/block]\n# Setting the sender's name\n\nSome mail servers allow you to set the sender name when sending mail. Nylas will pass along the default `name` stored on the [/account](ref:account) automatically. You can override this default name each time you send an email, by passing a `from` parameter. See [Sending directly](ref:sending-directly) for more info.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Sender name support\",\n \"body\": \"Not every mail server will respect this value. You might run into an issue where you set the \\\"From\\\" name, but the message that is sent does not have that value. You might need to reach out to your mail provider to see what default name they use, and if they support overriding this default name.\"\n}\n[/block]","category":"5e41e73d960b09003ca35973","githubsync":"","parentDoc":null,"project":"59245c10200df13100c88563","type":"basic","__v":0,"createdAt":"2017-05-24T22:25:03.101Z","excerpt":"","hidden":false,"next":{"pages":[],"description":""},"title":"Introduction","api":{"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"updates":[],"user":"5f2067586dda9a0045009159","slug":"sending","updatedAt":"2020-11-12T14:23:36.002Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-11-11T19:20:47.317Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359c0","githubsync":"","updates":[],"version":"5e41e73d960b09003ca35a9b","user":"5d404909c2f77c0012211f3e","createdAt":"2017-05-24T22:27:10.848Z","isReference":true,"link_url":"","order":1,"parentDoc":null,"title":"Sending drafts","__v":34,"body":"","sync_unique":"","project":"59245c10200df13100c88563","slug":"sending-drafts","api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /send HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"draft_id\": \"51si***\",\n \"version\": 0\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--"},{"name":"cURL","language":"curl","code":"curl -X POST 'https://api.nylas.com/send' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"draft_id\": \"{draft_id}\",\n \"version\": 0\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate draft id\ndraft = nylas.drafts.get(\"{id}\")\ndraft.send()\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.reply_to = [{'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'}]"},{"name":"Ruby SDK","language":"ruby","code":"# Replace {id} with the appropriate draft id\ndraft = api.drafts.find(\"{id}\")\ndraft.send!"},{"name":"Node.js SDK","language":"javascript","code":"// 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'}]"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.util.Arrays;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Draft;\nimport com.nylas.File;\nimport com.nylas.NameEmail;\n\npublic class NylasExamples {\n public static void sendDraftExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n\n // Create a new draft object\n Draft newDraft = new Draft();\n\n // Or, you can get an existing Draft by specifying its ID\n Draft draft = account.drafts().get(\"{id}\");\n\n draft.setSubject(\"With Love, From Nylas\");\n draft.setTo(Arrays.asList(new NameEmail(\"My Nylas Friend\", \"swag@nylas.com\")));\n // You can also assign cc, draft.bcc, and draft.from_ in the same manner\n draft.setBody(\"This email was sent using the Nylas email API. Visit https://nylas.com for details.\");\n draft.setReplyTo(new NameEmail(\"Your Name\", \"you@example.com\"));\n // Note: changing the from email address to somthing different may cause deliverability issues\n draft.setFrom(new NameEmail(\"Your Name\", \"you@example.com\"));\n\n // Replace {id} with the appropriate id for a file that you want to attach to a draft\n File file = account.files().get(\"{id}\");\n\n // Attach a file to a draft\n draft.attach(file);\n\n // Remove a file attachment from a draft\n draft.detach(file);\n\n // You must save the draft for changes to take effect\n draft = account.drafts().save(draft);\n // Note: Nylas saves all drafts, but not all providers\n // display the drafts on their user interface\n\n // Finally, send the draft\n account.drafts().send(draft);\n }\n}"}]},"results":{"codes":[{"name":"","status":200,"language":"json","code":""},{"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":"","status":400}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"592608be82c3660f00c2b64e"},{"name":"draft_id","type":"string","default":"","desc":"The ID of the existing draft.","required":true,"in":"body","ref":"","_id":"592608be82c3660f00c2b64d"},{"name":"version","type":"int","default":"","desc":"The version of the draft. This must be the most recent version or the request will fail.","required":true,"in":"body","ref":"","_id":"592608be82c3660f00c2b64c"},{"name":"tracking","type":"object","default":"","desc":"An optional object that allows you to enable [message tracking features](ref:message-tracking-overview) for this message or thread.","required":false,"in":"body","ref":"","_id":"5e151525db417d00653b6802"}],"url":"/send#drafts","method":"post","apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca35973","excerpt":"Sends an existing draft identified by the specified draft ID.","hidden":false,"link_external":false,"next":{"pages":[],"description":""},"type":"endpoint","updatedAt":"2019-12-09T17:45:25.308Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.493Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/send#drafts"}},{"_id":"5e41e73d960b09003ca359c1","githubsync":"","next":{"pages":[],"description":""},"parentDoc":null,"type":"endpoint","updates":[],"api":{"results":{"codes":[{"language":"json","code":"{\n \"account_id\": \"43jf3n4***\",\n \"bcc\": [],\n \"body\": \"Sounds great! See you then.\",\n \"cc\": [],\n \"date\": 1559772028,\n \"events\": [],\n \"files\": [],\n \"folder\": null,\n \"from\": [\n {\n \"email\": \"nylastest***@yahoo.com\",\n \"name\": \"John Doe\"\n }\n ],\n \"id\": \"2poq0fz6***\",\n \"object\": \"message\",\n \"reply_to\": [],\n \"snippet\": \"Sounds great! See you then.\",\n \"starred\": false,\n \"subject\": \"Re: Meeting\",\n \"thread_id\": \"cvsppkteox***\",\n \"to\": [\n {\n \"email\": \"no-reply@cc.yahoo-inc.com\",\n \"name\": \"{{name}}\"\n }\n ],\n \"unread\": false\n}","name":"","status":200},{"code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":"","status":400,"language":"json"}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /send HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"reply_to_message_id\": \"7a893****\"\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--"},{"name":"cURL","language":"curl","code":"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}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Send replies by setting reply_to_message_id for a draft\nmessage = nylas.messages.get('{id}')\ndraft = nylas.drafts.create()\ndraft.reply_to_message_id = message.id\ndraft.body = \"This is my response\"\ndraft.to = message.from_\ndraft.send()\n\n\n# Replace {id} with the appropriate id for a file that you want to attach to a draft\nfile = nylas.files.get('{id}')\n# Attach / Remove a file attachment\ndraft.attach(file)\ndraft.detach(file)\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.reply_to = [{'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'}]\n"},{"name":"Ruby SDK","language":"ruby","code":"nylas.send!(\n to: [{ email: 'swag@nylas.com', name: \"Nylas\" }],\n subject: \"With Love, from Nylas\",\n body: \"This email was sent using the Nylas Email API. Visit https://nylas.com for details.\"\n ).to_h"},{"name":"Node.js SDK","language":"javascript","code":"const replyCallback = function (err, message) {\n if (err) {\n \tconsole.log(err);\n } else {\n const draft = nylas.drafts.build();\n // Send replies by setting replyToMessageId for a draft\n draft.replyToMessageId = message.id;\n draft.to = message.from;\n draft.body = 'This is my response';\n draft.send();\n }\n}\n\nnylas.messages.find('{id}', replyCallback);\n\n// Replace {id} with the appropriate id for a file that you want to attach to a draft\nnylas.files.find('{id}').then(file => {\n draft.files = [file]; // Attach file(s)\n draft.files = []; // Detach files\n draft.save();\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'}]"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.util.Arrays;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Draft;\nimport com.nylas.File;\nimport com.nylas.NameEmail;\n\npublic class NylasExamples {\n public static void sendDirectExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n \n // Create a new draft object\n Draft newDraft = new Draft();\n\n // Or, you can get an existing Draft by specifying its ID\n Draft draft = account.drafts().get(\"{id}\");\n \n draft.setSubject(\"With Love, From Nylas\");\n draft.setTo(Arrays.asList(new NameEmail(\"My Nylas Friend\", \"swag@nylas.com\")));\n // You can also assign cc, bcc, and from in the same manner\n draft.setBody(\"This email was sent using the Nylas email API. Visit https://nylas.com for details.\");\n draft.setReplyTo(new NameEmail(\"Your Name\", \"you@example.com\"));\n // Note: changing the from email address to somthing different may cause deliverability issues\n draft.setFrom(new NameEmail(\"Your Name\", \"you@example.com\"));\n \n // Replace {id} with the appropriate id for a file that you want to attach to a draft\n File file = account.files().get(\"{id}\");\n \n // Attach a file to a draft\n draft.attach(file);\n \n // Remove a file attachment from a draft\n draft.detach(file);\n\n // Send the draft without saving it to the third party provider\n account.drafts().send(draft);\n }\n}"}]},"auth":"required","params":[{"name":"subject","type":"string","default":"","desc":"The subject line of the messages.","required":false,"in":"body","ref":"","_id":"592608be82c3660f00c2b64d"},{"name":"from","type":"array_object","default":"","desc":"An array containing a single name and email pair to set as the \"from\" header.","required":false,"in":"body","ref":"NameEmailPair","_id":"59260bbda6ca570f00199398"},{"name":"reply_to","type":"array_object","default":"","desc":"An array of name+email pairs to set an alternative `Reply-To` header in the final sent message.","required":false,"in":"body","ref":"NameEmailPair","_id":"59260bbda6ca570f00199397"},{"name":"reply_to_message_id","type":"string","default":"","desc":"The `message_id` of a message this draft is a reply to, allowing the sending API to include threading-specific headers for other mail clients.","required":false,"in":"body","ref":"","_id":"592608be82c3660f00c2b64c"},{"name":"to","type":"array_object","default":"","desc":"An array of name+email pairs of the recipients.","required":false,"in":"body","ref":"NameEmailPair","_id":"59260bbda6ca570f00199396"},{"name":"cc","type":"array_object","default":"","desc":"An array of name+email pairs of the recipients to be cc’d.","required":false,"in":"body","ref":"NameEmailPair","_id":"59260bbda6ca570f00199395"},{"name":"bcc","type":"array_object","default":"","desc":"An array of name+email pairs of the recipients to be bcc’d.","required":false,"in":"body","ref":"NameEmailPair","_id":"59260bbda6ca570f00199394"},{"name":"body","type":"string","default":"","desc":"The full HTML body to send. If replying to a message, you should include quoted text here.","required":false,"in":"body","ref":"","_id":"59260bbda6ca570f00199393"},{"name":"file_ids","type":"array_string","default":"","desc":"An array of IDs for the [File](ref:files) to attach, if you are including attachments. Note that sending will fail, if these files have not yet been uploaded.","required":false,"in":"body","ref":"","_id":"59260bbda6ca570f00199392"},{"name":"tracking","type":"object","default":"","desc":"An optional object that allows you to enable [message tracking features](ref:message-tracking-overview) for this message or thread.","required":false,"in":"body","ref":"tracking","_id":"59260bbda6ca570f00199391"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"592608be82c3660f00c2b64e"}],"url":"/send#directly","method":"post","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T22:39:57.838Z","excerpt":"Sends a message directly, without saving them as drafts beforehand.","isReference":true,"project":"59245c10200df13100c88563","title":"Sending directly","version":"5e41e73d960b09003ca35a9b","body":"[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"All of these attributes are individually optional. However, sending a message will fail if there is no recipient specified in either `to`, `cc`, or `bcc`.\",\n \"title\": \"A note on sending directly\"\n}\n[/block]\nA successful response will include a full new [Message](ref:messages) object.","category":"5e41e73d960b09003ca35973","order":2,"slug":"sending-directly","hidden":false,"link_url":"","link_external":false,"sync_unique":"","user":"5d404909c2f77c0012211f3e","__v":40,"updatedAt":"2019-12-09T17:45:25.318Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:38.443Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/send#directly"}},{"_id":"5e41e73d960b09003ca359c2","updates":[],"user":"5d404909c2f77c0012211f3e","__v":35,"category":"5e41e73d960b09003ca35973","link_external":false,"link_url":"","excerpt":"Sends a raw MIME message.\n\nPlease note: when making your call to the endpoint, do not include the hashtag and what appears after the hashtag in your URL. This appears here solely for the purpose of demarcating our documentation. Make your call to `https://api.nylas.com/send` with the appropriate payload.","hidden":false,"isReference":true,"parentDoc":null,"slug":"sending-raw-mime","title":"Sending raw MIME","version":"5e41e73d960b09003ca35a9b","api":{"results":{"codes":[{"status":200,"language":"json","code":"","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"592608be82c3660f00c2b64e"},{"name":"Content-Type","type":"string","default":"message/rfc822","desc":"","required":false,"in":"header","ref":"","_id":"5ca689715e368700454af095"}],"url":"/send#raw","method":"post","examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /send HTTP/1.1\nHost: api.nylas.com\nAccept: message/rfc822\nContent-Type: message/rfc822\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache\n\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nIn-Reply-To: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com>\nReferences: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com>\nSubject: Meeting on Thursday\nFrom: Bill <test@test.com>\nTo: Ben Bitdiddle <test@test.com>\n\nHey Ben,\n\nWould you like to grab coffee @ 2pm this Thursday?\"\nBill"},{"name":"cURL","language":"curl","code":"curl -X POST 'https://api.nylas.com/send' \\\n-H 'Content-Type: message/rfc822' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d 'MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nIn-Reply-To: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com>\nReferences: <84umizq7c4jtrew491brpa6iu-0@mailer.nylas.com>\nSubject: With Love, From Nylas\nFrom: You <you@example.com>\nTo: My Nylas Friend <swag@nylas.com>\n\nThis email was sent via raw MIME using the Nylas email API. Visit https://nylas.com for details.'"},{"name":"Python SDK","language":"python","code":"# This is not implemented in the Python SDK"},{"name":"Ruby SDK","language":"ruby","code":"api.messages.raw.send(message.id)"},{"name":"Node.js SDK","language":"javascript","code":"// Send a message with raw MIME\nconst draft = nylas.drafts.build({ rawMime }); // rawMIME should be a MIME-format string with headers and multipart message\ndraft.send().then(message => console.log(message));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Message;\n\npublic class NylasExamples {\n public static void sendRawMimeExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n // rawMIME should be a MIME-format string with headers and multipart message\n String rawMime = \"\"; \n Message message = account.drafts().sendRawMime(rawMime);\n }\n}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-24T22:42:14.784Z","next":{"pages":[],"description":""},"sync_unique":"","type":"endpoint","body":"You can also send via submitting raw MIME message object. The submitted object is entirely preserved, except the `bcc` header which is removed. Additional headers used by Nylas may be added.\n\nIf the message is in reply to an existing message, you should make sure to include the `In-Reply-To` and `References` headers. These headers are set to the `Message-Id` header of the message you are replying to and `Message-Id` header of related messages, respectively. For more details, see [this article](http://cr.yp.to/immhf/thread.html).\n\nA successful response will include a full new [Message](ref:messages) object.","githubsync":"","order":3,"project":"59245c10200df13100c88563","updatedAt":"2019-05-30T22:26:01.152Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.716Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/send#raw"}},{"_id":"5e41e73d960b09003ca359c3","project":"59245c10200df13100c88563","updates":[],"createdAt":"2017-05-24T22:51:32.921Z","hidden":false,"isReference":true,"link_external":false,"next":{"pages":[],"description":""},"order":0,"user":"5d404909c2f77c0012211f3e","api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"body":"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. Note that before creating or modifying a draft to include an attachment, you must upload it via this API and use the returned file ID.\n\nActual attached files may be relatively large (upwards of 25MB), so this API has separate endpoints for requesting file [Metadata](ref:metadata) and [Downloading](ref:filesiddownload) the actual file.\n\nFiles can be downloaded by appending `/download` to the file metadata URI. If available, the response will include the filename in the `Content-Disposition` header.\n\nThe [Upload](ref:upload) 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.\n[block:callout]\n{\n \"type\": \"danger\",\n \"title\": \"Files are only stored temporarily\",\n \"body\": \"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.\"\n}\n[/block]\n## Filtering and Files\n\nThis endpoint supports [Filters](ref:filters) and [Pagination](ref:pagination), which allow you to fetch multiple files matching specific criteria and iterate through a large set of files. See the query parameters in the endpoints below to see what kind of filtering is supported.\n\n## Popular Content-Type values corresponding to popular file extensions\n\n| Document | Content-Type\n| ----------:|:------- |\n| PNG images | `image/png`\n| JPEG images | `image/jpeg`\n| PDF documents | `application/pdf`\n| ZIP archives | `application/zip`\n| MS Word (.doc) | `application/msword`\n| MS Excel (.xls) | `application/vnd.ms-excel`\n| MS Powerpoint (.ppt) | `application/vnd.ms-powerpoint`\n| MS Word (.docx) | `application/vnd.openxmlformats-officedocument.wordprocessingml.document`\n| Microsoft Powerpoint (.pptx) | `application/vnd.openxmlformats-officedocument.presentationml.pesentation`\n| Microsoft Excel (.xlsx) | `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`\n\nHere is a more complete [list of Content Types](https://docs.nylas.com/docs/file-attachment-media-types).","link_url":"","slug":"files","type":"basic","version":"5e41e73d960b09003ca35a9b","__v":0,"category":"5e41e73d960b09003ca35974","excerpt":"","githubsync":"","parentDoc":null,"sync_unique":"","title":"Introduction","updatedAt":"2019-09-26T14:55:47.629Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359c4","type":"endpoint","api":{"results":{"codes":[{"code":"[\n {\n \"account_id\": \"43jf3n4es****\",\n \"content_type\": \"image/jpeg\",\n \"filename\": \"image.jpg\",\n \"id\": \"9etjh6talp1m***\",\n \"object\": \"file\",\n \"size\": 72379\n }\n {\n \"account_id\": \"32kw6xxqt9ws****\",\n \"content_type\": \"image/jpeg\",\n \"filename\": \"image2.jpg\",\n \"id\": \"3js0rl93rlxq5***\",\n \"object\": \"file\",\n \"size\": 83739\n }\n\n]","language":"json","status":200,"name":""},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"examples":{"codes":[{"code":"GET /files HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"# Return all file attachments found in the user's account\ncurl -X GET 'https://api.nylas.com/files/' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \n\n# Use limit and offset to control pagination\ncurl -X GET 'https://api.nylas.com/files/?limit=5&offset=10' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \n\n# Available filters: content_type, message_id, filename\ncurl -X GET 'https://api.nylas.com/files?content_type=image/jpeg' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all file attachments found in the user's account\nnylas.files.all()\n\n# Use limit and offset to control pagination\nnylas.files.where(limit=5, offset=10)\n\n# .where() returns files that are filtered by specified arguments\n# Available filters: content_type, message_id, filename\nfile = nylas.files.where(content_type='application/pdf').first()\n# .first() returns the oldest file from the results of a query\n\n\n# The following attributes are available for the file object\nfile.size\nfile.account_id\nfile.object\nfile.filename\nfile.content_type\nfile.message_ids\nfile.content_id\nfile.id","language":"python","name":"Python SDK"},{"code":"example_file = api.files.first\n\n# Listing files\napi.files.limit(2).map(&:to_h)","language":"ruby","name":"Ruby SDK"},{"code":"// Return all file attachments found in the user's account\nnylas.files.list().then(files => console.log(files));\n\n// Use limit and offset to control pagination\nnylas.files.list({limit: 5, offset: 10}).then(files => console.log(files));\n\n// .list() and .first() return files that are filtered by specified arguments\n// Available filters: contentType, messageId, filename\nnylas.files.first({content_type: 'application/pdf'}).then(file => console.log(file));\n// .first() returns the oldest file from the results of a query\n\n\n// The following attributes are available for the file object\nfile.id\nfile.object\nfile.accountId\nfile.contentType\nfile.size\nfile.filename\nfile.messageIds\nfile.contentId\nfile.contentDisposition","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.File;\nimport com.nylas.FileQuery;\nimport com.nylas.Files;\n\npublic class NylasExamples {\n public static void getFilesExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Files files = account.files();\n \n // Return all files found in the user's inbox \n files.list();\n \n // Return files that are filtered by specified arguments\n // Available Filters: contentType, messageId, filename\n files.list(new FileQuery().filename(\"My File\"));\n \n // Use offset, and limit to control pagination\n files.list(new FileQuery().limit(5).offset(10));\n \n // Return the most recent file\n File file = files.list(new FileQuery().limit(1)).get(0);\n \n // The following attributes are available for the file object\n file.getId();\n file.getContentId();\n file.getContentType();\n file.getFilename();\n file.getMessageIds();\n file.getSize();\n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"filename","type":"string","default":"","desc":"Return files that match the specified file name.","required":false,"in":"query","ref":"","_id":"5984b0e5ac2c870037138bda"},{"name":"message_id","type":"string","default":"","desc":"Return files matching the specified message ID.","required":false,"in":"query","ref":"","_id":"5984b0e5ac2c870037138bd9"},{"name":"content_type","type":"string","default":"","desc":"Return files matching the specified content type.","required":false,"in":"query","ref":"","_id":"5984b0e5ac2c870037138bd8"},{"name":"view","type":"string","default":"","desc":"Return files matching the specified `count` or `ids`. See [Views](ref:views) for more info.","required":false,"in":"query","ref":"","_id":"5984b0e5ac2c870037138bd7"}],"url":"/files","method":"get","apiSetting":"5e41e73d960b09003ca3598d"},"link_external":false,"project":"59245c10200df13100c88563","slug":"metadata","sync_unique":"","user":"5d404909c2f77c0012211f3e","body":"Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|:----|\n| `id` | string | Globally unique object identifier |\n| `object` | string | A string describing the type of object (value is \"file\")\n| `account_id` | string | Reference to parent account object |\n| `filename` | string | Name of the file, if available\n| `size` | integer | Size of the file, in bytes\n| `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.\n| `message_ids` | array | Array of identifiers for messages that contain this attachment. (Not guaranteed to be a complete set)\n| `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.","excerpt":"Searches for files using the specified filter criteria, and returns information about each file's metadata.","githubsync":"","next":{"description":"","pages":[]},"order":1,"parentDoc":null,"title":"/files","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35974","createdAt":"2017-05-24T22:56:39.473Z","link_url":"","updates":[],"__v":27,"hidden":false,"isReference":true,"updatedAt":"2019-07-08T22:25:48.910Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:13:19.824Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/files"}},{"_id":"5e41e73d960b09003ca359c5","__v":20,"category":"5e41e73d960b09003ca35974","isReference":true,"version":"5e41e73d960b09003ca35a9b","api":{"params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the file for which to search.","required":false,"in":"path","ref":"","_id":"59260fc2d235fa0f002c1a8e"}],"results":{"codes":[{"name":"","code":"{\n \"account_id\": \"43jf3n4es3***\",\n \"content_type\": \"image/jpeg\",\n \"filename\": \"image.jpg\",\n \"id\": \"9etjh6talp***\",\n \"object\": \"file\",\n \"size\": 72379\n}","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"url":"/files/{id}","auth":"required","examples":{"codes":[{"code":"GET /files/9etjh6talp*** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"curl -X GET 'https://api.nylas.com/files/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate file id\nfile = nylas.files.get('{id}')\n\n# The following attributes are available for the file object\nfile.size\nfile.account_id\nfile.object\nfile.filename\nfile.content_type\nfile.message_ids\nfile.content_id\nfile.id","language":"python","name":"Python SDK"},{"code":"# Retrieving file metadata\nexample_file = api.files.first\napi.files.find(example_file.id).to_h","language":"ruby","name":"Ruby SDK"},{"code":"// Replace {id} with the appropriate file id\nnylas.files.find('{id}').then(file => console.log(file));\n\n// The following attributes are available for the file object\nfile.id\nfile.object\nfile.accountId\nfile.contentType\nfile.size\nfile.filename\nfile.messageIds\nfile.contentId\nfile.contentDisposition","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.File;\nimport com.nylas.Files;\n\npublic class NylasExamples {\n public static void getFileExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Files files = account.files();\n \n // Get a file by specifying the file ID \n File file = files.get(\"FILE_ID\");\n \n // The following attributes are available for the file object\n file.getId();\n file.getContentId();\n file.getContentType();\n file.getFilename();\n file.getMessageIds();\n file.getSize();\n }\n}"}]},"method":"get","apiSetting":"5e41e73d960b09003ca3598d"},"type":"endpoint","user":"5d404909c2f77c0012211f3e","parentDoc":null,"project":"59245c10200df13100c88563","slug":"get-metadata","excerpt":"Searches for a file identified by the specified file ID, and returns the file metadata.","githubsync":"","next":{"pages":[],"description":""},"link_url":"","order":2,"sync_unique":"","title":"/files/{id}","body":"","createdAt":"2017-05-24T22:57:06.026Z","hidden":false,"link_external":false,"updates":[],"updatedAt":"2019-12-09T17:45:25.320Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.895Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/files/{id}"}},{"_id":"5e41e73d960b09003ca359c6","link_external":false,"next":{"pages":[],"description":""},"slug":"filesiddownload","sync_unique":"","title":"/files/{id}/download","api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /files/4zv7p****/download HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"curl -X GET 'https://api.nylas.com/files/{id}/download' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate file id\nfile = nylas.files.get('{id}')\n\n# .download() returns the file itself.\n# Most files will be returned as a binary object\nfile.download()"},{"name":"Ruby SDK","language":"ruby","code":"# Downloading a particular file\nexample_file = api.files.first\nexample_file.download\n\n# Downloading a particular file is cached. Notice the path didn't change\nexample_file = api.files.first\nexample_file.download\n\n# Re-downloading a file, notice the path does change.\nexample_file = api.files.first\nexample_file.download!"},{"name":"Node.js SDK","language":"javascript","code":"// Replace {id} with the appropriate file id\nlet file;\nnylas.files.find('{id}').then(res => file = res);\n\n// .download() returns the file itself.\n// Most files will be returned as a binary object\nfile.download().then(res => console.log(res));"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.nio.file.Paths;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.File;\nimport com.nylas.Files;\n\npublic class NylasExamples {\n public static void downloadFileExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Files files = account.files();\n \n File file = files.get(\"{fileId}\");\n \n byte[] fileBytes = files.downloadBytes(file.getId());\n java.nio.file.Files.write(Paths.get(\"/tmp/\" + file.getFilename()), fileBytes);\n \n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the file to download.","required":false,"in":"path","ref":"","_id":"59260fc2d235fa0f002c1a8e"}],"url":"/files/{id}/download","method":"get","results":{"codes":[{"name":"","code":"Response will return file data for download.","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"apiSetting":"5e41e73d960b09003ca3598d"},"parentDoc":null,"type":"endpoint","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","excerpt":"Download the actual file","hidden":false,"link_url":"","order":3,"__v":20,"body":"","category":"5e41e73d960b09003ca35974","createdAt":"2017-05-24T22:57:54.761Z","githubsync":"","isReference":true,"project":"59245c10200df13100c88563","updates":[],"updatedAt":"2019-12-09T17:45:25.320Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.723Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/files/{id}/download"}},{"_id":"5e41e73d960b09003ca359c7","category":"5e41e73d960b09003ca35974","next":{"pages":[],"description":""},"parentDoc":null,"slug":"upload","title":"/files","version":"5e41e73d960b09003ca35a9b","__v":25,"api":{"auth":"required","examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /files HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUW****\ncache-control: no-cache\n{\n \"file\": file_attachment\n}------WebKitFormBoundary7MA4YWxkTrZu0gW--"},{"name":"cURL","language":"curl","code":"curl -X POST 'https://api.nylas.com/files/' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' \\\n--form 'file=@{path_to_file}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Create a new file with the stream interface for binary objects\nattachment = open('attachment.pdf', 'r')\nfile = nylas.files.create()\nfile.filename = 'attachment.pdf'\nfile.stream = attachment\n# .save() saves the file to Nylas, file.id can then be used to attach the file to an email\nfile.save()\nattachment.close()\n\n# Create a new file with the data interface for text objects\nfile = nylas.files.create()\nfile.filename = 'test.txt'\nfile.data = \"Hello World.\"\nfile.save()"},{"name":"Ruby SDK","language":"ruby","code":"# Uploading a file\napi.files.create(file: File.open(File.expand_path(__FILE__), 'r')).to_h"},{"name":"Node.js SDK","language":"javascript","code":"fs.readFile(filePath, (err, data) => {\n f = nylas.files.build({\n filename: filePath,\n data: data,\n contentType: 'text/plain',\n });\n\n f.upload((err, file) => {\n // Create a draft and attach the file to it.\n const draft = nylas.drafts.build({\n subject: 'Ice Cream',\n to: [{ email: 'helena@nylas.com' }],\n body: 'Hey, find the file attached.',\n });\n\n draft.files = [file];\n\n draft.send().then(message => {\n console.log(`${message.id} was sent`);\n });\n });\n});\n\n// Stream files from AWS\nconst AWS = require('aws-sdk');\nconst Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\nconst nylas = Nylas.with(ACCESS_TOKEN);\n\nvar s3 = new AWS.S3();\nvar s3Stream = s3.getObject({Bucket: s3bucket, Key: s3key}).createReadStream();\n\nvar newFile = nylas.files.build({filename: 'newfileyay.jpg', data: s3Stream, contentType: 'image/jpeg', size: s3size});\nnewFile.upload();"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport java.nio.file.Paths;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Files;\nimport com.nylas.File;\n\npublic class NylasExamples {\n public static void postFileExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Files files = account.files();\n\n byte[] myFile = java.nio.file.Files.readAllBytes(Paths.get(\"/path/to/myFile.pdf\"));\n File upload = files.upload(\"My Upload\", \"application/pdf\", myFile);\n System.out.println(upload);\n }\n}"}]},"method":"post","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"file","type":"file","default":"","desc":"The file to upload. Upload size limit is ~25 MB.","required":true,"in":"body","ref":"","_id":"592611006ef4610f00cfaf58"}],"results":{"codes":[{"name":"","code":"[\n {\n \"account_id\": \"43jf3n4es3***\",\n \"content_type\": \"image/jpeg\",\n \"filename\": \"image.jpg\",\n \"id\": \"9etjh6talp1m***\",\n \"object\": \"file\",\n \"size\": 72379\n }\n]","language":"json","status":200},{"code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"url":"/files","apiSetting":"5e41e73d960b09003ca3598d"},"hidden":false,"link_external":false,"link_url":"","type":"endpoint","user":"5d404909c2f77c0012211f3e","body":"This 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](http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2) with a single field named `file`.\n\nA successful upload will return an array with a single file object. This object's ID may be attached to a [Draft](ref:drafts) by appending it to `file_ids` array of the draft object. Additionally, if the object is an image it may be included inline in the body of the email by referencing it inside an `img` tag like so: `<img src=\"cid:file_id\">`. See [Sending](ref:sending) for more info about inline images.","createdAt":"2017-05-24T23:02:24.177Z","excerpt":"Uploads a new file.","order":4,"updates":[],"githubsync":"","isReference":true,"project":"59245c10200df13100c88563","sync_unique":"","updatedAt":"2019-12-09T17:45:25.321Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:38.871Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/files"}},{"_id":"5e41e73d960b09003ca35a25","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35974","user":"5d404909c2f77c0012211f3e","updates":["5e8331c8820b7a001e8068ab"],"next":{"pages":[],"description":""},"createdAt":"2018-03-13T21:36:37.074Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"code":"DELETE /files/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"curl -X DELETE 'https://api.nylas.com/files/{id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN' ","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Replace {id} with the appropriate file id\nnylas.files.delete('{id}')\n\n# Note: Only files that have been uploaded via Nylas can be deleted.","language":"python","name":"Python SDK"},{"code":"","language":"ruby","name":"Ruby SDK"},{"code":"// Replace {id} with the appropriate file id\nnylas.files.delete('{id}')\n\n// Note: Only files that have been uploaded via Nylas can be deleted.","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Files;\n\npublic class NylasExamples {\n public static void deleteFileExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Files files = account.files();\n \n files.delete(\"{fileId}\");\n \n }\n}"}]},"results":{"codes":[{"name":"","code":"","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the file to delete.","required":false,"in":"path","ref":"","_id":"59260fc2d235fa0f002c1a8e"}],"url":"/files/{id}","method":"delete"},"isReference":true,"order":5,"body":"A successful deletion will return `null` along with a 200 OK response code.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Note\",\n \"body\": \"You can only delete files that have been uploaded directly to the API, and not files that have been generated from message attachments.\"\n}\n[/block]","excerpt":"Deletes an existing file identified by the specified file ID.","slug":"files-delete","type":"endpoint","title":"/files/{id}","__v":26,"parentDoc":null,"updatedAt":"2019-12-09T17:45:25.321Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:17:39.601Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/files/{id}"}},{"_id":"5e41e73d960b09003ca359c8","api":{"url":"","method":"get","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[]},"createdAt":"2017-05-24T23:24:50.368Z","slug":"calendars","user":"5f2067586dda9a0045009159","category":"5e41e73d960b09003ca35975","excerpt":"","order":0,"type":"basic","githubsync":"","parentDoc":null,"project":"59245c10200df13100c88563","title":"Introduction","__v":2,"body":"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.\n\nThe calendar endpoint supports [Pagination](ref:pagination) (although most users have only a few calendars) and [Views](ref:views).\n\n## Provider-backed calendars\n\nThe primary calendar of the account is usually uses the same name as the email address, or is sometimes simply called \"Calendar.\" Users may also have other custom calendars, access to colleagues' calendars, or access to shared team calendars. See [Events](ref:events) for more details.\n\nEvents can be viewed, added, modified, and deleted on calendars where `read_only` is false. Changes are automatically synced back to the provider.\n\n## The Emailed events calendar\n\nAll accounts also include a special calendar called \"Emailed events\" which contains event invitations that have been sent to the user's mailbox. This calendar is read-only, meaning events cannot be added, updated, or deleted. However, the events can handle RSVPs. See the [Events](ref:events) documentation for details.\n\n## Virtual Calendars\n\nVirtual Calendars are used when you need to schedule people or objects that do not have an associated calendar. Review the [Virtual Calendar documentation](https://docs.nylas.com/docs/virtual-calendars) to learn more.","hidden":false,"isReference":true,"link_external":false,"link_url":"","next":{"description":"","pages":[]},"sync_unique":"","updates":["5ad27358a1add30003dae100","5ad2735f17932b000393bea3"],"version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-10-14T16:34:46.843Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-10-14T16:08:42.702Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359c9","api":{"url":"/calendars","method":"get","examples":{"codes":[{"code":"GET /calendars HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"curl -X GET 'https://api.nylas.com/calendars' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all calendars found in the user's account\nnylas.calendars.all()\n\n# Returns a count of the calendars the user account has\nnylas.calendars.where(view='count')\n# You can also provide view='id' to provide the calendar ids only.\n\n# Return the first calendar\ncalendar = nylas.calendars.first()\n\n\n# The following attributes are available for the calendar object\ncalendar.id\ncalendar.object\ncalendar.account_id\ncalendar.name\ncalendar.description\ncalendar.read_only","language":"python","name":"Python SDK"},{"code":"# Return all calendars found in the user's account\nnylas.calendars\n\n# Return the ids of all calendars for a user account\nnylas.calendars.ids\n\n# Return the count of the calendars a user account has\napi.calendars.count\n\n# Return the first two calendars for the user account\ncalendars.calendars.limit(2)\n\n# Return the first calendar\ncalendar = nylas.calendars.first\n\n# The following attributes are available for the calendar object\ncalendar.id\ncalendar.object\ncalendar.account_id\ncalendar.name\ncalendar.description\ncalendar.read_only","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// Get all calendars found in the user's account\nnylas.calendars.list().then(calendars => console.log(calendars));\n\n// Get a count of all the users' calendars\nnylas.calendars.count().then(calendarCount => console.log(calendarCount));\n\n// Get the first calendar\nnylas.calendars.first().then(calendar => console.log(calendar));\n\n// The following attributes are available for the Calendar object\ncalendar.id\ncalendar.object\ncalendar.accountId\ncalendar.name\ncalendar.description\ncalendar.readOnly","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Calendar;\nimport com.nylas.CalendarQuery;\nimport com.nylas.Calendars;\n\npublic class NylasExamples {\n public static void getCalendarsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Calendars calendars = account.calendars();\n \n // Return all calendars found for the user \n calendars.list();\n \n // Use offset, and limit to control pagination\n calendars.list(new CalendarQuery().limit(2).offset(4));\n \n // Return the first calendar\n Calendar calendar = calendars.list(new CalendarQuery().limit(1)).get(0);\n \n // The following attributes are available for the calendar object\n calendar.getId();\n calendar.getAccountId();\n calendar.getDescription();\n calendar.getName();\n calendar.isReadOnly();\n }\n}"}]},"results":{"codes":[{"status":200,"name":"","code":"[\n {\n \"description\": null,\n \"id\": \"67qmz3fuk9wf***\",\n \"name\": \"Calendar\",\n \"account_id\": \"bh1vu31mw9ap***\",\n \"object\": \"calendar\",\n \"read_only\": false\n },\n {\n \"description\": \"Emailed events\",\n \"id\": \"b4xm1jjibrxky***\",\n \"name\": \"Emailed events\",\n \"account_id\": \"bh1vu31mw9a***\",\n \"object\": \"calendar\",\n \"read_only\": true\n }\n]","language":"json"},{"code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"auth":"never","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"view","type":"string","default":"","desc":"Return calendars matching the specified view. Value can be `count` or `ids`. Reference [Views](ref:views) for more info.","required":false,"in":"query","ref":"","_id":"5984b16853d075003907728a"},{"name":"limit","type":"string","default":"","desc":"Return calendars with a specified result limit. Reference [Pagination](ref:pagination) for additional details.","required":false,"in":"query","ref":"","_id":"5984b1da339eac000f54a888"},{"name":"offset","type":"string","default":"","desc":"Return calendars matching the specified result pagination offset. See [Pagination](ref:pagination) for additional details.","required":false,"in":"query","ref":"","_id":"5984b1da339eac000f54a887"}],"apiSetting":"5e41e73d960b09003ca3598d"},"excerpt":"Searches for calendars using the specified filter criteria.","isReference":true,"link_external":false,"link_url":"","parentDoc":null,"sync_unique":"","updates":[],"user":"5f2067586dda9a0045009159","createdAt":"2017-05-24T23:28:12.781Z","slug":"calendars-1","__v":28,"body":"Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----|----|---|\n| `id` | string | Globally unique object identifier |\n| `object` | string | A string describing the type of object (value is \"file\")\n| `account_id` | string | Reference to parent account object |\n| `name` | string | Name of the Calendar\n| `description` | string | Description of the Calendar\n| `read_only` | boolean | True if the Calendar is read only |","githubsync":"","order":1,"type":"endpoint","category":"5e41e73d960b09003ca35975","hidden":false,"next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","title":"/calendars","version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-11-06T20:57:44.339Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:47.553Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars"}},{"_id":"5e41e73d960b09003ca359ca","version":"5e41e73d960b09003ca35a9b","__v":20,"excerpt":"Searches for a calendar identified by the specified calendar ID.","hidden":false,"isReference":true,"link_external":false,"parentDoc":null,"project":"59245c10200df13100c88563","sync_unique":"","api":{"url":"/calendars/{id}","method":"get","results":{"codes":[{"code":"{\n \"description\": null,\n \"id\": \"67qmz3fuk9w***\",\n \"name\": \"Calendar\",\n \"account_id\": \"bh1vu31mw9***\",\n \"object\": \"calendar\",\n \"read_only\": false\n}","language":"json","status":200,"name":""},{"language":"json","status":400,"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}"}]},"examples":{"codes":[{"code":"GET /calendars/4zv7p**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Basic WVVUWjZ2****\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"curl -X GET 'https://api.nylas.com/calendars/{calendar_id}' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return a single calendar by specifying its id\ncalendar = nylas.calendars.get('{id}')\n\n\n# The following attributes are available for the calendar object\ncalendar.id\ncalendar.object\ncalendar.account_id\ncalendar.name\ncalendar.description\ncalendar.read_only","language":"python","name":"Python SDK"},{"code":"# Return a single calendar by specifying its id\ncalendar = nylas.calendars.find('{id}')\n\n# The following attributes are available for the calendar object\ncalendar.id\ncalendar.object\ncalendar.account_id\ncalendar.name\ncalendar.description\ncalendar.read_only","language":"ruby","name":"Ruby SDK"},{"code":"const Nylas = require('nylas');\nNylas.config({clientId: 'clientId', clientSecret: 'clientSecret'});\nconst nylas = Nylas.with('access_token');\n\n// Get a calendar by its id\nnylas.calendars.find('calendarId').then(calendar => console.log(calendar));\n\n// The following attributes are available for the Calendar object\ncalendar.id\ncalendar.object\ncalendar.accountId\ncalendar.name\ncalendar.description\ncalendar.readOnly","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Calendar;\nimport com.nylas.Calendars;\n\npublic class NylasExamples {\n public static void getCalendarExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Calendars calendars = account.calendars();\n \n // Get a calendar by specifying the calendar ID \n Calendar calendar = calendars.get(\"FILE_ID\");\n \n // The following attributes are available for the calendar object\n calendar.getId();\n calendar.getAccountId();\n calendar.getDescription();\n calendar.getName();\n calendar.isReadOnly();\n }\n}"}]},"auth":"required","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the calendar for which to search.","required":false,"in":"path","ref":"","_id":"5926174dc7e1ab0f003d5370"}],"apiSetting":"5e41e73d960b09003ca3598d"},"category":"5e41e73d960b09003ca35975","link_url":"","next":{"pages":[],"description":""},"body":"","createdAt":"2017-05-24T23:29:17.341Z","order":2,"user":"5d404909c2f77c0012211f3e","githubsync":"","slug":"calendars-2","title":"/calendars/{id}","type":"endpoint","updates":[],"updatedAt":"2019-12-09T17:45:25.323Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:07:30.771Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars/{id}"}},{"_id":"5ef8f7baaee4a000186544bc","metadata":{"image":[],"title":"","description":""},"api":{"method":"post","url":"/calendars","auth":"never","examples":{"codes":[{"code":"curl -X POST \\\n\"https://api.nylas.com/calendars\" \\\n-d '{\n \"name\":\"My New Calendar\",\n \"description\":\"Description of my new calendar.\",\n \"location\":\"Location description\",\n \"timezone\":\"America/Los_Angeles\"\n}'","language":"curl","name":"cURL"},{"code":"# Not yet supported","language":"python","name":"Python SDK"},{"code":"# Not yet supported","language":"ruby","name":"Ruby SDK"},{"code":"// Not yet supported","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"// Not yet supported"}]},"results":{"codes":[{"status":200,"name":"","code":"{\n \"account_id\": \"eof2wrhqkl7kdwhy9hylpv9o9\",\n \"description\": \"Description of my new calendar.\",\n \"id\": \"8e570s302fdazx9zqwiuk9jqn\",\n \"is_primary\": false,\n \"job_status_id\": \"48pp6ijzrxpw9jors9ylnsxnf\",\n \"location\": \"Location description\",\n \"name\": \"My New Calendar\",\n \"object\": \"calendar\",\n \"read_only\": false,\n \"timezone\": \"America/Los_Angeles\"\n}","language":"json"},{"code":"{\n \"message\": \"Message about the error goes here\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"name","type":"string","default":"","desc":"Name of the Calendar","required":true,"in":"body","ref":"","_id":"5ef8f87bb6b805005f757351"},{"name":"description","type":"string","default":"","desc":"Description of the Calendar","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f757350"},{"name":"location","type":"string","default":"","desc":"Geographic location of the calendar as free-form text","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f75734f"},{"name":"timezone","type":"string","default":"","desc":"[IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York).","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f75734e"}],"apiSetting":"5e41e73d960b09003ca3598d"},"next":{"description":"","pages":[]},"title":"/calendars","updates":[],"type":"endpoint","slug":"calendars-3","excerpt":"Create a new Calendar","body":"[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Google Support\",\n \"body\": \"Creating calendars is currently only supported for Gmail and GSuite account types.\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"When making modifications to calendar objects, Nylas exposes a [Job Status](ref:job-statuses) that represents whether the action has synced back to the provider or not.\",\n \"title\": \"Calendar Modifications include job status\"\n}\n[/block]\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|-----:|:----|:----|\n| `account_id` | string | Reference to parent account object |\n| `description` | string | Description of the Calendar\n| `id` | string | Globally unique object identifier |\n| `is_primary` | boolean | A boolean denoting whether this is the primary calendar associated with a account|\n| `job_status_id` | string | [Job status ID](ref:job-statuses) for the calendar modification. \n| `location` |string| Geographic location of the calendar as free-form text |\n| `name` | string | Name of the Calendar\n| `object` | string | A string describing the type of object (value is \"file\")\n| `read_only` | boolean | True if the Calendar is read only |\n| `timezone` |string | [IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York).","order":3,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"pendingAlgoliaPublish":false,"createdAt":"2020-06-28T20:04:10.357Z","updatedAt":"2020-06-28T20:09:19.446Z","user":"59245bff200df13100c88562","category":"5e41e73d960b09003ca35975","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","__v":7,"parentDoc":null,"tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars"}},{"_id":"5ef8f97e02d23300251adc8f","metadata":{"image":[],"title":"","description":""},"api":{"method":"put","url":"/calendars/{id}","auth":"required","examples":{"codes":[{"code":"curl -X PUT \\\n\"https://api.nylas.com/calendars\" \\\n-d '{\n\t\"description\":\"Updating the description my new calendar.\"\n}'","language":"curl","name":"cURL"},{"code":"# Not yet supported","language":"python","name":"Python SDK"},{"code":"# Not yet supported","language":"ruby","name":"Ruby SDK"},{"code":"// Not yet supported","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"// Not yet supported"}]},"results":{"codes":[{"status":200,"name":"","code":"{\n \"account_id\": \"eof2wrhqkl7kdwhy9hylpv9o9\",\n \"description\": \"Updating the description of my new calendar.\",\n \"id\": \"8e570s302fdazx9zqwiuk9jqn\",\n \"is_primary\": false,\n \"job_status_id\": \"48pp6ijzrxpw9jors9ylnsxnf\",\n \"location\": \"test_room\",\n \"name\": \"calendar_test\",\n \"object\": \"calendar\",\n \"read_only\": false,\n \"timezone\": \"America/Los_Angeles\"\n}","language":"json"},{"code":"{\n \"message\": \"Message about the error goes here\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"name","type":"string","default":"","desc":"Name of the Calendar","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f757351"},{"name":"description","type":"string","default":"","desc":"Description of the Calendar","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f757350"},{"name":"location","type":"string","default":"","desc":"Geographic location of the calendar as free-form text","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f75734f"},{"name":"timezone","type":"string","default":"","desc":"[IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York).","required":false,"in":"body","ref":"","_id":"5ef8f87bb6b805005f75734e"},{"name":"id","type":"string","default":"","desc":"The id of the calendar to modify","required":false,"in":"path","ref":"","_id":"5ef8faa824d9ae0052969334"}],"apiSetting":"5e41e73d960b09003ca3598d"},"next":{"description":"","pages":[]},"title":"/calendars{id}","updates":[],"type":"endpoint","slug":"calendars-4","excerpt":"Update an existing calendar","body":"[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Google Support\",\n \"body\": \"Modifying calendars is currently only supported for Gmail and GSuite account types.\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"When making modifications to calendar objects, Nylas exposes a [Job Status](ref:job-statuses) that represents whether the action has synced back to the provider or not.\",\n \"title\": \"Calendar Modifications include job status\"\n}\n[/block]\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|-----:|:----|:----|\n| `account_id` | string | Reference to parent account object |\n| `description` | string | Description of the Calendar\n| `id` | string | Globally unique object identifier |\n| `is_primary` | boolean | A boolean denoting whether this is the primary calendar associated with a account|\n| `job_status_id` | string | [Job status ID](ref:job-statuses) for the calendar modification. \n| `location` |string| Geographic location of the calendar as free-form text |\n| `name` | string | Name of the Calendar\n| `object` | string | A string describing the type of object (value is \"file\")\n| `read_only` | boolean | True if the Calendar is read only |\n| `timezone` |string | [IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York).","order":4,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"pendingAlgoliaPublish":false,"createdAt":"2020-06-28T20:11:42.574Z","updatedAt":"2020-06-28T20:18:24.409Z","user":"59245bff200df13100c88562","category":"5e41e73d960b09003ca35975","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","__v":4,"parentDoc":null,"tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars/{id}"}},{"_id":"5ef8fa45b9678f0012f4952d","metadata":{"image":[],"title":"","description":""},"api":{"method":"delete","url":"/calendars/{id}","auth":"never","examples":{"codes":[{"code":"curl -X DELETE \\\n\"https://api.nylas.com/calendars/38mgop88je038mgop88je0/","language":"curl","name":"cURL"},{"code":"# Not yet supported","language":"python","name":"Python SDK"},{"code":"# Not yet supported","language":"ruby","name":"Ruby SDK"},{"code":"// Not yet supported","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"// Not yet supported"}]},"results":{"codes":[{"status":200,"name":"","code":"{\n \"job_status_id\": \"d38mgop88je0agkqrf03sw0sw\"\n}","language":"json"},{"code":"{\n \"message\": \"Message about the error goes here\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The Calendar ID to delete","required":false,"in":"path","ref":"","_id":"5ef8fa45b9678f0012f4952e"}],"apiSetting":"5e41e73d960b09003ca3598d"},"next":{"description":"","pages":[]},"title":"/calendars/{id}","updates":[],"type":"endpoint","slug":"calendarsid","excerpt":"Delete a calendar","body":"Deletes an existing calendar identified by the specific calendar ID. You cannot delete a calendar where `is_primary: true`. \n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Google Support\",\n \"body\": \"Deleting calendars is currently only supported for Gmail and GSuite account types.\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"When making modifications to calendar objects, Nylas exposes a [Job Status](ref:job-statuses) that represents whether the action has synced back to the provider or not.\",\n \"title\": \"Calendar Modifications include job status\"\n}\n[/block]\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n\n| Attribute | Type | Description |\n|----:|:----|\n| `job_status_id` | string | [Job status ID](ref:job-statuses) for the calendar modification.","order":5,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"pendingAlgoliaPublish":false,"createdAt":"2020-06-28T20:15:01.237Z","updatedAt":"2020-06-28T20:15:01.237Z","user":"59245bff200df13100c88562","category":"5e41e73d960b09003ca35975","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","__v":1,"parentDoc":null,"tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars/{id}"}},{"_id":"5e41e73d960b09003ca35a8f","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-10-28T17:49:49.799Z","createdAt":"2019-10-11T18:46:38.426Z","project":"59245c10200df13100c88563","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca35975","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":6,"body":"The `/calendars/free-busy` endpoint allows you to query availability information for a Calendar during a certain time period without accessing sensitive information about events within the window, like titles, descriptions, or locations.\n\nTo get started, you'll need an authenticated account that has one of the following scopes: `calendar`, `calendar.read_only`.\n\nTo request free / busy information for a given calendar you need to pass 3 items:\n- The account's `access_token`\n- The start and end time of the range you're checking availability\n- The email address representing the calendar for which you want to check availability.","excerpt":"","slug":"free-busy","type":"basic","metadata":{"description":"","title":"","image":[]},"title":"Free / Busy Status","__v":0,"parentDoc":null,"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca35a8e","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-10-18T20:23:15.166Z","createdAt":"2019-10-11T18:24:20.818Z","project":"59245c10200df13100c88563","user":"5f2067586dda9a0045009159","category":"5e41e73d960b09003ca35975","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","results":{"codes":[{"status":200,"name":"","code":"[ \n {\n \"object\": \"free_busy\",\n\t \"email\": \"sarah@nylas.com\",\n \"time_slots\": [\n { \n \"object\": \"time_slot\",\n \"status\": \"busy\",\n \"start_time\": 1409594400,\n \"end_time\": 1409598000\n },\n { \n \"object\": \"time_slot\",\n \"status\": \"busy\",\n \"start_time\": 1409598000,\n \"end_time\": 1409599000\n }\n ]\n }\n]","language":"json"},{"code":"{\n \"message\": \"Error message from the provider\",\n \"type\": \"provider_error\"\n}","language":"json","status":400,"name":""},{"status":400,"language":"json","code":"{\n \"type\": \"invalid_request_error\", \n \"message\": \"The time range specified is too large. Must be less than 90 days.\"\n}"}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /calendars/free-busy HTTP/1.1\nHost: https://api.nylas.com\nContent-Type: application/json\nAuthorization: Basic myAccessToken==\n\n{\n\t\"start_time\":\"1409594400\",\n\t\"end_time\":\"1409598000\",\n\t\"emails\": [\"sarah@nylas.com\"]\n} "},{"name":"cURL","language":"curl","code":"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} \""},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nfrom datetime import datetime, timedelta\n\n# Create a client that has access an end user account\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Search for free-busy time slots over the next 24 hours.\nstart_time = datetime.now()\nend_time = datetime.now() + timedelta(hours = 24)\n# Provide the email address to check, a start time, and an end time\nfree_busy = nylas.free_busy(\"your_email@example.com\", start_time, end_time)"},{"name":"Ruby SDK","language":"ruby","code":"# Not yet supported in the Nylas Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"const Nylas = require('nylas');\n\nNylas.config({\n clientId: CLIENT_ID,\n clientSecret: CLIENT_SECRET,\n});\n\n// Create a client that has access an end user account\nconst nylas = Nylas.with(ACCESS_TOKEN);\n\n// Search for free-busy time slots over the next 24 hours.\nconst startTime = Math.floor(Date.now() / 1000) // current unix timestamp in seconds\nconst endTime = startTime + (60 * 60 * 24) // add 24 hours in seconds\n\n// Provide the email address to check, a start time, and an end time\nnylas.calendars.freeBusy(\n {\n startTime: startTime, \n end_time: endTime, \n emails: ['your_email@example.com']\n }).then(freeBusy => console.log(freeBusy));"},{"name":"Java SDK","language":"java","code":"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<FreeBusy> 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}"}]},"auth":"never","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"start_time","type":"int","default":"","desc":"Unix timestamp for the beginning of the freebusy window.","required":true,"in":"body","ref":"","_id":"5dcc94eb683bb3005c4801fe"},{"name":"end_time","type":"string","default":"","desc":"Unix timestamp for the end of the freebusy window.","required":true,"in":"body","ref":"","_id":"5dcc94eb683bb3005c4801fd"},{"name":"emails","type":"array_string","default":"","desc":"The email to check freebusy times for.","required":true,"in":"body","ref":"","_id":"5dcc94eb683bb3005c4801fc"}],"url":"/calendars/free-busy","method":"post"},"isReference":true,"order":7,"body":"Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|:----|:----|----|\n| `object` | string | A string describing the type of object (value is \"free_busy\")\n| `email` | string | Which email this free_busy information applies to |\n| `time_slots` | array | An array of `time_slot` objects. See below for a description of the `time_slot` object. |\n\nThe `time_slot` sub-object contains the following attributes:\n\n| Attribute | Type | Description |\n|:----|:----|----|\n| `object` | string | A string describing the type of object (value is \"time_slot\")\n| `status` | string | Value is `busy` which indicates this time_slot is busy. |\n| `start_time` | integer | Unix timestamp of the start time of the time_slot.\n| `end_time` | integer | Unix timestamp of the end time of the time_slot.","excerpt":"Query free / busy information for a calendar during a certain time period.","slug":"calendars-free-busy","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"/calendars/free-busy","__v":26,"parentDoc":null,"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-10-15T16:24:33.459Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars/free-busy"}},{"_id":"5ebf2cf830a2c700183eaeaa","metadata":{"image":[],"title":"","description":""},"api":{"method":"get","url":"","auth":"required","results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"params":[]},"next":{"description":"","pages":[]},"title":"Availability","updates":["5ef3f2fb9a34120018be8a8d"],"type":"basic","slug":"availability","excerpt":"","body":"[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"The Availability Endpoint is in Beta\",\n \"body\": \"The Availability endpoint has been thoroughly tested and is stable enough to use in production. However, it may be subject to change based on customer feedback, so if this is an issue for you, we suggest waiting for general release.\"\n}\n[/block]\nThe `/calendars/availability` endpoint finds availability across all the time slots and free/busy data for a list of email addresses that are passed in. \n\nTo get started, you'll need an authenticated account that has one of the following scopes: `calendar`, `calendar.read_only`.\n\nTo request free / busy information for a given calendar, pass in 3 items:\n- The start and end time of the range for which you're checking availability\n- A list of email address representing the calendar for which you want to check availability\n- Optionally, a list of time slots as returned by our [/calendars/free-busy](ref:calendars-free-busy) endpoint (this is only needed if you'd like to pass in the availability of someone who is outside of the enterprise domain of the authenticated user)","order":8,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"pendingAlgoliaPublish":false,"createdAt":"2020-05-15T23:44:01.825Z","updatedAt":"2020-06-29T15:56:59.579Z","user":"5d404909c2f77c0012211f3e","category":"5e41e73d960b09003ca35975","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","__v":1,"parentDoc":null,"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5ebf2e6b18a5b80025536e5e","metadata":{"image":[],"title":"","description":""},"api":{"method":"post","url":"/calendars/availability","auth":"never","apiSetting":"5e41e73d960b09003ca3598d","results":{"codes":[{"status":200,"name":"","code":"{\n \"object\": \"availability\",\n \"time_slots\": [\n {\n \"end\": 1601386200,\n \"object\": \"time_slot\",\n \"start\": 1601384400,\n \"status\": \"free\"\n },\n {\n \"end\": 1601388000,\n \"object\": \"time_slot\",\n \"start\": 1601386200,\n \"status\": \"free\"\n }\n }","language":"json"},{"code":"{\n \"message\": \"Error message from the provider\",\n \"type\": \"provider_error\"\n}","language":"json","status":400,"name":""},{"status":400,"language":"json","code":"{\n \"type\": \"invalid_request_error\", \n \"message\": \"The time range specified is too large. Must be less than 90 days.\"\n}"}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /calendars/availability HTTP/1.1\nHost: https://api.nylas.com\nContent-Type: application/json\nAuthorization: Basic myAccessToken==\n\n{\n \"duration_minutes\": 30,\n \"start_time\": 1601038800,\n \"end_time\": 1601082000,\n \"interval_minutes\": 10,\n \"emails\": [\n \"tom@brightideas.com\",\n \"jane@brightideas.com\"\n ],\n \"free_busy\": [\n {\n \"email\": \"marie@radioactivity.com\",\n \"object\": \"free_busy\",\n \"time_slots\": [\n {\n \"start_time\": 1601042400,\n \"end_time\": 1601044200,\n \"object\": \"time_slot\",\n \"status\": \"busy\"\n }\n ]\n },\n {\n \"email\": \"lamarr@player.com\",\n \"object\": \"free_busy\",\n \"time_slots\": [\n {\n \"start_time\": 1601042400,\n \"end_time\": 1601044200,\n \"object\": \"time_slot\",\n \"status\": \"busy\"\n }\n ]\n }\n ]\n}\n"},{"name":"cURL","language":"curl","code":"curl --location --request POST 'https://api.nylas.com/calendars/availability' \\\n--header 'Authorization: Bearer BEARER_AUTH' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n \"duration_minutes\": 30,\n \"start_time\": 1601038800,\n \"end_time\": 1601082000,\n \"interval_minutes\": 10,\n \"emails\": [\n \"tom@brightideas.com\",\n \"jane@brightideas.com\"\n ],\n \"free_busy\": [\n {\n \"email\": \"marie@radioactivity.com\",\n \"object\": \"free_busy\",\n \"time_slots\": [\n {\n \"start_time\": 1601042400,\n \"end_time\": 1601044200,\n \"object\": \"time_slot\",\n \"status\": \"busy\"\n }\n ]\n },\n {\n \"email\": \"lamarr@player.com\",\n \"object\": \"free_busy\",\n \"time_slots\": [\n {\n \"start_time\": 1601042400,\n \"end_time\": 1601044200,\n \"object\": \"time_slot\",\n \"status\": \"busy\"\n }\n ]\n }\n ]\n}\n'"},{"code":"from nylas import APIClient\nimport datetime\nimport timedelta\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\nemails = [\"tom@brightideas.com\", \"charlie@turing-complete.com\"]\n# Set duration and interval with int representing the number of minutes\nduration = 15\ninterval = 5\nstart_time = datetime.now()\nend_time = start_time + timedelta(hours=2)\n\navailability = nylas.availability(emails, duration, interval, start_time, end_time)\n\n# Optionally, you can also pass a free busy object\nfree_busy = nylas.free_busy(\"skwolek@fibers.com\", start_time, end_time)\navailability = nylas.availability(emails, duration, interval, start_time, end_endtime, free_busy)\n\n","language":"python","name":"Python SDK"}]},"params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"start_time","type":"int","default":"","desc":"Unix timestamp for the beginning of the freebusy window.","required":true,"in":"body","ref":"","_id":"5dcc94eb683bb3005c4801fe"},{"name":"end_time","type":"int","default":"","desc":"Unix timestamp for the end of the freebusy window.","required":true,"in":"body","ref":"","_id":"5dcc94eb683bb3005c4801fd"},{"name":"emails","type":"array_string","default":"","desc":"A list of email addresses in the same domain to compute availability for.","required":true,"in":"body","ref":"","_id":"5dcc94eb683bb3005c4801fc"},{"name":"free_busy","type":"array_object","default":"","desc":"A dictionary of free/busy data for users not in your organization whose availability cannot be automatically queried. Required even as an empty array.","required":true,"in":"body","ref":"","_id":"5ebf2f579ba04e005d5416b3"},{"name":"duration_minutes","type":"int","default":"","desc":"An integer representing the total number of minutes the event should last.","required":true,"in":"body","ref":"","_id":"5f2c6a716f961301b5748ff3"},{"name":"interval_minutes","type":"int","default":"","desc":"An integer representing how many minutes it should check for availability. For example, if you need to schedule a 30 minute meeting (duration_minutes) and want to check for availability every 10 minutes (interval_minutes).","required":true,"in":"body","ref":"","_id":"5f2c6a716f961301b5748ff2"}]},"next":{"description":"","pages":[]},"title":"/calendars/availability","updates":[],"type":"endpoint","slug":"calendaravailability","excerpt":"Query free / busy information for a calendar during a certain time period.","body":"[block:api-header]\n{\n \"title\": \"Free/Busy Parameters\"\n}\n[/block]\nThe Nylas Availability API is designed to arrange a variety of use cases. For example, it supports both internal meetings as well as meetings between several internal and external people. It does this through Free/Busy parameters.\n\nFor every participant to a meeting, you will need to add one or more free/busy parameters, depending on their needs.\n\nNote that this API supports automatic free/busy lookups – that means that if a participants belongs to the same organization as the authenticated user, then you will be able to ask Nylas to fill in their availability automatically.\n\nOptionally, you can also pass your own free/busy availability if the participant isn't a member of the same organization as the authenticated user. \n\n\n[block:api-header]\n{\n \"title\": \"Automatic lookup\"\n}\n[/block]\nIn the simplest case – if you're trying to arrange a meeting between people belonging to the same organization, you can just pass the participants email address and the API will look up their free/busy information.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"\\\"emails\\\": [\\\"kelly@nylas.com\\\", \\\"cameron@nylas.com\\\"]\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"title\": \"Specifying availability for a participant directly\"\n}\n[/block]\nTo do this you can supply a list of timeslots where the participant is busy – the algorithm will take care of computing when they're available. These timeslots are of the same form as the timeslot responses from our [Free/Busy endpoint](ref:calendars-free-busy) \n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\\"free_busy\\\": \\n\\t[{\\n \\t\\t\\\"email\\\": \\\"visitor@contoso.com\\\",\\n \\t\\t\\t\\\"time_slots\\\": [{\\\"start_time\\\": 1584377898,\\n \\t\\t\\t\\\"end_time\\\": 1584379800,\\n \\t\\t\\t\\\"object': \\\"time_slot\\\",\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\\"status\\\": \\\"busy\\\"}]}]\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]","order":9,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"pendingAlgoliaPublish":false,"createdAt":"2020-05-15T23:44:02.270Z","updatedAt":"2020-06-24T22:26:45.314Z","user":"5f2067586dda9a0045009159","category":"5e41e73d960b09003ca35975","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","__v":26,"parentDoc":null,"previousSlug":"","slugUpdatedAt":"2020-07-14T18:30:06.997Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/calendars/availability"}},{"_id":"5e41e73d960b09003ca359cb","sync_unique":"","user":"59245bff200df13100c88562","githubsync":"","link_url":"","hidden":false,"next":{"pages":[],"description":""},"order":0,"slug":"events","__v":0,"excerpt":"","updates":[],"api":{"params":[],"url":"","method":"get","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required"},"category":"5e41e73d960b09003ca35976","isReference":true,"link_external":false,"parentDoc":null,"project":"59245c10200df13100c88563","title":"Introduction","type":"basic","body":"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.\n\n## Events supports [Filtering](ref:filters) and [Pagination](ref:pagination)\n\nThe events endpoint supports filters, which allow you to fetch multiple events matching specific criteria, as well as pagination. See the [Events](ref:get-events) endpoint query parameters, for specific query parameters you can use to filter Events.\n\n## Event subobjects\n\nThere are various subobjects within the Event object itself. To learn more about each of these subobjects see [Event Subobjects](ref:event-subobjects)\n\n## Recurring events\n\nNylas supports creating, updating, and deleting recurring events for both Google and Microsoft calendars. \n\nA recurring event is an event that occurs more than once according to a predefined rule, like weekly meetings and daily stand ups.\n\nRecurring events contain a sub-object called `recurrence` that has recurrence info in RRULE form; [this tool](http://jakubroztocil.github.io/rrule/) is helpful in understanding the RRULE spec. See [RFC-5545](https://tools.ietf.org/html/rfc5545#section-3.8.5).\n\nNylas uses a single \"master event\" to represent a recurring event series that includes the RRULE information within the `recurrence` object. You can use the `expand_recurring` URL parameter to expand events server-side, so your application doesn't need to worry about handling RRULEs. **Note:** When using this query parameter, you must also use filters to specify a time range.\n\nNylas also supports event overrides and exdates. An override is any modification to an expanded event from a recurring event series. If you modify an expanded event it will create a persistent version of this event called an **override** that is separate from the recurring event series, but still related to the master event. Similarly, an **exdate** is a list of timestamps that indicate which dates have been excluded, or deleted from a series. These are represented within the `rrule` array.\n\nYou can create overrides and exdates by modifying or deleting inflated events from a series or by updating the `recurrence` object manually.\n\nPlease see the [recurrence section](ref:event-subobjects#section-recurrence) below for more specific information about supported RRULEs and modification types.","createdAt":"2017-05-24T23:33:14.005Z","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-12-18T00:19:47.051Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359cc","next":{"pages":[],"description":""},"api":{"auth":"required","examples":{"codes":[{"code":"GET /events HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Bearer ACCESS_TOKEN\ncache-control: no-cache","language":"http","name":"HTTP"},{"code":"\n# Return all events found for the user's account. Limited to 100 results\ncurl -X GET \\\n https://api.nylas.com/events \\\n -H 'Authorization: Bearer ACCESS_TOKEN' \\\n\n# Return events that are filtered by specified arguments\ncurl -X GET \\\n 'https://api.nylas.com/events?title=Birthday%20Party%21' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' \n# Available filters: show_cancelled, event_id, description, title, location,\n# busy, starts_before, starts_after, ends_before, ends_after\n\n# Use offset, and limit to paginate the results\ncurl -X GET \\\n 'https://api.nylas.com/events?limit=10&offset=5' \\\n -H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Expand recurring events into multiple event objects.\ncurl -X GET \\\n 'https://api.nylas.com/events?expand_recurring=true' \\\n -H 'Authorization: Bearer ACCESS_TOKEN'\n\n# Use special views like ids and count\ncurl -X GET \\\n 'https://api.nylas.com/events/?view=ids' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' \n\ncurl -X GET \\\n 'https://api.nylas.com/events/?view=count' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' ","language":"curl","name":"cURL"},{"code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all events found for the user's account\nnylas.events.all()\n\n# Return events that are filtered by specified arguments\nnylas.events.where(title='Birthday Party!')\n# Available filters: show_cancelled, event_id, description, title, location,\n# busy, starts_before, starts_after, ends_before, ends_after\n\n# Use offset, and limit to paginate the results\nnylas.events.where(limit=10, offset=5)\n\n# Expand recurring events into multiple event objects.\nnylas.events.where(expand_recurring=True)\n\n# Return the first event\nevent = nylas.events.first()\n\n# The following attributes are available for the event object\nevent.title\nevent.description\nevent.read_only\nevent.id\nevent.when\nevent.status\nevent.busy\nevent.object\nevent.message_id\nevent.participants\nevent.location\nevent.owner\nevent.calendar_id\nevent.account_id","language":"python","name":"Python SDK"},{"code":"# Counting the events\napi.events.count\n\n# Retrieving a few events\napi.events.limit(2).map(&:to_h)\n\n# Expand recurring events into independent event objects\napi.events.expand_recurring.map(&:to_h)\n\n# Include cancelled events\napi.events.show_cancelled.map(&:to_h)","language":"ruby","name":"Ruby SDK"},{"code":"// Return all events found for the user's account\nnylas.events.list().then(events => console.log(events));\n\n// Return events that are filtered by specified arguments\nnylas.events.list({title: 'Birthday Party!'}).then(events => console.log(events));\n// Available filters: show_cancelled, event_id, calendar_id, description, title, \n// location, starts_before, starts_after, ends_before, ends_after\n\n// Use offset, and limit to paginate the results\nnylas.events.list({limit: 10, offset: 5}).then(events => console.log(events));\n\n// Expand recurring events into multiple event objects.\nnylas.events.list({expand_recurring: true}).then(events => console.log(events));\n\n// Return the first event\nnylas.events.first().then(event => console.log(event));\n\n// The following attributes are available for the event object\nevent.id\nevent.object\nevent.accountId\nevent.calendarId\nevent.messageId\nevent.title\nevent.description\nevent.owner\nevent.participants\nevent.readOnly\nevent.location\nevent.when\nevent.start\nevent.end\nevent.busy\nevent.status\nevent.iCalUID","language":"javascript","name":"Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Event;\nimport com.nylas.EventQuery;\nimport com.nylas.Events;\n\npublic class NylasExamples {\n public static void getEventsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Events events = account.events();\n \n // Return all events found in the user's inbox \n events.list();\n \n // Return events that are filtered by specified arguments\n events.list(new EventQuery().title(\"Birthday Party\"));\n // Available Filters: description, endsAfter, endsBefore, \n // eventId, location, startsAfter, startsBefore, title\n \n // Use offset, and limit to control pagination\n events.list(new EventQuery().limit(10).offset(10));\n \n // Return the first event from a calendar\n Event event = events.list(new EventQuery().limit(1)).get(0);\n \n // The following attributes are available for the event object\n event.getId();\n event.getBusy();\n event.getCalendarId();\n event.getDescription();\n event.getLocation();\n event.getMasterEventId();\n event.getOriginalStartTime();\n event.getOwner();\n event.getParticipants();\n event.getReadOnly();\n event.getRecurrence();\n event.getStatus();\n event.getTitle();\n }\n}"}]},"method":"get","params":[{"name":"expand_recurring","type":"boolean","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"59271492a40a201b00ea9dc1"},{"name":"show_cancelled","type":"boolean","default":"","desc":"Return events matching the specified cancellation. If the cancellation is `true`, the results will include cancelled events. This is set to `false` by default.","required":false,"in":"query","ref":"","_id":"59271492a40a201b00ea9dc0"},{"name":"limit","type":"int","default":"","desc":"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](ref:pagination) for additional info.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d74"},{"name":"offset","type":"int","default":"","desc":"Return events matching the specified offset. This is zero-based offset from default object sorting. See [Pagination](ref:pagination) for additional info.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d73"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"event_id","type":"string","default":"","desc":"Return the event matching the specified event ID.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d72"},{"name":"calendar_id","type":"string","default":"","desc":"Return events belonging to the specified calendar ID.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d71"},{"name":"title","type":"string","default":"","desc":"Return events matching the specified title.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d70"},{"name":"description","type":"string","default":"","desc":"Return events matching the specified description.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d6f"},{"name":"location","type":"string","default":"","desc":"Return events matching the specified location.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d6e"},{"name":"starts_before","type":"int","default":"","desc":"Return events starting before the specified unix timestamp.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d6d"},{"name":"starts_after","type":"int","default":"","desc":"Return events starting after the specified unix timestamp.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d6c"},{"name":"ends_before","type":"int","default":"","desc":"Return events ending before the specified unix timestamp.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d6b"},{"name":"ends_after","type":"int","default":"","desc":"Return events ending after the specified unix timestamp.","required":false,"in":"query","ref":"","_id":"592719376c729e0f00596d6a"}],"results":{"codes":[{"code":"[\n {\n \"account_id\": \"iy7wkz66wrbeccc6nisy\",\n \"busy\": true,\n \"calendar_id\": \"412pwfsq3k7uklj1zkq5\",\n \"description\": \"This is a super important meeting\",\n \t\"ical_uid\": \"u284408b07jkh6n1j6k8qt9sa8@google.com\",\n \"id\": \"c7n5vl6dhbdeqwjaxk29\",\n \"location\": null,\n \"message_id\": null,\n \"object\": \"event\",\n \"owner\": \"My Nylas Friend <swag@nylas.com>\",\n \"participants\": [\n {\n \"comment\": null,\n \"email\": \"you@your_company.com\",\n \"name\": null,\n \"status\": \"yes\"\n },\n {\n \"comment\": null,\n \"email\": \"someone@example.com\",\n \"name\": null,\n \"status\": \"maybe\"\n }\n ],\n \"read_only\": true,\n \"status\": \"confirmed\",\n \"title\": \"Meet with Nylas\",\n \"when\": {\n \"end_time\": 1478568600,\n \"object\": \"timespan\",\n \"start_time\": 1478565000\n }\n }\n]","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"url":"/events","apiSetting":"5e41e73d960b09003ca3598d"},"isReference":true,"sync_unique":"","title":"/events","updates":[],"user":"5d404909c2f77c0012211f3e","__v":46,"body":"[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"Events are always sorted by their start date.\",\n \"title\": \"Note about event sorting\"\n}\n[/block]\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|--|:----|\n| `id` | string | A globally unique object identifier.\n| `object` | string | A string describing the type of object (value is `\"event\"`).\n| `account_id` | string | A reference to the parent account object.\n| `calendar_id` | string | A reference to the parent calendar object.\n| `title` | string | The title of the event, usually short (maximum string length of 1024 characters).\n| `description` | string | The description of the event, which may contain more details or an agenda (maximum string length of 8192 characters).\n| `ical_uid` | string | 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. Can be `null`. |\n| `when` | subobject | One of four sub-objects corresponding to the time and duration of an event: `time`, `timespan`, `date`, or `datespan`. See below for more details.\n| `location` | string | A location, such as a physical address or meeting room name.\n| `owner` | string | The owner of the event, usually specified with their email or name and email.\n| `participants` | array | An array of other participants invited to the event. Keys are `email`, `name`, `status`. Participants may also be rooms or resources. See below for more details.\n| `status` | string | One of the following values: `confirmed`, `tentative`, or `cancelled`.\n| `read_only` | boolean | Indicates whether the event can be modified.\n| `busy` | boolean | On shared or public calendars, indicates whether to show this event's time block as available. (Also called *transparency* in some systems.)\n| `recurrence` | subobject | Included if the event is a master recurring event. See below for the subobject definition.\n| `master_event_id` | string | Only included in exceptions (overrides) to recurring events, the ID of the recurring event.\n| `original_start_time` | unix timestamp | Only included in exceptions (overrides) to recurring events, the start time of the recurring event.","category":"5e41e73d960b09003ca35976","excerpt":"Searches for events using the specified filter criteria.","hidden":false,"type":"endpoint","version":"5e41e73d960b09003ca35a9b","createdAt":"2017-05-25T17:25:50.757Z","githubsync":"","link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"59245c10200df13100c88563","slug":"get-events","updatedAt":"2020-02-11T00:18:27.990Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:47.753Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/events"}},{"_id":"5e41e73d960b09003ca359ce","body":"","githubsync":"","isReference":true,"sync_unique":"","user":"5d404909c2f77c0012211f3e","__v":25,"excerpt":"Searches for an event identified by the specified event ID.","project":"59245c10200df13100c88563","title":"/events/{id}","updates":[],"api":{"auth":"required","examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /events/4zv7p**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Bearer ACCESS_TOKEN\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"# Return an event by specifying its id\ncurl -X GET \\\n 'https://api.nylas.com/events/{id}' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' "},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return an event by specifying its id\nevent = nylas.events.get('{id}')\n\n# The following attributes are available for the event object\nevent.title\nevent.description\nevent.read_only\nevent.id\nevent.when\nevent.status\nevent.busy\nevent.object\nevent.message_id\nevent.participants\nevent.location\nevent.owner\nevent.calendar_id\nevent.account_id"},{"name":"Ruby SDK","language":"ruby","code":"# Retrieving a particular event\nexample_event = api.events.last\napi.events.find(example_event.id).to_h"},{"name":"Node.js SDK","language":"javascript","code":"// Return an event by specifying its id\nlet event;\nnylas.events.find('{id}').then(resp => event = resp);\n\n// The following attributes are available for the event object\nevent.id\nevent.object\nevent.accountId\nevent.calendarId\nevent.messageId\nevent.title\nevent.description\nevent.owner\nevent.participants\nevent.readOnly\nevent.location\nevent.when\nevent.start\nevent.end\nevent.busy\nevent.status\nevent.iCalUID"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Event;\nimport com.nylas.Events;\n\npublic class NylasExamples {\n public static void getEventExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Events events = account.events();\n \n // Return an event by specifying the ID\n Event event = events.get(\"{eventId}\");\n \n // The following attributes are available for the event object\n event.getId();\n event.getBusy();\n event.getCalendarId();\n event.getDescription();\n event.getLocation();\n event.getMasterEventId();\n event.getOriginalStartTime();\n event.getOwner();\n event.getParticipants();\n event.getReadOnly();\n event.getRecurrence();\n event.getStatus();\n event.getTitle();\n }\n}"}]},"method":"get","params":[{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the event for which to search.","required":false,"in":"path","ref":"","_id":"592719686c729e0f00596d78"}],"results":{"codes":[{"code":"{\n \"object\": \"event\",\n \"id\": \"4ee4xbnx7pxdb9g7c2f8ncyto\",\n \"calendar_id\": \"ci0k1wfyv533ccgox4t7uri4h\",\n \"account_id\": \"14e5bn96uizyuhidhcw5rfrb0\",\n \"description\": null,\n \"ical_uid\": \"u284408b07jkh6n1j6k8qt9sa8@google.com\",\n \"location\": null,\n \"owner\": \"Ben Bitdiddle <example@gmail.com>\",\n \"participants\": [\n {\n \"email\": \"example@gmail.com\",\n \"name\": \"Ben Bitdiddle\",\n \"status\": \"yes\"\n }\n ],\n \"read_only\": false,\n \"title\": \"Meeting with Ben Bitdiddle\",\n \"when\": {\n \"object\": \"timespan\",\n \"end_time\": 1408123800,\n \"start_time\": 1408120200\n },\n \"busy\": true,\n \"status\": \"confirmed\"\n}","language":"json","status":200,"name":""},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"url":"/events/{id}","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-25T17:50:32.110Z","hidden":false,"next":{"pages":[],"description":""},"order":2,"parentDoc":null,"type":"endpoint","version":"5e41e73d960b09003ca35a9b","link_external":false,"link_url":"","slug":"get-event","category":"5e41e73d960b09003ca35976","updatedAt":"2019-12-09T17:45:25.325Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T22:08:28.644Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/events/{id}"}},{"_id":"5e41e73d960b09003ca359cf","category":"5e41e73d960b09003ca35976","hidden":false,"isReference":true,"next":{"pages":[],"description":""},"user":"5d404909c2f77c0012211f3e","__v":60,"api":{"method":"post","params":[{"name":"notify_participants","type":"boolean","default":"","desc":"If set to true, email notifications containing the calendar event will be sent to all event participants.","required":false,"in":"query","ref":"","_id":"59271c6cc4ee340f0012868d"},{"name":"calendar_id","type":"string","default":"","desc":"Creates an event in the specified calendar ID. See [Calendar](ref:calendars) for more info.","required":true,"in":"body","ref":"","_id":"59271c6cc4ee340f0012868c"},{"name":"when","type":"json","default":"","desc":"Creates an event with the specified time and duration. The values can be one of four subobjects corresponding to the time and duration of an event. Reference [Time, Timespan, Date, or Datespan](ref:event-subobjects) for additional information.","required":true,"in":"body","ref":"","_id":"59271c6cc4ee340f0012868b"},{"name":"title","type":"string","default":"","desc":"Creates an event with the specified title. This value is usually short.","required":false,"in":"body","ref":"","_id":"59271c6cc4ee340f0012868a"},{"name":"description","type":"string","default":"","desc":"Creates an event with the specified description. This value may contain more details about an event or an agenda.","required":false,"in":"body","ref":"","_id":"59271d9fa40a201b00ea9fce"},{"name":"location","type":"string","default":"","desc":"Creates an event with the specified location. For example a physical address or meeting room name.","required":false,"in":"body","ref":"","_id":"59271c6cc4ee340f00128689"},{"name":"participants","type":"array_object","default":"","desc":"Creates an event with the specified participants. The value is an array of [Participant](ref:event-subobjects) sub-objects.","required":false,"in":"body","ref":"Participant","_id":"59271c6cc4ee340f00128688"},{"name":"busy","type":"boolean","default":"","desc":"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.","required":false,"in":"body","ref":"","_id":"59271d9fa40a201b00ea9fcd"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"recurrence","type":"json","default":"","desc":"Creates an event with the specified recurrence. See the [Recurrence](ref:event-subobjects) subobject for additional information.","required":false,"in":"body","ref":"","_id":"5ab2d9077559ce00123a5b2d"}],"results":{"codes":[{"name":"","code":"{\n \"account_id\": \"ecx8e0yqpss57bd9ou2o21o7o\",\n \"busy\": true,\n \"calendar_id\": \"63hm8edcyaz8xot643sm1i8il\",\n \"description\": null,\n \"ical_uid\": \"u2844b07jkh6n1j086k8qt9sa8@google.com\",\n \"id\": \"16cef4u77ce8it1r10d3efyky\",\n \"location\": \"Coffee Shop\",\n \"message_id\": null,\n \"object\": \"event\",\n \"owner\": \"Mike Pfister <inboxapptest415@gmail.com>\",\n \"participants\": [\n {\n \"comment\": null,\n \"email\": \"nylatest2@nylatest.onmicrosoft.com\",\n \"name\": \"Sarah Nylanaut\",\n \"status\": \"noreply\"\n }\n ],\n \"read_only\": false,\n \"status\": \"confirmed\",\n \"title\": \"Example Event\",\n \"when\": {\n \"end_time\": 1581382005,\n \"object\": \"timespan\",\n \"start_time\": 1581380205\n }\n}","language":"json","status":200},{"code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"url":"/events","auth":"required","examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /events HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Bearer ACCESS_TOKEN\ncache-control: no-cache\n{\n \"title\":\"Example Event\",\n \"when\" : {\n \"start_time\": {{timestamp}},\n \"end_time\": {{timestamp2}}\n },\n \"calendar_id\": {{calendar_id}}\n}"},{"name":"cURL","language":"curl","code":"\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 }'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n#Create a new event\nevent = nylas.events.create()\n\n# .save()must be called to save the event to the third party provider\n# The event object must have values assigned to calendar_id and when before you can save it.\nevent.save(notify_participants='true')\n# notify_participants='true' will send a notification email to\n# all email addresses specified in the participant subobject\n\n\nevent.title = \"Party!\"\nevent.location = \"My House!\"\nevent.description = \"Let's celebrate our calendar integration!!\"\nevent.busy = True\n\n# Provide the appropriate id for a calendar to add the event to a specific calendar\nevent.calendar_id='{id}'\n\n# Participants are added as a list of dictionary objects\n# email is required, name is optional\nevent.participants = [{\"name\": \"My Nylas Friend\", 'email': 'swag@nylas.com'}]\n\n# The event date/time can be set in one of 3 ways.\n# For details: https://docs.nylas.com/reference#event-subobjects\nevent.when = {\"start_time\": 1577829600, \"end_time\": 1577840400}\nevent.when = {\"time\": 1577829600}\nevent.when = {\"date\": \"2020-01-01\"}\nevent.when = {\"start_date\": \"2019-08-29\", \"end_date\": \"2019-09-01\"}"},{"name":"Ruby SDK","language":"ruby","code":"# Creating an event\nexample_event = api.events.last\napi.events.create(title: \"A fun event!\", location: \"The Party Zone\", calendar_id: calendar.id,\n when: { start_time: Time.now + 60, end_time: Time.now + 120 }).to_h"},{"name":"Node.js SDK","language":"javascript","code":"//Create a new event\nlet event = nylas.events.build();\n\n// .save()must be called to save the event to the third party provider\n// The event object must have values assigned to calendarId and when before you can save it.\nevent.save({notify_participants: true});\n// {notify_participants: true} will send a notification email to\n// all email addresses specified in the participant subobject\n\n\nevent.title = 'Party!';\nevent.location = 'My House!';\nevent.description = 'Let\\'s celebrate our calendar integration!!';\nevent.busy = true;\n\n// Provide the appropriate id for a calendar to add the event to a specific calendar\nevent.calendarId='{id}';\n\n// Participants are added as a list of dictionary objects\n// email is required, name is optional\nevent.participants = [{name: 'My Nylas Friend', email: 'swag@nylas.com'}];\n\n// The event date/time can be set in one of 4 ways.\n// For details: https://docs.nylas.com/reference#event-subobjects\nevent.when = {time: 1408875644};\nevent.when = {start_time: 1577829600, end_time: 1577840400};\nevent.when = {date: '2020-01-01'};\nevent.when = {start_date: '2019-08-29', end_date: '2019-09-01'};\n\n// You may also set the date/time with the NodeSDK's start and end attributes.\n// start and end can be assigned to either a number or string\n// if start = end, the when parameter will be either suboject type date or time\nevent.start = 1577829600;\nevent.end = 1577840400;\nor\nevent.start = '2019-08-29';\nevent.end = '2019-09-01';"},{"name":"cURL (Recurring Event)","language":"curl","code":"curl -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 }'"},{"name":"Java SDK","language":"java","code":"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}"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"body":"[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"Events are always sorted by their start date.\",\n \"title\": \"Note about event sorting\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"A note about notify_participants for Microsoft accounts\",\n \"body\": \"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`.\\n\\nSetting `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.\"\n}\n[/block]\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|----:|--|:----|\n| `id` | string | A globally unique object identifier.\n| `object` | string | A string describing the type of object (value is `\"event\"`).\n| `account_id` | string | A reference to the parent account object.\n| `calendar_id` | string | A reference to the parent calendar object.\n| `title` | string | The title of the event, usually short (maximum string length of 1024 characters).\n| `description` | string | The description of the event, which may contain more details or an agenda (maximum string length of 8192 characters).\n| `ical_uid` | string | 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. Can be `null`. |\n| `when` | subobject | One of four sub-objects corresponding to the time and duration of an event: `time`, `timespan`, `date`, or `datespan`. See below for more details.\n| `location` | string | A location, such as a physical address or meeting room name.\n| `owner` | string | The owner of the event, usually specified with their email or name and email.\n| `participants` | array | An array of other participants invited to the event. Keys are `email`, `name`, `status`. Participants may also be rooms or resources. See below for more details.\n| `status` | string | One of the following values: `confirmed`, `tentative`, or `cancelled`.\n| `read_only` | boolean | Indicates whether the event can be modified.\n| `busy` | boolean | On shared or public calendars, indicates whether to show this event's time block as available. (Also called *transparency* in some systems.)\n| `recurrence` | subobject | Included if the event is a master recurring event. See below for the subobject definition.\n| `master_event_id` | string | Only included in exceptions (overrides) to recurring events, the ID of the recurring event.\n| `original_start_time` | unix timestamp | Only included in exceptions (overrides) to recurring events, the start time of the recurring event.","title":"/events","updates":["5eb59fea960701002fd34169"],"createdAt":"2017-05-25T18:03:24.284Z","link_url":"","slug":"post-event","link_external":false,"sync_unique":"","type":"endpoint","excerpt":"Creates a new event.","githubsync":"","version":"5e41e73d960b09003ca35a9b","order":3,"parentDoc":null,"project":"59245c10200df13100c88563","updatedAt":"2020-05-08T18:12:27.875Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:48.718Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/events"}},{"_id":"5e41e73d960b09003ca359d0","hidden":false,"isReference":true,"excerpt":"Updates an existing event identified by the specified event ID.","parentDoc":null,"project":"59245c10200df13100c88563","slug":"eventsid","type":"endpoint","githubsync":"","order":4,"link_url":"","user":"5d404909c2f77c0012211f3e","api":{"auth":"required","params":[{"name":"notify_participants","type":"boolean","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"59271c6cc4ee340f0012868d"},{"name":"when","type":"json","default":"","desc":"Updates the event with the specified time and date information. The value can be one of four subobjects corresponding to the time and duration of an event. See [Time, Timespan, Date, or Datespan](ref:event-subobjects) for additional information.","required":false,"in":"body","ref":"","_id":"59271c6cc4ee340f0012868b"},{"name":"title","type":"string","default":"","desc":"Updates the event with the specified title. This value is usually short.","required":false,"in":"body","ref":"","_id":"59271c6cc4ee340f0012868a"},{"name":"description","type":"string","default":"","desc":"Updates the event with the specified description. This value may contain more event details or an agenda.","required":false,"in":"body","ref":"","_id":"59271d9fa40a201b00ea9fce"},{"name":"location","type":"string","default":"","desc":"Updates the event with the specified location. For example, a physical address or meeting room name.","required":false,"in":"body","ref":"","_id":"59271c6cc4ee340f00128689"},{"name":"participants","type":"array_object","default":"","desc":"Updates the event with the specified participants. This value is an array of [Participant](ref:event-subobjects) sub-objects.","required":false,"in":"body","ref":"Participant","_id":"59271c6cc4ee340f00128688"},{"name":"busy","type":"boolean","default":"","desc":"Updates the 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.","required":false,"in":"body","ref":"","_id":"59271d9fa40a201b00ea9fcd"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the event to update.","required":false,"in":"path","ref":"","_id":"59271f5ca40a201b00ea9ffb"},{"name":"recurrence","type":"json","default":"","desc":"Updates the event with the specified recurrence. See the [Recurrence](ref:event-subobjects) subobject for additional information.","required":false,"in":"body","ref":"","_id":"5ab2db7a4eb086002602ae2a"}],"url":"/events/{id}","method":"put","results":{"codes":[{"name":"","code":"","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"PUT /events/51si**** HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Bearer ACCESS_TOKEN\nUser-Agent: PostmanRuntime/7.13.0\nAccept: */*\nCache-Control: no-cache\nHost: api.nylas.com\naccept-encoding: gzip, deflate\ncontent-length: 43\nConnection: keep-alive\ncache-control: no-cache\n\n{\n \"title\": \"My Renamed Event\"\n}"},{"name":"cURL","language":"curl","code":"\ncurl -X PUT 'https://api.nylas.com/events/{id}' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"title\":\"Birthday Party II\",\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\": \"aristotle'\\''s birthday bash!\",\n \"when\": { \"date\": \"2019-12-31\" }\n}'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# You can only modify events that are not ready only for the user\nevent = nylas.events.where(read_only=False).first()\n\n# .save()must be called to save the event to the third party provider\nevent.save(notify_participants='true')\n# notify_participants='true' will send a notification email to\n# all emails specified in the participant subobject\n\n\nevent.title = \"Party!\"\nevent.location = \"My House!\"\nevent.description = \"Let's celebrate our calendar integration!!\"\nevent.busy = True\n# Provide the appropriate id for a calendar to add the event to a specific calendar\nevent.calendar_id='{id}'\n\n# Participants are added as a list of dictionary objects\n# email is required, name is optional\nevent.participants = [{\"name\": \"My Nylas Friend\", 'email': 'swag@nylas.com'}]\n\n# The event dat/time can be set in one of 3 ways.\n# For details: https://docs.nylas.com/reference#event-subobjects\nevent.when = {\"start_time\": 1577829600, \"end_time\": 1577840400}\nevent.when = {\"time\": 1577829600}\nevent.when = {\"date\": \"2020-01-01\"}\nevent.when = {\"start_date\": \"2019-08-29\", \"end_date\": \"2019-09-01\"}"},{"name":"Ruby SDK","language":"ruby","code":"# Updating an event\nexample_event = api.events.last\nexample_event.update(location: \"Somewhere else!\")"},{"name":"Node.js SDK","language":"javascript","code":"// You can only modify events that are not ready only for the user\nevent = nylas.events.list({calendarId: 'non read only calendar id', limit: 1});\n\n// .save()must be called to save the event to the third party provider\nevent.save({notify_participants: true});\n// {notify_participants: true} will send a notification email to\n// all emails specified in the participant subobject\n\n\nevent.title = 'Party!';\nevent.location = 'My House!';\nevent.description = 'Let's celebrate our calendar integration!!';\nevent.busy = true;\n\n// Provide the appropriate id for a calendar to add the event to a specific calendar\nevent.calendarId='{id}';\n\n// Participants are added as a list of dictionary objects\n// email is required, name is optional\nevent.participants = [{name: 'My Nylas Friend', email: 'swag@nylas.com'}];\n\n// The event dat/time can be set in one of 3 ways.\n// For details: https://docs.nylas.com/reference#event-subobjects\nevent.when = {time: 1408875644};\nevent.when = {start_time: 1577829600, end_time: 1577840400};\nevent.when = {date: '2020-01-01'};\nevent.when = {start_date: '2019-08-29', end_date: '2019-09-01'};\n\n// You may also set the date/time with the NodeSDK's start and end attributes.\n// start and end can be assigned to either a number or string\n// if start = end, the when parameter will be either suboject type date or time\nevent.start = 1577829600;\nevent.end = 1577840400;\nor\nevent.start = '2019-08-29';\nevent.end = '2019-09-01';"},{"name":"Java SDK","language":"java","code":"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}\n"}]},"apiSetting":"5e41e73d960b09003ca3598d"},"body":"[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"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.\",\n \"title\": \"Note about read_only and recurring event updates\"\n}\n[/block]","createdAt":"2017-05-25T18:15:56.190Z","link_external":false,"next":{"pages":[],"description":""},"sync_unique":"","title":"/events/{id}","updates":["5ebeca47184849006ffa4099"],"__v":52,"category":"5e41e73d960b09003ca35976","version":"5e41e73d960b09003ca35a9b","updatedAt":"2019-12-09T17:45:25.326Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:07:45.803Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/events/{id}"}},{"_id":"5e41e73d960b09003ca359d1","__v":25,"isReference":true,"link_url":"","next":{"pages":[],"description":""},"parentDoc":null,"project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","excerpt":"Deletes an existing event identified by the specified event ID.","slug":"eventsid-1","body":"Events can also be deleted from the calendar. Pass the `notify_participants` URL parameter to notify those who have been invited that the event has been cancelled.","category":"5e41e73d960b09003ca35976","createdAt":"2017-05-25T18:17:34.799Z","githubsync":"","link_external":false,"sync_unique":"","updates":[],"api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"DELETE /events/51si**** HTTP/1.1\nHost: api.nylas.com\nAuthorization: Bearer ACCESS_TOKEN\nContent-Type: application/json\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"curl -X DELETE 'https://api.nylas.com/events/{id}' \\\n -H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Delete an Event and notify all participants via email\nnylas.events.delete('{id}', notify_participants='true')"},{"name":"Ruby SDK","language":"ruby","code":"# Deleting an event\nexample_event = api.events.last\nexample_event.destroy"},{"name":"Node.js SDK","language":"javascript","code":"// Delete an Event and notify all participants via email\nnylas.events.delete('{id}', {notify_participants: true});"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\n\npublic class NylasExamples {\n public static void deleteEventExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n \n // Delete an event by specifying its ID and notify participants\n account.events().delete(\"EVENT_ID\", true);\n }\n}"}]},"results":{"codes":[{"name":"","code":"","language":"json","status":200},{"name":"","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400}]},"auth":"required","params":[{"name":"notify_participants","type":"boolean","default":"","desc":"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.","required":false,"in":"query","ref":"","_id":"59271c6cc4ee340f0012868d"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"},{"name":"id","type":"string","default":"","desc":"The ID of the event to delete.","required":false,"in":"path","ref":"","_id":"59271f5ca40a201b00ea9ffb"}],"url":"/events/{id}","method":"delete","apiSetting":"5e41e73d960b09003ca3598d"},"hidden":false,"order":5,"title":"/events/{id}","type":"endpoint","user":"5d404909c2f77c0012211f3e","updatedAt":"2019-12-09T17:45:25.327Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T21:32:38.791Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/events/{id}"}},{"_id":"5e41e73d960b09003ca359cd","__v":2,"excerpt":"","githubsync":"","next":{"pages":[],"description":""},"project":"59245c10200df13100c88563","sync_unique":"","updates":["5da6282acc9987003881f918","5ee18c617ec29f01f51e51c2"],"createdAt":"2017-05-25T17:27:01.291Z","isReference":true,"slug":"event-subobjects","type":"basic","user":"5d404909c2f77c0012211f3e","version":"5e41e73d960b09003ca35a9b","hidden":false,"link_external":false,"parentDoc":null,"title":"Event Subobjects","api":{"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"name":"","status":400,"language":"json","code":"{}"}]},"auth":"required","params":[],"url":"","method":"get"},"body":"The [Event](ref:events) object has various subobjects that are detailed below.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"A note about the `object` attribute\",\n \"body\": \"For each of the following event sub-objects, you might notice an `object` attribute. This is an attribute that is only returned by the Nylas API, to easily indicate the type of subobject. You should not send this `object` attribute when submitting POST or PUT requests to the /event endpoint.\"\n}\n[/block]\n# Participants\n\nThe `participants` attribute is returned as an array of dictionaries, corresponding to participants. These include the keys:\n\n| Attribute | Type | Description |\n|----:|-|:----|\n| `name` | string | (*Optional*) The participant's full name.\n| `email` | string | The participant's email address.\n| `status` | string | The participant's attendance status. Allowed values are `yes`, `maybe`, `no` and `noreply`. The default value is `noreply`.\n| `comment` | string | (*Optional*) A comment by the participant.\n\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Be Careful When Setting Status on Event Creation\",\n \"body\": \"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.\\n\\nIn most cases, the default value of `noreply` is the best option.\"\n}\n[/block]\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"\\\"participants\\\": [\\n {\\n \\\"comment\\\": null,\\n \\\"email\\\": \\\"kelly@nylas.com\\\",\\n \\\"name\\\": \\\"Kelly Nylanaut\\\",\\n \\\"status\\\": \\\"noreply\\\"\\n },\\n {\\n \\\"comment\\\": null,\\n \\\"email\\\": \\\"sarah@nylas.com\\\",\\n \\\"name\\\": \\\"Sarah Nylanaut\\\",\\n \\\"status\\\": \\\"no\\\"\\n }\\n]\",\n \"language\": \"json\",\n \"name\": \"Example participants array\"\n }\n ]\n}\n[/block]\n# Time\n\nThe `time` subobject corresponds a single moment in time, which has no duration. Reminders or alarms are represented as `time` subobjects.\n\n| Attribute | Type | Description |\n|----:|-|:----|\n| `object` | string | A string describing the type of object (e.g. \"time\"). Do not submit this value in POST or PUT requests. This is a read-only attribute that Nylas API returns, to help you detect the type of event subobject.\n| `time` |unix timestamp | A UNIX timestamp (UTC).\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n\\\"object\\\": \\\"time\\\",\\n\\\"time\\\": 1408875644\\n}\",\n \"language\": \"json\",\n \"name\": \"Example: the 2014 San Francisco earthquake\"\n }\n ]\n}\n[/block]\n# Timespan\n\nA span of time with a specific beginning and end time. An hour lunch meeting would be represented as `timespan` subobjects.\n\n| Attribute | Type | Description |\n|----:|-|:----|\n| `object` | string | A string describing the type of object (e.g. \"timespan\"). Do not submit this value in POST or PUT requests. This is a read-only attribute that Nylas API returns, to help you detect the type of event subobject.\n| `start_time` | unix timestamp | The start time of the event.\n| `end_time` | unix timestamp | The end time of the event.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"object\\\": \\\"timespan\\\",\\n \\\"start_time\\\": 1409594400,\\n \\\"end_time\\\": 1409598000\\n}\",\n \"language\": \"json\",\n \"name\": \"Example: a morning meeting\"\n }\n ]\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Object Key Not Required When Posting an Event\",\n \"body\": \"The above object is an example of a returned response for a `timespan` subobject. You do not need to specify the object when submitting a POST or PUT request for timespan or datespan. Simply include the `start_time` and `end_time` when sending the request:\\n\\n```\\n{\\n \\\"start_time\\\": 1409594400,\\n \\\"end_time\\\": 1409598000\\n}\\n```\"\n}\n[/block]\n# Date\n\nA specific date for an event, without a clock-based start or end time. Your birthday and holidays would be represented as `date` subobjects.\n\n| Attribute | Type | Description |\n|----:|-|:----|\n| `object`| string | A string describing the type of object (e.g \"date\"). Do not submit this value in POST or PUT requests. This is a read-only attribute that Nylas API returns, to help you detect the type of event subobject.\n| `date`| date | Date of occurance in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates).\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"object\\\": \\\"date\\\",\\n \\\"date\\\": \\\"1912-06-23\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example: the birthdate of Alan Turing\"\n }\n ]\n}\n[/block]\n# Datespan\n\nA span of entire days without specific times. A business quarter or academic semester would be represented as `datespan` subobjects.\n\n| Attribute | Type | Description |\n|----:|-|:----|\n| `object` | string | A string describing the type of object (value is \"datespan\"). Do not submit this value in POST or PUT requests. This is a read-only attribute that Nylas API returns to help you detect the type of event subobject.\n| `start_date` |date | The start date in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates).\n| `end_date` |date | The end date in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates).\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"object\\\": \\\"datespan\\\",\\n \\\"start_date\\\": \\\"1815-12-10\\\",\\n \\\"end_date\\\": \\\"1852-11-27\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"Example: the lifespan of Ada Lovelace\"\n }\n ]\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Object Key Not Required When Posting an Event\",\n \"body\": \"The above object is an example of a returned response for a `datespan` subject. You do not need to specify the object when submitting a POST or PUT request for timespan or datespan. Simply include the `start_date` and `end_date` when sending the request:\\n\\n```\\n{\\n \\\"start_date\\\": \\\"1815-12-10\\\",\\n \\\"end_date\\\": \\\"1852-11-27\\\"\\n}\\n```\"\n}\n[/block]\n\n# Recurrence\n\n| Attribute | Type | Description |\n|----:|-|:----|\n| `timezone` | string | [IANA time zone database](https://en.wikipedia.org/wiki/Tz_database) formatted string (e.g. America/New_York).\n| `rrule` | array | 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. [This tool](http://jakubroztocil.github.io/rrule/) is helpful in understanding the RRULE spec.\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"\\\"recurrence\\\": {\\n \\\"rrule\\\": [\\n \\\"RRULE:FREQ=WEEKLY;BYDAY=MO\\\"\\n ],\\n \\\"timezone\\\": \\\"America/New_York\\\"\\n},\",\n \"language\": \"json\",\n \"name\": \"Example: an event that repeats weekly\"\n }\n ]\n}\n[/block]\n**Important Notes**\n\nPlease note that updating or deleting a recurring event will impact ALL instances of the event. Any individual modifications (overrides), such as a one-off time change, will be updated or deleted as well.\n\nIf the recurring event has overrides, these will be returned as separate, individual events, regardless if `expand_recurring` is `true`.\n\nIf `expand_recurring` is not set, any one-off cancellations will be returned in addition to the base event, for apps that are expanding the recurrence client-side. A cancellation has the field `cancelled` set to `true`.\n\nIf requesting events without the `expand_recurring` parameter, the events endpoint will only return the 'master' recurring event (only if it falls within the requested time range). \n\nIf `BYDAY` isn't included in the RRULE string for weekly events, for example `FREQ=WEEKLY`, Nylas will fallback to information based on the event's date or time values.\n\n\n**Provider Differences**\n\nThere are a few important differences between how recurring events work between providers. Please see the table below:\n\n| Description | Google Behavior | Microsoft Behavior |\n|:----|:----|:----|\n| Modifying the recurrence of a series, like changing an event from weekly to daily | Overrides will remain unchanged if they are still part of the recurrence | Overrides will be removed |\n| Changes to busy status on the master event for a series | Busy status updates for all events in the series, including overrides| Busy status will not update for overrides that were created through Nylas, but they will update for overrides created through Microsoft's native calendar interface. |\n| Deleting a single occurence from a series within the provider's native calendar UI | This delete will appear as an override event and its status will be set to `cancelled` via the Nylas API | This delete will appear as an exdate via the Nylas API |\n| Creating a recurring event in the provider's UI with an \"end date\" for the recurrence. | The end date will show up as midnight after the last occurrence in the account's local timezone, minus a second via the Nylas API. | The end date will show up as the start time of the last occurence in the series via the Nylas API. |\n\nThere are a few limitations for Microsoft accounts as well: \n\n- If an exdate is created for a recurring event, you won't be able to recover or revert the removed occurence. You can either create a new, separate event to represent a recovered exdate or use other event properties like `status` that can be changed at any time instead of using exdates, if you need to the ability to change them later.\n\nThe following RRULEs are not supported for Microsoft accounts at this time:\n\n- `RRULE:FREQ=MONTHLY;BYDAY=1TH,3TH` (A Monthly recurrence with multiple days. You can't include different indices with Microsoft accounts. The index property is on the monthly recurrence object, not on each day-of-week object)","category":"5e41e73d960b09003ca35976","link_url":"","order":6,"updatedAt":"2020-06-11T14:59:39.512Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca359d2","link_external":false,"link_url":"","sync_unique":"","user":"5d404909c2f77c0012211f3e","__v":24,"body":"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.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"RSVP Errors\",\n \"body\": \"Behind the scenes, RSVPs work by sending an email back to the event organizer in [iMIP format](https://tools.ietf.org/html/rfc6047). Therefore, errors when RSVPing to events follow the same status codes as [sending errors](ref:section-sending-errors).\"\n}\n[/block]","excerpt":"The RSVP endpoint allows you to send attendance status updates to event organizers. Note this is only possible for events that appears on the “Emailed events”, which are calendar invitations.","githubsync":"","isReference":true,"next":{"description":"","pages":[]},"type":"endpoint","updates":[],"api":{"method":"post","results":{"codes":[{"status":200,"name":"","code":"","language":"json"},{"code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","language":"json","status":400,"name":""}]},"examples":{"codes":[{"name":"HTTP","language":"http","code":"POST /send-rsvp HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Bearer ACCESS_TOKEN\ncache-control: no-cache\n{\n \"event_id\": \"7a893****\",\n \"status\": \"yes\",\n \"account_id\": \"3k24****\"\n}"},{"name":"cURL","language":"curl","code":"curl -X POST 'https://api.nylas.com/send-rsvp/' \\\n -H 'Authorization: Bearer ACCESS_TOKEN' \\\n-d '{\n \"event_id\": \"{event_id}\",\n \"status\": \"yes\",\n \"comment\": \"Excited to come!\",\n \"account_id\": \"{account_id}\"\n}'"},{"name":"Python SDK","language":"python","code":"# RSVP to an invite. Note that you can only RSVP to invites found in the\n# \"Emailed events\" calendar.\nevent = nylas.events.get(\"{id}\")\n# .rsvp() accepts a status and an optional message.\n# The message will be sent via email to all participants\nevent.rsvp(\"maybe\", \"I will try to make it\")\n# rsvp status must be one of yes, no, or maybe"},{"name":"Ruby SDK","language":"ruby","code":"# RSVPing to an Event\ncalendar = api.calendars.select { |c| c.name == \"Emailed events\" }.first\nevent = calendar.events.first\nevent.rsvp(:yes, notify_participants: true)\nevent.rsvp(:no, notify_participants: true)\nevent.rsvp(:maybe, notify_participants: true)"},{"name":"Node.js SDK","language":"javascript","code":"// RSVP to an invite. Note that you can only RSVP to invites found in the\n// \"Emailed events\" calendar.\nnylas.events\n .find(\"{id}\")\n // .rsvp() accepts a status and an optional message.\n // The message will be sent via email to all participants\n .then(event => event.rsvp('maybe', 'I may attend this event'))\n // Possible rsvp statuses include yes, no, and maybe\n .then(event => console.log('RSVP sent!'));"},{"name":"Java SDK","language":"java","code":"// The Java SDK is in beta and may experience breaking changes.\n// Nylas recommends it for testing purposes only.\nimport java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\n\npublic class NylasExamples {\n public static void sendRsvpExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n // RSVP to an invite. You can only RSVP to invites found in the \"Emailed events\" calendar.\n // rsvp() accepts a status and an optional message\n // status must be one of yes, no, or maybe\n // If notifyParticipants is true, the message will be sent via email to all participants\n account.events().rsvp(\"{eventId}\", \"maybe\", \"{accountId}\", \"I may attend this event\", true);\n System.out.println(\"RSVP sent!\");\n }\n}"}]},"auth":"required","params":[{"_id":"59271c6cc4ee340f0012868d","ref":"","in":"query","required":false,"desc":"If set to true, email notifications containing the calendar event will be sent to all event participants.","default":"","type":"boolean","name":"notify_participants"},{"_id":"5925c830aef9fd2700852730","ref":"","in":"header","required":true,"desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","default":"","type":"string","name":"Authorization"},{"_id":"592720706c729e0f00596e20","ref":"","in":"body","required":true,"desc":"Sends a RSVP status update for the specified event ID. This value must be a valid event ID from the “Emailed events” calendar.","default":"","type":"string","name":"event_id"},{"_id":"592720706c729e0f00596e1f","ref":"","in":"body","required":true,"desc":"Sends a RSVP status update with the specified status. This value can be one of `yes`, `no`, or `maybe`.","default":"","type":"string","name":"status"},{"_id":"592720706c729e0f00596e1e","ref":"","in":"body","required":true,"desc":"Sends a RSVP status update for the specified account ID. See the parent [Account](ref:accounts) object for additional information.","default":"","type":"string","name":"account_id"},{"_id":"5c3fa168943afb0045e3f164","ref":"","in":"body","required":false,"desc":"Sends a RSVP status update with the specified comment.","default":"","type":"string","name":"comment"}],"url":"/send-rsvp","apiSetting":"5e41e73d960b09003ca3598d"},"createdAt":"2017-05-25T18:20:32.809Z","project":"59245c10200df13100c88563","slug":"rsvping-to-invitations","title":"RSVPing to invitations","parentDoc":null,"version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35976","hidden":false,"order":7,"updatedAt":"2019-12-09T17:45:25.329Z","metadata":{"title":"","description":"","image":[]},"tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/send-rsvp"}},{"_id":"5e41e73d960b09003ca35a90","version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-11-05T20:54:54.512Z","createdAt":"2019-10-11T19:39:00.443Z","project":"59245c10200df13100c88563","user":"5f2067586dda9a0045009159","category":"5e41e73d960b09003ca3598a","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":0,"body":"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.\n\n> 📘\n>\n> 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.\n\n\n# Authentication\n\nDepending on if you are using GSuite or Microsoft Office 365 you'll need to enable certain permissions. \n\n## Microsoft \n\nFor 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.\n\nYou also need to enable the `room_resources.read_only` scope. See the [authentication scopes](doc:authentication-scopes) guide for more info.\n\n## GSuite\n\nYou need to enable the `room_resources.read_only` scope. See the [authentication scopes](doc:authentication-scopes) guide for more info.","excerpt":"","slug":"room-resources","type":"basic","metadata":{"description":"","title":"","image":[]},"title":"Introduction","__v":0,"parentDoc":null,"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-11-04T23:30:59.932Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca35a91","version":"5e41e73d960b09003ca35a9b","updatedAt":"2020-11-05T21:23:13.444Z","createdAt":"2019-10-18T20:26:53.706Z","project":"59245c10200df13100c88563","user":"5f2067586dda9a0045009159","category":"5e41e73d960b09003ca3598a","updates":[],"next":{"pages":[],"description":""},"link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /resources HTTP/1.1\nHost: https://api.nylas.com\nContent-Type: application/json\nAuthorization: Basic myAccessToken=="},{"name":"cURL","language":"curl","code":"curl -X GET \"https://api.nylas.com/resources\" \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Basic myAccessToken==\""},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\n\n# Create a client that has access to an end user account.\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n# Get a list of all resources available for the account.\nresources = nylas.room_resources\n\nresource = resources[0]\n# The following attributes are available for resources\nprint(resource.name)\nprint(resource.email)"},{"name":"Ruby SDK","language":"ruby","code":"# Not yet supported in the Nylas Ruby SDK"},{"name":"Node.js SDK","language":"javascript","code":"// Not yet supported in the Nylas Node.js SDK"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport java.util.List;\n\nimport com.nylas.NylasClient;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.RoomResource;\n\npublic class DocExamples {\n\n public static void main(String[] args) throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN});\n \n List<RoomResource> roomResources = account.events().roomResources();\n RoomResource roomResource = roomResources.get(0);\n \n // The following attributes are available for the RoomResource Class\n roomResource.getName();\n roomResource.getEmail();\n } \n}"}]},"results":{"codes":[{"status":200,"name":"","code":"//GSuite Example\n[\n {\n \"object\": \"room_resource\",\n \"email\": \"training-room-1A@google.com\",\n \"name\": \"Training Room 1A\", \n \"capacity\": \"8\",\n \"building\": \"West Building\",\n \"floor_name\": \"7\",\n \"floor_number\": null\n }, \n {\n \"object\": \"room_resource\",\n \"email\": \"training-room-2B@google.com\",\n \"name\": \"Training Room 2B\",\n \"capacity\": \"8\",\n \"building\": \"East Building\",\n \"floor_name\": \"9\",\n \"floor_number\": null\n }, \n]\n\n//Microsoft Example\n\n[\n {\n \"object\": \"room_resource\",\n \"email\": \"training-room-1A@office365.com\",\n \"name\": \"Training Room 1A\", \n \"capacity\": \"8\",\n \"building\": \"West Building\",\n \"floor_name\": \"Windchomes\",\n \"floor_number\": \"6\"\n }, \n {\n \"object\": \"room_resource\",\n \"email\": \"training-room-1A@office365.com\",\n \"name\": \"Training Room 2B\",\n \"capacity\": \"8\",\n \"building\": \"East Building\",\n \"floor_name\": \"Songbird\",\n \"floor_number\": \"8\"\n }, \n]","language":"json"}]},"apiSetting":"5e41e73d960b09003ca3598d","auth":"never","params":[{"name":"Authorization","type":"string","default":"","desc":"The access token, passed as an HTTP Basic Auth username. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5925c830aef9fd2700852730"}],"url":"/resources","method":"get"},"isReference":true,"order":1,"body":"Responses are encoded as UTF-8 JSON objects with the following attributes:\n\n| Attribute | Type | Description |\n|:----|:----|----|\n| `object` | string | A string describing the type of object (value is \"room_resource\")\n| `email` | string | The email address of the resource. |\n| `name` | string | The name of the resource. |\n| `capacity` | string | The capacity of the room set the organization admin.|\n| `building` | string | The building identifier set by the organization admin. |\n| `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. |\n|` floor_number` | string |Microsoft uses floor number to popular this field. GSuite will always return null. |","excerpt":"Get resource information from GSuite and Office365 organizations.","slug":"resources","type":"endpoint","metadata":{"description":"","title":"","image":[]},"title":"/resources","__v":14,"parentDoc":null,"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-14T17:16:00.625Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/resources"}},{"_id":"5e41e73d960b09003ca35a16","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35977","user":"5f2067586dda9a0045009159","updates":["5e4735c51edac200561a8234"],"next":{"pages":[],"description":""},"createdAt":"2018-01-31T22:44:18.826Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"auth":"required","params":[],"url":"","method":"get"},"isReference":true,"order":0,"body":"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.\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Version 2.0 only\",\n \"body\": \"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](https://docs.nylas.com/reference#api-versioning) section.\"\n}\n[/block]\n## Contacts supports [Filtering](ref:filters) and [Pagination](ref:pagination)\n\nThe contacts endpoint supports filters, which allow you to fetch multiple contacts matching specific criteria, as well as pagination. See the [Contacts](ref:contacts-1) endpoint query parameters, for specific query parameters you can use to filter Contacts.\n\n## The Contact Object\n\nResponses are encoded as UTF-8 JSON objects with the following attributes:\n\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`id`\",\n \"0-1\": \"string\",\n \"0-2\": \"A globally unique object identifier.\",\n \"1-0\": \"`object`\",\n \"1-1\": \"string\",\n \"1-2\": \"A string describing the type of object (e.g `\\\"contact\\\"`).\",\n \"2-0\": \"`account_id`\",\n \"2-1\": \"string\",\n \"2-2\": \"A reference to the parent account object.\",\n \"3-0\": \"`given_name`\",\n \"3-1\": \"string\",\n \"3-2\": \"The given name of the contact.\",\n \"4-0\": \"`middle_name`\",\n \"4-1\": \"string\",\n \"4-2\": \"The middle name of the contact.\",\n \"5-0\": \"`surname`\",\n \"5-1\": \"string\",\n \"5-2\": \"The surname of the contact.\",\n \"6-0\": \"`suffix`\",\n \"6-1\": \"string\",\n \"6-2\": \"The suffix of the contact. (e.g. Jr., Sr., III).\",\n \"7-0\": \"`nickname`\",\n \"7-1\": \"string\",\n \"7-2\": \"The nickname of the contact.\",\n \"9-0\": \"`company_name`\",\n \"9-1\": \"string\",\n \"9-2\": \"The name of the company, for which the contact works.\",\n \"11-0\": \"`manager_name`\",\n \"8-0\": \"`birthday`\",\n \"8-1\": \"string\",\n \"8-2\": \"The birthday of contact in the format `YYYY-MM-DD`.\",\n \"10-0\": \"`job_title`\",\n \"10-1\": \"string\",\n \"10-2\": \"The job title of the contact.\",\n \"11-1\": \"string\",\n \"11-2\": \"The name of the manager for the contact.\",\n \"12-0\": \"`office_location`\",\n \"12-1\": \"string\",\n \"12-2\": \"The location of the office for the contact. This is a free-form field.\",\n \"13-0\": \"`notes`\",\n \"13-1\": \"string\",\n \"13-2\": \"Notes about the contact. This field has [limited support](ref:limitations-for-exchange-accounts).\",\n \"14-0\": \"`picture_url`\",\n \"14-1\": \"string\",\n \"14-2\": \"The URL of endpoint for the contact's picture. See [GET /contacts/<id>/picture](ref:contactsidpicture) for more information.\",\n \"15-0\": \"`emails`\",\n \"15-1\": \"List[Email]\",\n \"15-2\": \"A list of email address objects. See [Email](ref:section-email) for more information.\",\n \"16-0\": \"`im_addresses`\",\n \"16-1\": \"List[IMAddress]\",\n \"16-2\": \"A list of Instant Messaging (IM) Address objects. See [IM Address](ref:section-instant-messenger-im-address) for more information.\",\n \"17-0\": \"`physical_addresses`\",\n \"17-1\": \"List[PhysicalAddress]\",\n \"17-2\": \"A list of physical address objects. See [Physical Address](ref:section-physical-address) for more information.\",\n \"18-2\": \"A list of phone number objects. See [Phone Number](ref:section-phone-number) for more information.\",\n \"18-0\": \"`phone_numbers`\",\n \"18-1\": \"List[PhoneNumber]\",\n \"19-0\": \"`web_pages`\",\n \"19-1\": \"List[WebPage]\",\n \"19-2\": \"A list of web page objects. See [Web Page](ref:section-web-page) for more information.\",\n \"20-0\": \"`groups`\",\n \"20-1\": \"List[ContactGroup]\",\n \"20-2\": \"A list of Contact Groups, to which the contact belongs. See [Contact Group](ref:section-contact-group) for more information.\",\n \"21-0\": \"`source`\",\n \"21-1\": \"string\",\n \"21-2\": \"The source of the contact will be: \\n\\n- `address_book`: Denotes a user-created contact.\\n- `inbox`: Denotes a contact parsed from an email.\"\n },\n \"cols\": 3,\n \"rows\": 22\n}\n[/block]\nA few of the fields on the contact model have list values. These are lists of different objects: Email, IM Address, Physical Address, Phone Number, Web Page and Contact Group. \n\n## Email\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`type`\",\n \"0-1\": \"string\",\n \"0-2\": \"The type of the email address. The value can be `work` or `personal`.\",\n \"1-0\": \"`email`\",\n \"1-1\": \"string\",\n \"1-2\": \"The email address. This is a free-form string.\"\n },\n \"cols\": 3,\n \"rows\": 2\n}\n[/block]\n## Instant Messenger (IM) Address\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`type`\",\n \"0-1\": \"string\",\n \"0-2\": \"The type of the IM address. The value can be `gtalk`, `aim`, `yahoo`, `lync`, `skype`, `qq`, `msn`, `icc`, or `jabber`.\",\n \"1-0\": \"`im_address`\",\n \"1-1\": \"string\",\n \"1-2\": \"The IM address. This is a free-form string.\"\n },\n \"cols\": 3,\n \"rows\": 2\n}\n[/block]\n## Physical Address\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`format`\",\n \"0-1\": \"string\",\n \"0-2\": \"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`.\",\n \"1-0\": \"`type`\",\n \"1-1\": \"string\",\n \"1-2\": \"The type of the address. The value can be `work`, `home` or `other`.\",\n \"2-0\": \"`street_address`\",\n \"2-1\": \"string\",\n \"2-2\": \"The street address, which includes a house number and street name.\",\n \"3-0\": \"`city`\",\n \"3-1\": \"string\",\n \"3-2\": \"The city of the address.\",\n \"4-0\": \"`postal_code`\",\n \"4-1\": \"string\",\n \"4-2\": \"The postal code of the address.\",\n \"5-0\": \"`state`\",\n \"5-1\": \"string\",\n \"5-2\": \"The state of the address. This can be a full name or the state abbreviation.\",\n \"6-0\": \"`country`\",\n \"6-1\": \"string\",\n \"6-2\": \"The country of the address. This can be a full name or the country abbreviation.\"\n },\n \"cols\": 3,\n \"rows\": 7\n}\n[/block]\n## Phone Number\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`type`\",\n \"0-1\": \"string\",\n \"0-2\": \"The type of phone number. The value can be `business`, `home`, `mobile`, `pager`, `business_fax`, `home_fax`, `organization_main`, `assistant`, `radio` or `other`.\",\n \"1-0\": \"`number`\",\n \"1-1\": \"string\",\n \"1-2\": \"The phone number. This is a free-form string.\"\n },\n \"cols\": 3,\n \"rows\": 2\n}\n[/block]\n## Web Page\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`type`\",\n \"0-1\": \"string\",\n \"0-2\": \"Type of Web Page. The default values are profile, blog, homepage or work.\\nYou can add in a custom type when creating a type and Nylas will read custom types from incoming contact data.\",\n \"1-0\": \"`url`\",\n \"1-1\": \"string\",\n \"1-2\": \"The web page url. This is a free-form string.\"\n },\n \"cols\": 3,\n \"rows\": 2\n}\n[/block]\n## Contact Group\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Attribute\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\",\n \"0-0\": \"`id`\",\n \"1-0\": \"`object`\",\n \"2-0\": \"`account_id`\",\n \"3-0\": \"`name`\",\n \"4-0\": \"`path`\",\n \"1-1\": \"string\",\n \"3-1\": \"string\",\n \"4-1\": \"string\",\n \"0-1\": \"string\",\n \"2-1\": \"string\",\n \"0-2\": \"A globally unique object identifier.\",\n \"1-2\": \"A string describing the type of object. The value is `contact_group`.\",\n \"2-2\": \"A reference to the parent account object.\",\n \"3-2\": \"The name of the Contact Group.\",\n \"4-2\": \"A fully qualified path of the Contact Group, if nesting is permitted by the account's provider.\"\n },\n \"cols\": 3,\n \"rows\": 5\n}\n[/block]","excerpt":"","slug":"contacts-intro","type":"basic","title":"Introduction","__v":1,"parentDoc":null,"updatedAt":"2020-11-09T17:10:07.643Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-11-09T10:19:49.768Z","tutorials":[],"children":[],"childrenPages":[]},{"_id":"5e41e73d960b09003ca35a17","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35977","user":"5d404909c2f77c0012211f3e","updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-02-01T00:47:49.237Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","examples":{"codes":[{"name":"HTTP","language":"http","code":"GET /contacts HTTP/1.1\nHost: api.nylas.com\nContent-Type: application/json\nAuthorization: Bearer ACCESS_TOKEN\ncache-control: no-cache"},{"name":"cURL","language":"curl","code":"curl -X GET 'https://api.nylas.com/contacts' \\\n-H 'Authorization: Bearer ACCESS_TOKEN'"},{"name":"Python SDK","language":"python","code":"from nylas import APIClient\nnylas = APIClient(\n CLIENT_ID,\n CLIENT_SECRET,\n ACCESS_TOKEN\n)\n\n# Return all contacts found in the user's contact book\ncontacts = nylas.contacts.all()\n\n# Return contacts that are filtered by specified arguments\ncontacts = nylas.contacts.where(email='swag@nylas.com')\n# Available filters: email, phone_number,\n# street_address, postal_code, state, and country\n\n# Use offset, and limit to control pagination of the results\ncontacts = nylas.contacts.where(limit=10, offset=5)\n\n# Return the first contact\ncontact = nylas.contacts.first()\n\n# The following attributes are available for the contact object\ncontact.id\ncontact.given_name\ncontact.middle_name\ncontact.surname\ncontact.suffix\ncontact.nickname\ncontact.emails\ncontact.physical_addresses\ncontact.office_location\ncontact.picture_url\ncontact.account_id\ncontact.company_name\ncontact.notes\ncontact.object\ncontact.manager_name\ncontact.im_addresses\ncontact.web_pages\ncontact.phone_numbers\ncontact.job_title\ncontact.birthday"},{"name":"Ruby SDK","language":"ruby","code":"# Return all contacts found in the user's contact book\ncontacts = nylas.contacts\n\n# Return contacts that are filtered by specified arguments\ncontacts = nylas.contacts.where(email: 'swag@nylas.com')\n# Available filters: email, phone_number,\n# street_address, postal_code, state, and country\n\n# Use offset, and limit to control pagination of the results\ncontacts = nylas.contacts.limit(10).offset(5)\n\n# Return the first contact\ncontact = nylas.contacts.first\n\n# The following attributes are available for the contact object\ncontact.id\ncontact.given_name\ncontact.middle_name\ncontact.surname\ncontact.suffix\ncontact.nickname\ncontact.emails\ncontact.physical_addresses\ncontact.office_location\ncontact.picture_url\ncontact.account_id\ncontact.company_name\ncontact.notes\ncontact.object\ncontact.manager_name\ncontact.im_addresses\ncontact.web_pages\ncontact.phone_numbers\ncontact.job_title\ncontact.birthday\ncontact.groups"},{"name":"Node.js SDK","language":"javascript","code":"// Return all contacts found in the user's contact book\nnylas.contacts.list().then(contacts => console.log(contacts));\n\n// Return contacts that are filtered by specified arguments\nnylas.contacts.list({email: 'swag@nylas.com'}).then(resp => console.log(resp));\n// Available filters: email, phone_number,\n// street_address, postal_code, state, country, source, group, recurse\n\n// Use offset, and limit to control pagination of the results\nnylas.contacts.list({limit: 10, offset: 5}).then(contacts => console.log(contacts));\n\n// Return the first contact\nnylas.contacts.first().then(contact => console.log(contact));\n\n// The following attributes are available for the contact object\ncontact.id,\ncontact.object,\ncontact.accountId,\ncontact.givenName,\ncontact.middleName,\ncontact.surname,\ncontact.suffix,\ncontact.nickname,\ncontact.birthday,\ncontact.companyName,\ncontact.jobTitle,\ncontact.managerName,\ncontact.officeLocation,\ncontact.notes,\ncontact.pictureUrl,\ncontact.emailAddresses,\ncontact.imAddresses,\ncontact.physicalAddresses,\ncontact.phoneNumbers,\ncontact.webPages,\ncontact.groups,\ncontact.source"},{"name":"Java SDK","language":"java","code":"import java.io.IOException;\nimport com.nylas.RequestFailedException;\nimport com.nylas.NylasAccount;\nimport com.nylas.NylasClient;\nimport com.nylas.Contact;\nimport com.nylas.ContactQuery;\nimport com.nylas.Contacts;\n\npublic class NylasExamples {\n public static void getContactsExample() throws IOException, RequestFailedException {\n NylasClient nylas = new NylasClient();\n NylasAccount account = nylas.account(\"{ACCESS_TOKEN}\");\n Contacts contacts = account.contacts();\n \n // Return all contacts found in the user's inbox \n contacts.list();\n \n // Return contacts that are filtered by specified arguments\n contacts.list(new ContactQuery().email(\"swag@nylas.com\"));\n // Available filters: email, phoneNumber,\n // streetAddress, postalCode, state, country, source, groupId, recurse\n \n // Use offset, and limit to control pagination\n contacts.list(new ContactQuery().limit(10).offset(10));\n \n // Return the first contact\n Contact contact = contacts.list(new ContactQuery().limit(1)).get(0);\n \n // The following attributes are available for the contact object\n contact.getId();\n contact.getBirthday();\n contact.getCompanyName();\n contact.getEmails();\n contact.getGivenName();\n contact.getGroups();\n contact.getIMAddresses();\n contact.getJobTitle();\n contact.getManagerName();\n contact.getMiddleName();\n contact.getNickname();\n contact.getNotes();\n contact.getOfficeLocation();\n contact.getPhoneNumbers();\n contact.getPhysicalAddresses();\n contact.getPictureUrl();\n contact.getSource();\n contact.getSuffix();\n contact.getSurname();\n contact.getWebPages();\n }\n}"}]},"results":{"codes":[{"status":200,"language":"json","code":"[\n {\n \"account_id\": \"x2x2x2x2x2x2x2x2x2x2x2\",\n \"birthday\": \"1960-12-31\",\n \"company_name\": \"Nylas\",\n \"emails\": [\n {\n \"email\": \"john@doe.com\",\n \"type\": \"work\"\n }\n ],\n \"given_name\": \"John\",\n \"id\": \"z3z3z3z3z3z3z3z3z3z3z3\",\n \"im_addresses\": [\n {\n \"im_address\": \"myaimaddress\",\n \"type\": \"aim\"\n }\n ],\n \"job_title\": \"Software Engineer\",\n \"manager_name\": \"Bill the manager\",\n \"middle_name\": \"Jacob\",\n \"nickname\": \"JD\",\n \"notes\": \"Loves ramen\",\n \"object\": \"contact\",\n \"office_location\": \"123 North Pole Dr\",\n \"phone_numbers\": [\n {\n \"number\": \"1 800 123 4567\",\n \"type\": \"mobile\"\n }\n ],\n \"physical_addresses\": [],\n \"picture_url\": \"https://api.nylas.com/contacts/427abc427abc427abc/picture\",\n \"suffix\": \"Jr.\",\n \"surname\": \"Doe\",\n \"web_pages\": [],\n \"groups\": [\n {\n \"id\": \"a0a0a0a0a0a0a0a0a0a0a0\",\n \"object\": \"contact_group\",\n \"account_id\": \"x2x2x2x2x2x2x2x2x2x2x2\",\n \"name\": \"Work\",\n \"path\": \"Contacts/Work\"\n }\n ]\n }\n]","name":""},{"status":400,"language":"json","code":"{\n \"message\": \"Message about the error goes hser\",\n \"type\": \"error_type_goes_here\"\n}","name":""}]},"auth":"required","params":[{"name":"limit","type":"int","default":"","desc":"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. See [Pagination](ref:pagination) for additional info.","required":false,"in":"query","ref":"","_id":"5a78be14122f02001c53f368"},{"name":"offset","type":"int","default":"","desc":"Returns the contacts with the specified offset. This value is a zero-based offset from default object sorting. See [Pagination](ref:pagination) for additional info.","required":false,"in":"query","ref":"","_id":"5a78be14122f02001c53f367"},{"name":"email","type":"string","default":"","desc":"Returns the contacts matching the exact contact's email. For example: `/contacts?email=fred%40nylas.com`.","required":false,"in":"query","ref":"","_id":"5a78bfce122f02001c53f3c7"},{"name":"phone_number","type":"string","default":"","desc":"Returns the contacts matching the contact's exact phone number. For example: `/contacts?phone_number=4158889999`.","required":false,"in":"query","ref":"","_id":"5a78bfce122f02001c53f3c6"},{"name":"street_address","type":"string","default":"","desc":"Returns the contacts matching the one of the contact's exact street address. For example: `/contacts?street_address=1600%20Pennsylvania%20Ave`.","required":false,"in":"query","ref":"","_id":"5a79f8ebd0f5c40046a374d0"},{"name":"postal_code","type":"string","default":"","desc":"Returns the contacts matching the contact's exact postal code of one of the contact's addresses. For example: `/contacts?postal_code=20500`.","required":false,"in":"query","ref":"","_id":"5a78bfce122f02001c53f3c5"},{"name":"state","type":"string","default":"","desc":"Returns the contacts matching the contact's exact state for one of the contact's physical addresses. For example: `/contacts?state=CA`.","required":false,"in":"query","ref":"","_id":"5a78bfce122f02001c53f3c4"},{"name":"country","type":"string","default":"","desc":"Returns the contacts matching the contact's exact physical addresses. For example: `/contacts?country=USA`.","required":false,"in":"query","ref":"","_id":"5a78bfce122f02001c53f3c3"},{"name":"source","type":"string","default":"","desc":"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`.","required":false,"in":"query","ref":"","_id":"5a78bfce122f02001c53f3c2"},{"name":"Authorization","type":"string","default":"","desc":"The account access token, passed as an HTTP Bearer token. See the [access token guide](doc:using-access-tokens) for more information.","required":true,"in":"header","ref":"","_id":"5a7bae850cbdcc005ff16cca"},{"name":"group","type":"string","default":"","desc":"Returns the contacts belonging to the Contact Group matching this ID.","required":false,"in":"query","ref":"","_id":"5b21552f5f1e00000363005c"},{"name":"recurse","type":"boolean","default":"false","desc":"When set to `true`, returns the contacts also within the specified Contact Group subgroups, if the `group` parameter is set.","required":false,"in":"query","ref":"","_id":"5b21552f5f1e00000363005b"}],"url":"/contacts","method":"get"},"isReference":true,"order":1,"body":"You can get a list of contacts by sending a `GET` request to the `/contacts` endpoint. This will return a list of `Contact` JSON objects. \n\nThis list of contacts includes both contacts from the address book of the email provider, and contacts that we auto-generate from an account's emails. To separate these out, use the `source` filter. Setting `source=address_book` will return only contacts from the email provider. Setting `source=inbox` will return only the autogenerated contacts that Nylas creates from an account's emails. \n\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"It is important to note that parameter values must use [percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding) (also known as URL encoding).\",\n \"title\": \"Parameter Percent Encoding\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Exact Matches\",\n \"body\": \"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.\"\n}\n[/block]","excerpt":"Searches for contacts using the specified filter criteria.","slug":"contacts-1","type":"endpoint","title":"/contacts","__v":47,"parentDoc":null,"updatedAt":"2019-11-15T02:22:46.344Z","metadata":{"title":"","description":"","image":[]},"pendingAlgoliaPublish":false,"previousSlug":"","slugUpdatedAt":"2020-07-21T19:29:46.270Z","tutorials":[],"children":[],"childrenPages":[],"swagger":{"path":"/contacts"}},{"_id":"5e41e73d960b09003ca35a18","project":"59245c10200df13100c88563","version":"5e41e73d960b09003ca35a9b","category":"5e41e73d960b09003ca35977","user":"5d404909c2f77c0012211f3e","updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-02-01T01:04:31.758Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"apiSetting":"5e41e73d960b09003ca3598d","results":{"codes":[{"status":200,"name":"","code":" {\n \"account_id\": \"x2x2x2x2x2x2x2x2x2x2x2\",\n \"birthday\": \"1960