Create Contact
Create a new contact.
HTTP Request
POST/api/contacts
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| subject | String | Yes | 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
2api = requests.Session()
3api.headers.update({'Authorization': 'Token XXXXXXXXXXXXXXXXXXXXXX'})
4response = api.post('http://www.example.com/api/contacts/', json={
5 subject: "New Contact",
6 message: "Hello, this is a test contact.",
7 first_name: "John",
8 last_name: "Doe",
9 email: "john.doe@example.com",
10 mobile_number: "+1234567890"
11})
12print(response.json())1curl "http://www.example.com/api/contacts/" -X POST -H "Authorization: Token XXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{
2 subject: "New Contact",
3 message: "Hello, this is a test contact.",
4 first_name: "John",
5 last_name: "Doe",
6 email: "john.doe@example.com",
7 mobile_number: "+1234567890"
8}Status Codes
| Code | Description |
|---|---|
| 201 | Product created successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 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. |