Misar Docs
MisarMailMisar.BlogMisarReachMisarPostMisar.DevMisar PlatformMisar IdentityMisar Posts API
Sdks

C# SDK

Official Misar.Dev SDK for C# — build, deploy, and manage apps via api.misar.io/dev.

The official Misar.Dev client SDK for C#. Async, with built-in retries and typed exceptions. Targets .NET 8.

Installation

dotnet add package MisarDev

Requires .NET 8+.

Quick start

Construct a MisarDevClient with your API key (must start with mdk_) and point it at the Misar.Dev API:

using MisarDev;

using var client = new MisarDevClient(
    apiKey: "mdk_your_api_key",
    baseUrl: "https://api.misar.io/dev");

// List your projects
JsonElement projects = await client.ProjectsListAsync();
Console.WriteLine(projects);

MisarDevClient is IDisposable — dispose it (or use using) to release the internally-created HttpClient.

Configuration

ParameterDefaultDescription
apiKeyRequired. Must start with mdk_ or the constructor throws ArgumentException.
baseUrlhttps://misar.dev/apiSet to https://api.misar.io/dev.
maxRetries3Retry attempts for retryable status codes (429, 500, 502, 503, 504) with exponential backoff.
httpClientnullOptional pre-configured HttpClient (not disposed by the client when supplied).

Every request sends Authorization: Bearer <apiKey> and accepts application/json. Responses are returned as System.Text.Json.JsonElement.

Resources

This early v1.0.0 port implements the following methods. Each returns Task<JsonElement>.

MethodHTTPDescription
ProjectsListAsync()GET /projectsList projects.
ProjectsCreateAsync(object parameters)POST /projectsCreate a project.
TemplatesListAsync()GET /templatesList templates.
ApiKeysListAsync()GET /api-keysList API keys.
ChatCompleteAsync(object parameters)POST /chatSend a chat completion request.
UsageGetAsync()GET /usageRetrieve usage data.
// Create a project
JsonElement project = await client.ProjectsCreateAsync(new {
    name = "my-app",
    template = "nextjs"
});

// Chat completion
JsonElement reply = await client.ChatCompleteAsync(new {
    messages = new[] {
        new { role = "user", content = "Hello" }
    }
});

This is an early v1.0.0 port and intentionally exposes a subset of the full API surface (projects, templates, api-keys, chat, usage). Other resources available in the TypeScript SDK are not yet ported.

Error handling

Non-success responses throw a MisarDevException, specialized by status:

ExceptionStatusNotes
AuthException401Invalid or missing API key.
RateLimitException429Too many requests (retried first).
ServerException>= 500Upstream/server error (5xx retried first).
MisarDevExceptionotherBase type for all other non-2xx responses.
try
{
    var projects = await client.ProjectsListAsync();
}
catch (AuthException e)
{
    Console.WriteLine($"Auth failed: {e.Body}");
}
catch (RateLimitException e)
{
    Console.WriteLine($"Rate limited: {e.Body}");
}
catch (MisarDevException e)
{
    Console.WriteLine($"API error {e.StatusCode}: {e.Body}");
}

Retryable status codes (429, 500, 502, 503, 504) are retried automatically up to maxRetries before the exception is thrown.