Skip to main content
POST
/
api
/
portfolios
/
{slug}
/
contact
Send Contact Message
curl --request POST \
  --url https://api.example.com/api/portfolios/{slug}/contact \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "email": "<string>",
  "message": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "timestamp": "<string>",
  "data": null
}
This endpoint allows visitors to send contact messages to portfolio owners. No authentication is required. The portfolio owner will receive an email notification with the message details.

Path Parameters

slug
string
required
The portfolio owner’s unique slug identifier (e.g., “john-doe”)

Request Body

name
string
required
Sender’s full name (max 120 characters)
email
string
required
Sender’s email address (max 160 characters, must be valid email format)
message
string
required
The contact message content (max 5000 characters)

Response

success
boolean
required
Indicates if the message was sent successfully
message
string
required
A descriptive message about the response
timestamp
string
required
ISO 8601 timestamp of when the response was generated
data
null
required
Always null for this endpoint

Example Request

curl -X POST https://api.portfoliohub.com/api/portfolios/john-doe/contact \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Smith",
    "email": "[email protected]",
    "message": "Hi John, I came across your portfolio and would love to discuss a potential collaboration on a React project. Are you available for freelance work?"
  }'

Example Response

Success Response

{
  "success": true,
  "message": "Mensaje enviado exitosamente",
  "timestamp": "2026-03-09T10:30:00Z",
  "data": null
}

Error Responses

Portfolio Not Found

{
  "success": false,
  "message": "Profile not found with slug: invalid-slug",
  "timestamp": "2026-03-09T10:30:00Z",
  "data": null
}

Validation Errors

{
  "success": false,
  "message": "Validation failed",
  "timestamp": "2026-03-09T10:30:00Z",
  "data": {
    "name": "Name cannot be empty",
    "email": "Must be a valid email address",
    "message": "Message cannot be empty"
  }
}

Invalid Email Format

{
  "success": false,
  "message": "Validation failed",
  "timestamp": "2026-03-09T10:30:00Z",
  "data": {
    "email": "Must be a valid email address"
  }
}

Message Too Long

{
  "success": false,
  "message": "Validation failed",
  "timestamp": "2026-03-09T10:30:00Z",
  "data": {
    "message": "Message must not exceed 5000 characters"
  }
}

Validation Rules

Name Field

  • Required: Yes
  • Max length: 120 characters
  • Cannot be blank

Email Field

  • Required: Yes
  • Max length: 160 characters
  • Must be valid email format
  • Cannot be blank

Message Field

  • Required: Yes
  • Max length: 5000 characters
  • Cannot be blank

Behavior

  1. When a message is successfully submitted:
    • The message is saved to the database with status “NEW”
    • An email notification is sent to the portfolio owner’s registered email
    • The sender receives a success response
  2. The portfolio owner receives an email containing:
    • Sender’s name and email
    • The complete message
    • A link to view the message in their dashboard
  3. Messages are stored and can be managed through the authenticated API endpoints

Use Cases

  • Contact forms on portfolio websites
  • Inquiry submission for freelance work
  • Collaboration requests
  • General networking and outreach
  • Job opportunities and recruitment

Rate Limiting

While this endpoint doesn’t require authentication, it’s recommended to implement client-side rate limiting to prevent abuse:
  • Disable submit button for 5-10 seconds after successful submission
  • Show confirmation message to user
  • Clear form fields after successful submission

Security Notes

  • No authentication required (public endpoint)
  • All fields are validated on the server side
  • Email addresses are validated for proper format
  • Messages are sanitized before storage
  • Portfolio owners are notified via email automatically
  • Consider implementing CAPTCHA on the frontend to prevent spam

Best Practices

  1. Frontend Validation: Implement client-side validation matching server rules for better UX
  2. Error Handling: Display user-friendly error messages for validation failures
  3. Success Feedback: Show clear confirmation when message is sent successfully
  4. Form Reset: Clear the form after successful submission
  5. Loading States: Show loading indicator during submission
  6. Spam Prevention: Consider adding CAPTCHA or honeypot fields

Build docs developers (and LLMs) love