Skip to main content

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

FieldTypeRequiredDescription
subjectStringYesThe subject of the contact.
messageStringNoThe message content of the contact.
first_nameStringNoThe first name of the contact.
last_nameStringNoThe last name of the contact.
emailStringNoThe email address of the contact.
mobile_numberStringNoMobile number associated with the contact.

Example Requests

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())

Status Codes

CodeDescription
201Product created successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the contact.
subjectStringThe subject of the contact.
messageStringThe message content of the contact.
first_nameStringThe first name of the contact.
last_nameStringThe last name of the contact.
emailStringThe email address of the contact.
mobile_numberStringMobile number associated with the contact.
viewedBooleanWhether the contact has been viewed.
viewed_atString (ISO 8601)Timestamp when the contact was viewed.
created_atString (ISO 8601)Timestamp when the contact was created.
updated_atString (ISO 8601)Timestamp when the contact was last updated.