Update Contact
Update an existing contact.
HTTP Request
PATCH/api/contacts/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the contact to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| subject | String | No | The subject of the contact. |
| message | String | No | The message content of the contact. |
| first_name | String | No | The first name of the contact. |
| last_name | String | No | The last name of the contact. |
| String | No | The email address of the contact. | |
| mobile_number | String | No | Mobile number associated with the contact. |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token <your_api_key>'})
5response = api.patch('http://www.example.com/api/contacts/<ID>', json={
6 'subject': 'New Subject',
7 'message': 'Updated message content.',
8 'first_name': 'John',
9 'last_name': 'Doe',
10 'email': 'john.doe@example.com',
11 'mobile_number': '123-456-7890'
12})
13print(response.json())1curl "http://www.example.com/api/contacts/<ID>" -X PATCH -H "Content-Type: application/json" -d '{
2 "subject": "New Subject",
3 "message": "Updated message content.",
4 "first_name": "John",
5 "last_name": "Doe",
6 "email": "john.doe@example.com",
7 "mobile_number": "123-456-7890"
8 }'Status Codes
| Code | Description |
|---|---|
| 200 | Contact updated successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Contact not found |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the contact |
| subject | String | The subject of the contact |
| message | String | The message content of the contact |
| first_name | String | The first name of the contact |
| last_name | String | The last name of the contact |
| String | The email address of the contact | |
| mobile_number | String | Mobile number associated with the contact |
| viewed | Boolean | Whether the contact has been viewed |
| viewed_at | String (ISO 8601) | Timestamp when the contact was viewed |
| created_at | String (ISO 8601) | Timestamp when the contact was created |
| updated_at | String (ISO 8601) | Timestamp when the contact was last updated |