Create a new address

This code snippet creates a new address.

Example

Replace the following variables in the example code:

KeyDescription
ADDRESS_NAME

The name of the address.

ADDRESS_LINE_1

The first line of the full address.

ADDRESS_LINE_2

The second line of the full address.

ADDRESS_CITY

The city where this address is located.

ADDRESS_REGION

The state or region of the address.

ADDRESS_TYPE

The type of address.

ADDRESS_LOCATION_TYPE

The address location type, as domestic or business.

ADDRESS_POSTAL_CODE

The postal code.

ADDRESS_COUNTRY

The two character country code in ISO 3166-1 alpha-2 format.

Write the code

Add the following to create-address.sh:

curl -X "POST" "https://api.nexmo.com/v1/addresses" \
     -H 'Content-Type: application/json' \
     -u "$VONAGE_API_KEY:$VONAGE_API_SECRET" \
     -d $'{
           "address_name": "'$ADDRESS_NAME'",
           "address_line1": "'$ADDRESS_LINE_1'",
           "address_line2": "'$ADDRESS_LINE_2'",
           "city": "'$ADDRESS_CITY'",
           "region": "'$ADDRESS_REGION'",
           "type": "'$ADDRESS_TYPE'",
           "address_location_type": "'$ADDRESS_LOCATION_TYPE'",
           "postal_code": "'$ADDRESS_POSTAL_CODE'",
           "country": "'$ADDRESS_COUNTRY'"
     }'

View full source

Run your code

Save this file to your machine and run it:

bash create-address.sh