# Integrating delivery feedback with Node.js There are two endpoints we'll put into play to integrate delivery feedback: 1. First, we'll prepare a batch for delivery feedback by enabling it in our `/batches` POST Send request. 2. Then, we'll send another POST request to `/delivery_feedback` using the batch ID. ## Add delivery feedback to a batch The parameter we are concerned with for this first step is `feeback_enabled` in the **POST Send** request for the `/batches` endpoint. By setting `feedback_enabled` to `true` we are telling the API that we would like to *allow* feedback on this particular batch to be sent back to Sinch for routing optimization. ## Add the code to your file Copy and paste the "Set delivery feedback to true" code into a new file called `allowDelivery.mjs`. Set delivery feedback to true // Find your Service Plan ID and API Token at dashboard.sinch.com/sms/api/rest // Find your Sinch virtual numbers at dashboard.sinch.com/numbers/your-numbers/numbers const SERVICE_PLAN_ID = 'YOUR_service_plan_id'; const API_TOKEN = 'YOUR_API_token'; const SINCH_NUMBER = 'YOUR_Sinch_virtual_number'; const TO_NUMBER = 'recipient_numbers'; import fetch from 'node-fetch'; async function run() { const resp = await fetch( 'https://us.sms.api.sinch.com/xms/v1/' + SERVICE_PLAN_ID + '/batches', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + API_TOKEN }, body: JSON.stringify({ from: SINCH_NUMBER, to: [ TO_NUMBER ], body: 'Only the best route for this message.', type: 'mt_text', feedback_enabled: 'true', delivery_report: 'full' }) } ); const data = await resp.json(); console.log(data); } run(); ### Fill in your parameters 1. Assign your values to the following parameters: | Parameter | Your value | | --- | --- | | `SERVICE_PLAN_ID` | The service plan ID found on your [Sinch Build Dashboard](https://dashboard.sinch.com/sms/api/rest). SMS > APIs > REST configuration. | | `API_TOKEN` | The API token found on your [Sinch Build Dashboard](https://dashboard.sinch.com/sms/api/rest). SMS > APIs > REST configuration > Click Show to reveal your API token. | | `SINCH_NUMBER` | A free test number or any Sinch virtual number you've rented. Find the number on your [Sinch Build Dashboard](https://dashboard.sinch.com/sms/api/rest) by clicking the service plan ID link and scrolling to the bottom of the page. | | `TO_NUMBER` | Your receipient number(s). The phone number(s) to which you want to send the test SMS message. Even if you only send to one number, it is inside an array. | | `feedback_enabled` | Here is where you'll set the feedback status to `true`. This parameter is a boolean value and by default it is set to `false`. | 1. Save the file. ## Run the code 1. Run the following command in your terminal/command prompt to create a group: ```shell node allowDelivery.mjs ``` 1. Copy the batch ID value in the response. ### Successful Response A successful response will look like this: ```javascript { id: '01000008YAZ00000TMJ000005W', to: [ '12065551234' ], from: '12065555678', canceled: false, body: 'Only the best route for this message.', type: 'mt_text', created_at: '2022-08-03T20:15:49.706Z', modified_at: '2022-08-03T20:15:49.706Z', delivery_report: 'full', expire_at: '2022-08-06T20:15:49.706Z', feedback_enabled: true, flash_message: false } ``` Once the user has received a message on their device and you have received a successful reponse, you've now given permission to send delivery feedback for this batch to Sinch for optimal message routing. Let's go one step further and configure your batch to send feedback. Configure my batch for delivery feedback -> [Go Back](/docs/sms/tutorials/node/delivery-feedback/next_1)