Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 1.63 KB

File metadata and controls

83 lines (63 loc) · 1.63 KB

API Endpoints

This document describes all available HTTP endpoints for the Contact Us API.

GET /api/token

Generate a short-lived token for form submission. This should be called when the contact form page loads.

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_in": 300
}

Rate Limit: Per IP address

POST /api/contact

Submit contact form data. Requires a valid token and signature.

Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "message": "Hello, I would like to get in touch...",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "signature": "abc123def456...",
  "timestamp": 1699123456
}

Response:

{
  "status": "success",
  "message": "Your message has been received."
}

Rate Limit: Per IP and per origin

POST /api/signature

Generate an HMAC signature for contact form data. This endpoint validates the token and generates the signature server-side, keeping the signing secret secure.

Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "message": "Hello, I would like to get in touch...",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "timestamp": 1699123456
}

Response:

{
  "signature": "abc123def456...",
  "timestamp": 1699123456
}

Rate Limit: Per IP and per origin

Note: This endpoint requires a valid token from /api/token. The signing secret is kept server-side for security.

GET /health

Health check endpoint. Useful for monitoring and load balancer health checks.

Response:

{
  "status": "healthy"
}

Rate Limit: None