acumen/create_order

Create a new ACME order for certificate issuance.

Before obtaining a certificate, you must create an order specifying which identifiers (domain names or IP addresses) you want on the certificate.

Example

import acumen
import acumen/create_order
import acumen/order.{type Order}

let assert Ok(ord) = create_order.request(identifiers: [
  acumen.DnsIdentifier("example.com"),
  acumen.DnsIdentifier("www.example.com"),
])

let assert Ok(#(resp, ctx)) = acumen.execute(
  ctx,
  build: create_order.build(ord, _, registered_key),
  send: httpc.send,
)

let assert Ok(created_order) = create_order.response(resp)

Types

Request builder for order creation.

Use request to create a builder with required identifiers, optionally configure it with not_before, not_after, replaces, and profile, then call build.

pub opaque type RequestBuilder

Values

pub fn build(
  builder: RequestBuilder,
  context: acumen.Context,
  key: acumen.RegisteredKey,
) -> Result(request.Request(String), acumen.AcmeError)

Builds the signed HTTP request for order creation.

Sends the identifiers and any optional constraints (profile, notBefore/notAfter, replaces) to the ACME server’s newOrder endpoint.

pub fn not_after(
  builder: RequestBuilder,
  timestamp: timestamp.Timestamp,
) -> RequestBuilder

Sets the requested notAfter constraint on the certificate.

The CA may ignore this or apply its own constraints.

pub fn not_before(
  builder: RequestBuilder,
  timestamp: timestamp.Timestamp,
) -> RequestBuilder

Sets the requested notBefore constraint on the certificate.

The CA may ignore this or apply its own constraints.

pub fn profile(
  builder: RequestBuilder,
  name: String,
) -> RequestBuilder

Sets the certificate issuance profile for the order.

Available profiles can be discovered with acumen.profiles(directory).

pub fn replaces(
  builder: RequestBuilder,
  cert_id: String,
) -> RequestBuilder

Sets the certificate being replaced.

Build cert_id with renewal_info.cert_id or renewal_info.cert_id_from_certificate.

pub fn request(
  identifiers identifiers: List(acumen.Identifier),
) -> Result(RequestBuilder, acumen.AcmeError)

Creates a new order request builder. At least one identifier is required.

Example

let assert Ok(ord) = create_order.request(identifiers: [
  acumen.DnsIdentifier("example.com"),
  acumen.DnsIdentifier("www.example.com"),
])
pub fn response(
  resp: response.Response(String),
) -> Result(order.Order, acumen.AcmeError)

Parses the order creation response.

Accepts both 200 and 201 status codes — the server may return an existing order for duplicate identifiers.

Search Document