Send MMS with Node.js, Express, and Vonage: A Developer Guide - code-examples -

Frequently Asked Questions

Use the Vonage Messages API and Node.js SDK (@vonage/messages) with an Express server. Create an API endpoint that accepts recipient number and image URL, then uses the SDK to send the MMS message via Vonage.
It's a unified API from Vonage that lets you send various message types, including SMS, MMS, and WhatsApp messages, all through a single interface.
Vonage uses webhooks to send delivery receipts and status updates for your outgoing MMS messages, even if you're only sending and not receiving messages in your app. These webhooks must return a 200 OK status quickly.
Use the @vonage/messages SDK when building Node.js applications that send MMS or other messages through the Vonage Messages API. Don't use the older @vonage/server-sdk for this specific API.
Vonage's MMS sending with the Messages API is primarily for US numbers sending to US recipients. International MMS support is limited, so check the Vonage documentation for specifics on supported routes.
In the Vonage Dashboard, create a new application, enable the 'Messages' capability, generate public/private keys, link your US MMS number, and configure webhook URLs for status updates and inbound messages.
The imageUrl must be a publicly accessible URL directly to the image file (like .jpg, .png, or .gif). Vonage servers need to fetch the image from this URL, so it can't be behind a login or require special headers.
Trial accounts can only send to numbers you've verified and whitelisted in your Vonage Dashboard settings. Add the recipient's number to your 'Allowed Numbers' list.
Configure a webhook URL for status updates in your Vonage Application settings and implement the /webhooks/status endpoint in your Express app to process the delivery status data sent by Vonage.
The private.key file contains the private key of your Vonage application, used for authentication and secure communication with the Vonage API. Keep this file secure and never commit it to version control.
Double-check your VONAGE_API_KEY and VONAGE_API_SECRET in your .env file. Ensure they match the credentials from your Vonage API Dashboard and that the .env file is being loaded correctly by your application.
Set the Default SMS API to 'Messages API' in your Vonage Account settings *before* sending MMS. This ensures compatibility with the @vonage/messages SDK and correct webhook formatting.
Use ngrok to create a public URL for your local server, configure the ngrok URL as your webhook URL in your Vonage Application, and then send test requests to your local endpoint using tools like curl or Postman.
It's the file path to your private.key file relative to the root of your project. Ensure it's correct, as the Vonage SDK needs to load this key for authentication.