Update a subscriber’s email or mobile number
This tutorial demonstrates how to update a subscriber’s email address or mobile number using the Quoteable Service API. This process is useful when subscribers need to change their contact information.
Expected duration: Expect this tutorial to take about 15 minutes to complete.
Important notes
- You can update either the email, mobile, or both in a single request.
- If you only want to update one field, only include that field in your request body.
- The API returns the entire updated subscriber object, including fields you didn’t modify.
- Make sure the new email address is valid and the new mobile number is in the correct format.
Prerequisites
Before you start this tutorial:
- Make sure you have access to the Quoteable Service API.
- Make sure you have a tool such as Postman or cURL installed to make API requests.
- Know the
idof the subscriber you want to update.
Update subscriber information
To update a subscriber’s email or mobile number, send a PATCH request to the /subscribers/{id} endpoint with the updated information.
For endpoint details, see Update a subscriber.
Follow these steps:
- Open your API testing tool, such as Postman.
- Create a new request with the following details:
- METHOD: PATCH
- URL:
http://localhost:3000/subscribers/{id}(replace{id}with the actual subscriber ID) - Headers:
- Content-Type: application/json
- Request:
curl --request PATCH "http://localhost:3000/subscribers/{id}" \
--header "Content-Type: application/json" \
--data '{
"email": "new.email@example.com",
"mobile": "9876543210"
}'
Send the request.
A successful request returns a 200 OK status code with the updated subscriber object in the response body.
Example
Request:
curl --request PATCH "http://localhost:3000/subscribers/1" \
--header "Content-Type: application/json" \
--data '{
"email": "tony.stark.new@example.com",
"mobile": "2125559999"
}'
Response body:
{
"id": 1,
"lastName": "Stark",
"firstName": "Tony",
"email": "tony.stark.new@example.com",
"mobile": "2125559999",
"healthQuote": true,
"loveQuote": false,
"helpPplQuote": true,
"deliverTo": 1,
"frequency": 3
}
Error handling
If you encounter errors, here are some common issues and their solutions:
404 Not Found: Check that you’re using the correct subscriber ID.400 Bad Request: Make sure your JSON is correctly formatted.
What’s next?
Now that you’ve learned how to update a subscriber’s contact information, you can:
- Update other subscriber details, such as name or quote preferences.
- Retrieve the updated subscriber information to confirm changes.
- Use this method to build a user profile update feature in your application.