### Test Node.js SDK installation by getting application details Source: https://developer.nylas.com/docs/v3/sdks/node.md Test your Node.js SDK installation by making a request to retrieve your Nylas application details. This example uses environment variables for API keys and URIs, which is recommended for production. ```javascript import Nylas from "nylas"; const nylas = new Nylas({ apiKey: "", apiUri: "", }); const applicationDetails = await nylas.applications.getDetails(); console.log({ applicationDetails }); ``` -------------------------------- ### Check Availability with Python Source: https://developer.nylas.com/docs/v3/getting-started/calendar.md This Python example shows how to retrieve available meeting times for a list of participants. It prints the start time of each available slot. ```python availability = nylas.calendars.get_availability( request_body={ "start_time": int(time.time()), "end_time": int(time.time()) + 86400, "duration_minutes": 30, "participants": [ {"email": "alice@example.com"}, {"email": "bob@example.com"}, ], }, ) for slot in availability.data.time_slots: print(f"Available: {slot.start_time}") ``` -------------------------------- ### Construct Authorization Request URL Source: https://developer.nylas.com/docs/v3/auth/hosted-oauth-accesstoken.md This example shows the structure of a GET request to the `/v3/connect/auth` endpoint for initiating an OAuth authorization flow with PKCE. It includes parameters for client ID, redirect URI, response type, provider, scope, state, code challenge, and code challenge method. ```bash /connect/auth? client_id= &redirect_uri=https://myapp.com/callback-handler &response_type=code &provider= &scope= &state= &code_challenge=ZTk2YmY2Njg2YTNjMzUxMGU5ZTkyN2RiNzA2OWNiMWNiYTliOTliMDIyZjQ5NDgzYTZjZTMyNzA4MDllNjhhMg &code_challenge_method=S256 ``` -------------------------------- ### Send Email with Open Tracking using Kotlin SDK Source: https://developer.nylas.com/docs/v3/email/message-tracking.md This Kotlin example shows how to initialize the Nylas client and set up tracking options for sending an email. It's a starting point for integrating message tracking in Kotlin applications. ```kotlin import com.nylas.models.messages.TrackingOptions import com.nylas.models.EmailName import com.nylas.NylasClient fun main(args: Array) { val nylas: NylasClient = NylasClient(apiKey = "") val emailNames : List = listOf(EmailName("swag@example.com", "Nylas")) val options : TrackingOptions = TrackingOptions("Track when the message gets opened", true, false, false) ``` -------------------------------- ### Install Nylas SDK Source: https://developer.nylas.com/docs/v3/getting-started/coding-agents.md Install the Nylas SDK for Node.js, Python, or Ruby. ```bash npm install nylas ``` ```bash pip install nylas ``` ```bash gem install nylas ``` -------------------------------- ### Install and Authenticate Nylas CLI Source: https://developer.nylas.com/docs/v3/notifications/receive-webhooks-cli.md Install the Nylas CLI and authenticate with your API key before proceeding. ```bash curl -fsSL https://cli.nylas.com/install.sh | bash nylas init ``` -------------------------------- ### Install Dependencies Source: https://developer.nylas.com/docs/v3/auth/nylas-connect-react/use-external-idp/clerk.md Install the necessary Nylas and Clerk React packages using npm. ```bash npm install @nylas/react @clerk/clerk-react ``` -------------------------------- ### Start Dev Server with npm Source: https://developer.nylas.com/docs/v3/getting-started/scheduler.md Alternatively, start the local development server using npm. Replace with your desired port number. ```bash npm run dev -- --port ``` -------------------------------- ### Start Python Customer Onboarding Flow Source: https://developer.nylas.com/docs/v3/use-cases/automate/automate-customer-onboarding.md Initiates the customer onboarding sequence by creating a customer record, setting up a scheduling page, sending a welcome email, updating the onboarding state, and scheduling a follow-up check. ```python def start_onboarding(customer): # 1. Create the customer record save_customer_record(customer["email"], { "name": customer["name"], "email": customer["email"], "onboarding_state": "new", "created_at": time.time(), }) # 2. Create a per-customer scheduling page scheduler = create_kickoff_scheduler() scheduling_url = ( f"https://book.nylas.com/{scheduler.slug}" f"?name={customer['name']}&email__readonly={customer['email']}" ) # 3. Send the welcome email customer["scheduling_url"] = scheduling_url send_welcome_email(customer) # 4. Update state transition_to(customer["email"], "welcome_sent") # 5. Schedule a follow-up check after 48 hours schedule_followup_check(customer["email"], delay_hours=48) ``` -------------------------------- ### List Events using Nylas API Source: https://developer.nylas.com/docs/v3/guides/calendar/events/list-events-microsoft.md This example demonstrates how to make a GET request to the Nylas API to list events from a specified calendar. You can filter events by providing `start` and `end` timestamps. ```APIDOC ## GET /v3/grants//events ### Description Retrieves a list of events associated with a specific grant and calendar. Results can be filtered by start and end times. ### Method GET ### Endpoint `/v3/grants//events` ### Query Parameters - **calendar_id** (string) - Required - The ID of the calendar to retrieve events from. Use `primary` for the default calendar. - **start** (integer) - Optional - The start timestamp for filtering events. - **end** (integer) - Optional - The end timestamp for filtering events. ### Headers - **Authorization**: Bearer - **Content-Type**: application/json - **Accept**: application/json ### Request Example ```bash curl --compressed --request GET \ --url 'https://api.us.nylas.com/v3/grants//events?calendar_id=&start=&end=' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` ### Response #### Success Response (200) Returns a JSON object containing a list of event objects. - **request_id** (string) - Unique identifier for the request. - **data** (array) - An array of event objects. - **id** (string) - Unique identifier for the event. - **title** (string) - The title of the event. - **start_time** (integer) - The start time of the event in Unix timestamp format. - **end_time** (integer) - The end time of the event in Unix timestamp format. - **calendar_id** (string) - The ID of the calendar the event belongs to. - **grant_id** (string) - The ID of the grant associated with the event. - **created_at** (integer) - Timestamp when the event was created. - **updated_at** (integer) - Timestamp when the event was last updated. #### Response Example ```json { "request_id": "cbd60372-df33-41d3-b203-169ad5e3AAAA", "data": [ { "busy": true, "calendar_id": "primary", "conferencing": { "details": { "meeting_code": "ist-****-tcz", "url": "https://meet.google.com/ist-****-tcz" }, "provider": "Google Meet" }, "created_at": 1701974804, "creator": { "email": "anna.molly@example.com", "name": "" }, "description": null, "grant_id": "1e3288f6-124e-405d-a13a-635a2ee54eb2", "hide_participants": false, "html_link": "https://www.google.com/calendar/event?eid=NmE0dXIwabQAAAA", "ical_uid": "6aaaaaaame8kpgcid6hvd0q@google.com", "id": "6aaaaaaame8kpgcid6hvd", "object": "event", "organizer": { "email": "anna.molly@example.com", "name": "" }, "participants": [ { "email": "jenna.doe@example.com", "status": "yes" }, { "email": "anna.molly@example.com", "status": "yes" } ], "read_only": true, "reminders": { "overrides": null, "use_default": true }, "status": "confirmed", "title": "Holiday check in", "updated_at": 1701974915, "when": { "end_time": 1701978300, "end_timezone": "America/Los_Angeles", "object": "timespan", "start_time": 1701977400, "start_timezone": "America/Los_Angeles" } } ] } ``` ``` -------------------------------- ### Start Authorization Request with Ruby SDK Source: https://developer.nylas.com/docs/v3/auth/hosted-oauth-apikey.md Generate the OAuth 2.0 authorization URL using the Nylas Ruby SDK. This Sinatra application example defines a GET route to create and redirect to the authorization URL. ```ruby require 'nylas' require 'sinatra' nylas = Nylas::Client.new(api_key: "") get '/nylas/auth' do config = { client_id: "", provider: "google", redirect_uri: "http://localhost:4567/oauth/exchange", login_hint: "" } url = nylas.auth.url_for_oauth2(config) redirect url end ``` -------------------------------- ### Start Node.js Customer Onboarding Flow Source: https://developer.nylas.com/docs/v3/use-cases/automate/automate-customer-onboarding.md Initiates the customer onboarding sequence by creating a customer record, setting up a scheduling page, sending a welcome email, updating the onboarding state, and scheduling a follow-up check. ```javascript async function startOnboarding(customer) { // 1. Create the customer record await saveCustomerRecord(customer.email, { name: customer.name, email: customer.email, onboardingState: "new", createdAt: new Date().toISOString(), }); // 2. Create a per-customer scheduling page const scheduler = await createKickoffScheduler(); const schedulingUrl = `https://book.nylas.com/${scheduler.slug}?name=${encodeURIComponent(customer.name)}&email__readonly=${encodeURIComponent(customer.email)}`; // 3. Send the welcome email customer.schedulingUrl = schedulingUrl; await sendWelcomeEmail(customer); // 4. Update state await transitionTo( { email: customer.email, onboardingState: "new" }, "welcome_sent", { welcomeSentAt: new Date().toISOString() }, ); // 5. Schedule a follow-up check after 48 hours await scheduleFollowUpCheck(customer.email, 48); } ``` -------------------------------- ### Get Calendar Response Example Source: https://developer.nylas.com/docs/v3/calendar.md This is an example of the JSON response you can expect when successfully retrieving calendar information. ```json { "request_id": "123-456-789", "data": { "grant_id": "", "description": "Board game nights!", "id": "zd08j9stfph95u449vti", "is_primary": false, "name": "Game nights", "object": "calendar", "read_only": false, "timezone": "UTC", "hex_color": "#a47ae2", "hex_foreground_color": "#000000", "is_owned_by_user": true } } ``` -------------------------------- ### Meeting Follow-up Workflow Example Source: https://developer.nylas.com/docs/v3/getting-started/agent-notetaker.md This example demonstrates a realistic agent workflow combining calendar event listing, notetaker status checking, transcript retrieval, and email sending for meeting follow-ups. ```bash # 1. List today's calendar events to find meetings that happened nylas calendar events list --days 1 --json # 2. Check which notetakers have finished recording curl -s --request GET \ --url "https://api.us.nylas.com/v3/grants/$NYLAS_GRANT_ID/notetakers" \ --header "Authorization: Bearer $NYLAS_API_KEY" \ | jq '.data[] | select(.status == "completed")' # 3. Get the transcript curl -s --request GET \ --url "https://api.us.nylas.com/v3/grants/$NYLAS_GRANT_ID/notetakers//media" \ --header "Authorization: Bearer $NYLAS_API_KEY" # 4. (Agent processes the transcript with its LLM to extract # action items, decisions, and follow-ups) # 5. Send follow-up email with meeting summary nylas email send \ --to "team@example.com" \ --subject "Meeting notes: Q3 planning" \ --body "Here are the key decisions and action items from today..." \ --yes ``` -------------------------------- ### Install MCP Assistant Source: https://developer.nylas.com/docs/v3/getting-started/agent-contacts.md Register the Nylas CLI as an MCP server for typed contact tools if your agent supports Model Context Protocol. This example installs the assistant for 'claude-code'. ```bash nylas mcp install --assistant claude-code ``` -------------------------------- ### Example: Scheduling assistant workflow Source: https://developer.nylas.com/docs/v3/getting-started/agent-calendar.md A multi-step example demonstrating a common pattern for an agent handling meeting requests, from checking availability to sending confirmations. ```bash # 1. Check the user's schedule for next week nylas calendar events list --days 7 --json # 2. Find a time that works for all participants nylas calendar find-time \ --participants "alice@example.com,bob@example.com" \ --duration 60m \ --json # 3. (Agent picks the best slot based on preferences) # 4. Create the meeting nylas calendar events create \ --title "Q3 planning" \ --start "2026-04-16T10:00:00" \ --end "2026-04-16T11:00:00" \ --participants "alice@example.com,bob@example.com" \ --description "Quarterly planning session" # 5. Confirm via email nylas email send \ --to "alice@example.com,bob@example.com" \ --subject "Meeting scheduled: Q3 planning" \ --body "I've scheduled Q3 planning for April 16 at 10am. Calendar invite sent." \ --yes ``` -------------------------------- ### Full example: Reply to a message in Kotlin Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java/send-email.md A complete Kotlin example demonstrating how to reply to an email, including fetching the thread, creating a draft, and sending the message. ```kotlin fun main(args: Array) { val nylas: NylasClient = NylasClient(apiKey = "") val queryParams = ListThreadsQueryParams(limit = 1, inFolder = Collections.singletonList("inbox")) val threads : List = nylas.threads().list("", queryParams).data val len : Int? = threads[0].messageIds?.size val reply = len?.minus(1)?.let { threads[0].messageIds?.get(it) } val requestBody = CreateDraftRequest.Builder(). replyToMessageId(reply). subject(threads[0].subject). build() val draft = nylas.drafts().create("", requestBody) val msg = nylas.drafts().send( dotenv["NYLAS_GRANT_ID"], draft.data.id ) } ``` -------------------------------- ### Booking Created Payload Example Source: https://developer.nylas.com/docs/v3/use-cases/build/interview-scheduling-pipeline.md This is an example of the JSON payload received when a `booking.created` event occurs. It contains detailed information about the scheduled booking, including event IDs, start and end times, title, and meeting location. ```json { "specversion": "1.0", "type": "booking.created", "source": "/nylas/passthru", "id": "", "time": 1725895310, "data": { "application_id": "", "grant_id": "", "object": { "booking_id": "", "configuration_id": "", "object": "booking", "booking_info": { "event_id": "", "start_time": 1719842400, "end_time": 1719844500, "title": "Interview with Dana Chen", "location": "https://meet.google.com/abc-defg-hij" } } } } ``` -------------------------------- ### Service Account GET Request Example Source: https://developer.nylas.com/docs/v3/auth/nylas-service-account.md This bash script demonstrates how to make a GET request to the Nylas API using service account authentication. Ensure the private key is stored in 'private_key_b64.txt' and the NYLAS_KID environment variable is set. ```bash PRIVATE_KEY_B64="$(cat private_key_b64.txt)" \ REQUEST_PATH="/v3/admin/domains" \ NYLAS_KID="08d8bdae-9981-432c-ac66-3006919d908e" \ go run domain.go ``` -------------------------------- ### Full example: Reply to a message in Java Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java/send-email.md A complete Java example demonstrating how to reply to an email, including fetching the thread, creating a draft, and sending the message. ```java public class ReadThreadParameters { public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError { NylasClient nylas = new NylasClient.Builder("").build(); ListThreadsQueryParams queryParams = new ListThreadsQueryParams.Builder(). limit(1). inFolder(Collections.singletonList("inbox")). build(); ListResponse thread = nylas.threads().list("", queryParams); assert thread.getData().get(0).getMessageIds() != null; int len = thread.getData().get(0).getMessageIds().size() - 1; String reply = thread.getData().get(0).getMessageIds().get(len); CreateDraftRequest request_body = new CreateDraftRequest.Builder(). replyToMessageId(reply). subject(thread.getData().get(0).getSubject()). build(); Response draft = nylas.drafts().create("", request_body); Response msg = nylas.drafts().send("", draft.getData().getId()); } } ``` -------------------------------- ### List Events using cURL Source: https://developer.nylas.com/docs/v3/guides/calendar/events/list-events-ews.md This example shows how to list events from a calendar using a direct HTTP GET request with cURL. ```APIDOC ## List Events Make a [List Events request](/docs/reference/api/events/get-all-events/) with the grant ID and a `calendar_id`. Nylas returns the most recent events by default. You can use `primary` as the `calendar_id` to target the account's default calendar. These examples limit results to 5: ### Method GET ### Endpoint `https://api.us.nylas.com/v3/grants//events?calendar_id=&start=&end=` ### Headers - `Accept: application/json` - `Authorization: Bearer ` - `Content-Type: application/json` ### Query Parameters - **calendar_id** (string) - Required - The ID of the calendar to retrieve events from. - **start** (integer) - Optional - Unix timestamp for the start of the time range. - **end** (integer) - Optional - Unix timestamp for the end of the time range. ### Response Example (Success) ```json { "request_id": "cbd60372-df33-41d3-b203-169ad5e3AAAA", "data": [ { "busy": true, "calendar_id": "primary", "conferencing": { "details": { "meeting_code": "ist-****-tcz", "url": "https://meet.google.com/ist-****-tcz" }, "provider": "Google Meet" }, "created_at": 1701974804, "creator": { "email": "anna.molly@example.com", "name": "" }, "description": null, "grant_id": "1e3288f6-124e-405d-a13a-635a2ee54eb2", "hide_participants": false, "html_link": "https://www.google.com/calendar/event?eid=NmE0dXIwabQAAAA", "ical_uid": "6aaaaaaame8kpgcid6hvd0q@google.com", "id": "6aaaaaaame8kpgcid6hvd", "object": "event", "organizer": { "email": "anna.molly@example.com", "name": "" }, "participants": [ { "email": "jenna.doe@example.com", "status": "yes" }, { "email": "anna.molly@example.com", "status": "yes" } ], "read_only": true, "reminders": { "overrides": null, "use_default": true }, "status": "confirmed", "title": "Holiday check in", "updated_at": 1701974915, "when": { "end_time": 1701978300, "end_timezone": "America/Los_Angeles", "object": "timespan", "start_time": 1701977400, "start_timezone": "America/Los_Angeles" } } ] } ``` ``` -------------------------------- ### Start Dev Server with npx Source: https://developer.nylas.com/docs/v3/getting-started/scheduler.md Run a local development server from your project root using npx. Replace with your desired port number. ```bash npx serve --listen ``` -------------------------------- ### Create grant with Bring Your Own Authentication (Microsoft Example) Source: https://developer.nylas.com/docs/v3/auth/bring-your-own-authentication.md This example shows how to create a grant for a Microsoft provider using a refresh token. You can adapt the `provider` and `settings` for other providers. ```APIDOC ## POST /v3/connect/custom ### Description Creates a grant using Bring Your Own Authentication. This allows you to use your existing user credentials with Nylas. ### Method POST ### Endpoint https://api.us.nylas.com/v3/connect/custom ### Parameters #### Request Body - **provider** (string) - Required - The authentication provider (e.g., "microsoft", "google", "icloud"). - **settings** (object) - Required - Provider-specific settings. - **refresh_token** (string) - Required for most providers - The user's existing refresh token. - **username** (string) - Required for IMAP/POP3 - The user's email address. - **password** (string) - Required for IMAP/POP3 - The user's email password. - **scope** (array of strings) - Optional - The scopes to request for the grant. - **state** (string) - Optional - A unique identifier to maintain state between the request and the callback. ### Request Example ```json { "provider": "microsoft", "settings": { "refresh_token": "" } } ``` ### Response #### Success Response (200) - **request_id** (string) - Unique identifier for the request. - **data** (object) - Information about the created grant. - **id** (string) - The Nylas Grant ID. - **provider** (string) - The provider used for the grant. - **grant_status** (string) - The status of the grant (e.g., "valid"). - **email** (string) - The email address associated with the grant. - **scope** (array of strings) - The scopes granted. - **user_agent** (string) - The user agent string. - **ip** (string) - The IP address of the request. - **state** (string) - The state identifier. - **created_at** (integer) - Timestamp of when the grant was created. - **updated_at** (integer) - Timestamp of when the grant was last updated. #### Response Example ```json { "request_id": "5fa64c92-e840-4357-86b9-2aa364d35b88", "data": { "id": "", "provider": "microsoft", "grant_status": "valid", "email": "leyah@hotmail.com", "scope": ["Mail.Read", "User.Read", "offline_access"], "user_agent": "", "ip": "", "state": "", "created_at": 1617817109, "updated_at": 1617817109 } } ``` ``` -------------------------------- ### Filter Events Source: https://developer.nylas.com/docs/v3/calendar/using-the-events-api.md You can add query parameters to a `GET` request to filter the events that Nylas returns. For example, you can filter to return only events from a single calendar. ```APIDOC ## GET /v3/grants//events ### Description Filters a list of events based on provided query parameters. ### Method GET ### Endpoint `/v3/grants//events` ### Query Parameters - **calendar_id** (string) - Required - The ID of the calendar to filter events from. - **start** (timestamp) - Required - The start timestamp for filtering events. - **end** (timestamp) - Required - The end timestamp for filtering events. ### Request Example ```bash curl --compressed --request GET \ --url 'https://api.us.nylas.com/v3/grants//events?calendar_id=&start=&end=' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` ### Response #### Success Response (200) Returns a list of event objects that match the filter criteria. #### Response Example ```json { "request_id": "cbd60372-df33-41d3-b203-169ad5e3AAAA", "data": [ { "busy": true, "calendar_id": "primary", "conferencing": { "details": { "meeting_code": "ist-****-tcz", "url": "https://meet.google.com/ist-****-tcz" }, "provider": "Google Meet" }, "created_at": 1701974804, "creator": { "email": "anna.molly@example.com", "name": "" }, "description": null, "grant_id": "1e3288f6-124e-405d-a13a-635a2ee54eb2", "hide_participants": false, "html_link": "https://www.google.com/calendar/event?eid=NmE0dXIwabQAAAA", "ical_uid": "6aaaaaaame8kpgcid6hvd0q@google.com", "id": "6aaaaaaame8kpgcid6hvd", "object": "event", "organizer": { "email": "anna.molly@example.com", "name": "" }, "participants": [ { "email": "jenna.doe@example.com", "status": "yes" }, { "email": "anna.molly@example.com", "status": "yes" } ], "read_only": true, "reminders": { "overrides": null, "use_default": true }, "status": "confirmed", "title": "Holiday check in", "updated_at": 1701974915, "when": { "end_time": 1701978300, "end_timezone": "America/Los_Angeles", "object": "timespan", "start_time": 1701977400, "start_timezone": "America/Los_Angeles" } } ] } ``` ``` -------------------------------- ### Response for Get Attachment Metadata Source: https://developer.nylas.com/docs/v3/email/attachments.md This is an example JSON response when retrieving attachment metadata. It includes details like content type, filename, and size. ```json { "request_id": "5fa64c92-e840-4357-86b9-2aa123456789", "data": { "content_type": "image/png; name=\"pic.png\"", "filename": "pic.png", "grant_id": "", "content_id": "185e56cb50e12e82", "size": 13068, "content_id": "" } } ``` -------------------------------- ### Bootstrap React App and Install Dependencies Source: https://developer.nylas.com/docs/v3/getting-started/scheduler.md Bootstrap a new React application using Vite, install necessary routing and Nylas React components, and verify the project structure. ```bash npm create vite@latest nylas-scheduler # -> When prompted, choose the "React" template # -> When prompted, choose the "TypeScript" language cd nylas-scheduler/ npm install react-router-dom # Needed for routing npm install @nylas/react@latest # Install the Nylas React components # Quick verify: you should now have a `public/`, `src/`, and `node_modules/` folder inside the `nylas-scheduler` folder. ``` -------------------------------- ### Create Project Files (HTML) Source: https://developer.nylas.com/docs/v3/getting-started/scheduler.md Create the necessary HTML files for your project when using the Web Components (HTML) path. ```bash mkdir nylas-scheduler/ cd nylas-scheduler/ touch index.html touch scheduler-editor.html ``` -------------------------------- ### Filter Events with Query Parameters Source: https://developer.nylas.com/docs/v3/calendar/using-the-events-api.md Use query parameters with a GET request to filter events. This example shows filtering by calendar ID and a time range. ```bash curl --compressed --request GET \ --url 'https://api.us.nylas.com/v3/grants//events?calendar_id=&start=&end=' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` -------------------------------- ### Full example: Attach a file and send a message with Python Source: https://developer.nylas.com/docs/v3/sdks/python/send-email.md This comprehensive example demonstrates uploading a local file as an attachment and sending it as an email. It includes setting up the Nylas client, preparing the attachment, creating the draft, and sending the message. Ensure environment variables for API key and URI are set. ```python from dotenv import load_dotenv load_dotenv() from nylas import Client from nylas.utils.file_utils import attach_file_request_builder nylas = Client( os.environ.get('NYLAS_API_KEY'), os.environ.get('NYLAS_API_URI') ) attachment = attach_file_request_builder('attachment.pdf') draft = nylas.drafts.create( '', request_body={ "to": [{ "name": "Name", "email": email }], "reply_to": [{ "name": "Name", "email": email }], "subject": "Your Subject Here", "body": "Your email body here.", "attachments": [attachment] } ) draft = nylas.drafts.send( '', draft[0].id, ) ``` -------------------------------- ### Create a Scheduler Configuration Source: https://developer.nylas.com/docs/v3/use-cases/automate/automate-customer-onboarding.md Use the Create Configuration endpoint to set up a booking page for kickoff calls. This allows customers to book their own kickoff meetings. ```APIDOC ## POST /v3/grants//scheduling/configurations ### Description Creates a new scheduler configuration to set up a booking page for kickoff calls. ### Method POST ### Endpoint /v3/grants//scheduling/configurations ### Request Body - **requires_session_auth** (boolean) - Required - Specifies if session authentication is required. - **participants** (array) - Required - List of participants for the scheduling. - **name** (string) - Required - The name of the participant. - **email** (string) - Required - The email of the participant. - **is_organizer** (boolean) - Required - Whether the participant is the organizer. - **availability** (object) - Required - Availability settings for the participant. - **calendar_ids** (array of strings) - Required - List of calendar IDs for availability. - **booking** (object) - Required - Booking settings for the participant. - **calendar_id** (string) - Required - The calendar ID for booking. - **availability** (object) - Required - General availability settings. - **duration_minutes** (integer) - Required - The duration of the event in minutes. - **event_booking** (object) - Required - Settings for the event booking. - **title** (string) - Required - The title of the event. - **description** (string) - Optional - The description of the event. - **hide_participants** (boolean) - Required - Whether to hide participants. - **slug** (string) - Required - A unique identifier for the scheduling page. ### Request Example ```json { "requires_session_auth": false, "participants": [ { "name": "Acme Onboarding Team", "email": "onboarding@acme.com", "is_organizer": true, "availability": { "calendar_ids": ["primary"] }, "booking": { "calendar_id": "primary" } } ], "availability": { "duration_minutes": 30 }, "event_booking": { "title": "Kickoff Call - {{invitee_name}}", "description": "Welcome kickoff call to walk through account setup, answer questions, and align on goals.", "hide_participants": false }, "slug": "acme-kickoff" } ``` ### Response #### Success Response (200) - **slug** (string) - The unique slug for the created scheduling page. ``` ```javascript async function createKickoffScheduler() { const response = await nylas.scheduling.configurations.create({ identifier: process.env.NYLAS_GRANT_ID, requestBody: { requiresSessionAuth: false, participants: [ { name: "Acme Onboarding Team", email: "onboarding@acme.com", isOrganizer: true, availability: { calendarIds: ["primary"] }, booking: { calendarId: "primary" }, }, ], availability: { durationMinutes: 30 }, eventBooking: { title: "Kickoff Call", description: "Welcome kickoff to walk through setup and align on goals.", hideParticipants: false, }, slug: "acme-kickoff", }, }); console.log( `Scheduler created: https://book.nylas.com/${response.data.slug}`, ); return response.data; } ``` ```python def create_kickoff_scheduler(): response = nylas.scheduling.configurations.create( identifier=os.environ["NYLAS_GRANT_ID"], request_body={ "requires_session_auth": False, "participants": [ { "name": "Acme Onboarding Team", "email": "onboarding@acme.com", "is_organizer": True, "availability": {"calendar_ids": ["primary"]}, "booking": {"calendar_id": "primary"}, } ], "availability": {"duration_minutes": 30}, "event_booking": { "title": "Kickoff Call", "description": "Welcome kickoff to walk through setup and align on goals.", "hide_participants": False, }, "slug": "acme-kickoff", }, ) print(f"Scheduler created: https://book.nylas.com/{response.data.slug}") return response.data ``` -------------------------------- ### Get Calendar using Ruby SDK Source: https://developer.nylas.com/docs/v3/calendar.md Retrieve a calendar using the Nylas Ruby SDK. This example requires initializing the Nylas client with your API key. ```ruby require 'nylas' nylas = Nylas::Client.new(api_key: "") calendar, _request_ids = nylas.calendars.find( identifier: "", calendar_id: "" ) puts calendar ``` -------------------------------- ### Full Example: Attach File and Send Email (Kotlin) Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java/send-email.md Complete Kotlin example demonstrating how to attach a file to an email and send it using the Nylas SDK. Ensure you have your API key and grant ID configured. ```kotlin fun main(args: Array) { val nylas: NylasClient = NylasClient(apiKey = "") val attachment: CreateAttachmentRequest = FileUtils.attachFileRequestBuilder("src/main/kotlin/myFile.png") val requestBody = CreateDraftRequest.Builder(). subject("With Love, from Nylas"). body("This email was sent using the Nylas Email API. Visit https://nylas.com for details."). to(listOf(EmailName("swag@example.com", "Nylas"))). build() val draft = nylas.drafts().create("", requestBody).data nylas.drafts().send("", draft.id); } ``` -------------------------------- ### Test Nylas SDK Installation in Kotlin Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java.md Verify your Nylas SDK setup by fetching application details. Use your actual API key in place of ``. ```kotlin import com.nylas.NylasClient fun main(args: Array) { val nylas: NylasClient = NylasClient( apiKey = "" ) val application = nylas.applications().getDetails() print(application) } ``` -------------------------------- ### Full Example: Attach File and Send Email (Java) Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java/send-email.md Complete Java example demonstrating how to attach a file to an email and send it using the Nylas SDK. Ensure you have your API key and grant ID configured. ```java public class CreateDraft { public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError { NylasClient nylas = new NylasClient.Builder("").build(); CreateAttachmentRequest attachment = FileUtils.attachFileRequestBuilder("src/main/java/myFile.pdf"); List request = new ArrayList<>(); request.add(attachment); CreateDraftRequest requestBody = new CreateDraftRequest.Builder(). to(Collections.singletonList(new EmailName("swag@example.com", "Nylas"))). subject("With Love, from Nylas"). body("This email was sent using the Nylas Email API. Visit https://nylas.com for details."). attachments(request). build(); Response drafts = nylas.drafts().create(dotenv.get("NYLAS_GRANT_ID"), requestBody); nylas.drafts().send(dotenv.get("NYLAS_GRANT_ID"), drafts.getData().getId()); } } ``` -------------------------------- ### Get Calendar using Kotlin SDK Source: https://developer.nylas.com/docs/v3/calendar.md Fetch a calendar using the Nylas Kotlin SDK. This example shows the initialization of the client and the call to find a specific calendar. ```kotlin import com.nylas.NylasClient import com.nylas.models.* fun main(args: Array) { val nylas: NylasClient = NylasClient(apiKey = "") val calendar: Response = nylas.calendars().find("", "") println("Id: " + calendar.data.id + " | Name: " + calendar.data.name + " | Description: " + calendar.data.description) } ``` -------------------------------- ### Full example: Create an email draft in Kotlin Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java/send-email.md This complete example demonstrates creating a draft with recipients, subject, and body using the Nylas Kotlin SDK. Ensure you have your Nylas API key. ```kt fun main(args: Array) { val nylas: NylasClient = NylasClient(apiKey = "") val requestBody = CreateDraftRequest.Builder(). subject("With Love, from Nylas"). body("This email was sent using the Nylas Email API. Visit https://nylas.com for details."). to(listOf(EmailName("swag@example.com", "Nylas"))). build() val draft = nylas.drafts().create("", requestBody).data } ``` -------------------------------- ### Get Available Calendars Response Source: https://developer.nylas.com/docs/v3/calendar.md This is an example of the JSON response structure when requesting a user's available calendars. It includes details for each calendar such as its ID, name, and timezone. ```json { "request_id" : "123-456-789", "data" : [ { "grant_id": "" "description": "Board game nights!", "id": "zd08j9stfph95u449vti", "is_primary": false, "name": "Game nights", "object": "calendar", "read_only": true, "timezone": "America/Toronto", "hex_color": "#000000", "is_owned_by_user": true }, { "grant_id": "" "description": null, "id": "joujhadwh59pz9rvfjfw", "is_primary": false, "name": "jane.doe@example.com", "object": "calendar", "read_only": true, "timezone": "America/Toronto", "hex_color": "#000000", "is_owned_by_user": true } ] } ``` -------------------------------- ### Get Calendar using Node.js SDK Source: https://developer.nylas.com/docs/v3/calendar.md Use the Nylas Node.js SDK to find and retrieve a specific calendar. This example demonstrates how to initialize the SDK and make the find call. ```javascript import Nylas from "nylas"; const nylas = new Nylas({ apiKey: "", apiUri: "", }); async function fetchCalendar() { try { const calendar = await nylas.calendars.find({ identifier: "", calendarId: "", }); console.log("Calendar:", calendar); } catch (error) { console.error("Error fetching calendars:", error); } } fetchCalendar(); ``` -------------------------------- ### Full example: Create and send an email draft in Java Source: https://developer.nylas.com/docs/v3/sdks/kotlin-java/send-email.md This complete example demonstrates creating a draft with recipients, subject, and body, then sending it using the Nylas SDK. Ensure you have your Nylas API key and grant ID. ```java public class CreateDraft { public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError { NylasClient nylas = new NylasClient.Builder("").build(); CreateDraftRequest requestBody = new CreateDraftRequest.Builder(). to(Collections.singletonList(new EmailName("swag@example.com", "Nylas"))). subject("With Love, from Nylas"). body("This email was sent using the Nylas Email API. Visit https://nylas.com for details."). build(); Response drafts = nylas.drafts().create("", requestBody); System.out.println("Draft " + drafts.getData().getSubject() + " was created with ID " + drafts.getData().getId()); nylas.drafts().send("", drafts.getData().getId()); } } ``` -------------------------------- ### Create Event using CLI Source: https://developer.nylas.com/docs/v3/calendar/using-the-events-api.md This example demonstrates creating a basic event using the Nylas CLI, focusing on essential fields like title, start, and end times. ```APIDOC ## Create Event (CLI) ### Description Creates a basic calendar event using the Nylas CLI. This command is useful for quickly creating events with essential details. ### Command `nylas calendar events create` ### Options - **--title** (string) - Required - The title of the event. - **--start** (string) - Required - The start date and time of the event (e.g., "2026-12-31 9:00pm"). - **--end** (string) - Required - The end date and time of the event (e.g., "2026-12-31 11:59pm"). ### Notes To set additional fields like description, location, or other rich details, you can either send a full Create Event request or update the event after creation. ```