{"id":51013427,"url":"https://github.com/trycourier/demo-nodejs-send","last_synced_at":"2026-06-21T06:31:37.225Z","repository":{"id":46603523,"uuid":"515485279","full_name":"trycourier/demo-nodejs-send","owner":"trycourier","description":"Send API Example with multi-channel routing","archived":false,"fork":false,"pushed_at":"2022-07-20T07:05:19.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T22:32:48.424Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trycourier.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-19T07:43:11.000Z","updated_at":"2022-07-19T22:46:49.000Z","dependencies_parsed_at":"2022-07-19T14:38:53.131Z","dependency_job_id":null,"html_url":"https://github.com/trycourier/demo-nodejs-send","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/trycourier/demo-nodejs-send","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trycourier%2Fdemo-nodejs-send","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trycourier%2Fdemo-nodejs-send/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trycourier%2Fdemo-nodejs-send/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trycourier%2Fdemo-nodejs-send/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trycourier","download_url":"https://codeload.github.com/trycourier/demo-nodejs-send/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trycourier%2Fdemo-nodejs-send/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34597337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-21T06:31:36.439Z","updated_at":"2026-06-21T06:31:37.220Z","avatar_url":"https://github.com/trycourier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Demo: Send Messages with Node.js\n\n## Setup\n\n1. Install the Courier SDK\n   \n   * In terminal: `npm install @trycourier/courier`\n   * Access SDK in index.js:\n   ```javascript\n   const { CourierClient } = require(\"@trycourier/courier\")\n   ```\n   \n   [Learn more \u003e](https://www.courier.com/docs/guides/getting-started/nodejs/#using-the-sdk)\n\n2. Get your API key\n\n   * Save your API Key in a .env file by adding `API_KEY=\"[insert-api-key]\"` in a .env file. For protection, add the .env file in your .gitignore.\n   * Install the [dotenv npm package](https://www.npmjs.com/package/dotenv) to access the API Key by running the `npm install dotenv --save` command in terminal.\n   * Access your API Key in index.js:\n   ```javascript\n   const courier = CourierClient({ authorizationToken: process.env.API_KEY });\n   ```\n   \n   [Learn more \u003e](https://www.courier.com/docs/guides/getting-started/nodejs/#getting-your-api-keys)\n\n## Single Channel Send\n\n1. Save the email of your recipient in the .env file as `EMAIL=\"example@email.com\"`\n\n2. Add an asynchronous function in your index.js file, which encloses the send request:\n   ```javascript\n   async function send() {\n       const { requestId } = await courier.send({\n           message: {\n             to: {\n               email: process.env.EMAIL,\n             },\n             content: {\n               title: \"Welcome!\",\n               body: \"Thanks for signing up, {{name}}\",\n             },\n             data: {\n               name: \"@shreythecray\",\n             },\n             routing: {\n               method: \"single\",\n               channels: [\"email\"],\n             },\n           },\n         });\n\n         console.log(requestId)\n   }\n\n   send()\n   ```\n\nExample email received:\n\n\u003cimg width=\"1293\" alt=\"0-email\" src=\"https://user-images.githubusercontent.com/28051494/179698659-55f4e35b-da44-41ec-847f-89cad2188f9f.png\"\u003e\n\n\n## Multi-Channel Send\n\n1. Update the routing object within the send request:\n   * Provide options for multiple channels and allow Courier to send to the first channel that successfully complete:\n   ```javascript\n   sync function send() {\n       const { requestId } = await courier.send({\n           message: {\n             to: {\n               email: process.env.EMAIL,\n               //**NEW**\n               phone_number: process.env.PHONE\n             },\n             content: {\n               title: \"Welcome!\",\n               body: \"Thanks for signing up, {{name}}\",\n             },\n             data: {\n               name: \"@shreythecray\",\n             },\n             routing: {\n               //**NEW**\n               method: \"single\",\n               channels: [\"email\", \"sms\"],\n             },\n           },\n         });\n\n         console.log(requestId)\n   }\n\n   send()\n   ```\n\n   * Send to all listed channels:\n   ```javascript\n   sync function send() {\n       const { requestId } = await courier.send({\n           message: {\n             to: {\n               email: process.env.EMAIL,\n               //**NEW**\n               phone_number: process.env.PHONE\n             },\n             content: {\n               title: \"Welcome!\",\n               body: \"Thanks for signing up, {{name}}\",\n             },\n             data: {\n               name: \"@shreythecray\",\n             },\n             routing: {\n               //**NEW**\n               method: \"all\",\n               channels: [\"email\", \"sms\"],\n             },\n           },\n         });\n\n         console.log(requestId)\n   }\n\n   send()\n   ```\n\nExample SMS received:\n\n\u003cimg width=\"603\" alt=\"0-sms\" src=\"https://user-images.githubusercontent.com/28051494/179704311-975122dd-ade0-41c1-a43c-d2b2506ce26f.png\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrycourier%2Fdemo-nodejs-send","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrycourier%2Fdemo-nodejs-send","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrycourier%2Fdemo-nodejs-send/lists"}