Skip to content

Sky.Cms.Api.Shared Documentation

Summary

Reference for Sky.Cms.Api.Shared — the shared contact form API used across Editor and Publisher, including endpoints, architecture, and configuration.

Overview

Sky.Cms.Api.Shared is a .NET library that implements a custom CQRS-like pattern for handling API endpoints and business logic. Currently, it provides a contact form API that allows website administrators to receive visitor messages with built-in CAPTCHA validation and rate limiting.

Latest Updates: See Integration Updates for recent changes and integration notes.

Architecture

The API follows a modular architecture organized by features:

  • Controllers: HTTP API endpoints exposed to consumers
  • Services: Business logic for processing requests
  • Features: CQRS-style commands and queries organized by feature
  • Models: Data transfer objects and configuration classes
  • Extensions: Dependency injection setup and configuration
%%{init: {"theme":"base","themeVariables":{"primaryColor":"#eef6ff","primaryTextColor":"#0f172a","primaryBorderColor":"#2563eb","lineColor":"#334155","secondaryColor":"#f8fafc","tertiaryColor":"#ffffff","fontFamily":"Segoe UI, Arial, sans-serif"}}}%%
flowchart LR
   Consumer[Browser or external site] --> Controller[Controllers]
   Controller --> Features[Feature commands and queries]
   Features --> Services[Services]
   Services --> Models[DTOs and config models]
   Features --> Extensions[DI and configuration extensions]

See Architecture Overview for detailed information about the design patterns and structure.

Features

Contact Form API

A complete contact form submission system with:

  • Email notifications to administrators
  • CAPTCHA validation (reCAPTCHA or Cloudflare Turnstile)
  • Rate limiting per IP address
  • Anti-forgery token protection
  • Comprehensive error handling and logging
  • Flexible field name mapping for custom forms

See Contact Form API Documentation for complete endpoint details and usage examples.

Getting Started

Installation & Configuration

  1. Register the API services in your host application's Program.cs:
builder.Services.AddContactApi(builder.Configuration);
  1. Configure rate limiting middleware:
app.UseRateLimiter();
app.MapControllers();
  1. Add configuration to appsettings.json:
{
  "ContactApi": {
    "AdminEmail": "[email protected]",
    "MaxMessageLength": 5000,
    "RequireCaptcha": true,
    "CaptchaProvider": "turnstile",
    "CaptchaSiteKey": "your-site-key",
    "CaptchaSecretKey": "your-secret-key"
  }
}

Quick Tutorial

Want to add a contact form to your website? Follow the Step-by-Step Tutorial to get a working form in 5 minutes.

See Configuration Guide for all configuration options and environment variable support.

API Endpoints

Contact Form

  • GET /_api/contact/skycms-contact.js - Returns JavaScript library with embedded configuration
  • POST /_api/contact/submit - Submit a contact form

See Contact Form API for request/response schemas and examples.

For Developers

Future Enhancements

The API is designed to be extensible. Future endpoints may include:

  • Additional contact types or specialized forms
  • API authentication and authorization
  • More complex business logic operations

The modular feature-based architecture makes it easy to add new endpoints.

License

Licensed under the MIT License. See LICENSE-MIT in the repository root.