Submit Contact Message
Submit a contact form message via the SeggWat contact widget or API integration
Overview
This endpoint accepts contact form submissions from users. It's the same endpoint used by the SeggWat contact widget and can be called directly for custom integrations.
Authentication
No API key required. The endpoint uses the project_key to associate contact messages with your project.
Ensure your project key is kept secure and only used on your own domains. Configure allowed origins in your project settings to prevent unauthorized submissions.
Request
POST /api/v1/contact/submit
project_keystringrequiredYour project's unique identifier (UUID format)
Example: 550e8400-e29b-41d4-a716-446655440000
namestringrequiredThe sender's name
Example: "Jane Doe"
emailstringrequiredThe sender's email address (must be a valid email format)
Example: "jane@example.com"
subjectstringSubject line for the contact message (optional)
Example: "Question about pricing"
messagestringrequiredThe contact message text. Cannot be empty.
Example: "I'd like to learn more about your enterprise plan."
pathstringThe page path where the form was submitted (optional)
Example: /pricing
Best Practice: Use window.location.pathname to capture the current page
versionstringApplication or content version (optional)
Examples: 1.2.3, v2.0.0-beta
Response
statusnumberHTTP status code
200- Contact message submitted successfully400- Invalid request (missing required fields, invalid email format)403- Origin not allowed for this project404- Project not found500- Internal server error
Success Response
HTTP/1.1 200 OKError Responses
{
"error": "Invalid email format"
}Examples
Basic Contact Submission
const response = await fetch('https://seggwat.com/api/v1/contact/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
project_key: '550e8400-e29b-41d4-a716-446655440000',
name: 'Jane Doe',
email: 'jane@example.com',
message: 'I have a question about your pricing plans.'
})
});
if (response.ok) {
console.log('Message sent successfully');
} else {
console.error('Failed to send message');
}With Subject and Path
await fetch('https://seggwat.com/api/v1/contact/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
project_key: '550e8400-e29b-41d4-a716-446655440000',
name: 'John Smith',
email: 'john@company.com',
subject: 'Enterprise inquiry',
message: 'We are interested in the enterprise plan for our team of 50.',
path: window.location.pathname
})
});cURL Example
curl -X POST "https://seggwat.com/api/v1/contact/submit" \
-H "Content-Type: application/json" \
-d '{
"project_key": "550e8400-e29b-41d4-a716-446655440000",
"name": "Jane Doe",
"email": "jane@example.com",
"subject": "Question about pricing",
"message": "I would like to learn more about your enterprise plan.",
"path": "/pricing"
}'CORS
The API supports Cross-Origin Resource Sharing (CORS) for browser requests. Ensure your domain is listed in the allowed origins for your project.
Allowed methods: POST, OPTIONS
Allowed headers: Content-Type
Widget Integration
Instead of calling this API directly, consider using the pre-built contact widget:
<script src="https://seggwat.com/static/widgets/v1/seggwat-contact.js"
data-project-key="your-project-key"></script>The widget handles:
- Form UI with name, email, subject, and message fields
- Client-side validation
- API calls and error handling
- Internationalization
- Accessibility and mobile responsiveness
