List All Contacts
Retrieves a paginated list of all contacts messages with optional filtering, searching, and ordering.
HTTP Request
GET/api/contacts/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO AN EXTRA REDIRECT WITH 301 STATUS
Authorization
Authorization
- Required: Yes
- Permission: Staff with ContactPermission or Admin
- Permission Code: 4002
- Authentication: Token-based (Authorization: Token <your_api_key>)
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | — | Number of results to return per page. |
| offset | integer | — | Number of results to skip before returning results. |
| search | string | — | Search term to lookup results by`id`, `subject`, `first_name`, `last_name`, `email`, and `mobile_number`. |
| ordering | string | — | Order results by (`id`, `created_at`, `updated_at`, `viewed`, `viewed_at`, `subject`) |
| is_viewed | boolean | — | Filter by viewed status (`true` for viewed, `false` for not viewed). |
| viewed_date | string | — | Exact viewed date (`YYYY-MM-DD`). |
| viewed_date_from | string | — | Start date for contacts viewed after this date (`YYYY-MM-DD`). |
| viewed_date_to | string | — | End date for contacts viewed before this date (`YYYY-MM-DD`). |
| has_message | boolean | — | Filter by contacts that have a message (`true` for contacts with a message, `false` for those without). |
| has_mobile_number | boolean | — | Filter by contacts that have a mobile number (`true` for contacts with a mobile number, `false` for those without). |
| has_email | boolean | — | Filter by contacts that have an email address (`true` for contacts with an email, `false` for those without). |
| has_first_name | boolean | — | Filter by contacts that have a first name (`true` for contacts with a first name, `false` for those without). |
| has_last_name | boolean | — | Filter by contacts that have a last name (`true` for contacts with a last name, `false` for those without). |
| id_min | integer | — | Minimum ID of the contact. |
| id_max | integer | — | Maximum ID of the contact. |
| created_date | string | — | Exact creation date (`YYYY-MM-DD`). |
| updated_date | string | — | Exact last update date (`YYYY-MM-DD`). |
| created_from | string | — | Start date for contacts created after this date (`YYYY-MM-DD`). |
| updated_from | string | — | Start date for contacts updated after this date (`YYYY-MM-DD`). |
| created_to | string | — | End date for contacts created before this date (`YYYY-MM-DD`). |
| updated_to | string | — | End date for contacts updated before this date (`YYYY-MM-DD`). |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List all contacts
4response = requests.get('http://www.example.com/api/contacts/',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())1# List all contacts
2curl "http://www.example.com/api/contacts/" -H "Authorization: Token <your_api_key>"Contact Object Structure
| Field | Type | Description |
|---|---|---|
| count | Integer | Total number of categories |
| next | String | URL for the next page of results |
| previous | String | URL for the previous page of results |
| results | Array[Object] | Array of Contact objects |
Contact Object Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the contact. |
| first_name | String | The first name of the contact (nullable). |
| last_name | String | The last name of the contact (nullable). |
| String | The email address of the contact (nullable). | |
| mobile_number | String | Mobile number associated with the contact (nullable, valid iranian mobile number). |
| subject | String | The subject of the contact. |
| message | String | The message content of the contact (nullable). |
| viewed | Boolean | Whether the contact has been viewed. |
| viewed_at | String (ISO 8601) | Timestamp when the contact was viewed(nullable). |
| created_at | String (ISO 8601) | Timestamp when the contact was created. |
| updated_at | String (ISO 8601) | Timestamp when the contact was last updated. |
Example Response
{
"count": 16,
"next": "http://127.0.0.1:8000/api/contacts/?limit=3&offset=3",
"previous": null,
"results": [
{
"id": 16,
"first_name": "بهرام",
"last_name": "صادقیپور",
"email": null,
"mobile_number": "09492230370",
"subject": "Et necessitatibus molestiae est enim aliquam laborum.",
"message": "Dolores ullam qui quia sunt quo reiciendis. Ullam id omnis voluptas. Magni temporibus rerum. Et et et ut. Distinctio ipsam officiis quaerat. Accusantium eum ut adipisci et molestias nobis quos.",
"viewed": false,
"viewed_at": null,
"created_at": "2025-12-22T16:04:12.709202Z",
"updated_at": "2025-12-22T16:04:12.709209Z"
},
{
"id": 15,
"first_name": "بهرام",
"last_name": "احدی",
"email": null,
"mobile_number": "09739292354",
"subject": "Optio adipisci assumenda vel.",
"message": "default question",
"viewed": false,
"viewed_at": null,
"created_at": "2025-12-22T14:01:53.811903Z",
"updated_at": "2025-12-22T14:01:53.811909Z"
},
{
"id": 14,
"first_name": "پژمان",
"last_name": "فرهمند",
"email": null,
"mobile_number": "09683800286",
"subject": "Rerum voluptas voluptatem ullam et eum quis.",
"message": "hey",
"viewed": false,
"viewed_at": null,
"created_at": "2025-12-22T14:01:49.942276Z",
"updated_at": "2025-12-22T14:01:49.942282Z"
}
]
}