Skip to content

C API Reference

C API Reference v0.17.0

Functions

spikard_schema_query_only()

Create a simple schema configuration with only Query type.

This is a convenience function for schemas that only have queries.

Returns:

A QueryOnlyConfig with default settings

Signature:

SPIKARDAlefHandle spikard_schema_query_only();

Example:

SPIKARDAlefHandle result = spikard_schema_query_only();

Returns: SPIKARDAlefHandle


spikard_schema_query_mutation()

Create a schema configuration with Query and Mutation types.

This is a convenience function for schemas with queries and mutations but no subscriptions.

Returns:

A QueryMutationConfig with default settings

Signature:

SPIKARDAlefHandle spikard_schema_query_mutation();

Example:

SPIKARDAlefHandle result = spikard_schema_query_mutation();

Returns: SPIKARDAlefHandle


spikard_schema_full()

Create a schema configuration with all three root types.

This is a convenience function for fully-featured schemas.

Returns:

A FullSchemaConfig with default settings

Signature:

SPIKARDAlefHandle spikard_schema_full();

Example:

SPIKARDAlefHandle result = spikard_schema_full();

Returns: SPIKARDAlefHandle


Types

SPIKARDApiKeyAuthConfig

C representation: SPIKARDApiKeyAuthConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDApiKeyAuthConfig does not appear anywhere in the generated header.

Per-route API key authentication requirement.

Mirrors spikard_http.ApiKeyConfig for the same reason JwtAuthConfig mirrors spikard_http.JwtConfig: spikard-core cannot depend on spikard-http.

Field Type Default Description
enabled int32_t true Whether this per-route API key auth requirement is active. Present on 10/10 api_key_auth fixture payloads in the corpus; defaults to true for the same reason as JwtAuthConfig.enabled.
keys const char* /* serde(default) */ Valid API keys. Defaults to empty (rather than being a required field) so that fixtures/server_config.json's server_jwt_and_api_key_auth_combined payload ({"enabled": true, "header": "X-API-Key"}, no keys at all) deserializes instead of hard-failing with "missing field keys". An empty list is NOT "allow everyone": a later enforcement phase MUST treat an empty keys list as a hard misconfiguration error, never as an open gate.
header_name const char* "X-API-Key" Header name to check (e.g., "X-API-Key")

SPIKARDApiKeyConfig

C representation: SPIKARDApiKeyConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDApiKeyConfig does not appear anywhere in the generated header.

API Key authentication configuration

Field Type Default Description
keys const char* Valid API keys
header_name const char* "X-API-Key" Header name to check (e.g., "X-API-Key")

SPIKARDAsyncApiConfig

C representation: SPIKARDAsyncApiConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDAsyncApiConfig does not appear anywhere in the generated header.

AsyncAPI HTTP endpoint configuration

Field Type Default Description
enabled int32_t Enable AsyncAPI endpoints (default: false)
spec const char* NULL Pre-registered AsyncAPI spec to serve from GET /asyncapi.json

SPIKARDAuthorizationConfig

C representation: SPIKARDAuthorizationConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDAuthorizationConfig does not appear anywhere in the generated header.

Per-route roles/scopes/permissions authorization requirement.

spikard_http.auth.Claims does not yet carry roles, scopes, or permissions, so nothing can enforce this today. This type only defines the requirement shape; a later phase must extend Claims (or an equivalent claims-decoding path) to populate them before enforcement is possible.

Deserialization goes through AuthorizationConfigRepr rather than a derive so the fixture's singular {"required_role": "admin"} shape (fixtures/problem_details.json's problem_details_403_forbidden) populates required_roles instead of being silently dropped as an unrecognized field — a config that parses to "no constraint" from real authorization data is a vacuous-pass bug, not a compatibility shim. deny_unknown_fields on the repr means any other unrecognized key is a loud deserialize error instead.

Field Type Default Description
required_roles const char* NULL Roles the authenticated caller must have
required_scopes const char* NULL OAuth-style scopes the authenticated caller must have
required_permissions const char* NULL Fine-grained permissions the authenticated caller must have
require_all int32_t true When true, the caller must satisfy every listed requirement (AND); when false, any single listed requirement is sufficient (OR)

SPIKARDBackgroundJobMetadata

C representation: SPIKARDBackgroundJobMetadata is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDBackgroundJobMetadata does not appear anywhere in the generated header.

Field Type Default Description
name const char* "background_task" The name
request_id const char* NULL Request id

SPIKARDBackgroundTaskConfig

C representation: SPIKARDBackgroundTaskConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDBackgroundTaskConfig does not appear anywhere in the generated header.

Configuration for in-process background task execution.

Field Type Default Description
enabled int32_t false Whether the server starts a background task executor at router-construction time. ServerConfig.background_tasks is a bare struct rather than an Option, so its mere presence cannot mean "configured" the way Option-shaped middleware config does — every server has one. Without this flag every router build would spawn an executor task, which also requires an ambient Tokio runtime that a synchronous build_router_* caller may not have. Defaults to false so opting in is explicit, and matches the corpus vocabulary: fixtures/background_tasks.json spells its per-route payloads {"enabled": true, ...}.
max_queue_size uintptr_t 1024 Maximum queue size
max_concurrent_tasks uintptr_t 128 Maximum concurrent tasks
drain_timeout_secs uint64_t 30 Drain timeout secs

SPIKARDCompressionConfig

C representation: SPIKARDCompressionConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDCompressionConfig does not appear anywhere in the generated header.

Compression configuration shared across runtimes

Field Type Default Description
gzip int32_t true Enable gzip compression
brotli int32_t true Enable brotli compression
min_size uintptr_t 1024 Minimum response size to compress (bytes)
quality uint32_t 6 Compression quality (0-11 for brotli, 0-9 for gzip)

SPIKARDContactInfo

C representation: SPIKARDContactInfo is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDContactInfo does not appear anywhere in the generated header.

Contact information

Field Type Default Description
name const char* NULL Name of the contact person or organisation.
email const char* NULL Contact email address.
url const char* NULL URL pointing to the contact information page.

SPIKARDCorsConfig

C representation: SPIKARDCorsConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDCorsConfig does not appear anywhere in the generated header.

CORS configuration for a route

Field Type Default Description
allowed_origins const char* ["*"] Allowed origins
allowed_methods const char* ["*"] Allowed methods
allowed_headers const char* NULL Allowed headers
expose_headers const char* NULL Expose headers
max_age uint32_t* NULL Maximum age
allow_credentials int32_t* NULL Allow credentials

SPIKARDDynamicSchemaConfig

C representation: SPIKARDDynamicSchemaConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDDynamicSchemaConfig does not appear anywhere in the generated header.

Configuration for building and executing a dynamic-SDL schema.

Field Type Default Description
introspection_enabled int32_t Whether introspection queries (__schema, __type) are permitted.
max_complexity uintptr_t* NULL Maximum query complexity (NULL = unlimited).
max_depth uintptr_t* NULL Maximum query depth (NULL = unlimited).
field_errors const char* NULL Field-level errors to inject at specific response paths.

SPIKARDFieldErrorSpec

C representation: SPIKARDFieldErrorSpec is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDFieldErrorSpec does not appear anywhere in the generated header.

A field-level error to inject at a specific response path.

path is the dot-separated sequence of field names from the operation root to the field that should fail, e.g. "user" for a top-level field or "order.customer" for a nested one.

Field Type Default Description
path const char* Dot-separated path to the field that should error.
message const char* The error message to surface for that field.

SPIKARDFullSchemaConfig

C representation: SPIKARDFullSchemaConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDFullSchemaConfig does not appear anywhere in the generated header.

Configuration for fully-featured schemas with Query, Mutation, and Subscription types

Field Type Default Description
introspection_enabled int32_t true Enable introspection queries
complexity_limit uintptr_t* NULL Maximum query complexity (None = unlimited)
depth_limit uintptr_t* NULL Maximum query depth (None = unlimited)

SPIKARDGraphQlRouteConfig

C representation: SPIKARDGraphQlRouteConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDGraphQlRouteConfig does not appear anywhere in the generated header.

Configuration for GraphQL routes

Provides a builder pattern for configuring GraphQL route parameters for the Spikard HTTP server's routing system.

Methods
spikard_graph_ql_route_config_new()

Create a new GraphQL route configuration with defaults

Default values:

  • path: "/graphql"
  • method: "POST"
  • enable_playground: false

Signature:

SPIKARDAlefHandle spikard_graph_ql_route_config_new();

Example:

SPIKARDAlefHandle result = spikard_graph_ql_route_config_new();

Returns: SPIKARDAlefHandle

spikard_graph_ql_route_config_path()

Set the HTTP path for the GraphQL endpoint

Signature:

SPIKARDAlefHandle spikard_graph_ql_route_config_path(SPIKARDAlefHandle this, const char* path);

Example:

SPIKARDAlefHandle result = spikard_graph_ql_route_config_path(instance, "value");

Parameters:

Name Type Required Description
path const char* Yes The URL path (e.g., "/graphql", "/api/graphql")

Returns: SPIKARDAlefHandle

spikard_graph_ql_route_config_method()

Set the HTTP method for the GraphQL endpoint

Signature:

SPIKARDAlefHandle spikard_graph_ql_route_config_method(SPIKARDAlefHandle this, const char* method);

Example:

SPIKARDAlefHandle result = spikard_graph_ql_route_config_method(instance, "value");

Parameters:

Name Type Required Description
method const char* Yes The HTTP method (typically "POST")

Returns: SPIKARDAlefHandle

spikard_graph_ql_route_config_enable_playground()

Enable or disable the GraphQL Playground UI

Signature:

SPIKARDAlefHandle spikard_graph_ql_route_config_enable_playground(SPIKARDAlefHandle this, int32_t enable);

Example:

SPIKARDAlefHandle result = spikard_graph_ql_route_config_enable_playground(instance, true);

Parameters:

Name Type Required Description
enable int32_t Yes Whether to enable playground

Returns: SPIKARDAlefHandle

spikard_graph_ql_route_config_description()

Set a custom description for documentation

Signature:

SPIKARDAlefHandle spikard_graph_ql_route_config_description(SPIKARDAlefHandle this, const char* description);

Example:

SPIKARDAlefHandle result = spikard_graph_ql_route_config_description(instance, "value");

Parameters:

Name Type Required Description
description const char* Yes Documentation string

Returns: SPIKARDAlefHandle

spikard_graph_ql_route_config_get_path()

Get the configured path

Signature:

const char* spikard_graph_ql_route_config_get_path(SPIKARDAlefHandle this);

Example:

const char *result = spikard_graph_ql_route_config_get_path(instance);

Returns: const char*

spikard_graph_ql_route_config_get_method()

Get the configured method

Signature:

const char* spikard_graph_ql_route_config_get_method(SPIKARDAlefHandle this);

Example:

const char *result = spikard_graph_ql_route_config_get_method(instance);

Returns: const char*

spikard_graph_ql_route_config_is_playground_enabled()

Check if playground is enabled

Signature:

int32_t spikard_graph_ql_route_config_is_playground_enabled(SPIKARDAlefHandle this);

Example:

int32_t result = spikard_graph_ql_route_config_is_playground_enabled(instance);

Returns: int32_t

spikard_graph_ql_route_config_get_description()

Get the description if set

Signature:

const char* spikard_graph_ql_route_config_get_description(SPIKARDAlefHandle this);

Example:

const char* result = spikard_graph_ql_route_config_get_description(instance);

Returns: const char*


SPIKARDGrpcConfig

C representation: SPIKARDGrpcConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDGrpcConfig does not appear anywhere in the generated header.

Configuration for gRPC support

Controls how the server handles gRPC requests, including compression, timeouts, and protocol settings.

Stream Limits

This configuration enforces message-level size limits but delegates concurrent stream limiting to the HTTP/2 transport layer:

  • Message Size Limits: The max_message_size field is enforced per individual message (request or response) in both unary and streaming RPCs. When a single message exceeds this limit, the request is rejected with PAYLOAD_TOO_LARGE (HTTP 413).

  • Concurrent Stream Limits: The max_concurrent_streams is an advisory configuration passed to the HTTP/2 layer for connection-level stream negotiation. The HTTP/2 transport automatically enforces this limit and returns GOAWAY frames when exceeded. Applications should not rely on custom enforcement of this limit.

  • Stream Response Size Limits: The max_stream_response_bytes field caps the total encoded bytes emitted across a server-streaming or bidi-streaming response. When the cumulative size exceeds the limit, the stream is terminated with tonic.Status.resource_exhausted. Defaults to NULL (unbounded).

Field Type Default Description
enabled int32_t true Enable gRPC support
max_message_size uintptr_t 4194304 Maximum message size in bytes (for both sending and receiving) This limit applies to individual messages in both unary and streaming RPCs. When a single message exceeds this size, the request is rejected with HTTP 413 (Payload Too Large). Default: 4MB (4194304 bytes) Note: This limit does NOT apply to the total response size in streaming RPCs. For multi-message streams, the total response can exceed this limit as long as each individual message stays within the limit.
enable_compression int32_t true Enable gzip compression for gRPC messages
request_timeout uint64_t* NULL Timeout for gRPC requests in seconds (None = no timeout)
max_concurrent_streams uint32_t 100 Maximum number of concurrent streams per connection (HTTP/2 advisory) This value is communicated to HTTP/2 clients as the server's flow control limit. The HTTP/2 transport layer enforces this limit automatically via SETTINGS frames and GOAWAY responses. Applications should NOT implement custom enforcement. Default: 100 streams per connection # Stream Limiting Strategy - Per Connection: This limit applies per HTTP/2 connection, not globally - Transport Enforcement: HTTP/2 handles all stream limiting; applications need not implement custom checks - Streaming Requests: In server streaming or bidi streaming, each logical RPC consumes one stream slot. Message ordering within a stream follows HTTP/2 frame ordering.
enable_keepalive int32_t true Enable HTTP/2 keepalive
keepalive_interval uint64_t 75 HTTP/2 keepalive interval in seconds
keepalive_timeout uint64_t 20 HTTP/2 keepalive timeout in seconds
max_stream_response_bytes uintptr_t* NULL Total byte cap across an entire streaming response. When Some(n), the streaming adapter aborts the stream with tonic.Status.resource_exhausted once the cumulative encoded message bytes exceed n. The stream yields the error item and then terminates. Per-message cap remains max_message_size. This limit applies to server-streaming and bidirectional-streaming RPCs only; unary RPCs are governed solely by max_message_size. Default: NULL (unbounded total response size).

SPIKARDIntoHandler

C representation: SPIKARDIntoHandler is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDIntoHandler does not appear anywhere in the generated header.

Convert user-facing handler functions into the low-level Handler trait.

Methods
spikard_into_handler_into_handler()

Convert this value into a shared request handler.

Signature:

SPIKARDAlefHandle spikard_into_handler_into_handler(SPIKARDAlefHandle this);

Example:

SPIKARDAlefHandle result = spikard_into_handler_into_handler(instance);

Returns: SPIKARDAlefHandle


SPIKARDJsonRpcConfig

C representation: SPIKARDJsonRpcConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDJsonRpcConfig does not appear anywhere in the generated header.

JSON-RPC server configuration

Field Type Default Description
enabled int32_t true Enable JSON-RPC endpoint
endpoint_path const char* "/rpc" HTTP endpoint path for JSON-RPC requests (default: "/rpc")
enable_batch int32_t true Enable batch request processing (default: true)
max_batch_size uintptr_t 100 Maximum number of requests in a batch (default: 100)

SPIKARDJsonRpcMethodInfo

C representation: SPIKARDJsonRpcMethodInfo is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDJsonRpcMethodInfo does not appear anywhere in the generated header.

JSON-RPC method metadata for routes that support JSON-RPC

This struct captures the metadata needed to expose HTTP routes as JSON-RPC methods, enabling discovery and documentation of RPC-compatible endpoints.

Field Type Default Description
method_name const char* The JSON-RPC method name (e.g., "user.create")
description const char* NULL Optional description of what the method does
params_schema const char* NULL Optional JSON Schema for method parameters
result_schema const char* NULL Optional JSON Schema for the result
deprecated int32_t /* serde(default) */ Whether this method is deprecated
tags const char* /* serde(default) */ Tags for categorizing and grouping methods

SPIKARDJwtAuthConfig

C representation: SPIKARDJwtAuthConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDJwtAuthConfig does not appear anywhere in the generated header.

Per-route JWT authentication requirement.

spikard-http defines the canonical JwtConfig used by ServerConfig.jwt_auth, but spikard-core cannot depend on spikard-http (the dependency runs the other way), so that type cannot be reused here. This mirrors its fields so a later enforcement phase in spikard-http can convert between the two without losing information.

secret and public_key are both optional because asymmetric algorithms (RS256, ES256, ...) verify against a public key rather than a shared secret; see fixtures/auth.json's jwt_config_algorithm_rs256, which carries public_key and no secret at all. Exactly one is expected to be populated for a given algorithm, but that cross-field invariant is left to a later enforcement phase rather than the type itself.

Field Type Default Description
enabled int32_t true Whether this per-route JWT auth requirement is active. Present on 21/21 jwt_auth fixture payloads in the corpus; defaults to true because presence of a jwt_auth block has always meant "enabled" up to now. Without this field a fixture setting "enabled": false would silently keep auth on while the fixture's parse still succeeds — a vacuous pass.
secret const char* /* serde(default) */ Symmetric secret key for JWT verification (HS256, HS384, HS512)
public_key const char* /* serde(default) */ Asymmetric public key for JWT verification (RS256, ES256, etc.)
algorithm const char* "HS256" Required algorithm (HS256, HS384, HS512, RS256, etc.)
audience const char* NULL Required audience claim
issuer const char* NULL Required issuer claim
leeway uint64_t /* serde(default) */ Leeway for expiration checks (seconds)

SPIKARDJwtConfig

C representation: SPIKARDJwtConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDJwtConfig does not appear anywhere in the generated header.

JWT authentication configuration

Field Type Default Description
secret const char* Secret key for JWT verification
algorithm const char* "HS256" Required algorithm (HS256, HS384, HS512, RS256, etc.)
audience const char* NULL Required audience claim
issuer const char* NULL Required issuer claim
leeway uint64_t /* serde(default) */ Leeway for expiration checks (seconds)

SPIKARDLicenseInfo

C representation: SPIKARDLicenseInfo is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDLicenseInfo does not appear anywhere in the generated header.

License information

Field Type Default Description
name const char* SPDX license identifier or display name (e.g. "MIT").
url const char* NULL URL to the full license text.

SPIKARDLifecycleHookRef

C representation: SPIKARDLifecycleHookRef is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDLifecycleHookRef does not appear anywhere in the generated header.

A single lifecycle hook reference within a LifecycleHooksConfig phase.

Matches the fixture shape exactly (fixtures/lifecycle_hooks.json, fixtures/di.json): each entry is an object with a required name and handler, an optional list of dependency keys, and an optional free-form config blob (e.g. {"max_requests": 10, "window_seconds": 60} for a rate-limiting hook). deny_unknown_fields turns future fixture drift into a loud error.

Field Type Default Description
name const char* Registered name of the hook to run, resolved against the server's LifecycleHooks
handler const char* Name of the handler function this hook invokes
dependencies const char* NULL Dependency keys this hook requires (for DI), resolved before the hook runs
config const char* NULL Optional free-form configuration passed to the hook (e.g. rate-limit thresholds)
order uint32_t* NULL Explicit execution order within the phase, where the corpus states one (fixtures/lifecycle_hooks.json's hook_execution_order). Array position already implies an order, so this exists to let a fixture assert ordering rather than rely on it.

SPIKARDLifecycleHooksConfig

C representation: SPIKARDLifecycleHooksConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDLifecycleHooksConfig does not appear anywhere in the generated header.

Per-route selection of registered lifecycle hooks.

ServerConfig.lifecycle_hooks holds Arc<dyn LifecycleHook> function pointers and is marked #[serde(skip)] / #[alef(skip)] because closures cannot be serialized or cross the FFI boundary. A per-route field with that same shape would be invisible to alef, and therefore invisible to every binding — defeating the purpose of exposing it here. This descriptor carries LifecycleHookRef entries instead: each one names a registered hook (plus its declared dependencies and optional config), so a later enforcement phase can resolve those names against the server's registered LifecycleHooks and run the matches for this route. The five fields mirror the five hook phases documented in the tower-middleware-and-lifecycle project convention (onRequest, preValidation, preHandler, onResponse, onError).

Field Type Default Description
on_request const char* NULL Hooks to run in the on_request phase
pre_validation const char* NULL Hooks to run in the pre_validation phase
pre_handler const char* NULL Hooks to run in the pre_handler phase
on_response const char* NULL Hooks to run in the on_response phase
on_error const char* NULL Hooks to run in the on_error phase

SPIKARDOpenApiConfig

C representation: SPIKARDOpenApiConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDOpenApiConfig does not appear anywhere in the generated header.

OpenAPI configuration

Field Type Default Description
enabled int32_t false Enable OpenAPI generation (default: false for zero overhead)
title const char* "API" API title
version const char* "1.0.0" API version
description const char* NULL API description (supports markdown)
swagger_ui_path const char* "/docs" Path to serve Swagger UI (default: "/docs")
redoc_path const char* "/redoc" Path to serve Redoc (default: "/redoc")
openapi_json_path const char* "/openapi.json" Path to serve OpenAPI JSON spec (default: "/openapi.json")
contact SPIKARDAlefHandle NULL Contact information
license SPIKARDAlefHandle NULL License information
servers const char* NULL Server definitions
security_schemes const char* NULL Security schemes (auto-detected from middleware if not provided)

SPIKARDParseRequest

C representation: SPIKARDParseRequest is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDParseRequest does not appear anywhere in the generated header.

Request body for POST /asyncapi/parse

Field Type Default Description
spec const char* Spec

SPIKARDParseResult

C representation: SPIKARDParseResult is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDParseResult does not appear anywhere in the generated header.

Full parse result returned by POST /asyncapi/parse

Field Type Default Description
spec_version const char* Spec version
title const char* Title
api_version const char* Api version
channels const char* Channels
operations const char* Operations
messages const char* Messages

SPIKARDParsedChannel

C representation: SPIKARDParsedChannel is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDParsedChannel does not appear anywhere in the generated header.

A single channel extracted from an AsyncAPI spec

Field Type Default Description
name const char* Channel key from the spec (e.g. "chat/messages")
address const char* Channel address / path
messages const char* Message names declared on this channel
bindings const char* NULL Bindings (ws / http / amqp / …) as raw JSON for forward-compatibility

SPIKARDParsedMessage

C representation: SPIKARDParsedMessage is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDParsedMessage does not appear anywhere in the generated header.

A resolved message (name + JSON Schema)

Field Type Default Description
name const char* Message name
schema const char* NULL Resolved JSON Schema for the message payload, if available

SPIKARDParsedOperation

C representation: SPIKARDParsedOperation is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDParsedOperation does not appear anywhere in the generated header.

A single operation extracted from an AsyncAPI spec

Field Type Default Description
name const char* Operation name
action const char* Operation action: "send" or "receive"
channel const char* Channel reference (resolved to the channel name)

SPIKARDProblemDetails

C representation: SPIKARDProblemDetails is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDProblemDetails does not appear anywhere in the generated header.

RFC 9457 Problem Details for HTTP APIs

A machine-readable format for specifying errors in HTTP API responses. Per RFC 9457, all fields are optional. The type field defaults to "about:blank" if not specified.

Content-Type

Responses using this struct should set:

Content-Type: application/problem+json
{
  "type": "<https://spikard.dev/errors/validation-error>",
  "title": "Request Validation Failed",
  "status": 422,
  "detail": "2 validation errors in request body",
  "errors": [...]
}
Field Type Default Description
type_uri const char* "about:blank" A URI reference that identifies the problem type. Defaults to "about:blank" when absent. Should be a stable, human-readable identifier for the problem type.
title const char* "" A short, human-readable summary of the problem type. Should not change from occurrence to occurrence of the problem.
status uint16_t 500 The HTTP status code generated by the origin server. This is advisory; the actual HTTP status code takes precedence.
detail const char* NULL A human-readable explanation specific to this occurrence of the problem.
instance const char* NULL A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
extensions const char* NULL Extension members - problem-type-specific data. For validation errors, this typically contains an "errors" array.

SPIKARDQueryMutationConfig

C representation: SPIKARDQueryMutationConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDQueryMutationConfig does not appear anywhere in the generated header.

Configuration for schemas with Query and Mutation types

Field Type Default Description
introspection_enabled int32_t true Enable introspection queries
complexity_limit uintptr_t* NULL Maximum query complexity (None = unlimited)
depth_limit uintptr_t* NULL Maximum query depth (None = unlimited)

SPIKARDQueryOnlyConfig

C representation: SPIKARDQueryOnlyConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDQueryOnlyConfig does not appear anywhere in the generated header.

Configuration for schemas with only Query type

Field Type Default Description
introspection_enabled int32_t true Enable introspection queries
complexity_limit uintptr_t* NULL Maximum query complexity (None = unlimited)
depth_limit uintptr_t* NULL Maximum query depth (None = unlimited)

SPIKARDRateLimitConfig

C representation: SPIKARDRateLimitConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDRateLimitConfig does not appear anywhere in the generated header.

Rate limiting configuration shared across runtimes

Field Type Default Description
per_second uint64_t 100 Requests per second
burst uint32_t 200 Burst allowance
ip_based int32_t true Use IP-based rate limiting

SPIKARDRequest

C representation: SPIKARDRequest is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDRequest does not appear anywhere in the generated header.


SPIKARDRequestIdConfig

C representation: SPIKARDRequestIdConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDRequestIdConfig does not appear anywhere in the generated header.

Per-route request-id generation/propagation override.

Modeled as a struct rather than Option<bool> on RouteMetadata because the wire shape is an object, not a bare boolean: fixtures/request_id.json's request_id_middleware_can_be_disabled sends {"enabled": false}, which Option<bool> cannot deserialize at all ("invalid type: map, expected a boolean") — the very fixture whose purpose is proving the middleware can be disabled was the one that failed to parse.

Field Type Default Description
enabled int32_t Whether request-id generation/propagation is active for this route

SPIKARDResponse

C representation: SPIKARDResponse is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDResponse does not appear anywhere in the generated header.

HTTP Response with custom status code, headers, and content

Field Type Default Description
content const char* NULL Response body content
status_code uint16_t 200 HTTP status code (defaults to 200)
headers const char* NULL Response headers

SPIKARDRouteBuilder

C representation: SPIKARDRouteBuilder is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDRouteBuilder does not appear anywhere in the generated header.

Builder for defining a route.

Methods
spikard_route_builder_new()

Create a new builder for the provided HTTP method and path.

Signature:

SPIKARDAlefHandle spikard_route_builder_new(SPIKARDAlefHandle method, const char* path);

Example:

SPIKARDAlefHandle result = spikard_route_builder_new(0, "value");

Parameters:

Name Type Required Description
method SPIKARDAlefHandle Yes The method
path const char* Yes Path to the file

Returns: SPIKARDAlefHandle

spikard_route_builder_handler_name()

Assign an explicit handler name.

Signature:

SPIKARDAlefHandle spikard_route_builder_handler_name(SPIKARDAlefHandle this, const char* name);

Example:

SPIKARDAlefHandle result = spikard_route_builder_handler_name(instance, "value");

Parameters:

Name Type Required Description
name const char* Yes The name

Returns: SPIKARDAlefHandle

spikard_route_builder_request_schema_json()

Provide a raw JSON schema for the request body.

Signature:

SPIKARDAlefHandle spikard_route_builder_request_schema_json(SPIKARDAlefHandle this, const char* schema);

Example:

SPIKARDAlefHandle result = spikard_route_builder_request_schema_json(instance, NULL);

Parameters:

Name Type Required Description
schema const char* Yes The schema

Returns: SPIKARDAlefHandle

spikard_route_builder_response_schema_json()

Provide a raw JSON schema for the response body.

Signature:

SPIKARDAlefHandle spikard_route_builder_response_schema_json(SPIKARDAlefHandle this, const char* schema);

Example:

SPIKARDAlefHandle result = spikard_route_builder_response_schema_json(instance, NULL);

Parameters:

Name Type Required Description
schema const char* Yes The schema

Returns: SPIKARDAlefHandle

spikard_route_builder_params_schema_json()

Provide a raw JSON schema for request parameters.

Signature:

SPIKARDAlefHandle spikard_route_builder_params_schema_json(SPIKARDAlefHandle this, const char* schema);

Example:

SPIKARDAlefHandle result = spikard_route_builder_params_schema_json(instance, NULL);

Parameters:

Name Type Required Description
schema const char* Yes The schema

Returns: SPIKARDAlefHandle

spikard_route_builder_file_params_json()

Provide multipart file parameter configuration.

Signature:

SPIKARDAlefHandle spikard_route_builder_file_params_json(SPIKARDAlefHandle this, const char* schema);

Example:

SPIKARDAlefHandle result = spikard_route_builder_file_params_json(instance, NULL);

Parameters:

Name Type Required Description
schema const char* Yes The schema

Returns: SPIKARDAlefHandle

spikard_route_builder_cors()

Attach a CORS configuration for this route.

Signature:

SPIKARDAlefHandle spikard_route_builder_cors(SPIKARDAlefHandle this, SPIKARDAlefHandle cors);

Example:

SPIKARDAlefHandle result = spikard_route_builder_cors(instance, 0);

Parameters:

Name Type Required Description
cors SPIKARDAlefHandle Yes The cors config

Returns: SPIKARDAlefHandle

spikard_route_builder_compression()

Attach a compression configuration for this route.

Signature:

SPIKARDAlefHandle spikard_route_builder_compression(SPIKARDAlefHandle this, SPIKARDAlefHandle compression);

Example:

SPIKARDAlefHandle result = spikard_route_builder_compression(instance, 0);

Parameters:

Name Type Required Description
compression SPIKARDAlefHandle Yes The compression config

Returns: SPIKARDAlefHandle

spikard_route_builder_body_limit()

Attach a per-route maximum request body size in bytes, overriding the server-global default.

Signature:

SPIKARDAlefHandle spikard_route_builder_body_limit(SPIKARDAlefHandle this, uintptr_t max_bytes);

Example:

SPIKARDAlefHandle result = spikard_route_builder_body_limit(instance, 42);

Parameters:

Name Type Required Description
max_bytes uintptr_t Yes The max bytes

Returns: SPIKARDAlefHandle

spikard_route_builder_request_timeout()

Attach a per-route request timeout in seconds, overriding the server-global default.

Signature:

SPIKARDAlefHandle spikard_route_builder_request_timeout(SPIKARDAlefHandle this, uint64_t seconds);

Example:

SPIKARDAlefHandle result = spikard_route_builder_request_timeout(instance, 42);

Parameters:

Name Type Required Description
seconds uint64_t Yes The seconds

Returns: SPIKARDAlefHandle

spikard_route_builder_rate_limit()

Attach a per-route rate limiting configuration, overriding the server-global default.

Signature:

SPIKARDAlefHandle spikard_route_builder_rate_limit(SPIKARDAlefHandle this, SPIKARDAlefHandle rate_limit);

Example:

SPIKARDAlefHandle result = spikard_route_builder_rate_limit(instance, 0);

Parameters:

Name Type Required Description
rate_limit SPIKARDAlefHandle Yes The rate limit config

Returns: SPIKARDAlefHandle

spikard_route_builder_request_id()

Force per-route request-id generation on or off, overriding the server-global default.

Takes a plain bool rather than RequestIdConfig directly: the wire/metadata type had to become a struct to represent {"enabled": false} (see RequestIdConfig's docs), but this builder is the ergonomic call site (.request_id(true)), so it keeps accepting a bool and wraps it into RequestIdConfig internally in Self.into_metadata.

Signature:

SPIKARDAlefHandle spikard_route_builder_request_id(SPIKARDAlefHandle this, int32_t enabled);

Example:

SPIKARDAlefHandle result = spikard_route_builder_request_id(instance, true);

Parameters:

Name Type Required Description
enabled int32_t Yes The enabled

Returns: SPIKARDAlefHandle

spikard_route_builder_jwt_auth()

Require JWT authentication for this route.

Signature:

SPIKARDAlefHandle spikard_route_builder_jwt_auth(SPIKARDAlefHandle this, SPIKARDAlefHandle config);

Example:

SPIKARDAlefHandle result = spikard_route_builder_jwt_auth(instance, 0);

Parameters:

Name Type Required Description
config SPIKARDAlefHandle Yes The configuration options

Returns: SPIKARDAlefHandle

spikard_route_builder_api_key_auth()

Require API key authentication for this route.

Signature:

SPIKARDAlefHandle spikard_route_builder_api_key_auth(SPIKARDAlefHandle this, SPIKARDAlefHandle config);

Example:

SPIKARDAlefHandle result = spikard_route_builder_api_key_auth(instance, 0);

Parameters:

Name Type Required Description
config SPIKARDAlefHandle Yes The configuration options

Returns: SPIKARDAlefHandle

spikard_route_builder_authorization()

Attach a roles/scopes/permissions authorization requirement for this route.

Signature:

SPIKARDAlefHandle spikard_route_builder_authorization(SPIKARDAlefHandle this, SPIKARDAlefHandle config);

Example:

SPIKARDAlefHandle result = spikard_route_builder_authorization(instance, 0);

Parameters:

Name Type Required Description
config SPIKARDAlefHandle Yes The configuration options

Returns: SPIKARDAlefHandle

spikard_route_builder_lifecycle_hooks()

Select registered lifecycle hooks to run for this route.

Signature:

SPIKARDAlefHandle spikard_route_builder_lifecycle_hooks(SPIKARDAlefHandle this, SPIKARDAlefHandle hooks);

Example:

SPIKARDAlefHandle result = spikard_route_builder_lifecycle_hooks(instance, 0);

Parameters:

Name Type Required Description
hooks SPIKARDAlefHandle Yes The lifecycle hooks config

Returns: SPIKARDAlefHandle

spikard_route_builder_jsonrpc_method()

Expose this route as a JSON-RPC method.

Signature:

SPIKARDAlefHandle spikard_route_builder_jsonrpc_method(SPIKARDAlefHandle this, SPIKARDAlefHandle info);

Example:

SPIKARDAlefHandle result = spikard_route_builder_jsonrpc_method(instance, 0);

Parameters:

Name Type Required Description
info SPIKARDAlefHandle Yes The json rpc method info

Returns: SPIKARDAlefHandle

spikard_route_builder_openrpc_spec()

Attach a literal OpenRPC method spec document for this route, overriding auto-derivation from the Self.jsonrpc_method metadata when present.

Signature:

SPIKARDAlefHandle spikard_route_builder_openrpc_spec(SPIKARDAlefHandle this, const char* spec);

Example:

SPIKARDAlefHandle result = spikard_route_builder_openrpc_spec(instance, NULL);

Parameters:

Name Type Required Description
spec const char* Yes The spec

Returns: SPIKARDAlefHandle

spikard_route_builder_sync()

Mark the route as synchronous.

Signature:

SPIKARDAlefHandle spikard_route_builder_sync(SPIKARDAlefHandle this);

Example:

SPIKARDAlefHandle result = spikard_route_builder_sync(instance);

Returns: SPIKARDAlefHandle

spikard_route_builder_handler_dependencies()

Declare the dependency keys that must be resolved before this handler runs.

Signature:

SPIKARDAlefHandle spikard_route_builder_handler_dependencies(SPIKARDAlefHandle this, const char* dependencies);

Example:

SPIKARDAlefHandle result = spikard_route_builder_handler_dependencies(instance, NULL);

Parameters:

Name Type Required Description
dependencies const char* Yes The dependencies

Returns: SPIKARDAlefHandle


SPIKARDSchemaConfig

C representation: SPIKARDSchemaConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDSchemaConfig does not appear anywhere in the generated header.

Configuration for GraphQL schema building.

Encapsulates all schema-level configuration options including introspection control, complexity limits, and depth limits.

Field Type Default Description
introspection_enabled int32_t true Enable introspection queries
complexity_limit uintptr_t* NULL Maximum query complexity (None = unlimited)
depth_limit uintptr_t* NULL Maximum query depth (None = unlimited)

SPIKARDServerConfig

C representation: SPIKARDServerConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDServerConfig does not appear anywhere in the generated header.

Server configuration

Field Type Default Description
host const char* "127.0.0.1" Host to bind to
port uint16_t 8000 Port to bind to
workers uintptr_t 1 Number of Tokio runtime worker threads used by binding-managed server runtimes
enable_request_id int32_t false Enable request ID generation and propagation
max_body_size uintptr_t* 10485760 Maximum request body size in bytes (None = unlimited, not recommended)
request_timeout uint64_t* NULL Request timeout in seconds (None = no timeout)
compression SPIKARDAlefHandle NULL Enable compression middleware
rate_limit SPIKARDAlefHandle NULL Enable rate limiting
jwt_auth SPIKARDAlefHandle NULL JWT authentication configuration
api_key_auth SPIKARDAlefHandle NULL API Key authentication configuration
static_files const char* NULL Static file serving configuration
graceful_shutdown int32_t true Enable graceful shutdown on SIGTERM/SIGINT
shutdown_timeout uint64_t 30 Graceful shutdown timeout (seconds)
asyncapi SPIKARDAlefHandle NULL AsyncAPI HTTP endpoint configuration
openapi SPIKARDAlefHandle NULL OpenAPI documentation configuration
jsonrpc SPIKARDAlefHandle NULL JSON-RPC configuration
grpc SPIKARDAlefHandle NULL gRPC configuration
background_tasks SPIKARDAlefHandle Background task executor configuration
enable_http_trace int32_t false Enable per-request HTTP tracing (tower-http TraceLayer)

SPIKARDServerInfo

C representation: SPIKARDServerInfo is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDServerInfo does not appear anywhere in the generated header.

Server information

Field Type Default Description
url const char* Base URL of the server (e.g. "<https://api.example.com/v1>").
description const char* NULL Optional human-readable description of the server environment.

SPIKARDSseEvent

C representation: SPIKARDSseEvent is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDSseEvent does not appear anywhere in the generated header.

An individual SSE event

Represents a single Server-Sent Event to be sent to a connected client. Events can have an optional type, ID, and retry timeout for advanced scenarios.

SSE Format

Events are serialized to the following text format:

event: event_type
data: {"json":"value"}
id: event-123
retry: 3000
Field Type Default Description
event_type const char* NULL Event type (optional)
data const char* Event data (JSON value)
id const char* NULL Event ID (optional, for client-side reconnection)
retry uint64_t* NULL Retry timeout in milliseconds (optional)

SPIKARDStaticFilesConfig

C representation: SPIKARDStaticFilesConfig is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDStaticFilesConfig does not appear anywhere in the generated header.

Static file serving configuration

Field Type Default Description
directory const char* Directory path to serve
route_prefix const char* URL path prefix (e.g., "/static")
index_file int32_t true Fallback to index.html for directories
cache_control const char* NULL Cache-Control header value

SPIKARDTestingSseEvent

C representation: SPIKARDTestingSseEvent is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDTestingSseEvent does not appear anywhere in the generated header.

A single Server-Sent Event.

Field Type Default Description
data const char* The data field of the event.

SPIKARDUploadFile

C representation: SPIKARDUploadFile is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDUploadFile does not appear anywhere in the generated header.

Represents an uploaded file from multipart/form-data requests.

This struct provides efficient access to file content with automatic base64 decoding and implements standard I/O traits for compatibility.

Field Type Default Description
filename const char* Original filename from the client
content_type const char* NULL MIME type of the uploaded file
size uintptr_t* NULL Size of the file in bytes
content const uint8_t* File content (may be base64 encoded)
content_encoding const char* NULL Content encoding type

SPIKARDValidateRequest

C representation: SPIKARDValidateRequest is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDValidateRequest does not appear anywhere in the generated header.

Request body for POST /asyncapi/validate

Field Type Default Description
spec const char* Spec
channel const char* Channel
message const char* Message
payload const char* Payload

SPIKARDValidationResponse

C representation: SPIKARDValidationResponse is a documentation-only name for this type. The C ABI hands you a scalar SPIKARDAlefHandle handle -- the literal string SPIKARDValidationResponse does not appear anywhere in the generated header.

Response body for POST /asyncapi/validate

Field Type Default Description
valid int32_t Valid
errors const char* Errors

Enums

SPIKARDMethod

HTTP method

Value Description
SPIKARD_GET Get
SPIKARD_POST Post
SPIKARD_PUT Put
SPIKARD_PATCH Patch
SPIKARD_DELETE Delete
SPIKARD_HEAD Head
SPIKARD_OPTIONS Options
SPIKARD_CONNECT Connect
SPIKARD_TRACE Trace

SPIKARDLifecycleHookPhase

The five lifecycle phases a hook can be registered against.

Used to resolve a per-route named hook selection (LifecycleHooksConfig in spikard-core.http) against the hooks actually registered on the server: a name is looked up within one specific phase's registered hooks, not across all five, so a hook registered for on_response can never be silently picked up by a route asking for on_request.

Value Description
SPIKARD_ON_REQUEST On request
SPIKARD_PRE_VALIDATION Pre validation
SPIKARD_PRE_HANDLER Pre handler
SPIKARD_ON_RESPONSE On response
SPIKARD_ON_ERROR On error

SPIKARDSecuritySchemeInfo

Security scheme types

Value Description
SPIKARD_HTTP Http — Fields: scheme: const char*, bearer_format: const char*
SPIKARD_API_KEY Api key — Fields: location: const char*, name: const char*

Errors

SPIKARDAppError

Error type for application builder operations.

Variant Description
SPIKARD_ROUTE Route registration failed.
SPIKARD_SERVER Server/router construction failed.
SPIKARD_DECODE Failed to extract DTO from the request context.
SPIKARD_GRAPH_QL GraphQL route registration failed (e.g. an unrecognized schema_type).

SPIKARDGraphQlError

Errors that can occur during GraphQL operations

These errors are compatible with async-graphql error handling and can be converted to structured HTTP responses matching the project's error fixtures.

Variant Description
SPIKARD_EXECUTION_ERROR Error during schema execution Occurs when the GraphQL executor encounters a runtime error during query execution.
SPIKARD_SCHEMA_BUILD_ERROR Error during schema building Occurs when schema construction fails due to invalid definitions or conflicts.
SPIKARD_REQUEST_HANDLING_ERROR Error during request handling Occurs when the HTTP request cannot be properly handled or parsed.
SPIKARD_SERIALIZATION_ERROR Serialization error Occurs during JSON serialization/deserialization of GraphQL values.
SPIKARD_JSON_ERROR JSON parsing error Occurs when JSON input cannot be parsed.
SPIKARD_VALIDATION_ERROR GraphQL validation error Occurs when a GraphQL query fails schema validation.
SPIKARD_PARSE_ERROR GraphQL parse error Occurs when the GraphQL query string cannot be parsed.
SPIKARD_AUTHENTICATION_ERROR Authentication error Occurs when request authentication fails.
SPIKARD_AUTHORIZATION_ERROR Authorization error Occurs when user lacks required permissions.
SPIKARD_NOT_FOUND Not found error Occurs when a requested resource is not found.
SPIKARD_RATE_LIMIT_EXCEEDED Rate limit error Occurs when rate limit is exceeded.
SPIKARD_INVALID_INPUT Invalid input error with validation details Occurs during input validation with detailed error information.
SPIKARD_COMPLEXITY_LIMIT_EXCEEDED Query complexity limit exceeded Occurs when a GraphQL query exceeds the configured complexity limit.
SPIKARD_DEPTH_LIMIT_EXCEEDED Query depth limit exceeded Occurs when a GraphQL query exceeds the configured depth limit.
SPIKARD_INTROSPECTION_DISABLED Introspection query rejected because introspection is disabled Occurs when a query selects __schema or __type while the schema was configured with introspection disabled.
SPIKARD_INTERNAL_ERROR Internal server error Occurs when an unexpected internal error happens.

SPIKARDSchemaError

Error type for schema building operations

Variant Description
SPIKARD_BUILDING_FAILED Generic schema building error
SPIKARD_VALIDATION_ERROR Configuration validation error
SPIKARD_COMPLEXITY_LIMIT_EXCEEDED Complexity limit exceeded
SPIKARD_DEPTH_LIMIT_EXCEEDED Depth limit exceeded

Edit this page on GitHub