Skip to content

Commands

Arc commands follow a request/response pattern where every HTTP handler that performs a mutation returns a CommandResult or CommandResult<T> envelope. The CommandResultOperationTransformer automatically updates the generated operation documentation to reflect this.

For every endpoint whose controller action or method is identified as a command (not marked with [AspNetResult]), the transformer:

  1. Replaces the 200 response schema with CommandResult (for void/Task returns) or CommandResult<T> (for typed returns).
  2. Adds standard error response schemas for 400, 403, and 500 status codes — all using the same CommandResult/CommandResult<T> schema so clients only need to handle one type.
Status codeMeaning
200Command executed successfully
400Validation error or malformed payload
403Forbidden — insufficient permissions
500Unexpected server error

If the command returns a concept (a type inheriting from ConceptAs<T>), the transformer unwraps the concept to its underlying primitive type before generating the CommandResult<T> schema.

public record InvoiceId(Guid Value) : ConceptAs<Guid>(Value);
// Controller action — return type is InvoiceId
[HttpPost]
public Task<InvoiceId> CreateInvoice(CreateInvoice command) { ... }

The documented 200 response will use CommandResult<string> (uuid format) rather than CommandResult<InvoiceId>.

Decorate the action with [AspNetResult] to bypass the transformer and expose the raw return type directly:

[HttpPost]
[AspNetResult]
public Task<InvoiceId> CreateInvoice(CreateInvoice command) { ... }