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.

Request

POST /api/v1/contact/submit

project_keystringrequired

Your project's unique identifier (UUID format)

Example: 550e8400-e29b-41d4-a716-446655440000

namestringrequired

The sender's name

Example: "Jane Doe"

emailstringrequired

The sender's email address (must be a valid email format)

Example: "jane@example.com"

subjectstring

Subject line for the contact message (optional)

Example: "Question about pricing"

messagestringrequired

The contact message text. Cannot be empty.

Example: "I'd like to learn more about your enterprise plan."

pathstring

The page path where the form was submitted (optional)

Example: /pricing

Best Practice: Use window.location.pathname to capture the current page

versionstring

Application or content version (optional)

Examples: 1.2.3, v2.0.0-beta

Response

statusnumber

HTTP status code

  • 200 - Contact message submitted successfully
  • 400 - Invalid request (missing required fields, invalid email format)
  • 403 - Origin not allowed for this project
  • 404 - Project not found
  • 500 - Internal server error

Success Response

http
HTTP/1.1 200 OK

Error Responses

{
  "error": "Invalid email format"
}

Examples

Basic Contact Submission

javascript
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

javascript
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

bash
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:

html
<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
Navigation