Create a Template Fragment

A Template Fragment is the template's content, identified uniquely by it's channel and locale. To create a Fragment, you will need to have already created a Template.

KeyDescription
VONAGE_APPLICATION_ID

The Vonage Application ID.

VONAGE_APPLICATION_PRIVATE_KEY_PATH

Private key path.

JWT

Used to authenticate your request. See Authentication for more information, including how to generate a JWT.

TEMPLATE_ID

The custom template ID

Write the code

Add the following to create-template-fragment.sh:

curl -X POST "https://api.nexmo.com/v2/verify/templates/$VERIFY_TEMPLATE_ID/template_fragments" \
  -H "Authorization: Bearer $JWT"\
  -H 'Content-Type: application/json' \
  -d $'{
	  "channel": "sms",
    "locale": "en-us",
    "text": "The authentication code for your ${brand} is: ${code}"
  }'

View full source

Run your code

Save this file to your machine and run it:

sh create-template-fragment.sh