Contacts API

Base route: /api/contacts  |  Content-Type: application/json

Tip: This site enforces HTTPS redirection. Always call the API using https:// (or a relative path like /api/contacts) so requests such as POST/PUT aren't converted to GET during a redirect.
MCP Server: The Contacts API is also exposed as an MCP server (Streamable HTTP) at /mcp, with tools GetContacts, GetContact, CreateContact, UpdateContact, and DeleteContact for use by MCP-compatible AI agents and clients (e.g. VS Code, Claude Desktop). Point your MCP client at https://<your-host>/mcp.

Endpoints

Method Route Description Body
GET /api/contacts Get all contacts
GET /api/contacts/{id} Get a single contact by id
POST /api/contacts Create a new contact { "name", "email", "phone", "address", "status" }
PUT /api/contacts/{id} Update an existing contact (body id must match route id) { "id", "name", "email", "phone", "address", "status" }
DELETE /api/contacts/{id} Delete a contact by id

Sample requests

# Create
curl -X POST "https://<your-host>/api/contacts" ^
  -H "Content-Type: application/json" ^
  -d "{\"name\":\"Jane Doe\",\"email\":\"jane.doe@example.com\",\"phone\":\"555-123-4567\",\"address\":\"123 Main St\",\"status\":true}"

# Get all
curl "https://<your-host>/api/contacts"

# Get by id
curl "https://<your-host>/api/contacts/1"

# Update
curl -X PUT "https://<your-host>/api/contacts/1" ^
  -H "Content-Type: application/json" ^
  -d "{\"id\":1,\"name\":\"Jane Smith\",\"email\":\"jane.smith@example.com\",\"phone\":\"555-987-6543\",\"address\":\"456 Oak Ave\",\"status\":false}"

# Delete
curl -X DELETE "https://<your-host>/api/contacts/1"
$baseUrl = "https://<your-host>/api/contacts"

# Create
$body = @{ name="Jane Doe"; email="jane.doe@example.com"; phone="555-123-4567"; address="123 Main St"; status=$true } | ConvertTo-Json
$created = Invoke-RestMethod -Uri $baseUrl -Method Post -Body $body -ContentType "application/json"
$id = $created.id

# Get all
Invoke-RestMethod -Uri $baseUrl -Method Get

# Get by id
Invoke-RestMethod -Uri "$baseUrl/$id" -Method Get

# Update
$updateBody = @{ id=$id; name="Jane Smith"; email="jane.smith@example.com"; phone="555-987-6543"; address="456 Oak Ave"; status=$false } | ConvertTo-Json
Invoke-RestMethod -Uri "$baseUrl/$id" -Method Put -Body $updateBody -ContentType "application/json"

# Delete
Invoke-RestMethod -Uri "$baseUrl/$id" -Method Delete

Try it live

Requests below are sent (via fetch) to /api/contacts on this same site.

Create contact (POST)
Get by id (GET)
Delete (DELETE)
Response