Contacts API
- September 1, 2022
- AmpenetSolutions
- 0
The Ampenet SMS Contacts API allows you to manage contacts identifiable by a unique random ID. You can use this ID to create, view, update, or remove contacts. This API functions as a database of customer-specific contacts, allowing you to organize them and provide custom values that you may then utilize when sending SMS template messages.
The Contacts API employs HTTP verbs and a RESTful endpoint structure, as well as an access key for API authorization. The payloads of requests and responses are represented as JSON with UTF-8 encoding and URL encoded values.
API Endpoint
https://sms.ampenet.com/api/v3/contacts
Parameters
PARAMETER | REQUIRED | DESCRIPTION |
---|---|---|
Authorization | When calling our API, send your api token with the authentication type set as Bearer (Example: Authorization: Bearer {api_token}) | |
Accept | Set to application/json |
Create a Contact
This method creates a new contact object. With each request, Ampenet SMS returns the newly created contact object.
API Endpoint
https://sms.ampenet.com/api/v3/contacts/{group_id}/store
Parameters
PARAMETER | REQUIRED | TYPE | DESCRIPTION |
---|---|---|---|
group_id | string | Contact groups uid | |
phone | number | The phone number of the contact. | |
first_name | No | string | The first name of the contact. |
last_name | No | string | The last name of the contact. |
Example Request (PHP)
curl -X POST https://sms.ampenet.com/api/v3/contacts/6065ecdc9184a/store \
-H 'Authorization: Bearer 7|xs6pv2dspHJq8sWLhrpNFH5YLilMRQcVxLwSw2Sd' \
-d "phone=31612345678"
Returns (JSON)
Returns a contact object if the request was successful.
{
"status": "success",
"data": "contacts data with all details",
}
If the request failed, an error object will be returned.
{
"status": "error",
"message" : "A human-readable description of the error."
}
View a Contact
Returns the contact details for an existing contact. You simply need to supply the unique contact uid and group uid that was returned when the contact or group was created or received.
API Endpoint
https://sms.ampenet.com/api/v3/contacts/{group_id}/search/{uid}
Parameters
PARAMETER | REQUIRED | TYPE | DESCRIPTION |
---|---|---|---|
group_id | string | Contact groups uid | |
uid | string | Contact uid |
Example Request (PHP)
curl -X POST https://sms.ampenet.com/api/v3/contacts/6065ecdc9184a/search/606732aec8705 \
-H 'Authorization: Bearer 7|xs6pv2dspHJq8sWLhrpNFH5YLilMRQcVxLwSw2Sd'
Returns (JSON)
Returns a contact object if the request was successful.
{
"status": "success",
"data": "contacts data with all details",
}
If the request failed, an error object will be returned.
{
"status": "error",
"message" : "A human-readable description of the error."
}
Update a Contact
Updates an existing contact. You simply need to supply the unique contact uid and contact group uid that was returned when the contact was created.
API Endpoint
https://sms.ampenet.com/api/v3/contacts/{group_id}/update/{uid}
Parameters
PARAMETER | REQUIRED | TYPE | DESCRIPTION |
---|---|---|---|
group_id | string | Contact groups uid | |
uid | string | Contact uid | |
phone | number | The phone number of the contact. | |
first_name | No | string | The first name of the contact. |
last_name | No | string | The last name of the contact. |
Example Request (PHP)
curl -X PATCH https://sms.ampenet.com/api/v3/contacts/6065ecdc9184a/update/606732aec8705 \
-H 'Authorization: Bearer 7|xs6pv2dspHJq8sWLhrpNFH5YLilMRQcVxLwSw2Sd' \
-d "phone=31612345678"
Returns (JSON)
Returns a contact object if the request was successful.
{
"status": "success",
"data": "contacts data with all details",
}
If the request failed, an error object will be returned.
{
"status": "error",
"message" : "A human-readable description of the error."
}
Delete a Contact
Deletes an existing contact. You only need to supply the unique contact uid and group uid that was returned upon creation.
API Endpoint
https://sms.ampenet.com/api/v3/contacts/{group_id}/delete/{uid}
Parameters
PARAMETER | REQUIRED | TYPE | DESCRIPTION |
---|---|---|---|
group_id | string | Contact groups uid | |
uid | string | Contact uid |
Example Request (PHP)
curl -X DELETE https://sms.ampenet.com/api/v3/contacts/6065ecdc9184a/delete/606732aec8705 \
-H 'Authorization: Bearer 7|xs6pv2dspHJq8sWLhrpNFH5YLilMRQcVxLwSw2Sd'
Returns (JSON)
Returns a contact object if the request was successful.
{
"status": "success",
"data": "contacts data with all details",
}
If the request failed, an error object will be returned.
{
"status": "error",
"message" : "A human-readable description of the error."
}
View All Contacts in a Group
Lists all contacts in a group.
API Endpoint
https://sms.ampenet.com/api/v3/contacts/{group_id}/all
Parameters
PARAMETER | REQUIRED | TYPE | DESCRIPTION |
---|---|---|---|
group_id | string | Contact groups uid |
Example Request (PHP)
curl -X POST https://sms.ampenet.com/api/v3/contacts/6065ecdc9184a/all \
-H 'Authorization: Bearer 7|xs6pv2dspHJq8sWLhrpNFH5YLilMRQcVxLwSw2Sd'
Returns (JSON)
Returns a contact object if the request was successful.
{
"status": "success",
"data": "contacts data with pagination",
}
If the request failed, an error object will be returned.
{
"status": "error",
"message" : "A human-readable description of the error."
}